فهرست منبع

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6: (641 commits)
  Staging: remove sxg driver
  Staging: remove heci driver
  Staging: remove at76_usb wireless driver.
  Staging: rspiusb: remove the driver
  Staging: meilhaus: remove the drivers
  Staging: remove me4000 driver.
  Staging: line6: ffzb returns an unsigned integer
  Staging: line6: pod.c: style cleanups
  Staging: iio: introduce missing kfree
  Staging: dream: introduce missing kfree
  Staging: comedi: addi-data: NULL dereference of amcc in v_pci_card_list_init()
  Staging: vt665x: fix built-in compiling
  Staging: rt3090: enable NATIVE_WPA_SUPPLICANT_SUPPORT option
  Staging: rt3090: port changes in WPA_MIX_PAIR_CIPHER to rt3090
  Staging: rt3090: rename device from raX to wlanX
  Staging: rt3090: remove possible conflict with rt2860
  Staging: rt2860/rt2870/rt3070/rt3090: fix compiler warning on x86_64
  Staging: rt2860: add new device ids
  Staging: rt3090: add device id 1462:891a
  Staging: asus_oled: Cleaned up checkpatch issues.
  ...
Linus Torvalds 15 سال پیش
والد
کامیت
7ea61767e4
100فایلهای تغییر یافته به همراه8775 افزوده شده و 13915 حذف شده
  1. 20 16
      drivers/staging/Kconfig
  2. 11 9
      drivers/staging/Makefile
  3. 1 1
      drivers/staging/agnx/pci.c
  4. 1 1
      drivers/staging/altpciechdma/altpciechdma.c
  5. 313 275
      drivers/staging/android/binder.c
  6. 28 13
      drivers/staging/android/lowmemorykiller.c
  7. 0 16
      drivers/staging/android/lowmemorykiller.txt
  8. 221 183
      drivers/staging/asus_oled/asus_oled.c
  9. 0 8
      drivers/staging/at76_usb/Kconfig
  10. 0 1
      drivers/staging/at76_usb/Makefile
  11. 0 7
      drivers/staging/at76_usb/TODO
  12. 0 5579
      drivers/staging/at76_usb/at76_usb.c
  13. 0 706
      drivers/staging/at76_usb/at76_usb.h
  14. 17 24
      drivers/staging/b3dfg/b3dfg.c
  15. 490 512
      drivers/staging/comedi/comedi.h
  16. 57 58
      drivers/staging/comedi/comedi_compat32.c
  17. 2 2
      drivers/staging/comedi/comedi_compat32.h
  18. 151 127
      drivers/staging/comedi/comedi_fops.c
  19. 0 3
      drivers/staging/comedi/comedi_ksyms.c
  20. 48 37
      drivers/staging/comedi/comedidev.h
  21. 40 37
      drivers/staging/comedi/comedilib.h
  22. 102 82
      drivers/staging/comedi/drivers.c
  23. 42 27
      drivers/staging/comedi/drivers/8253.h
  24. 32 22
      drivers/staging/comedi/drivers/8255.c
  25. 10 6
      drivers/staging/comedi/drivers/8255.h
  26. 13 9
      drivers/staging/comedi/drivers/acl7225b.c
  27. 3 0
      drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h
  28. 3 0
      drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h
  29. 1 1
      drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
  30. 51 42
      drivers/staging/comedi/drivers/adl_pci6208.c
  31. 23 16
      drivers/staging/comedi/drivers/adl_pci7296.c
  32. 35 22
      drivers/staging/comedi/drivers/adl_pci7432.c
  33. 79 47
      drivers/staging/comedi/drivers/adl_pci8164.c
  34. 189 172
      drivers/staging/comedi/drivers/adl_pci9111.c
  35. 250 214
      drivers/staging/comedi/drivers/adl_pci9118.c
  36. 190 181
      drivers/staging/comedi/drivers/adq12b.c
  37. 229 188
      drivers/staging/comedi/drivers/adv_pci1710.c
  38. 40 33
      drivers/staging/comedi/drivers/adv_pci1723.c
  39. 160 146
      drivers/staging/comedi/drivers/adv_pci_dio.c
  40. 20 16
      drivers/staging/comedi/drivers/aio_aio12_8.c
  41. 20 10
      drivers/staging/comedi/drivers/aio_iiro_16.c
  42. 166 148
      drivers/staging/comedi/drivers/amplc_dio200.c
  43. 63 55
      drivers/staging/comedi/drivers/amplc_pc236.c
  44. 53 48
      drivers/staging/comedi/drivers/amplc_pc263.c
  45. 137 123
      drivers/staging/comedi/drivers/amplc_pci224.c
  46. 224 200
      drivers/staging/comedi/drivers/amplc_pci230.c
  47. 24 18
      drivers/staging/comedi/drivers/c6xdigio.c
  48. 96 72
      drivers/staging/comedi/drivers/cb_das16_cs.c
  49. 319 269
      drivers/staging/comedi/drivers/cb_pcidas.c
  50. 502 471
      drivers/staging/comedi/drivers/cb_pcidas64.c
  51. 115 103
      drivers/staging/comedi/drivers/cb_pcidda.c
  52. 37 37
      drivers/staging/comedi/drivers/cb_pcidio.c
  53. 49 40
      drivers/staging/comedi/drivers/cb_pcimdas.c
  54. 31 30
      drivers/staging/comedi/drivers/cb_pcimdda.c
  55. 31 25
      drivers/staging/comedi/drivers/comedi_bond.c
  56. 9 5
      drivers/staging/comedi/drivers/comedi_fc.c
  57. 2 2
      drivers/staging/comedi/drivers/comedi_fc.h
  58. 18 11
      drivers/staging/comedi/drivers/comedi_parport.c
  59. 83 60
      drivers/staging/comedi/drivers/comedi_test.c
  60. 27 21
      drivers/staging/comedi/drivers/contec_pci_dio.c
  61. 65 54
      drivers/staging/comedi/drivers/daqboard2000.c
  62. 318 304
      drivers/staging/comedi/drivers/das08.c
  63. 2 1
      drivers/staging/comedi/drivers/das08.h
  64. 13 12
      drivers/staging/comedi/drivers/das08_cs.c
  65. 389 373
      drivers/staging/comedi/drivers/das16.c
  66. 73 59
      drivers/staging/comedi/drivers/das16m1.c
  67. 337 298
      drivers/staging/comedi/drivers/das1800.c
  68. 14 9
      drivers/staging/comedi/drivers/das6402.c
  69. 119 105
      drivers/staging/comedi/drivers/das800.c
  70. 81 63
      drivers/staging/comedi/drivers/dmm32at.c
  71. 137 105
      drivers/staging/comedi/drivers/dt2801.c
  72. 117 61
      drivers/staging/comedi/drivers/dt2811.c
  73. 9 7
      drivers/staging/comedi/drivers/dt2814.c
  74. 21 17
      drivers/staging/comedi/drivers/dt2815.c
  75. 11 8
      drivers/staging/comedi/drivers/dt2817.c
  76. 152 112
      drivers/staging/comedi/drivers/dt282x.c
  77. 79 66
      drivers/staging/comedi/drivers/dt3000.c
  78. 44 41
      drivers/staging/comedi/drivers/dt9812.c
  79. 21 16
      drivers/staging/comedi/drivers/fl512.c
  80. 123 113
      drivers/staging/comedi/drivers/gsc_hpdi.c
  81. 109 89
      drivers/staging/comedi/drivers/icp_multi.c
  82. 47 27
      drivers/staging/comedi/drivers/icp_multi.h
  83. 76 51
      drivers/staging/comedi/drivers/ii_pci20kc.c
  84. 156 142
      drivers/staging/comedi/drivers/jr3_pci.c
  85. 20 20
      drivers/staging/comedi/drivers/jr3_pci.h
  86. 35 32
      drivers/staging/comedi/drivers/ke_counter.c
  87. 244 224
      drivers/staging/comedi/drivers/me4000.c
  88. 114 104
      drivers/staging/comedi/drivers/me_daq.c
  89. 75 63
      drivers/staging/comedi/drivers/mite.c
  90. 90 54
      drivers/staging/comedi/drivers/mite.h
  91. 24 24
      drivers/staging/comedi/drivers/mpc624.c
  92. 16 10
      drivers/staging/comedi/drivers/mpc8260cpm.c
  93. 27 18
      drivers/staging/comedi/drivers/multiq3.c
  94. 58 51
      drivers/staging/comedi/drivers/ni_6527.c
  95. 211 191
      drivers/staging/comedi/drivers/ni_65xx.c
  96. 168 125
      drivers/staging/comedi/drivers/ni_660x.c
  97. 56 45
      drivers/staging/comedi/drivers/ni_670x.c
  98. 47 46
      drivers/staging/comedi/drivers/ni_at_a2150.c
  99. 38 31
      drivers/staging/comedi/drivers/ni_at_ao.c
  100. 161 157
      drivers/staging/comedi/drivers/ni_atmio.c

+ 20 - 16
drivers/staging/Kconfig

@@ -45,12 +45,6 @@ source "drivers/staging/et131x/Kconfig"
 
 
 source "drivers/staging/slicoss/Kconfig"
 source "drivers/staging/slicoss/Kconfig"
 
 
-source "drivers/staging/sxg/Kconfig"
-
-source "drivers/staging/me4000/Kconfig"
-
-source "drivers/staging/meilhaus/Kconfig"
-
 source "drivers/staging/go7007/Kconfig"
 source "drivers/staging/go7007/Kconfig"
 
 
 source "drivers/staging/usbip/Kconfig"
 source "drivers/staging/usbip/Kconfig"
@@ -61,8 +55,6 @@ source "drivers/staging/wlan-ng/Kconfig"
 
 
 source "drivers/staging/echo/Kconfig"
 source "drivers/staging/echo/Kconfig"
 
 
-source "drivers/staging/at76_usb/Kconfig"
-
 source "drivers/staging/poch/Kconfig"
 source "drivers/staging/poch/Kconfig"
 
 
 source "drivers/staging/agnx/Kconfig"
 source "drivers/staging/agnx/Kconfig"
@@ -73,7 +65,7 @@ source "drivers/staging/rt2860/Kconfig"
 
 
 source "drivers/staging/rt2870/Kconfig"
 source "drivers/staging/rt2870/Kconfig"
 
 
-source "drivers/staging/rt3070/Kconfig"
+source "drivers/staging/rt3090/Kconfig"
 
 
 source "drivers/staging/comedi/Kconfig"
 source "drivers/staging/comedi/Kconfig"
 
 
@@ -87,16 +79,16 @@ source "drivers/staging/rtl8187se/Kconfig"
 
 
 source "drivers/staging/rtl8192su/Kconfig"
 source "drivers/staging/rtl8192su/Kconfig"
 
 
-source "drivers/staging/rspiusb/Kconfig"
+source "drivers/staging/rtl8192e/Kconfig"
 
 
 source "drivers/staging/mimio/Kconfig"
 source "drivers/staging/mimio/Kconfig"
 
 
 source "drivers/staging/frontier/Kconfig"
 source "drivers/staging/frontier/Kconfig"
 
 
-source "drivers/staging/epl/Kconfig"
-
 source "drivers/staging/android/Kconfig"
 source "drivers/staging/android/Kconfig"
 
 
+source "drivers/staging/dream/Kconfig"
+
 source "drivers/staging/dst/Kconfig"
 source "drivers/staging/dst/Kconfig"
 
 
 source "drivers/staging/pohmelfs/Kconfig"
 source "drivers/staging/pohmelfs/Kconfig"
@@ -109,8 +101,6 @@ source "drivers/staging/phison/Kconfig"
 
 
 source "drivers/staging/p9auth/Kconfig"
 source "drivers/staging/p9auth/Kconfig"
 
 
-source "drivers/staging/heci/Kconfig"
-
 source "drivers/staging/line6/Kconfig"
 source "drivers/staging/line6/Kconfig"
 
 
 source "drivers/gpu/drm/radeon/Kconfig"
 source "drivers/gpu/drm/radeon/Kconfig"
@@ -119,13 +109,27 @@ source "drivers/staging/octeon/Kconfig"
 
 
 source "drivers/staging/serqt_usb2/Kconfig"
 source "drivers/staging/serqt_usb2/Kconfig"
 
 
+source "drivers/staging/quatech_usb2/Kconfig"
+
 source "drivers/staging/vt6655/Kconfig"
 source "drivers/staging/vt6655/Kconfig"
 
 
-source "drivers/staging/cpc-usb/Kconfig"
+source "drivers/staging/vt6656/Kconfig"
 
 
-source "drivers/staging/pata_rdc/Kconfig"
+source "drivers/staging/cpc-usb/Kconfig"
 
 
 source "drivers/staging/udlfb/Kconfig"
 source "drivers/staging/udlfb/Kconfig"
 
 
+source "drivers/staging/hv/Kconfig"
+
+source "drivers/staging/vme/Kconfig"
+
+source "drivers/staging/rar/Kconfig"
+
+source "drivers/staging/sep/Kconfig"
+
+source "drivers/staging/iio/Kconfig"
+
+source "drivers/staging/cowloop/Kconfig"
+
 endif # !STAGING_EXCLUDE_BUILD
 endif # !STAGING_EXCLUDE_BUILD
 endif # STAGING
 endif # STAGING

+ 11 - 9
drivers/staging/Makefile

@@ -5,43 +5,45 @@ obj-$(CONFIG_STAGING)		+= staging.o
 
 
 obj-$(CONFIG_ET131X)		+= et131x/
 obj-$(CONFIG_ET131X)		+= et131x/
 obj-$(CONFIG_SLICOSS)		+= slicoss/
 obj-$(CONFIG_SLICOSS)		+= slicoss/
-obj-$(CONFIG_SXG)		+= sxg/
-obj-$(CONFIG_ME4000)		+= me4000/
-obj-$(CONFIG_MEILHAUS)		+= meilhaus/
 obj-$(CONFIG_VIDEO_GO7007)	+= go7007/
 obj-$(CONFIG_VIDEO_GO7007)	+= go7007/
 obj-$(CONFIG_USB_IP_COMMON)	+= usbip/
 obj-$(CONFIG_USB_IP_COMMON)	+= usbip/
 obj-$(CONFIG_W35UND)		+= winbond/
 obj-$(CONFIG_W35UND)		+= winbond/
 obj-$(CONFIG_PRISM2_USB)	+= wlan-ng/
 obj-$(CONFIG_PRISM2_USB)	+= wlan-ng/
 obj-$(CONFIG_ECHO)		+= echo/
 obj-$(CONFIG_ECHO)		+= echo/
-obj-$(CONFIG_USB_ATMEL)		+= at76_usb/
 obj-$(CONFIG_POCH)		+= poch/
 obj-$(CONFIG_POCH)		+= poch/
 obj-$(CONFIG_AGNX)		+= agnx/
 obj-$(CONFIG_AGNX)		+= agnx/
 obj-$(CONFIG_OTUS)		+= otus/
 obj-$(CONFIG_OTUS)		+= otus/
 obj-$(CONFIG_RT2860)		+= rt2860/
 obj-$(CONFIG_RT2860)		+= rt2860/
 obj-$(CONFIG_RT2870)		+= rt2870/
 obj-$(CONFIG_RT2870)		+= rt2870/
-obj-$(CONFIG_RT3070)		+= rt3070/
+obj-$(CONFIG_RT3090)		+= rt3090/
 obj-$(CONFIG_COMEDI)		+= comedi/
 obj-$(CONFIG_COMEDI)		+= comedi/
 obj-$(CONFIG_ASUS_OLED)		+= asus_oled/
 obj-$(CONFIG_ASUS_OLED)		+= asus_oled/
 obj-$(CONFIG_PANEL)		+= panel/
 obj-$(CONFIG_PANEL)		+= panel/
 obj-$(CONFIG_ALTERA_PCIE_CHDMA)	+= altpciechdma/
 obj-$(CONFIG_ALTERA_PCIE_CHDMA)	+= altpciechdma/
 obj-$(CONFIG_RTL8187SE)		+= rtl8187se/
 obj-$(CONFIG_RTL8187SE)		+= rtl8187se/
 obj-$(CONFIG_RTL8192SU)		+= rtl8192su/
 obj-$(CONFIG_RTL8192SU)		+= rtl8192su/
-obj-$(CONFIG_USB_RSPI)		+= rspiusb/
+obj-$(CONFIG_RTL8192E)		+= rtl8192e/
 obj-$(CONFIG_INPUT_MIMIO)	+= mimio/
 obj-$(CONFIG_INPUT_MIMIO)	+= mimio/
 obj-$(CONFIG_TRANZPORT)		+= frontier/
 obj-$(CONFIG_TRANZPORT)		+= frontier/
-obj-$(CONFIG_EPL)		+= epl/
 obj-$(CONFIG_ANDROID)		+= android/
 obj-$(CONFIG_ANDROID)		+= android/
+obj-$(CONFIG_ANDROID)		+= dream/
 obj-$(CONFIG_DST)		+= dst/
 obj-$(CONFIG_DST)		+= dst/
 obj-$(CONFIG_POHMELFS)		+= pohmelfs/
 obj-$(CONFIG_POHMELFS)		+= pohmelfs/
 obj-$(CONFIG_STLC45XX)		+= stlc45xx/
 obj-$(CONFIG_STLC45XX)		+= stlc45xx/
 obj-$(CONFIG_B3DFG)		+= b3dfg/
 obj-$(CONFIG_B3DFG)		+= b3dfg/
 obj-$(CONFIG_IDE_PHISON)	+= phison/
 obj-$(CONFIG_IDE_PHISON)	+= phison/
 obj-$(CONFIG_PLAN9AUTH)		+= p9auth/
 obj-$(CONFIG_PLAN9AUTH)		+= p9auth/
-obj-$(CONFIG_HECI)		+= heci/
 obj-$(CONFIG_LINE6_USB)		+= line6/
 obj-$(CONFIG_LINE6_USB)		+= line6/
 obj-$(CONFIG_USB_SERIAL_QUATECH2)	+= serqt_usb2/
 obj-$(CONFIG_USB_SERIAL_QUATECH2)	+= serqt_usb2/
+obj-$(CONFIG_USB_SERIAL_QUATECH_USB2)	+= quatech_usb2/
 obj-$(CONFIG_OCTEON_ETHERNET)	+= octeon/
 obj-$(CONFIG_OCTEON_ETHERNET)	+= octeon/
 obj-$(CONFIG_VT6655)		+= vt6655/
 obj-$(CONFIG_VT6655)		+= vt6655/
+obj-$(CONFIG_VT6656)		+= vt6656/
 obj-$(CONFIG_USB_CPC)		+= cpc-usb/
 obj-$(CONFIG_USB_CPC)		+= cpc-usb/
-obj-$(CONFIG_RDC_17F3101X)	+= pata_rdc/
 obj-$(CONFIG_FB_UDL)		+= udlfb/
 obj-$(CONFIG_FB_UDL)		+= udlfb/
+obj-$(CONFIG_HYPERV)		+= hv/
+obj-$(CONFIG_VME_BUS)		+= vme/
+obj-$(CONFIG_RAR_REGISTER)	+= rar/
+obj-$(CONFIG_DX_SEP)		+= sep/
+obj-$(CONFIG_IIO)		+= iio/
+obj-$(CONFIG_COWLOOP)		+= cowloop/

+ 1 - 1
drivers/staging/agnx/pci.c

@@ -280,7 +280,7 @@ static void agnx_stop(struct ieee80211_hw *dev)
 	/* make sure hardware will not generate irq */
 	/* make sure hardware will not generate irq */
 	agnx_hw_reset(priv);
 	agnx_hw_reset(priv);
 	free_irq(priv->pdev->irq, dev);
 	free_irq(priv->pdev->irq, dev);
-	flush_workqueue(priv->hw->workqueue);
+/*	flush_workqueue(priv->hw->workqueue); */
 /*	cancel_delayed_work_sync(&priv->periodic_work); */
 /*	cancel_delayed_work_sync(&priv->periodic_work); */
 	unfill_rings(priv);
 	unfill_rings(priv);
 	rings_free(priv);
 	rings_free(priv);

+ 1 - 1
drivers/staging/altpciechdma/altpciechdma.c

@@ -550,7 +550,7 @@ static int __devinit dma_test(struct ape_dev *ape, struct pci_dev *dev)
 #if 0
 #if 0
 		*(u32 *)(buffer_virt + i) = i / PAGE_SIZE + 1;
 		*(u32 *)(buffer_virt + i) = i / PAGE_SIZE + 1;
 #else
 #else
-		*(u32 *)(buffer_virt + i) = (buffer_virt + i);
+		*(u32 *)(buffer_virt + i) = (u32)(unsigned long)(buffer_virt + i);
 #endif
 #endif
 #if 0
 #if 0
   compare((u32 *)buffer_virt, (u32 *)(buffer_virt + 2 * PAGE_SIZE), 8192);
   compare((u32 *)buffer_virt, (u32 *)(buffer_virt + 2 * PAGE_SIZE), 8192);

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 313 - 275
drivers/staging/android/binder.c


+ 28 - 13
drivers/staging/android/lowmemorykiller.c

@@ -1,4 +1,20 @@
 /* drivers/misc/lowmemorykiller.c
 /* drivers/misc/lowmemorykiller.c
+ *
+ * The lowmemorykiller driver lets user-space specify a set of memory thresholds
+ * where processes with a range of oom_adj values will get killed. Specify the
+ * minimum oom_adj values in /sys/module/lowmemorykiller/parameters/adj and the
+ * number of free pages in /sys/module/lowmemorykiller/parameters/minfree. Both
+ * files take a comma separated list of numbers in ascending order.
+ *
+ * For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and
+ * "1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill processes
+ * with a oom_adj value of 8 or higher when the free memory drops below 4096 pages
+ * and kill processes with a oom_adj value of 0 or higher when the free memory
+ * drops below 1024 pages.
+ *
+ * The driver considers memory used for caches to be free, but if a large
+ * percentage of the cached memory is locked this can be very inaccurate
+ * and processes may not get killed until the normal oom killer is triggered.
  *
  *
  * Copyright (C) 2007-2008 Google, Inc.
  * Copyright (C) 2007-2008 Google, Inc.
  *
  *
@@ -19,12 +35,6 @@
 #include <linux/oom.h>
 #include <linux/oom.h>
 #include <linux/sched.h>
 #include <linux/sched.h>
 
 
-static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask);
-
-static struct shrinker lowmem_shrinker = {
-	.shrink = lowmem_shrink,
-	.seeks = DEFAULT_SEEKS * 16
-};
 static uint32_t lowmem_debug_level = 2;
 static uint32_t lowmem_debug_level = 2;
 static int lowmem_adj[6] = {
 static int lowmem_adj[6] = {
 	0,
 	0,
@@ -47,13 +57,6 @@ static int lowmem_minfree_size = 4;
 			printk(x);			\
 			printk(x);			\
 	} while (0)
 	} while (0)
 
 
-module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR);
-module_param_array_named(adj, lowmem_adj, int, &lowmem_adj_size,
-			 S_IRUGO | S_IWUSR);
-module_param_array_named(minfree, lowmem_minfree, uint, &lowmem_minfree_size,
-			 S_IRUGO | S_IWUSR);
-module_param_named(debug_level, lowmem_debug_level, uint, S_IRUGO | S_IWUSR);
-
 static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
 static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
 {
 {
 	struct task_struct *p;
 	struct task_struct *p;
@@ -140,6 +143,11 @@ static int lowmem_shrink(int nr_to_scan, gfp_t gfp_mask)
 	return rem;
 	return rem;
 }
 }
 
 
+static struct shrinker lowmem_shrinker = {
+	.shrink = lowmem_shrink,
+	.seeks = DEFAULT_SEEKS * 16
+};
+
 static int __init lowmem_init(void)
 static int __init lowmem_init(void)
 {
 {
 	register_shrinker(&lowmem_shrinker);
 	register_shrinker(&lowmem_shrinker);
@@ -151,6 +159,13 @@ static void __exit lowmem_exit(void)
 	unregister_shrinker(&lowmem_shrinker);
 	unregister_shrinker(&lowmem_shrinker);
 }
 }
 
 
+module_param_named(cost, lowmem_shrinker.seeks, int, S_IRUGO | S_IWUSR);
+module_param_array_named(adj, lowmem_adj, int, &lowmem_adj_size,
+			 S_IRUGO | S_IWUSR);
+module_param_array_named(minfree, lowmem_minfree, uint, &lowmem_minfree_size,
+			 S_IRUGO | S_IWUSR);
+module_param_named(debug_level, lowmem_debug_level, uint, S_IRUGO | S_IWUSR);
+
 module_init(lowmem_init);
 module_init(lowmem_init);
 module_exit(lowmem_exit);
 module_exit(lowmem_exit);
 
 

+ 0 - 16
drivers/staging/android/lowmemorykiller.txt

@@ -1,16 +0,0 @@
-The lowmemorykiller driver lets user-space specify a set of memory thresholds
-where processes with a range of oom_adj values will get killed. Specify the
-minimum oom_adj values in /sys/module/lowmemorykiller/parameters/adj and the
-number of free pages in /sys/module/lowmemorykiller/parameters/minfree. Both
-files take a comma separated list of numbers in ascending order.
-
-For example, write "0,8" to /sys/module/lowmemorykiller/parameters/adj and
-"1024,4096" to /sys/module/lowmemorykiller/parameters/minfree to kill processes
-with a oom_adj value of 8 or higher when the free memory drops below 4096 pages
-and kill processes with a oom_adj value of 0 or higher when the free memory
-drops below 1024 pages.
-
-The driver considers memory used for caches to be free, but if a large
-percentage of the cached memory is locked this can be very inaccurate
-and processes may not get killed until the normal oom killer is triggered.
-

+ 221 - 183
drivers/staging/asus_oled/asus_oled.c

@@ -63,26 +63,31 @@ static uint start_off;
 
 
 module_param(start_off, uint, 0644);
 module_param(start_off, uint, 0644);
 
 
-MODULE_PARM_DESC(start_off, "Set to 1 to switch off OLED display after it is attached");
+MODULE_PARM_DESC(start_off,
+		 "Set to 1 to switch off OLED display after it is attached");
 
 
-typedef enum {
+enum oled_pack_mode{
 	PACK_MODE_G1,
 	PACK_MODE_G1,
 	PACK_MODE_G50,
 	PACK_MODE_G50,
 	PACK_MODE_LAST
 	PACK_MODE_LAST
-} oled_pack_mode_t;
+};
 
 
 struct oled_dev_desc_str {
 struct oled_dev_desc_str {
 	uint16_t		idVendor;
 	uint16_t		idVendor;
 	uint16_t		idProduct;
 	uint16_t		idProduct;
-	uint16_t		devWidth; // width of display
-	oled_pack_mode_t	packMode; // formula to be used while packing the picture
+	/* width of display */
+	uint16_t		devWidth;
+	/* formula to be used while packing the picture */
+	enum oled_pack_mode	packMode;
 	const char		*devDesc;
 	const char		*devDesc;
 };
 };
 
 
 /* table of devices that work with this driver */
 /* table of devices that work with this driver */
 static struct usb_device_id id_table[] = {
 static struct usb_device_id id_table[] = {
-	{ USB_DEVICE(0x0b05, 0x1726) }, // Asus G1/G2 (and variants)
-	{ USB_DEVICE(0x0b05, 0x175b) }, // Asus G50V (and possibly others - G70? G71?)
+	/* Asus G1/G2 (and variants)*/
+	{ USB_DEVICE(0x0b05, 0x1726) },
+	/* Asus G50V (and possibly others - G70? G71?)*/
+	{ USB_DEVICE(0x0b05, 0x175b) },
 	{ },
 	{ },
 };
 };
 
 
@@ -95,20 +100,6 @@ static struct oled_dev_desc_str oled_dev_desc_table[] = {
 
 
 MODULE_DEVICE_TABLE(usb, id_table);
 MODULE_DEVICE_TABLE(usb, id_table);
 
 
-#define SETUP_PACKET_HEADER(packet, val1, val2, val3, val4, val5, val6, val7) \
-	do {					\
-		memset(packet, 0, sizeof(struct asus_oled_header));		\
-		packet->header.magic1 = 0x55;		\
-		packet->header.magic2 = 0xaa;		\
-		packet->header.flags = val1;		\
-		packet->header.value3 = val2;		\
-		packet->header.buffer1 = val3;		\
-		packet->header.buffer2 = val4;		\
-		packet->header.value6 = val5;		\
-		packet->header.value7 = val6;		\
-		packet->header.value8 = val7;		\
-	} while (0);
-
 struct asus_oled_header {
 struct asus_oled_header {
 	uint8_t		magic1;
 	uint8_t		magic1;
 	uint8_t		magic2;
 	uint8_t		magic2;
@@ -128,10 +119,10 @@ struct asus_oled_packet {
 } __attribute((packed));
 } __attribute((packed));
 
 
 struct asus_oled_dev {
 struct asus_oled_dev {
-	struct usb_device *	udev;
+	struct usb_device       *udev;
 	uint8_t			pic_mode;
 	uint8_t			pic_mode;
 	uint16_t		dev_width;
 	uint16_t		dev_width;
-	oled_pack_mode_t	pack_mode;
+	enum oled_pack_mode	pack_mode;
 	size_t			height;
 	size_t			height;
 	size_t			width;
 	size_t			width;
 	size_t			x_shift;
 	size_t			x_shift;
@@ -144,12 +135,28 @@ struct asus_oled_dev {
 	struct device		*dev;
 	struct device		*dev;
 };
 };
 
 
+static void setup_packet_header(struct asus_oled_packet *packet, char flags,
+			 char value3, char buffer1, char buffer2, char value6,
+			 char value7, char value8)
+{
+	memset(packet, 0, sizeof(struct asus_oled_header));
+	packet->header.magic1 = 0x55;
+	packet->header.magic2 = 0xaa;
+	packet->header.flags = flags;
+	packet->header.value3 = value3;
+	packet->header.buffer1 = buffer1;
+	packet->header.buffer2 = buffer2;
+	packet->header.value6 = value6;
+	packet->header.value7 = value7;
+	packet->header.value8 = value8;
+}
+
 static void enable_oled(struct asus_oled_dev *odev, uint8_t enabl)
 static void enable_oled(struct asus_oled_dev *odev, uint8_t enabl)
 {
 {
 	int a;
 	int a;
 	int retval;
 	int retval;
 	int act_len;
 	int act_len;
-	struct asus_oled_packet * packet;
+	struct asus_oled_packet *packet;
 
 
 	packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL);
 	packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL);
 
 
@@ -158,7 +165,7 @@ static void enable_oled(struct asus_oled_dev *odev, uint8_t enabl)
 		return;
 		return;
 	}
 	}
 
 
-	SETUP_PACKET_HEADER(packet, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00);
+	setup_packet_header(packet, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00);
 
 
 	if (enabl)
 	if (enabl)
 		packet->bitmap[0] = 0xaf;
 		packet->bitmap[0] = 0xaf;
@@ -182,29 +189,34 @@ static void enable_oled(struct asus_oled_dev *odev, uint8_t enabl)
 	kfree(packet);
 	kfree(packet);
 }
 }
 
 
-static ssize_t set_enabled(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t set_enabled(struct device *dev, struct device_attribute *attr,
+			   const char *buf, size_t count)
 {
 {
 	struct usb_interface *intf = to_usb_interface(dev);
 	struct usb_interface *intf = to_usb_interface(dev);
 	struct asus_oled_dev *odev = usb_get_intfdata(intf);
 	struct asus_oled_dev *odev = usb_get_intfdata(intf);
-	int temp = simple_strtoul(buf, NULL, 10);
+	int temp = strict_strtoul(buf, 10, NULL);
 
 
 	enable_oled(odev, temp);
 	enable_oled(odev, temp);
 
 
 	return count;
 	return count;
 }
 }
 
 
-static ssize_t class_set_enabled(struct device *device, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t class_set_enabled(struct device *device,
+				 struct device_attribute *attr,
+				 const char *buf, size_t count)
 {
 {
-	struct asus_oled_dev *odev = (struct asus_oled_dev *) dev_get_drvdata(device);
+	struct asus_oled_dev *odev =
+		(struct asus_oled_dev *) dev_get_drvdata(device);
 
 
-	int temp = simple_strtoul(buf, NULL, 10);
+	int temp = strict_strtoul(buf, 10, NULL);
 
 
 	enable_oled(odev, temp);
 	enable_oled(odev, temp);
 
 
 	return count;
 	return count;
 }
 }
 
 
-static ssize_t get_enabled(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t get_enabled(struct device *dev, struct device_attribute *attr,
+			   char *buf)
 {
 {
 	struct usb_interface *intf = to_usb_interface(dev);
 	struct usb_interface *intf = to_usb_interface(dev);
 	struct asus_oled_dev *odev = usb_get_intfdata(intf);
 	struct asus_oled_dev *odev = usb_get_intfdata(intf);
@@ -212,15 +224,18 @@ static ssize_t get_enabled(struct device *dev, struct device_attribute *attr, ch
 	return sprintf(buf, "%d\n", odev->enabled);
 	return sprintf(buf, "%d\n", odev->enabled);
 }
 }
 
 
-static ssize_t class_get_enabled(struct device *device, struct device_attribute *attr, char *buf)
+static ssize_t class_get_enabled(struct device *device,
+				 struct device_attribute *attr, char *buf)
 {
 {
-	struct asus_oled_dev *odev = (struct asus_oled_dev *) dev_get_drvdata(device);
+	struct asus_oled_dev *odev =
+		(struct asus_oled_dev *) dev_get_drvdata(device);
 
 
 	return sprintf(buf, "%d\n", odev->enabled);
 	return sprintf(buf, "%d\n", odev->enabled);
 }
 }
 
 
-static void send_packets(struct usb_device *udev, struct asus_oled_packet *packet,
-	char *buf, uint8_t p_type, size_t p_num)
+static void send_packets(struct usb_device *udev,
+			 struct asus_oled_packet *packet,
+			 char *buf, uint8_t p_type, size_t p_num)
 {
 {
 	size_t i;
 	size_t i;
 	int act_len;
 	int act_len;
@@ -229,65 +244,76 @@ static void send_packets(struct usb_device *udev, struct asus_oled_packet *packe
 		int retval;
 		int retval;
 
 
 		switch (p_type) {
 		switch (p_type) {
-			case ASUS_OLED_ROLL:
-				SETUP_PACKET_HEADER(packet, 0x40, 0x80, p_num, i + 1, 0x00, 0x01, 0xff);
+		case ASUS_OLED_ROLL:
+			setup_packet_header(packet, 0x40, 0x80, p_num,
+					    i + 1, 0x00, 0x01, 0xff);
 			break;
 			break;
-			case ASUS_OLED_STATIC:
-				SETUP_PACKET_HEADER(packet, 0x10 + i, 0x80, 0x01, 0x01, 0x00, 0x01, 0x00);
+		case ASUS_OLED_STATIC:
+			setup_packet_header(packet, 0x10 + i, 0x80, 0x01,
+					    0x01, 0x00, 0x01, 0x00);
 			break;
 			break;
-			case ASUS_OLED_FLASH:
-				SETUP_PACKET_HEADER(packet, 0x10 + i, 0x80, 0x01, 0x01, 0x00, 0x00, 0xff);
+		case ASUS_OLED_FLASH:
+			setup_packet_header(packet, 0x10 + i, 0x80, 0x01,
+					    0x01, 0x00, 0x00, 0xff);
 			break;
 			break;
 		}
 		}
 
 
-		memcpy(packet->bitmap, buf + (ASUS_OLED_PACKET_BUF_SIZE*i), ASUS_OLED_PACKET_BUF_SIZE);
+		memcpy(packet->bitmap, buf + (ASUS_OLED_PACKET_BUF_SIZE*i),
+		       ASUS_OLED_PACKET_BUF_SIZE);
 
 
-		retval = usb_bulk_msg(udev,
-			usb_sndctrlpipe(udev, 2),
-			packet,
-			sizeof(struct asus_oled_packet),
-			&act_len,
-			-1);
+		retval = usb_bulk_msg(udev, usb_sndctrlpipe(udev, 2),
+				      packet, sizeof(struct asus_oled_packet),
+				      &act_len, -1);
 
 
 		if (retval)
 		if (retval)
 			dev_dbg(&udev->dev, "retval = %d\n", retval);
 			dev_dbg(&udev->dev, "retval = %d\n", retval);
 	}
 	}
 }
 }
 
 
-static void send_packet(struct usb_device *udev, struct asus_oled_packet *packet, size_t offset, size_t len, char *buf, uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5, uint8_t b6) {
+static void send_packet(struct usb_device *udev,
+			struct asus_oled_packet *packet,
+			size_t offset, size_t len, char *buf, uint8_t b1,
+			uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5,
+			uint8_t b6) {
 	int retval;
 	int retval;
 	int act_len;
 	int act_len;
 
 
-	SETUP_PACKET_HEADER(packet, b1, b2, b3, b4, b5, b6, 0x00);
+	setup_packet_header(packet, b1, b2, b3, b4, b5, b6, 0x00);
 	memcpy(packet->bitmap, buf + offset, len);
 	memcpy(packet->bitmap, buf + offset, len);
 
 
 	retval = usb_bulk_msg(udev,
 	retval = usb_bulk_msg(udev,
-			usb_sndctrlpipe(udev, 2),
-			packet,
-			sizeof(struct asus_oled_packet),
-			&act_len,
-			-1);
+			      usb_sndctrlpipe(udev, 2),
+			      packet,
+			      sizeof(struct asus_oled_packet),
+			      &act_len,
+			      -1);
 
 
 	if (retval)
 	if (retval)
 		dev_dbg(&udev->dev, "retval = %d\n", retval);
 		dev_dbg(&udev->dev, "retval = %d\n", retval);
 }
 }
 
 
 
 
-static void send_packets_g50(struct usb_device *udev, struct asus_oled_packet *packet, char *buf)
+static void send_packets_g50(struct usb_device *udev,
+			     struct asus_oled_packet *packet, char *buf)
 {
 {
-	send_packet(udev, packet,     0, 0x100, buf, 0x10, 0x00, 0x02, 0x01, 0x00, 0x01);
-	send_packet(udev, packet, 0x100, 0x080, buf, 0x10, 0x00, 0x02, 0x02, 0x80, 0x00);
-
-	send_packet(udev, packet, 0x180, 0x100, buf, 0x11, 0x00, 0x03, 0x01, 0x00, 0x01);
-	send_packet(udev, packet, 0x280, 0x100, buf, 0x11, 0x00, 0x03, 0x02, 0x00, 0x01);
-	send_packet(udev, packet, 0x380, 0x080, buf, 0x11, 0x00, 0x03, 0x03, 0x80, 0x00);
+	send_packet(udev, packet,     0, 0x100, buf,
+		    0x10, 0x00, 0x02, 0x01, 0x00, 0x01);
+	send_packet(udev, packet, 0x100, 0x080, buf,
+		    0x10, 0x00, 0x02, 0x02, 0x80, 0x00);
+
+	send_packet(udev, packet, 0x180, 0x100, buf,
+		    0x11, 0x00, 0x03, 0x01, 0x00, 0x01);
+	send_packet(udev, packet, 0x280, 0x100, buf,
+		    0x11, 0x00, 0x03, 0x02, 0x00, 0x01);
+	send_packet(udev, packet, 0x380, 0x080, buf,
+		    0x11, 0x00, 0x03, 0x03, 0x80, 0x00);
 }
 }
 
 
 
 
 static void send_data(struct asus_oled_dev *odev)
 static void send_data(struct asus_oled_dev *odev)
 {
 {
 	size_t packet_num = odev->buf_size / ASUS_OLED_PACKET_BUF_SIZE;
 	size_t packet_num = odev->buf_size / ASUS_OLED_PACKET_BUF_SIZE;
-	struct asus_oled_packet * packet;
+	struct asus_oled_packet *packet;
 
 
 	packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL);
 	packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL);
 
 
@@ -297,20 +323,20 @@ static void send_data(struct asus_oled_dev *odev)
 	}
 	}
 
 
 	if (odev->pack_mode == PACK_MODE_G1) {
 	if (odev->pack_mode == PACK_MODE_G1) {
-		// When sending roll-mode data the display updated only first packet.
-		// I have no idea why, but when static picture is send just before
-		// rolling picture - everything works fine.
+		/* When sending roll-mode data the display updated only
+		   first packet.  I have no idea why, but when static picture
+		   is sent just before rolling picture everything works fine. */
 		if (odev->pic_mode == ASUS_OLED_ROLL)
 		if (odev->pic_mode == ASUS_OLED_ROLL)
-			send_packets(odev->udev, packet, odev->buf, ASUS_OLED_STATIC, 2);
+			send_packets(odev->udev, packet, odev->buf,
+				     ASUS_OLED_STATIC, 2);
 
 
-		// Only ROLL mode can use more than 2 packets.
+		/* Only ROLL mode can use more than 2 packets.*/
 		if (odev->pic_mode != ASUS_OLED_ROLL && packet_num > 2)
 		if (odev->pic_mode != ASUS_OLED_ROLL && packet_num > 2)
 			packet_num = 2;
 			packet_num = 2;
 
 
-		send_packets(odev->udev, packet, odev->buf, odev->pic_mode, packet_num);
-	}
-	else
-	if (odev->pack_mode == PACK_MODE_G50) {
+		send_packets(odev->udev, packet, odev->buf,
+			     odev->pic_mode, packet_num);
+	} else if (odev->pack_mode == PACK_MODE_G50) {
 		send_packets_g50(odev->udev, packet, odev->buf);
 		send_packets_g50(odev->udev, packet, odev->buf);
 	}
 	}
 
 
@@ -319,53 +345,55 @@ static void send_data(struct asus_oled_dev *odev)
 
 
 static int append_values(struct asus_oled_dev *odev, uint8_t val, size_t count)
 static int append_values(struct asus_oled_dev *odev, uint8_t val, size_t count)
 {
 {
-	while (count-- > 0) {
-		if (val) {
-			size_t x = odev->buf_offs % odev->width;
-			size_t y = odev->buf_offs / odev->width;
-			size_t i;
-
-			x += odev->x_shift;
-			y += odev->y_shift;
-
-			switch (odev->pack_mode)
-			{
-				case PACK_MODE_G1:
-					// i = (x/128)*640 + 127 - x + (y/8)*128;
-					// This one for 128 is the same, but might be better for different widths?
-					i = (x/odev->dev_width)*640 + odev->dev_width - 1 - x + (y/8)*odev->dev_width;
-				break;
+	while (count-- > 0 && val) {
+		size_t x = odev->buf_offs % odev->width;
+		size_t y = odev->buf_offs / odev->width;
+		size_t i;
 
 
-				case PACK_MODE_G50:
-					i =  (odev->dev_width - 1 - x)/8 + y*odev->dev_width/8;
-				break;
+		x += odev->x_shift;
+		y += odev->y_shift;
+
+		switch (odev->pack_mode) {
+		case PACK_MODE_G1:
+			/* i = (x/128)*640 + 127 - x + (y/8)*128;
+			   This one for 128 is the same, but might be better
+			   for different widths? */
+			i = (x/odev->dev_width)*640 +
+				odev->dev_width - 1 - x +
+				(y/8)*odev->dev_width;
+			break;
 
 
-				default:
-					i = 0;
-					printk(ASUS_OLED_ERROR "Unknown OLED Pack Mode: %d!\n", odev->pack_mode);
-				break;
-			}
+		case PACK_MODE_G50:
+			i =  (odev->dev_width - 1 - x)/8 + y*odev->dev_width/8;
+			break;
 
 
-			if (i >= odev->buf_size) {
-				printk(ASUS_OLED_ERROR "Buffer overflow! Report a bug in the driver: offs: %d >= %d i: %d (x: %d y: %d)\n",
-					(int) odev->buf_offs, (int) odev->buf_size, (int) i, (int) x, (int) y);
-				return -EIO;
-			}
+		default:
+			i = 0;
+			printk(ASUS_OLED_ERROR "Unknown OLED Pack Mode: %d!\n",
+			       odev->pack_mode);
+			break;
+		}
 
 
-			switch (odev->pack_mode)
-			{
-				case PACK_MODE_G1:
-					odev->buf[i] &= ~(1<<(y%8));
-				break;
+		if (i >= odev->buf_size) {
+			printk(ASUS_OLED_ERROR "Buffer overflow! Report a bug:"
+			       "offs: %d >= %d i: %d (x: %d y: %d)\n",
+			       (int) odev->buf_offs, (int) odev->buf_size,
+			       (int) i, (int) x, (int) y);
+			return -EIO;
+		}
 
 
-				case PACK_MODE_G50:
-					odev->buf[i] &= ~(1<<(x%8));
-				break;
+		switch (odev->pack_mode) {
+		case PACK_MODE_G1:
+			odev->buf[i] &= ~(1<<(y%8));
+			break;
 
 
-				default:
-					// cannot get here; stops gcc complaining
-				;
-			}
+		case PACK_MODE_G50:
+			odev->buf[i] &= ~(1<<(x%8));
+			break;
+
+		default:
+			/* cannot get here; stops gcc complaining*/
+			;
 		}
 		}
 
 
 		odev->last_val = val;
 		odev->last_val = val;
@@ -375,7 +403,8 @@ static int append_values(struct asus_oled_dev *odev, uint8_t val, size_t count)
 	return 0;
 	return 0;
 }
 }
 
 
-static ssize_t odev_set_picture(struct asus_oled_dev *odev, const char *buf, size_t count)
+static ssize_t odev_set_picture(struct asus_oled_dev *odev,
+				const char *buf, size_t count)
 {
 {
 	size_t offs = 0, max_offs;
 	size_t offs = 0, max_offs;
 
 
@@ -383,32 +412,31 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, const char *buf, siz
 		return 0;
 		return 0;
 
 
 	if (tolower(buf[0]) == 'b') {
 	if (tolower(buf[0]) == 'b') {
-	    // binary mode, set the entire memory
+		/* binary mode, set the entire memory*/
 
 
-	    size_t i;
+		size_t i;
 
 
-	    odev->buf_size = (odev->dev_width * ASUS_OLED_DISP_HEIGHT) / 8;
+		odev->buf_size = (odev->dev_width * ASUS_OLED_DISP_HEIGHT) / 8;
 
 
-	    if (odev->buf)
-		    kfree(odev->buf);
-	    odev->buf = kmalloc(odev->buf_size, GFP_KERNEL);
+		kfree(odev->buf);
+		odev->buf = kmalloc(odev->buf_size, GFP_KERNEL);
 
 
-	    memset(odev->buf, 0xff, odev->buf_size);
+		memset(odev->buf, 0xff, odev->buf_size);
 
 
-	    for (i = 1; i < count && i <= 32 * 32; i++) {
-		odev->buf[i-1] = buf[i];
-		odev->buf_offs = i-1;
-	    }
+		for (i = 1; i < count && i <= 32 * 32; i++) {
+			odev->buf[i-1] = buf[i];
+			odev->buf_offs = i-1;
+		}
 
 
-	    odev->width = odev->dev_width / 8;
-	    odev->height = ASUS_OLED_DISP_HEIGHT;
-	    odev->x_shift = 0;
-	    odev->y_shift = 0;
-	    odev->last_val =  0;
+		odev->width = odev->dev_width / 8;
+		odev->height = ASUS_OLED_DISP_HEIGHT;
+		odev->x_shift = 0;
+		odev->y_shift = 0;
+		odev->last_val =  0;
 
 
-	    send_data(odev);
+		send_data(odev);
 
 
-	    return count;
+		return count;
 	}
 	}
 
 
 	if (buf[0] == '<') {
 	if (buf[0] == '<') {
@@ -416,20 +444,21 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, const char *buf, siz
 		size_t w = 0, h = 0;
 		size_t w = 0, h = 0;
 		size_t w_mem, h_mem;
 		size_t w_mem, h_mem;
 
 
-		if (count < 10 || buf[2] != ':') {
+		if (count < 10 || buf[2] != ':')
 			goto error_header;
 			goto error_header;
-		}
+
 
 
 		switch (tolower(buf[1])) {
 		switch (tolower(buf[1])) {
-			case ASUS_OLED_STATIC:
-			case ASUS_OLED_ROLL:
-			case ASUS_OLED_FLASH:
-				odev->pic_mode = buf[1];
-				break;
-			default:
-				printk(ASUS_OLED_ERROR "Wrong picture mode: '%c'.\n", buf[1]);
-				return -EIO;
-				break;
+		case ASUS_OLED_STATIC:
+		case ASUS_OLED_ROLL:
+		case ASUS_OLED_FLASH:
+			odev->pic_mode = buf[1];
+			break;
+		default:
+			printk(ASUS_OLED_ERROR "Wrong picture mode: '%c'.\n",
+			       buf[1]);
+			return -EIO;
+			break;
 		}
 		}
 
 
 		for (i = 3; i < count; ++i) {
 		for (i = 3; i < count; ++i) {
@@ -438,11 +467,11 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, const char *buf, siz
 
 
 				if (w > ASUS_OLED_MAX_WIDTH)
 				if (w > ASUS_OLED_MAX_WIDTH)
 					goto error_width;
 					goto error_width;
-			}
-			else if (tolower(buf[i]) == 'x')
+			} else if (tolower(buf[i]) == 'x') {
 				break;
 				break;
-			else
+			} else {
 				goto error_width;
 				goto error_width;
+			}
 		}
 		}
 
 
 		for (++i; i < count; ++i) {
 		for (++i; i < count; ++i) {
@@ -451,11 +480,11 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, const char *buf, siz
 
 
 				if (h > ASUS_OLED_DISP_HEIGHT)
 				if (h > ASUS_OLED_DISP_HEIGHT)
 					goto error_height;
 					goto error_height;
-			}
-			else if (tolower(buf[i]) == '>')
+			} else if (tolower(buf[i]) == '>') {
 				break;
 				break;
-			else
+			} else {
 				goto error_height;
 				goto error_height;
+			}
 		}
 		}
 
 
 		if (w < 1 || w > ASUS_OLED_MAX_WIDTH)
 		if (w < 1 || w > ASUS_OLED_MAX_WIDTH)
@@ -481,8 +510,7 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, const char *buf, siz
 
 
 		odev->buf_size = w_mem * h_mem / 8;
 		odev->buf_size = w_mem * h_mem / 8;
 
 
-		if (odev->buf)
-			kfree(odev->buf);
+		kfree(odev->buf);
 		odev->buf = kmalloc(odev->buf_size, GFP_KERNEL);
 		odev->buf = kmalloc(odev->buf_size, GFP_KERNEL);
 
 
 		if (odev->buf == NULL) {
 		if (odev->buf == NULL) {
@@ -503,8 +531,7 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, const char *buf, siz
 		if (odev->pic_mode == ASUS_OLED_FLASH) {
 		if (odev->pic_mode == ASUS_OLED_FLASH) {
 			if (h < ASUS_OLED_DISP_HEIGHT/2)
 			if (h < ASUS_OLED_DISP_HEIGHT/2)
 				odev->y_shift = (ASUS_OLED_DISP_HEIGHT/2 - h)/2;
 				odev->y_shift = (ASUS_OLED_DISP_HEIGHT/2 - h)/2;
-		}
-		else {
+		} else {
 			if (h < ASUS_OLED_DISP_HEIGHT)
 			if (h < ASUS_OLED_DISP_HEIGHT)
 				odev->y_shift = (ASUS_OLED_DISP_HEIGHT - h)/2;
 				odev->y_shift = (ASUS_OLED_DISP_HEIGHT - h)/2;
 		}
 		}
@@ -522,20 +549,21 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev, const char *buf, siz
 			ret = append_values(odev, 1, 1);
 			ret = append_values(odev, 1, 1);
 			if (ret < 0)
 			if (ret < 0)
 				return ret;
 				return ret;
-		}
-		else if (buf[offs] == '0' || buf[offs] == ' ') {
+		} else if (buf[offs] == '0' || buf[offs] == ' ') {
 			ret = append_values(odev, 0, 1);
 			ret = append_values(odev, 0, 1);
 			if (ret < 0)
 			if (ret < 0)
 				return ret;
 				return ret;
-		}
-		else if (buf[offs] == '\n') {
-			// New line detected. Lets assume, that all characters till the end of the
-			// line were equal to the last character in this line.
+		} else if (buf[offs] == '\n') {
+			/* New line detected. Lets assume, that all characters
+			   till the end of the line were equal to the last
+			   character in this line.*/
 			if (odev->buf_offs % odev->width != 0)
 			if (odev->buf_offs % odev->width != 0)
 				ret = append_values(odev, odev->last_val,
 				ret = append_values(odev, odev->last_val,
-				      odev->width - (odev->buf_offs % odev->width));
-				if (ret < 0)
-					return ret;
+						    odev->width -
+						    (odev->buf_offs %
+						     odev->width));
+			if (ret < 0)
+				return ret;
 		}
 		}
 
 
 		offs++;
 		offs++;
@@ -559,47 +587,52 @@ error_header:
 	return -EIO;
 	return -EIO;
 }
 }
 
 
-static ssize_t set_picture(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t set_picture(struct device *dev, struct device_attribute *attr,
+			   const char *buf, size_t count)
 {
 {
 	struct usb_interface *intf = to_usb_interface(dev);
 	struct usb_interface *intf = to_usb_interface(dev);
 
 
 	return odev_set_picture(usb_get_intfdata(intf), buf, count);
 	return odev_set_picture(usb_get_intfdata(intf), buf, count);
 }
 }
 
 
-static ssize_t class_set_picture(struct device *device, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t class_set_picture(struct device *device,
+				 struct device_attribute *attr,
+				 const char *buf, size_t count)
 {
 {
-	return odev_set_picture((struct asus_oled_dev *) dev_get_drvdata(device), buf, count);
+	return odev_set_picture((struct asus_oled_dev *)
+				dev_get_drvdata(device), buf, count);
 }
 }
 
 
 #define ASUS_OLED_DEVICE_ATTR(_file)		dev_attr_asus_oled_##_file
 #define ASUS_OLED_DEVICE_ATTR(_file)		dev_attr_asus_oled_##_file
 
 
-static DEVICE_ATTR(asus_oled_enabled, S_IWUGO | S_IRUGO, get_enabled, set_enabled);
+static DEVICE_ATTR(asus_oled_enabled, S_IWUGO | S_IRUGO,
+		   get_enabled, set_enabled);
 static DEVICE_ATTR(asus_oled_picture, S_IWUGO , NULL, set_picture);
 static DEVICE_ATTR(asus_oled_picture, S_IWUGO , NULL, set_picture);
 
 
-static DEVICE_ATTR(enabled, S_IWUGO | S_IRUGO, class_get_enabled, class_set_enabled);
+static DEVICE_ATTR(enabled, S_IWUGO | S_IRUGO,
+		   class_get_enabled, class_set_enabled);
 static DEVICE_ATTR(picture, S_IWUGO, NULL, class_set_picture);
 static DEVICE_ATTR(picture, S_IWUGO, NULL, class_set_picture);
 
 
-static int asus_oled_probe(struct usb_interface *interface, const struct usb_device_id *id)
+static int asus_oled_probe(struct usb_interface *interface,
+			   const struct usb_device_id *id)
 {
 {
 	struct usb_device *udev = interface_to_usbdev(interface);
 	struct usb_device *udev = interface_to_usbdev(interface);
 	struct asus_oled_dev *odev = NULL;
 	struct asus_oled_dev *odev = NULL;
 	int retval = -ENOMEM;
 	int retval = -ENOMEM;
 	uint16_t dev_width = 0;
 	uint16_t dev_width = 0;
-	oled_pack_mode_t pack_mode = PACK_MODE_LAST;
-	const struct oled_dev_desc_str * dev_desc = oled_dev_desc_table;
+	enum oled_pack_mode pack_mode = PACK_MODE_LAST;
+	const struct oled_dev_desc_str *dev_desc = oled_dev_desc_table;
 	const char *desc = NULL;
 	const char *desc = NULL;
 
 
 	if (!id) {
 	if (!id) {
-		// Even possible? Just to make sure...
+		/* Even possible? Just to make sure...*/
 		dev_err(&interface->dev, "No usb_device_id provided!\n");
 		dev_err(&interface->dev, "No usb_device_id provided!\n");
 		return -ENODEV;
 		return -ENODEV;
 	}
 	}
 
 
-	for (; dev_desc->idVendor; dev_desc++)
-	{
+	for (; dev_desc->idVendor; dev_desc++) {
 		if (dev_desc->idVendor == id->idVendor
 		if (dev_desc->idVendor == id->idVendor
-			&& dev_desc->idProduct == id->idProduct)
-		{
+		    && dev_desc->idProduct == id->idProduct) {
 			dev_width = dev_desc->devWidth;
 			dev_width = dev_desc->devWidth;
 			desc = dev_desc->devDesc;
 			desc = dev_desc->devDesc;
 			pack_mode = dev_desc->packMode;
 			pack_mode = dev_desc->packMode;
@@ -608,7 +641,8 @@ static int asus_oled_probe(struct usb_interface *interface, const struct usb_dev
 	}
 	}
 
 
 	if (!desc || dev_width < 1 || pack_mode == PACK_MODE_LAST) {
 	if (!desc || dev_width < 1 || pack_mode == PACK_MODE_LAST) {
-		dev_err(&interface->dev, "Missing or incomplete device description!\n");
+		dev_err(&interface->dev,
+			"Missing or incomplete device description!\n");
 		return -ENODEV;
 		return -ENODEV;
 	}
 	}
 
 
@@ -636,16 +670,18 @@ static int asus_oled_probe(struct usb_interface *interface, const struct usb_dev
 
 
 	usb_set_intfdata(interface, odev);
 	usb_set_intfdata(interface, odev);
 
 
-	retval = device_create_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(enabled));
+	retval = device_create_file(&interface->dev,
+				    &ASUS_OLED_DEVICE_ATTR(enabled));
 	if (retval)
 	if (retval)
 		goto err_files;
 		goto err_files;
 
 
-	retval = device_create_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(picture));
+	retval = device_create_file(&interface->dev,
+				    &ASUS_OLED_DEVICE_ATTR(picture));
 	if (retval)
 	if (retval)
 		goto err_files;
 		goto err_files;
 
 
 	odev->dev = device_create(oled_class, &interface->dev, MKDEV(0, 0),
 	odev->dev = device_create(oled_class, &interface->dev, MKDEV(0, 0),
-				NULL, "oled_%d", ++oled_num);
+				  NULL, "oled_%d", ++oled_num);
 
 
 	if (IS_ERR(odev->dev)) {
 	if (IS_ERR(odev->dev)) {
 		retval = PTR_ERR(odev->dev);
 		retval = PTR_ERR(odev->dev);
@@ -662,7 +698,9 @@ static int asus_oled_probe(struct usb_interface *interface, const struct usb_dev
 	if (retval)
 	if (retval)
 		goto err_class_picture;
 		goto err_class_picture;
 
 
-	dev_info(&interface->dev, "Attached Asus OLED device: %s [width %u, pack_mode %d]\n", desc, odev->dev_width, odev->pack_mode);
+	dev_info(&interface->dev,
+		 "Attached Asus OLED device: %s [width %u, pack_mode %d]\n",
+		 desc, odev->dev_width, odev->pack_mode);
 
 
 	if (start_off)
 	if (start_off)
 		enable_oled(odev, 0);
 		enable_oled(odev, 0);
@@ -703,8 +741,7 @@ static void asus_oled_disconnect(struct usb_interface *interface)
 
 
 	usb_put_dev(odev->udev);
 	usb_put_dev(odev->udev);
 
 
-	if (odev->buf)
-		kfree(odev->buf);
+	kfree(odev->buf);
 
 
 	kfree(odev);
 	kfree(odev);
 
 
@@ -720,7 +757,8 @@ static struct usb_driver oled_driver = {
 
 
 static ssize_t version_show(struct class *dev, char *buf)
 static ssize_t version_show(struct class *dev, char *buf)
 {
 {
-	return sprintf(buf, ASUS_OLED_UNDERSCORE_NAME " %s\n", ASUS_OLED_VERSION);
+	return sprintf(buf, ASUS_OLED_UNDERSCORE_NAME " %s\n",
+		       ASUS_OLED_VERSION);
 }
 }
 
 
 static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
 static CLASS_ATTR(version, S_IRUGO, version_show, NULL);

+ 0 - 8
drivers/staging/at76_usb/Kconfig

@@ -1,8 +0,0 @@
-config USB_ATMEL
-	tristate "Atmel at76c503/at76c505/at76c505a USB cards"
-	depends on WLAN_80211 && USB
-	default N
-	select FW_LOADER
-	---help---
-	  Enable support for USB Wireless devices using Atmel at76c503,
-	  at76c505 or at76c505a chips.

+ 0 - 1
drivers/staging/at76_usb/Makefile

@@ -1 +0,0 @@
-obj-$(CONFIG_USB_ATMEL)		+= at76_usb.o

+ 0 - 7
drivers/staging/at76_usb/TODO

@@ -1,7 +0,0 @@
-Fix the mac80211 port of at76_usb (the proper in-kernel wireless
-stack) and get it included to the mainline. Patches available here:
-
-http://git.kernel.org/?p=linux/kernel/git/linville/wireless-legacy.git;a=shortlog;h=at76
-
-Contact Kalle Valo <kalle.valo@iki.fi> and linux-wireless list
-<linux-wireless@vger.kernel.org> for more information.

+ 0 - 5579
drivers/staging/at76_usb/at76_usb.c

@@ -1,5579 +0,0 @@
-/*
- * at76c503/at76c505 USB driver
- *
- * Copyright (c) 2002 - 2003 Oliver Kurth
- * Copyright (c) 2004 Joerg Albert <joerg.albert@gmx.de>
- * Copyright (c) 2004 Nick Jones
- * Copyright (c) 2004 Balint Seeber <n0_5p4m_p13453@hotmail.com>
- * Copyright (c) 2007 Guido Guenther <agx@sigxcpu.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 file is part of the Berlios driver for WLAN USB devices based on the
- * Atmel AT76C503A/505/505A.
- *
- * Some iw_handler code was taken from airo.c, (C) 1999 Benjamin Reed
- */
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/spinlock.h>
-#include <linux/list.h>
-#include <linux/usb.h>
-#include <linux/netdevice.h>
-#include <linux/if_arp.h>
-#include <linux/etherdevice.h>
-#include <linux/ethtool.h>
-#include <linux/wireless.h>
-#include <net/iw_handler.h>
-#include <net/ieee80211_radiotap.h>
-#include <linux/firmware.h>
-#include <linux/leds.h>
-#include <linux/ieee80211.h>
-
-#include "at76_usb.h"
-
-/* Version information */
-#define DRIVER_NAME "at76_usb"
-#define DRIVER_VERSION	"0.17"
-#define DRIVER_DESC "Atmel at76x USB Wireless LAN Driver"
-
-/* at76_debug bits */
-#define DBG_PROGRESS		0x00000001	/* authentication/accociation */
-#define DBG_BSS_TABLE		0x00000002	/* show BSS table after scans */
-#define DBG_IOCTL		0x00000004	/* ioctl calls / settings */
-#define DBG_MAC_STATE		0x00000008	/* MAC state transitions */
-#define DBG_TX_DATA		0x00000010	/* tx header */
-#define DBG_TX_DATA_CONTENT	0x00000020	/* tx content */
-#define DBG_TX_MGMT		0x00000040	/* tx management */
-#define DBG_RX_DATA		0x00000080	/* rx data header */
-#define DBG_RX_DATA_CONTENT	0x00000100	/* rx data content */
-#define DBG_RX_MGMT		0x00000200	/* rx mgmt frame headers */
-#define DBG_RX_BEACON		0x00000400	/* rx beacon */
-#define DBG_RX_CTRL		0x00000800	/* rx control */
-#define DBG_RX_MGMT_CONTENT	0x00001000	/* rx mgmt content */
-#define DBG_RX_FRAGS		0x00002000	/* rx data fragment handling */
-#define DBG_DEVSTART		0x00004000	/* fw download, device start */
-#define DBG_URB			0x00008000	/* rx urb status, ... */
-#define DBG_RX_ATMEL_HDR	0x00010000	/* Atmel-specific Rx headers */
-#define DBG_PROC_ENTRY		0x00020000	/* procedure entries/exits */
-#define DBG_PM			0x00040000	/* power management settings */
-#define DBG_BSS_MATCH		0x00080000	/* BSS match failures */
-#define DBG_PARAMS		0x00100000	/* show configured parameters */
-#define DBG_WAIT_COMPLETE	0x00200000	/* command completion */
-#define DBG_RX_FRAGS_SKB	0x00400000	/* skb header of Rx fragments */
-#define DBG_BSS_TABLE_RM	0x00800000	/* purging bss table entries */
-#define DBG_MONITOR_MODE	0x01000000	/* monitor mode */
-#define DBG_MIB			0x02000000	/* dump all MIBs on startup */
-#define DBG_MGMT_TIMER		0x04000000	/* dump mgmt_timer ops */
-#define DBG_WE_EVENTS		0x08000000	/* dump wireless events */
-#define DBG_FW			0x10000000	/* firmware download */
-#define DBG_DFU			0x20000000	/* device firmware upgrade */
-
-#define DBG_DEFAULTS		0
-
-/* Use our own dbg macro */
-#define at76_dbg(bits, format, arg...) \
-	do { \
-		if (at76_debug & (bits)) \
-		printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , ## arg); \
-	} while (0)
-
-static int at76_debug = DBG_DEFAULTS;
-
-/* Protect against concurrent firmware loading and parsing */
-static struct mutex fw_mutex;
-
-static struct fwentry firmwares[] = {
-	[0] = {""},
-	[BOARD_503_ISL3861] = {"atmel_at76c503-i3861.bin"},
-	[BOARD_503_ISL3863] = {"atmel_at76c503-i3863.bin"},
-	[BOARD_503] = {"atmel_at76c503-rfmd.bin"},
-	[BOARD_503_ACC] = {"atmel_at76c503-rfmd-acc.bin"},
-	[BOARD_505] = {"atmel_at76c505-rfmd.bin"},
-	[BOARD_505_2958] = {"atmel_at76c505-rfmd2958.bin"},
-	[BOARD_505A] = {"atmel_at76c505a-rfmd2958.bin"},
-	[BOARD_505AMX] = {"atmel_at76c505amx-rfmd.bin"},
-};
-
-#define USB_DEVICE_DATA(__ops)	.driver_info = (kernel_ulong_t)(__ops)
-
-static struct usb_device_id dev_table[] = {
-	/*
-	 * at76c503-i3861
-	 */
-	/* Generic AT76C503/3861 device */
-	{USB_DEVICE(0x03eb, 0x7603), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* Linksys WUSB11 v2.1/v2.6 */
-	{USB_DEVICE(0x066b, 0x2211), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* Netgear MA101 rev. A */
-	{USB_DEVICE(0x0864, 0x4100), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* Tekram U300C / Allnet ALL0193 */
-	{USB_DEVICE(0x0b3b, 0x1612), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* HP HN210W J7801A */
-	{USB_DEVICE(0x03f0, 0x011c), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* Sitecom/Z-Com/Zyxel M4Y-750 */
-	{USB_DEVICE(0x0cde, 0x0001), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* Dynalink/Askey WLL013 (intersil) */
-	{USB_DEVICE(0x069a, 0x0320), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* EZ connect 11Mpbs Wireless USB Adapter SMC2662W v1 */
-	{USB_DEVICE(0x0d5c, 0xa001), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* BenQ AWL300 */
-	{USB_DEVICE(0x04a5, 0x9000), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* Addtron AWU-120, Compex WLU11 */
-	{USB_DEVICE(0x05dd, 0xff31), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* Intel AP310 AnyPoint II USB */
-	{USB_DEVICE(0x8086, 0x0200), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* Dynalink L11U */
-	{USB_DEVICE(0x0d8e, 0x7100), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* Arescom WL-210, FCC id 07J-GL2411USB */
-	{USB_DEVICE(0x0d8e, 0x7110), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* I-O DATA WN-B11/USB */
-	{USB_DEVICE(0x04bb, 0x0919), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/* BT Voyager 1010 */
-	{USB_DEVICE(0x069a, 0x0821), USB_DEVICE_DATA(BOARD_503_ISL3861)},
-	/*
-	 * at76c503-i3863
-	 */
-	/* Generic AT76C503/3863 device */
-	{USB_DEVICE(0x03eb, 0x7604), USB_DEVICE_DATA(BOARD_503_ISL3863)},
-	/* Samsung SWL-2100U */
-	{USB_DEVICE(0x055d, 0xa000), USB_DEVICE_DATA(BOARD_503_ISL3863)},
-	/*
-	 * at76c503-rfmd
-	 */
-	/* Generic AT76C503/RFMD device */
-	{USB_DEVICE(0x03eb, 0x7605), USB_DEVICE_DATA(BOARD_503)},
-	/* Dynalink/Askey WLL013 (rfmd) */
-	{USB_DEVICE(0x069a, 0x0321), USB_DEVICE_DATA(BOARD_503)},
-	/* Linksys WUSB11 v2.6 */
-	{USB_DEVICE(0x077b, 0x2219), USB_DEVICE_DATA(BOARD_503)},
-	/* Network Everywhere NWU11B */
-	{USB_DEVICE(0x077b, 0x2227), USB_DEVICE_DATA(BOARD_503)},
-	/* Netgear MA101 rev. B */
-	{USB_DEVICE(0x0864, 0x4102), USB_DEVICE_DATA(BOARD_503)},
-	/* D-Link DWL-120 rev. E */
-	{USB_DEVICE(0x2001, 0x3200), USB_DEVICE_DATA(BOARD_503)},
-	/* Actiontec 802UAT1, HWU01150-01UK */
-	{USB_DEVICE(0x1668, 0x7605), USB_DEVICE_DATA(BOARD_503)},
-	/* AirVast W-Buddie WN210 */
-	{USB_DEVICE(0x03eb, 0x4102), USB_DEVICE_DATA(BOARD_503)},
-	/* Dick Smith Electronics XH1153 802.11b USB adapter */
-	{USB_DEVICE(0x1371, 0x5743), USB_DEVICE_DATA(BOARD_503)},
-	/* CNet CNUSB611 */
-	{USB_DEVICE(0x1371, 0x0001), USB_DEVICE_DATA(BOARD_503)},
-	/* FiberLine FL-WL200U */
-	{USB_DEVICE(0x1371, 0x0002), USB_DEVICE_DATA(BOARD_503)},
-	/* BenQ AWL400 USB stick */
-	{USB_DEVICE(0x04a5, 0x9001), USB_DEVICE_DATA(BOARD_503)},
-	/* 3Com 3CRSHEW696 */
-	{USB_DEVICE(0x0506, 0x0a01), USB_DEVICE_DATA(BOARD_503)},
-	/* Siemens Santis ADSL WLAN USB adapter WLL 013 */
-	{USB_DEVICE(0x0681, 0x001b), USB_DEVICE_DATA(BOARD_503)},
-	/* Belkin F5D6050, version 2 */
-	{USB_DEVICE(0x050d, 0x0050), USB_DEVICE_DATA(BOARD_503)},
-	/* iBlitzz, BWU613 (not *B or *SB) */
-	{USB_DEVICE(0x07b8, 0xb000), USB_DEVICE_DATA(BOARD_503)},
-	/* Gigabyte GN-WLBM101 */
-	{USB_DEVICE(0x1044, 0x8003), USB_DEVICE_DATA(BOARD_503)},
-	/* Planex GW-US11S */
-	{USB_DEVICE(0x2019, 0x3220), USB_DEVICE_DATA(BOARD_503)},
-	/* Internal WLAN adapter in h5[4,5]xx series iPAQs */
-	{USB_DEVICE(0x049f, 0x0032), USB_DEVICE_DATA(BOARD_503)},
-	/* Corega Wireless LAN USB-11 mini */
-	{USB_DEVICE(0x07aa, 0x0011), USB_DEVICE_DATA(BOARD_503)},
-	/* Corega Wireless LAN USB-11 mini2 */
-	{USB_DEVICE(0x07aa, 0x0018), USB_DEVICE_DATA(BOARD_503)},
-	/* Uniden PCW100 */
-	{USB_DEVICE(0x05dd, 0xff35), USB_DEVICE_DATA(BOARD_503)},
-	/*
-	 * at76c503-rfmd-acc
-	 */
-	/* SMC2664W */
-	{USB_DEVICE(0x083a, 0x3501), USB_DEVICE_DATA(BOARD_503_ACC)},
-	/* Belkin F5D6050, SMC2662W v2, SMC2662W-AR */
-	{USB_DEVICE(0x0d5c, 0xa002), USB_DEVICE_DATA(BOARD_503_ACC)},
-	/*
-	 * at76c505-rfmd
-	 */
-	/* Generic AT76C505/RFMD */
-	{USB_DEVICE(0x03eb, 0x7606), USB_DEVICE_DATA(BOARD_505)},
-	/*
-	 * at76c505-rfmd2958
-	 */
-	/* Generic AT76C505/RFMD, OvisLink WL-1130USB */
-	{USB_DEVICE(0x03eb, 0x7613), USB_DEVICE_DATA(BOARD_505_2958)},
-	/* Fiberline FL-WL240U */
-	{USB_DEVICE(0x1371, 0x0014), USB_DEVICE_DATA(BOARD_505_2958)},
-	/* CNet CNUSB-611G */
-	{USB_DEVICE(0x1371, 0x0013), USB_DEVICE_DATA(BOARD_505_2958)},
-	/* Linksys WUSB11 v2.8 */
-	{USB_DEVICE(0x1915, 0x2233), USB_DEVICE_DATA(BOARD_505_2958)},
-	/* Xterasys XN-2122B, IBlitzz BWU613B/BWU613SB */
-	{USB_DEVICE(0x12fd, 0x1001), USB_DEVICE_DATA(BOARD_505_2958)},
-	/* Corega WLAN USB Stick 11 */
-	{USB_DEVICE(0x07aa, 0x7613), USB_DEVICE_DATA(BOARD_505_2958)},
-	/* Microstar MSI Box MS6978 */
-	{USB_DEVICE(0x0db0, 0x1020), USB_DEVICE_DATA(BOARD_505_2958)},
-	/*
-	 * at76c505a-rfmd2958
-	 */
-	/* Generic AT76C505A device */
-	{USB_DEVICE(0x03eb, 0x7614), USB_DEVICE_DATA(BOARD_505A)},
-	/* Generic AT76C505AS device */
-	{USB_DEVICE(0x03eb, 0x7617), USB_DEVICE_DATA(BOARD_505A)},
-	/* Siemens Gigaset USB WLAN Adapter 11 */
-	{USB_DEVICE(0x1690, 0x0701), USB_DEVICE_DATA(BOARD_505A)},
-	/* OQO Model 01+ Internal Wi-Fi */
-	{USB_DEVICE(0x1557, 0x0002), USB_DEVICE_DATA(BOARD_505A)},
-	/*
-	 * at76c505amx-rfmd
-	 */
-	/* Generic AT76C505AMX device */
-	{USB_DEVICE(0x03eb, 0x7615), USB_DEVICE_DATA(BOARD_505AMX)},
-	{}
-};
-
-MODULE_DEVICE_TABLE(usb, dev_table);
-
-/* Supported rates of this hardware, bit 7 marks basic rates */
-static const u8 hw_rates[] = { 0x82, 0x84, 0x0b, 0x16 };
-
-/* Frequency of each channel in MHz */
-static const long channel_frequency[] = {
-	2412, 2417, 2422, 2427, 2432, 2437, 2442,
-	2447, 2452, 2457, 2462, 2467, 2472, 2484
-};
-
-#define NUM_CHANNELS ARRAY_SIZE(channel_frequency)
-
-static const char *const preambles[] = { "long", "short", "auto" };
-
-static const char *const mac_states[] = {
-	[MAC_INIT] = "INIT",
-	[MAC_SCANNING] = "SCANNING",
-	[MAC_AUTH] = "AUTH",
-	[MAC_ASSOC] = "ASSOC",
-	[MAC_JOINING] = "JOINING",
-	[MAC_CONNECTED] = "CONNECTED",
-	[MAC_OWN_IBSS] = "OWN_IBSS"
-};
-
-/* Firmware download */
-/* DFU states */
-#define STATE_IDLE			0x00
-#define STATE_DETACH			0x01
-#define STATE_DFU_IDLE			0x02
-#define STATE_DFU_DOWNLOAD_SYNC		0x03
-#define STATE_DFU_DOWNLOAD_BUSY		0x04
-#define STATE_DFU_DOWNLOAD_IDLE		0x05
-#define STATE_DFU_MANIFEST_SYNC		0x06
-#define STATE_DFU_MANIFEST		0x07
-#define STATE_DFU_MANIFEST_WAIT_RESET	0x08
-#define STATE_DFU_UPLOAD_IDLE		0x09
-#define STATE_DFU_ERROR			0x0a
-
-/* DFU commands */
-#define DFU_DETACH			0
-#define DFU_DNLOAD			1
-#define DFU_UPLOAD			2
-#define DFU_GETSTATUS			3
-#define DFU_CLRSTATUS			4
-#define DFU_GETSTATE			5
-#define DFU_ABORT			6
-
-#define FW_BLOCK_SIZE 1024
-
-struct dfu_status {
-	unsigned char status;
-	unsigned char poll_timeout[3];
-	unsigned char state;
-	unsigned char string;
-} __attribute__((packed));
-
-static inline int at76_is_intersil(enum board_type board)
-{
-	return (board == BOARD_503_ISL3861 || board == BOARD_503_ISL3863);
-}
-
-static inline int at76_is_503rfmd(enum board_type board)
-{
-	return (board == BOARD_503 || board == BOARD_503_ACC);
-}
-
-static inline int at76_is_505a(enum board_type board)
-{
-	return (board == BOARD_505A || board == BOARD_505AMX);
-}
-
-/* Load a block of the first (internal) part of the firmware */
-static int at76_load_int_fw_block(struct usb_device *udev, int blockno,
-				  void *block, int size)
-{
-	return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), DFU_DNLOAD,
-			       USB_TYPE_CLASS | USB_DIR_OUT |
-			       USB_RECIP_INTERFACE, blockno, 0, block, size,
-			       USB_CTRL_GET_TIMEOUT);
-}
-
-static int at76_dfu_get_status(struct usb_device *udev,
-			       struct dfu_status *status)
-{
-	int ret;
-
-	ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), DFU_GETSTATUS,
-			      USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE,
-			      0, 0, status, sizeof(struct dfu_status),
-			      USB_CTRL_GET_TIMEOUT);
-	return ret;
-}
-
-static u8 at76_dfu_get_state(struct usb_device *udev, u8 *state)
-{
-	int ret;
-
-	ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), DFU_GETSTATE,
-			      USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE,
-			      0, 0, state, 1, USB_CTRL_GET_TIMEOUT);
-	return ret;
-}
-
-/* Convert timeout from the DFU status to jiffies */
-static inline unsigned long at76_get_timeout(struct dfu_status *s)
-{
-	return msecs_to_jiffies((s->poll_timeout[2] << 16)
-				| (s->poll_timeout[1] << 8)
-				| (s->poll_timeout[0]));
-}
-
-/* Load internal firmware from the buffer.  If manifest_sync_timeout > 0, use
- * its value in jiffies in the MANIFEST_SYNC state.  */
-static int at76_usbdfu_download(struct usb_device *udev, u8 *buf, u32 size,
-				int manifest_sync_timeout)
-{
-	u8 *block;
-	struct dfu_status dfu_stat_buf;
-	int ret = 0;
-	int need_dfu_state = 1;
-	int is_done = 0;
-	u8 dfu_state = 0;
-	u32 dfu_timeout = 0;
-	int bsize = 0;
-	int blockno = 0;
-
-	at76_dbg(DBG_DFU, "%s( %p, %u, %d)", __func__, buf, size,
-		 manifest_sync_timeout);
-
-	if (!size) {
-		dev_printk(KERN_ERR, &udev->dev, "FW buffer length invalid!\n");
-		return -EINVAL;
-	}
-
-	block = kmalloc(FW_BLOCK_SIZE, GFP_KERNEL);
-	if (!block)
-		return -ENOMEM;
-
-	do {
-		if (need_dfu_state) {
-			ret = at76_dfu_get_state(udev, &dfu_state);
-			if (ret < 0) {
-				dev_printk(KERN_ERR, &udev->dev,
-					   "cannot get DFU state: %d\n", ret);
-				goto exit;
-			}
-			need_dfu_state = 0;
-		}
-
-		switch (dfu_state) {
-		case STATE_DFU_DOWNLOAD_SYNC:
-			at76_dbg(DBG_DFU, "STATE_DFU_DOWNLOAD_SYNC");
-			ret = at76_dfu_get_status(udev, &dfu_stat_buf);
-			if (ret >= 0) {
-				dfu_state = dfu_stat_buf.state;
-				dfu_timeout = at76_get_timeout(&dfu_stat_buf);
-				need_dfu_state = 0;
-			} else
-				dev_printk(KERN_ERR, &udev->dev,
-					   "at76_dfu_get_status returned %d\n",
-					   ret);
-			break;
-
-		case STATE_DFU_DOWNLOAD_BUSY:
-			at76_dbg(DBG_DFU, "STATE_DFU_DOWNLOAD_BUSY");
-			need_dfu_state = 1;
-
-			at76_dbg(DBG_DFU, "DFU: Resetting device");
-			schedule_timeout_interruptible(dfu_timeout);
-			break;
-
-		case STATE_DFU_DOWNLOAD_IDLE:
-			at76_dbg(DBG_DFU, "DOWNLOAD...");
-			/* fall through */
-		case STATE_DFU_IDLE:
-			at76_dbg(DBG_DFU, "DFU IDLE");
-
-			bsize = min_t(int, size, FW_BLOCK_SIZE);
-			memcpy(block, buf, bsize);
-			at76_dbg(DBG_DFU, "int fw, size left = %5d, "
-				 "bsize = %4d, blockno = %2d", size, bsize,
-				 blockno);
-			ret =
-			    at76_load_int_fw_block(udev, blockno, block, bsize);
-			buf += bsize;
-			size -= bsize;
-			blockno++;
-
-			if (ret != bsize)
-				dev_printk(KERN_ERR, &udev->dev,
-					   "at76_load_int_fw_block "
-					   "returned %d\n", ret);
-			need_dfu_state = 1;
-			break;
-
-		case STATE_DFU_MANIFEST_SYNC:
-			at76_dbg(DBG_DFU, "STATE_DFU_MANIFEST_SYNC");
-
-			ret = at76_dfu_get_status(udev, &dfu_stat_buf);
-			if (ret < 0)
-				break;
-
-			dfu_state = dfu_stat_buf.state;
-			dfu_timeout = at76_get_timeout(&dfu_stat_buf);
-			need_dfu_state = 0;
-
-			/* override the timeout from the status response,
-			   needed for AT76C505A */
-			if (manifest_sync_timeout > 0)
-				dfu_timeout = manifest_sync_timeout;
-
-			at76_dbg(DBG_DFU, "DFU: Waiting for manifest phase");
-			schedule_timeout_interruptible(dfu_timeout);
-			break;
-
-		case STATE_DFU_MANIFEST:
-			at76_dbg(DBG_DFU, "STATE_DFU_MANIFEST");
-			is_done = 1;
-			break;
-
-		case STATE_DFU_MANIFEST_WAIT_RESET:
-			at76_dbg(DBG_DFU, "STATE_DFU_MANIFEST_WAIT_RESET");
-			is_done = 1;
-			break;
-
-		case STATE_DFU_UPLOAD_IDLE:
-			at76_dbg(DBG_DFU, "STATE_DFU_UPLOAD_IDLE");
-			break;
-
-		case STATE_DFU_ERROR:
-			at76_dbg(DBG_DFU, "STATE_DFU_ERROR");
-			ret = -EPIPE;
-			break;
-
-		default:
-			at76_dbg(DBG_DFU, "DFU UNKNOWN STATE (%d)", dfu_state);
-			ret = -EINVAL;
-			break;
-		}
-	} while (!is_done && (ret >= 0));
-
-exit:
-	kfree(block);
-	if (ret >= 0)
-		ret = 0;
-
-	return ret;
-}
-
-/* Report that the scan results are ready */
-static inline void at76_iwevent_scan_complete(struct net_device *netdev)
-{
-	union iwreq_data wrqu;
-	wrqu.data.length = 0;
-	wrqu.data.flags = 0;
-	wireless_send_event(netdev, SIOCGIWSCAN, &wrqu, NULL);
-	at76_dbg(DBG_WE_EVENTS, "%s: SIOCGIWSCAN sent", netdev->name);
-}
-
-static inline void at76_iwevent_bss_connect(struct net_device *netdev,
-					    u8 *bssid)
-{
-	union iwreq_data wrqu;
-	wrqu.data.length = 0;
-	wrqu.data.flags = 0;
-	memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
-	wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-	wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
-	at76_dbg(DBG_WE_EVENTS, "%s: %s: SIOCGIWAP sent", netdev->name,
-		 __func__);
-}
-
-static inline void at76_iwevent_bss_disconnect(struct net_device *netdev)
-{
-	union iwreq_data wrqu;
-	wrqu.data.length = 0;
-	wrqu.data.flags = 0;
-	memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
-	wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-	wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
-	at76_dbg(DBG_WE_EVENTS, "%s: %s: SIOCGIWAP sent", netdev->name,
-		 __func__);
-}
-
-#define HEX2STR_BUFFERS 4
-#define HEX2STR_MAX_LEN 64
-#define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10)
-
-/* Convert binary data into hex string */
-static char *hex2str(void *buf, int len)
-{
-	static atomic_t a = ATOMIC_INIT(0);
-	static char bufs[HEX2STR_BUFFERS][3 * HEX2STR_MAX_LEN + 1];
-	char *ret = bufs[atomic_inc_return(&a) & (HEX2STR_BUFFERS - 1)];
-	char *obuf = ret;
-	u8 *ibuf = buf;
-
-	if (len > HEX2STR_MAX_LEN)
-		len = HEX2STR_MAX_LEN;
-
-	if (len <= 0) {
-		ret[0] = '\0';
-		return ret;
-	}
-
-	while (len--) {
-		*obuf++ = BIN2HEX(*ibuf >> 4);
-		*obuf++ = BIN2HEX(*ibuf & 0xf);
-		*obuf++ = '-';
-		ibuf++;
-	}
-	*(--obuf) = '\0';
-
-	return ret;
-}
-
-#define MAC2STR_BUFFERS 4
-
-static inline char *mac2str(u8 *mac)
-{
-	static atomic_t a = ATOMIC_INIT(0);
-	static char bufs[MAC2STR_BUFFERS][6 * 3];
-	char *str;
-
-	str = bufs[atomic_inc_return(&a) & (MAC2STR_BUFFERS - 1)];
-	sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x",
-		mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-	return str;
-}
-
-/* LED trigger */
-static int tx_activity;
-static void at76_ledtrig_tx_timerfunc(unsigned long data);
-static DEFINE_TIMER(ledtrig_tx_timer, at76_ledtrig_tx_timerfunc, 0, 0);
-DEFINE_LED_TRIGGER(ledtrig_tx);
-
-static void at76_ledtrig_tx_timerfunc(unsigned long data)
-{
-	static int tx_lastactivity;
-
-	if (tx_lastactivity != tx_activity) {
-		tx_lastactivity = tx_activity;
-		led_trigger_event(ledtrig_tx, LED_FULL);
-		mod_timer(&ledtrig_tx_timer, jiffies + HZ / 4);
-	} else
-		led_trigger_event(ledtrig_tx, LED_OFF);
-}
-
-static void at76_ledtrig_tx_activity(void)
-{
-	tx_activity++;
-	if (!timer_pending(&ledtrig_tx_timer))
-		mod_timer(&ledtrig_tx_timer, jiffies + HZ / 4);
-}
-
-/* Check if the given ssid is hidden */
-static inline int at76_is_hidden_ssid(u8 *ssid, int length)
-{
-	static const u8 zeros[32];
-
-	if (length == 0)
-		return 1;
-
-	if (length == 1 && ssid[0] == ' ')
-		return 1;
-
-	return (memcmp(ssid, zeros, length) == 0);
-}
-
-static inline void at76_free_bss_list(struct at76_priv *priv)
-{
-	struct list_head *next, *ptr;
-	unsigned long flags;
-
-	spin_lock_irqsave(&priv->bss_list_spinlock, flags);
-
-	priv->curr_bss = NULL;
-
-	list_for_each_safe(ptr, next, &priv->bss_list) {
-		list_del(ptr);
-		kfree(list_entry(ptr, struct bss_info, list));
-	}
-
-	spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
-}
-
-static int at76_remap(struct usb_device *udev)
-{
-	int ret;
-	ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0a,
-			      USB_TYPE_VENDOR | USB_DIR_OUT |
-			      USB_RECIP_INTERFACE, 0, 0, NULL, 0,
-			      USB_CTRL_GET_TIMEOUT);
-	if (ret < 0)
-		return ret;
-	return 0;
-}
-
-static int at76_get_op_mode(struct usb_device *udev)
-{
-	int ret;
-	u8 saved;
-	u8 *op_mode;
-
-	op_mode = kmalloc(1, GFP_NOIO);
-	if (!op_mode)
-		return -ENOMEM;
-	ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33,
-			      USB_TYPE_VENDOR | USB_DIR_IN |
-			      USB_RECIP_INTERFACE, 0x01, 0, op_mode, 1,
-			      USB_CTRL_GET_TIMEOUT);
-	saved = *op_mode;
-	kfree(op_mode);
-
-	if (ret < 0)
-		return ret;
-	else if (ret < 1)
-		return -EIO;
-	else
-		return saved;
-}
-
-/* Load a block of the second ("external") part of the firmware */
-static inline int at76_load_ext_fw_block(struct usb_device *udev, int blockno,
-					 void *block, int size)
-{
-	return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e,
-			       USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
-			       0x0802, blockno, block, size,
-			       USB_CTRL_GET_TIMEOUT);
-}
-
-static inline int at76_get_hw_cfg(struct usb_device *udev,
-				  union at76_hwcfg *buf, int buf_size)
-{
-	return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33,
-			       USB_TYPE_VENDOR | USB_DIR_IN |
-			       USB_RECIP_INTERFACE, 0x0a02, 0,
-			       buf, buf_size, USB_CTRL_GET_TIMEOUT);
-}
-
-/* Intersil boards use a different "value" for GetHWConfig requests */
-static inline int at76_get_hw_cfg_intersil(struct usb_device *udev,
-					   union at76_hwcfg *buf, int buf_size)
-{
-	return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33,
-			       USB_TYPE_VENDOR | USB_DIR_IN |
-			       USB_RECIP_INTERFACE, 0x0902, 0,
-			       buf, buf_size, USB_CTRL_GET_TIMEOUT);
-}
-
-/* Get the hardware configuration for the adapter and put it to the appropriate
- * fields of 'priv' (the GetHWConfig request and interpretation of the result
- * depends on the board type) */
-static int at76_get_hw_config(struct at76_priv *priv)
-{
-	int ret;
-	union at76_hwcfg *hwcfg = kmalloc(sizeof(*hwcfg), GFP_KERNEL);
-
-	if (!hwcfg)
-		return -ENOMEM;
-
-	if (at76_is_intersil(priv->board_type)) {
-		ret = at76_get_hw_cfg_intersil(priv->udev, hwcfg,
-					       sizeof(hwcfg->i));
-		if (ret < 0)
-			goto exit;
-		memcpy(priv->mac_addr, hwcfg->i.mac_addr, ETH_ALEN);
-		priv->regulatory_domain = hwcfg->i.regulatory_domain;
-	} else if (at76_is_503rfmd(priv->board_type)) {
-		ret = at76_get_hw_cfg(priv->udev, hwcfg, sizeof(hwcfg->r3));
-		if (ret < 0)
-			goto exit;
-		memcpy(priv->mac_addr, hwcfg->r3.mac_addr, ETH_ALEN);
-		priv->regulatory_domain = hwcfg->r3.regulatory_domain;
-	} else {
-		ret = at76_get_hw_cfg(priv->udev, hwcfg, sizeof(hwcfg->r5));
-		if (ret < 0)
-			goto exit;
-		memcpy(priv->mac_addr, hwcfg->r5.mac_addr, ETH_ALEN);
-		priv->regulatory_domain = hwcfg->r5.regulatory_domain;
-	}
-
-exit:
-	kfree(hwcfg);
-	if (ret < 0)
-		printk(KERN_ERR "%s: cannot get HW Config (error %d)\n",
-		       priv->netdev->name, ret);
-
-	return ret;
-}
-
-static struct reg_domain const *at76_get_reg_domain(u16 code)
-{
-	int i;
-	static struct reg_domain const fd_tab[] = {
-		{0x10, "FCC (USA)", 0x7ff},	/* ch 1-11 */
-		{0x20, "IC (Canada)", 0x7ff},	/* ch 1-11 */
-		{0x30, "ETSI (most of Europe)", 0x1fff},	/* ch 1-13 */
-		{0x31, "Spain", 0x600},	/* ch 10-11 */
-		{0x32, "France", 0x1e00},	/* ch 10-13 */
-		{0x40, "MKK (Japan)", 0x2000},	/* ch 14 */
-		{0x41, "MKK1 (Japan)", 0x3fff},	/* ch 1-14 */
-		{0x50, "Israel", 0x3fc},	/* ch 3-9 */
-		{0x00, "<unknown>", 0xffffffff}	/* ch 1-32 */
-	};
-
-	/* Last entry is fallback for unknown domain code */
-	for (i = 0; i < ARRAY_SIZE(fd_tab) - 1; i++)
-		if (code == fd_tab[i].code)
-			break;
-
-	return &fd_tab[i];
-}
-
-static inline int at76_get_mib(struct usb_device *udev, u16 mib, void *buf,
-			       int buf_size)
-{
-	int ret;
-
-	ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33,
-			      USB_TYPE_VENDOR | USB_DIR_IN |
-			      USB_RECIP_INTERFACE, mib << 8, 0, buf, buf_size,
-			      USB_CTRL_GET_TIMEOUT);
-	if (ret >= 0 && ret != buf_size)
-		return -EIO;
-	return ret;
-}
-
-/* Return positive number for status, negative for an error */
-static inline int at76_get_cmd_status(struct usb_device *udev, u8 cmd)
-{
-	u8 *stat_buf;
-	int ret;
-
-	stat_buf = kmalloc(40, GFP_NOIO);
-	if (!stat_buf)
-		return -ENOMEM;
-
-	ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x22,
-			      USB_TYPE_VENDOR | USB_DIR_IN |
-			      USB_RECIP_INTERFACE, cmd, 0, stat_buf,
-			      40, USB_CTRL_GET_TIMEOUT);
-	if (ret >= 0)
-		ret = stat_buf[5];
-	kfree(stat_buf);
-
-	return ret;
-}
-
-static int at76_set_card_command(struct usb_device *udev, u8 cmd, void *buf,
-				 int buf_size)
-{
-	int ret;
-	struct at76_command *cmd_buf = kmalloc(sizeof(struct at76_command) +
-					       buf_size, GFP_KERNEL);
-
-	if (!cmd_buf)
-		return -ENOMEM;
-
-	cmd_buf->cmd = cmd;
-	cmd_buf->reserved = 0;
-	cmd_buf->size = cpu_to_le16(buf_size);
-	memcpy(cmd_buf->data, buf, buf_size);
-
-	ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e,
-			      USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
-			      0, 0, cmd_buf,
-			      sizeof(struct at76_command) + buf_size,
-			      USB_CTRL_GET_TIMEOUT);
-	kfree(cmd_buf);
-	return ret;
-}
-
-#define MAKE_CMD_STATUS_CASE(c)	case (c): return #c
-static const char *at76_get_cmd_status_string(u8 cmd_status)
-{
-	switch (cmd_status) {
-		MAKE_CMD_STATUS_CASE(CMD_STATUS_IDLE);
-		MAKE_CMD_STATUS_CASE(CMD_STATUS_COMPLETE);
-		MAKE_CMD_STATUS_CASE(CMD_STATUS_UNKNOWN);
-		MAKE_CMD_STATUS_CASE(CMD_STATUS_INVALID_PARAMETER);
-		MAKE_CMD_STATUS_CASE(CMD_STATUS_FUNCTION_NOT_SUPPORTED);
-		MAKE_CMD_STATUS_CASE(CMD_STATUS_TIME_OUT);
-		MAKE_CMD_STATUS_CASE(CMD_STATUS_IN_PROGRESS);
-		MAKE_CMD_STATUS_CASE(CMD_STATUS_HOST_FAILURE);
-		MAKE_CMD_STATUS_CASE(CMD_STATUS_SCAN_FAILED);
-	}
-
-	return "UNKNOWN";
-}
-
-/* Wait until the command is completed */
-static int at76_wait_completion(struct at76_priv *priv, int cmd)
-{
-	int status = 0;
-	unsigned long timeout = jiffies + CMD_COMPLETION_TIMEOUT;
-
-	do {
-		status = at76_get_cmd_status(priv->udev, cmd);
-		if (status < 0) {
-			printk(KERN_ERR "%s: at76_get_cmd_status failed: %d\n",
-			       priv->netdev->name, status);
-			break;
-		}
-
-		at76_dbg(DBG_WAIT_COMPLETE,
-			 "%s: Waiting on cmd %d, status = %d (%s)",
-			 priv->netdev->name, cmd, status,
-			 at76_get_cmd_status_string(status));
-
-		if (status != CMD_STATUS_IN_PROGRESS
-		    && status != CMD_STATUS_IDLE)
-			break;
-
-		schedule_timeout_interruptible(HZ / 10);	/* 100 ms */
-		if (time_after(jiffies, timeout)) {
-			printk(KERN_ERR
-			       "%s: completion timeout for command %d\n",
-			       priv->netdev->name, cmd);
-			status = -ETIMEDOUT;
-			break;
-		}
-	} while (1);
-
-	return status;
-}
-
-static int at76_set_mib(struct at76_priv *priv, struct set_mib_buffer *buf)
-{
-	int ret;
-
-	ret = at76_set_card_command(priv->udev, CMD_SET_MIB, buf,
-				    offsetof(struct set_mib_buffer,
-					     data) + buf->size);
-	if (ret < 0)
-		return ret;
-
-	ret = at76_wait_completion(priv, CMD_SET_MIB);
-	if (ret != CMD_STATUS_COMPLETE) {
-		printk(KERN_INFO
-		       "%s: set_mib: at76_wait_completion failed "
-		       "with %d\n", priv->netdev->name, ret);
-		ret = -EIO;
-	}
-
-	return ret;
-}
-
-/* Return < 0 on error, == 0 if no command sent, == 1 if cmd sent */
-static int at76_set_radio(struct at76_priv *priv, int enable)
-{
-	int ret;
-	int cmd;
-
-	if (priv->radio_on == enable)
-		return 0;
-
-	cmd = enable ? CMD_RADIO_ON : CMD_RADIO_OFF;
-
-	ret = at76_set_card_command(priv->udev, cmd, NULL, 0);
-	if (ret < 0)
-		printk(KERN_ERR "%s: at76_set_card_command(%d) failed: %d\n",
-		       priv->netdev->name, cmd, ret);
-	else
-		ret = 1;
-
-	priv->radio_on = enable;
-	return ret;
-}
-
-/* Set current power save mode (AT76_PM_OFF/AT76_PM_ON/AT76_PM_SMART) */
-static int at76_set_pm_mode(struct at76_priv *priv)
-{
-	int ret = 0;
-
-	priv->mib_buf.type = MIB_MAC_MGMT;
-	priv->mib_buf.size = 1;
-	priv->mib_buf.index = offsetof(struct mib_mac_mgmt, power_mgmt_mode);
-	priv->mib_buf.data.byte = priv->pm_mode;
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0)
-		printk(KERN_ERR "%s: set_mib (pm_mode) failed: %d\n",
-		       priv->netdev->name, ret);
-
-	return ret;
-}
-
-/* Set the association id for power save mode */
-static int at76_set_associd(struct at76_priv *priv, u16 id)
-{
-	int ret = 0;
-
-	priv->mib_buf.type = MIB_MAC_MGMT;
-	priv->mib_buf.size = 2;
-	priv->mib_buf.index = offsetof(struct mib_mac_mgmt, station_id);
-	priv->mib_buf.data.word = cpu_to_le16(id);
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0)
-		printk(KERN_ERR "%s: set_mib (associd) failed: %d\n",
-		       priv->netdev->name, ret);
-
-	return ret;
-}
-
-/* Set the listen interval for power save mode */
-static int at76_set_listen_interval(struct at76_priv *priv, u16 interval)
-{
-	int ret = 0;
-
-	priv->mib_buf.type = MIB_MAC;
-	priv->mib_buf.size = 2;
-	priv->mib_buf.index = offsetof(struct mib_mac, listen_interval);
-	priv->mib_buf.data.word = cpu_to_le16(interval);
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0)
-		printk(KERN_ERR
-		       "%s: set_mib (listen_interval) failed: %d\n",
-		       priv->netdev->name, ret);
-
-	return ret;
-}
-
-static int at76_set_preamble(struct at76_priv *priv, u8 type)
-{
-	int ret = 0;
-
-	priv->mib_buf.type = MIB_LOCAL;
-	priv->mib_buf.size = 1;
-	priv->mib_buf.index = offsetof(struct mib_local, preamble_type);
-	priv->mib_buf.data.byte = type;
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0)
-		printk(KERN_ERR "%s: set_mib (preamble) failed: %d\n",
-		       priv->netdev->name, ret);
-
-	return ret;
-}
-
-static int at76_set_frag(struct at76_priv *priv, u16 size)
-{
-	int ret = 0;
-
-	priv->mib_buf.type = MIB_MAC;
-	priv->mib_buf.size = 2;
-	priv->mib_buf.index = offsetof(struct mib_mac, frag_threshold);
-	priv->mib_buf.data.word = cpu_to_le16(size);
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0)
-		printk(KERN_ERR "%s: set_mib (frag threshold) failed: %d\n",
-		       priv->netdev->name, ret);
-
-	return ret;
-}
-
-static int at76_set_rts(struct at76_priv *priv, u16 size)
-{
-	int ret = 0;
-
-	priv->mib_buf.type = MIB_MAC;
-	priv->mib_buf.size = 2;
-	priv->mib_buf.index = offsetof(struct mib_mac, rts_threshold);
-	priv->mib_buf.data.word = cpu_to_le16(size);
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0)
-		printk(KERN_ERR "%s: set_mib (rts) failed: %d\n",
-		       priv->netdev->name, ret);
-
-	return ret;
-}
-
-static int at76_set_autorate_fallback(struct at76_priv *priv, int onoff)
-{
-	int ret = 0;
-
-	priv->mib_buf.type = MIB_LOCAL;
-	priv->mib_buf.size = 1;
-	priv->mib_buf.index = offsetof(struct mib_local, txautorate_fallback);
-	priv->mib_buf.data.byte = onoff;
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0)
-		printk(KERN_ERR "%s: set_mib (autorate fallback) failed: %d\n",
-		       priv->netdev->name, ret);
-
-	return ret;
-}
-
-static int at76_add_mac_address(struct at76_priv *priv, void *addr)
-{
-	int ret = 0;
-
-	priv->mib_buf.type = MIB_MAC_ADDR;
-	priv->mib_buf.size = ETH_ALEN;
-	priv->mib_buf.index = offsetof(struct mib_mac_addr, mac_addr);
-	memcpy(priv->mib_buf.data.addr, addr, ETH_ALEN);
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0)
-		printk(KERN_ERR "%s: set_mib (MAC_ADDR, mac_addr) failed: %d\n",
-		       priv->netdev->name, ret);
-
-	return ret;
-}
-
-static void at76_dump_mib_mac_addr(struct at76_priv *priv)
-{
-	int i;
-	int ret;
-	struct mib_mac_addr *m = kmalloc(sizeof(struct mib_mac_addr),
-					 GFP_KERNEL);
-
-	if (!m)
-		return;
-
-	ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m,
-			   sizeof(struct mib_mac_addr));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_get_mib (MAC_ADDR) failed: %d\n",
-		       priv->netdev->name, ret);
-		goto exit;
-	}
-
-	at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x",
-		 priv->netdev->name,
-		 mac2str(m->mac_addr), m->res[0], m->res[1]);
-	for (i = 0; i < ARRAY_SIZE(m->group_addr); i++)
-		at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: group addr %d: %s, "
-			 "status %d", priv->netdev->name, i,
-			 mac2str(m->group_addr[i]), m->group_addr_status[i]);
-exit:
-	kfree(m);
-}
-
-static void at76_dump_mib_mac_wep(struct at76_priv *priv)
-{
-	int i;
-	int ret;
-	int key_len;
-	struct mib_mac_wep *m = kmalloc(sizeof(struct mib_mac_wep), GFP_KERNEL);
-
-	if (!m)
-		return;
-
-	ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m,
-			   sizeof(struct mib_mac_wep));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_get_mib (MAC_WEP) failed: %d\n",
-		       priv->netdev->name, ret);
-		goto exit;
-	}
-
-	at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: priv_invoked %u def_key_id %u "
-		 "key_len %u excl_unencr %u wep_icv_err %u wep_excluded %u "
-		 "encr_level %u key %d", priv->netdev->name,
-		 m->privacy_invoked, m->wep_default_key_id,
-		 m->wep_key_mapping_len, m->exclude_unencrypted,
-		 le32_to_cpu(m->wep_icv_error_count),
-		 le32_to_cpu(m->wep_excluded_count), m->encryption_level,
-		 m->wep_default_key_id);
-
-	key_len = (m->encryption_level == 1) ?
-	    WEP_SMALL_KEY_LEN : WEP_LARGE_KEY_LEN;
-
-	for (i = 0; i < WEP_KEYS; i++)
-		at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: key %d: %s",
-			 priv->netdev->name, i,
-			 hex2str(m->wep_default_keyvalue[i], key_len));
-exit:
-	kfree(m);
-}
-
-static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
-{
-	int ret;
-	struct mib_mac_mgmt *m = kmalloc(sizeof(struct mib_mac_mgmt),
-					 GFP_KERNEL);
-
-	if (!m)
-		return;
-
-	ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m,
-			   sizeof(struct mib_mac_mgmt));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_get_mib (MAC_MGMT) failed: %d\n",
-		       priv->netdev->name, ret);
-		goto exit;
-	}
-
-	at76_dbg(DBG_MIB, "%s: MIB MAC_MGMT: beacon_period %d CFP_max_duration "
-		 "%d medium_occupancy_limit %d station_id 0x%x ATIM_window %d "
-		 "CFP_mode %d privacy_opt_impl %d DTIM_period %d CFP_period %d "
-		 "current_bssid %s current_essid %s current_bss_type %d "
-		 "pm_mode %d ibss_change %d res %d "
-		 "multi_domain_capability_implemented %d "
-		 "international_roaming %d country_string %.3s",
-		 priv->netdev->name, le16_to_cpu(m->beacon_period),
-		 le16_to_cpu(m->CFP_max_duration),
-		 le16_to_cpu(m->medium_occupancy_limit),
-		 le16_to_cpu(m->station_id), le16_to_cpu(m->ATIM_window),
-		 m->CFP_mode, m->privacy_option_implemented, m->DTIM_period,
-		 m->CFP_period, mac2str(m->current_bssid),
-		 hex2str(m->current_essid, IW_ESSID_MAX_SIZE),
-		 m->current_bss_type, m->power_mgmt_mode, m->ibss_change,
-		 m->res, m->multi_domain_capability_implemented,
-		 m->multi_domain_capability_enabled, m->country_string);
-exit:
-	kfree(m);
-}
-
-static void at76_dump_mib_mac(struct at76_priv *priv)
-{
-	int ret;
-	struct mib_mac *m = kmalloc(sizeof(struct mib_mac), GFP_KERNEL);
-
-	if (!m)
-		return;
-
-	ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_get_mib (MAC) failed: %d\n",
-		       priv->netdev->name, ret);
-		goto exit;
-	}
-
-	at76_dbg(DBG_MIB, "%s: MIB MAC: max_tx_msdu_lifetime %d "
-		 "max_rx_lifetime %d frag_threshold %d rts_threshold %d "
-		 "cwmin %d cwmax %d short_retry_time %d long_retry_time %d "
-		 "scan_type %d scan_channel %d probe_delay %u "
-		 "min_channel_time %d max_channel_time %d listen_int %d "
-		 "desired_ssid %s desired_bssid %s desired_bsstype %d",
-		 priv->netdev->name, le32_to_cpu(m->max_tx_msdu_lifetime),
-		 le32_to_cpu(m->max_rx_lifetime),
-		 le16_to_cpu(m->frag_threshold), le16_to_cpu(m->rts_threshold),
-		 le16_to_cpu(m->cwmin), le16_to_cpu(m->cwmax),
-		 m->short_retry_time, m->long_retry_time, m->scan_type,
-		 m->scan_channel, le16_to_cpu(m->probe_delay),
-		 le16_to_cpu(m->min_channel_time),
-		 le16_to_cpu(m->max_channel_time),
-		 le16_to_cpu(m->listen_interval),
-		 hex2str(m->desired_ssid, IW_ESSID_MAX_SIZE),
-		 mac2str(m->desired_bssid), m->desired_bsstype);
-exit:
-	kfree(m);
-}
-
-static void at76_dump_mib_phy(struct at76_priv *priv)
-{
-	int ret;
-	struct mib_phy *m = kmalloc(sizeof(struct mib_phy), GFP_KERNEL);
-
-	if (!m)
-		return;
-
-	ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_get_mib (PHY) failed: %d\n",
-		       priv->netdev->name, ret);
-		goto exit;
-	}
-
-	at76_dbg(DBG_MIB, "%s: MIB PHY: ed_threshold %d slot_time %d "
-		 "sifs_time %d preamble_length %d plcp_header_length %d "
-		 "mpdu_max_length %d cca_mode_supported %d operation_rate_set "
-		 "0x%x 0x%x 0x%x 0x%x channel_id %d current_cca_mode %d "
-		 "phy_type %d current_reg_domain %d",
-		 priv->netdev->name, le32_to_cpu(m->ed_threshold),
-		 le16_to_cpu(m->slot_time), le16_to_cpu(m->sifs_time),
-		 le16_to_cpu(m->preamble_length),
-		 le16_to_cpu(m->plcp_header_length),
-		 le16_to_cpu(m->mpdu_max_length),
-		 le16_to_cpu(m->cca_mode_supported), m->operation_rate_set[0],
-		 m->operation_rate_set[1], m->operation_rate_set[2],
-		 m->operation_rate_set[3], m->channel_id, m->current_cca_mode,
-		 m->phy_type, m->current_reg_domain);
-exit:
-	kfree(m);
-}
-
-static void at76_dump_mib_local(struct at76_priv *priv)
-{
-	int ret;
-	struct mib_local *m = kmalloc(sizeof(struct mib_phy), GFP_KERNEL);
-
-	if (!m)
-		return;
-
-	ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(struct mib_local));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_get_mib (LOCAL) failed: %d\n",
-		       priv->netdev->name, ret);
-		goto exit;
-	}
-
-	at76_dbg(DBG_MIB, "%s: MIB LOCAL: beacon_enable %d "
-		 "txautorate_fallback %d ssid_size %d promiscuous_mode %d "
-		 "preamble_type %d", priv->netdev->name, m->beacon_enable,
-		 m->txautorate_fallback, m->ssid_size, m->promiscuous_mode,
-		 m->preamble_type);
-exit:
-	kfree(m);
-}
-
-static void at76_dump_mib_mdomain(struct at76_priv *priv)
-{
-	int ret;
-	struct mib_mdomain *m = kmalloc(sizeof(struct mib_mdomain), GFP_KERNEL);
-
-	if (!m)
-		return;
-
-	ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m,
-			   sizeof(struct mib_mdomain));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_get_mib (MDOMAIN) failed: %d\n",
-		       priv->netdev->name, ret);
-		goto exit;
-	}
-
-	at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s",
-		 priv->netdev->name,
-		 hex2str(m->channel_list, sizeof(m->channel_list)));
-
-	at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: tx_powerlevel %s",
-		 priv->netdev->name,
-		 hex2str(m->tx_powerlevel, sizeof(m->tx_powerlevel)));
-exit:
-	kfree(m);
-}
-
-static int at76_get_current_bssid(struct at76_priv *priv)
-{
-	int ret = 0;
-	struct mib_mac_mgmt *mac_mgmt =
-	    kmalloc(sizeof(struct mib_mac_mgmt), GFP_KERNEL);
-
-	if (!mac_mgmt) {
-		ret = -ENOMEM;
-		goto exit;
-	}
-
-	ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, mac_mgmt,
-			   sizeof(struct mib_mac_mgmt));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_get_mib failed: %d\n",
-		       priv->netdev->name, ret);
-		goto error;
-	}
-	memcpy(priv->bssid, mac_mgmt->current_bssid, ETH_ALEN);
-	printk(KERN_INFO "%s: using BSSID %s\n", priv->netdev->name,
-	       mac2str(priv->bssid));
-error:
-	kfree(mac_mgmt);
-exit:
-	return ret;
-}
-
-static int at76_get_current_channel(struct at76_priv *priv)
-{
-	int ret = 0;
-	struct mib_phy *phy = kmalloc(sizeof(struct mib_phy), GFP_KERNEL);
-
-	if (!phy) {
-		ret = -ENOMEM;
-		goto exit;
-	}
-	ret = at76_get_mib(priv->udev, MIB_PHY, phy, sizeof(struct mib_phy));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_get_mib(MIB_PHY) failed: %d\n",
-		       priv->netdev->name, ret);
-		goto error;
-	}
-	priv->channel = phy->channel_id;
-error:
-	kfree(phy);
-exit:
-	return ret;
-}
-
-/**
- * at76_start_scan - start a scan
- *
- * @use_essid - use the configured ESSID in non passive mode
- */
-static int at76_start_scan(struct at76_priv *priv, int use_essid)
-{
-	struct at76_req_scan scan;
-
-	memset(&scan, 0, sizeof(struct at76_req_scan));
-	memset(scan.bssid, 0xff, ETH_ALEN);
-
-	if (use_essid) {
-		memcpy(scan.essid, priv->essid, IW_ESSID_MAX_SIZE);
-		scan.essid_size = priv->essid_size;
-	} else
-		scan.essid_size = 0;
-
-	/* jal: why should we start at a certain channel? we do scan the whole
-	   range allowed by reg domain. */
-	scan.channel = priv->channel;
-
-	/* atmelwlandriver differs between scan type 0 and 1 (active/passive)
-	   For ad-hoc mode, it uses type 0 only. */
-	scan.scan_type = priv->scan_mode;
-
-	/* INFO: For probe_delay, not multiplying by 1024 as this will be
-	   slightly less than min_channel_time
-	   (per spec: probe delay < min. channel time) */
-	scan.min_channel_time = cpu_to_le16(priv->scan_min_time);
-	scan.max_channel_time = cpu_to_le16(priv->scan_max_time);
-	scan.probe_delay = cpu_to_le16(priv->scan_min_time * 1000);
-	scan.international_scan = 0;
-
-	/* other values are set to 0 for type 0 */
-
-	at76_dbg(DBG_PROGRESS, "%s: start_scan (use_essid = %d, intl = %d, "
-		 "channel = %d, probe_delay = %d, scan_min_time = %d, "
-		 "scan_max_time = %d)",
-		 priv->netdev->name, use_essid,
-		 scan.international_scan, scan.channel,
-		 le16_to_cpu(scan.probe_delay),
-		 le16_to_cpu(scan.min_channel_time),
-		 le16_to_cpu(scan.max_channel_time));
-
-	return at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan));
-}
-
-/* Enable monitor mode */
-static int at76_start_monitor(struct at76_priv *priv)
-{
-	struct at76_req_scan scan;
-	int ret;
-
-	memset(&scan, 0, sizeof(struct at76_req_scan));
-	memset(scan.bssid, 0xff, ETH_ALEN);
-
-	scan.channel = priv->channel;
-	scan.scan_type = SCAN_TYPE_PASSIVE;
-	scan.international_scan = 0;
-
-	ret = at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan));
-	if (ret >= 0)
-		ret = at76_get_cmd_status(priv->udev, CMD_SCAN);
-
-	return ret;
-}
-
-static int at76_start_ibss(struct at76_priv *priv)
-{
-	struct at76_req_ibss bss;
-	int ret;
-
-	WARN_ON(priv->mac_state != MAC_OWN_IBSS);
-	if (priv->mac_state != MAC_OWN_IBSS)
-		return -EBUSY;
-
-	memset(&bss, 0, sizeof(struct at76_req_ibss));
-	memset(bss.bssid, 0xff, ETH_ALEN);
-	memcpy(bss.essid, priv->essid, IW_ESSID_MAX_SIZE);
-	bss.essid_size = priv->essid_size;
-	bss.bss_type = ADHOC_MODE;
-	bss.channel = priv->channel;
-
-	ret = at76_set_card_command(priv->udev, CMD_START_IBSS, &bss,
-				    sizeof(struct at76_req_ibss));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: start_ibss failed: %d\n",
-		       priv->netdev->name, ret);
-		return ret;
-	}
-
-	ret = at76_wait_completion(priv, CMD_START_IBSS);
-	if (ret != CMD_STATUS_COMPLETE) {
-		printk(KERN_ERR "%s: start_ibss failed to complete, %d\n",
-		       priv->netdev->name, ret);
-		return ret;
-	}
-
-	ret = at76_get_current_bssid(priv);
-	if (ret < 0)
-		return ret;
-
-	ret = at76_get_current_channel(priv);
-	if (ret < 0)
-		return ret;
-
-	/* not sure what this is good for ??? */
-	priv->mib_buf.type = MIB_MAC_MGMT;
-	priv->mib_buf.size = 1;
-	priv->mib_buf.index = offsetof(struct mib_mac_mgmt, ibss_change);
-	priv->mib_buf.data.byte = 0;
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0) {
-		printk(KERN_ERR "%s: set_mib (ibss change ok) failed: %d\n",
-		       priv->netdev->name, ret);
-		return ret;
-	}
-
-	netif_carrier_on(priv->netdev);
-	netif_start_queue(priv->netdev);
-	return 0;
-}
-
-/* Request card to join BSS in managed or ad-hoc mode */
-static int at76_join_bss(struct at76_priv *priv, struct bss_info *ptr)
-{
-	struct at76_req_join join;
-
-	BUG_ON(!ptr);
-
-	memset(&join, 0, sizeof(struct at76_req_join));
-	memcpy(join.bssid, ptr->bssid, ETH_ALEN);
-	memcpy(join.essid, ptr->ssid, ptr->ssid_len);
-	join.essid_size = ptr->ssid_len;
-	join.bss_type = (priv->iw_mode == IW_MODE_ADHOC ? 1 : 2);
-	join.channel = ptr->channel;
-	join.timeout = cpu_to_le16(2000);
-
-	at76_dbg(DBG_PROGRESS,
-		 "%s join addr %s ssid %s type %d ch %d timeout %d",
-		 priv->netdev->name, mac2str(join.bssid), join.essid,
-		 join.bss_type, join.channel, le16_to_cpu(join.timeout));
-	return at76_set_card_command(priv->udev, CMD_JOIN, &join,
-				     sizeof(struct at76_req_join));
-}
-
-/* Calculate padding from txbuf->wlength (which excludes the USB TX header),
-   likely to compensate a flaw in the AT76C503A USB part ... */
-static inline int at76_calc_padding(int wlen)
-{
-	/* add the USB TX header */
-	wlen += AT76_TX_HDRLEN;
-
-	wlen = wlen % 64;
-
-	if (wlen < 50)
-		return 50 - wlen;
-
-	if (wlen >= 61)
-		return 64 + 50 - wlen;
-
-	return 0;
-}
-
-/* We are doing a lot of things here in an interrupt. Need
-   a bh handler (Watching TV with a TV card is probably
-   a good test: if you see flickers, we are doing too much.
-   Currently I do see flickers... even with our tasklet :-( )
-   Maybe because the bttv driver and usb-uhci use the same interrupt
-*/
-/* Or maybe because our BH handler is preempting bttv's BH handler.. BHs don't
- * solve everything.. (alex) */
-static void at76_rx_callback(struct urb *urb)
-{
-	struct at76_priv *priv = urb->context;
-
-	priv->rx_tasklet.data = (unsigned long)urb;
-	tasklet_schedule(&priv->rx_tasklet);
-	return;
-}
-
-static void at76_tx_callback(struct urb *urb)
-{
-	struct at76_priv *priv = urb->context;
-	struct net_device_stats *stats = &priv->stats;
-	unsigned long flags;
-	struct at76_tx_buffer *mgmt_buf;
-	int ret;
-
-	switch (urb->status) {
-	case 0:
-		stats->tx_packets++;
-		break;
-	case -ENOENT:
-	case -ECONNRESET:
-		/* urb has been unlinked */
-		return;
-	default:
-		at76_dbg(DBG_URB, "%s - nonzero tx status received: %d",
-			 __func__, urb->status);
-		stats->tx_errors++;
-		break;
-	}
-
-	spin_lock_irqsave(&priv->mgmt_spinlock, flags);
-	mgmt_buf = priv->next_mgmt_bulk;
-	priv->next_mgmt_bulk = NULL;
-	spin_unlock_irqrestore(&priv->mgmt_spinlock, flags);
-
-	if (!mgmt_buf) {
-		netif_wake_queue(priv->netdev);
-		return;
-	}
-
-	/* we don't copy the padding bytes, but add them
-	   to the length */
-	memcpy(priv->bulk_out_buffer, mgmt_buf,
-	       le16_to_cpu(mgmt_buf->wlength) + AT76_TX_HDRLEN);
-	usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe,
-			  priv->bulk_out_buffer,
-			  le16_to_cpu(mgmt_buf->wlength) + mgmt_buf->padding +
-			  AT76_TX_HDRLEN, at76_tx_callback, priv);
-	ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
-	if (ret)
-		printk(KERN_ERR "%s: error in tx submit urb: %d\n",
-		       priv->netdev->name, ret);
-
-	kfree(mgmt_buf);
-}
-
-/* Send a management frame on bulk-out.  txbuf->wlength must be set */
-static int at76_tx_mgmt(struct at76_priv *priv, struct at76_tx_buffer *txbuf)
-{
-	unsigned long flags;
-	int ret;
-	int urb_status;
-	void *oldbuf = NULL;
-
-	netif_carrier_off(priv->netdev);	/* stop netdev watchdog */
-	netif_stop_queue(priv->netdev);	/* stop tx data packets */
-
-	spin_lock_irqsave(&priv->mgmt_spinlock, flags);
-
-	urb_status = priv->tx_urb->status;
-	if (urb_status == -EINPROGRESS) {
-		/* cannot transmit now, put in the queue */
-		oldbuf = priv->next_mgmt_bulk;
-		priv->next_mgmt_bulk = txbuf;
-	}
-	spin_unlock_irqrestore(&priv->mgmt_spinlock, flags);
-
-	if (oldbuf) {
-		/* a data/mgmt tx is already pending in the URB -
-		   if this is no error in some situations we must
-		   implement a queue or silently modify the old msg */
-		printk(KERN_ERR "%s: removed pending mgmt buffer %s\n",
-		       priv->netdev->name, hex2str(oldbuf, 64));
-		kfree(oldbuf);
-		return 0;
-	}
-
-	txbuf->tx_rate = TX_RATE_1MBIT;
-	txbuf->padding = at76_calc_padding(le16_to_cpu(txbuf->wlength));
-	memset(txbuf->reserved, 0, sizeof(txbuf->reserved));
-
-	if (priv->next_mgmt_bulk)
-		printk(KERN_ERR "%s: URB status %d, but mgmt is pending\n",
-		       priv->netdev->name, urb_status);
-
-	at76_dbg(DBG_TX_MGMT,
-		 "%s: tx mgmt: wlen %d tx_rate %d pad %d %s",
-		 priv->netdev->name, le16_to_cpu(txbuf->wlength),
-		 txbuf->tx_rate, txbuf->padding,
-		 hex2str(txbuf->packet, le16_to_cpu(txbuf->wlength)));
-
-	/* txbuf was not consumed above -> send mgmt msg immediately */
-	memcpy(priv->bulk_out_buffer, txbuf,
-	       le16_to_cpu(txbuf->wlength) + AT76_TX_HDRLEN);
-	usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe,
-			  priv->bulk_out_buffer,
-			  le16_to_cpu(txbuf->wlength) + txbuf->padding +
-			  AT76_TX_HDRLEN, at76_tx_callback, priv);
-	ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
-	if (ret)
-		printk(KERN_ERR "%s: error in tx submit urb: %d\n",
-		       priv->netdev->name, ret);
-
-	kfree(txbuf);
-
-	return ret;
-}
-
-/* Go to the next information element */
-static inline void next_ie(struct ieee80211_info_element **ie)
-{
-	*ie = (struct ieee80211_info_element *)(&(*ie)->data[(*ie)->len]);
-}
-
-/* Challenge is the challenge string (in TLV format)
-   we got with seq_nr 2 for shared secret authentication only and
-   send in seq_nr 3 WEP encrypted to prove we have the correct WEP key;
-   otherwise it is NULL */
-static int at76_auth_req(struct at76_priv *priv, struct bss_info *bss,
-			 int seq_nr, struct ieee80211_info_element *challenge)
-{
-	struct at76_tx_buffer *tx_buffer;
-	struct ieee80211_hdr_3addr *mgmt;
-	struct ieee80211_auth *req;
-	int buf_len = (seq_nr != 3 ? AUTH_FRAME_SIZE :
-		       AUTH_FRAME_SIZE + 1 + 1 + challenge->len);
-
-	BUG_ON(!bss);
-	BUG_ON(seq_nr == 3 && !challenge);
-	tx_buffer = kmalloc(buf_len + MAX_PADDING_SIZE, GFP_ATOMIC);
-	if (!tx_buffer)
-		return -ENOMEM;
-
-	req = (struct ieee80211_auth *)tx_buffer->packet;
-	mgmt = &req->header;
-
-	/* make wireless header */
-	/* first auth msg is not encrypted, only the second (seq_nr == 3) */
-	mgmt->frame_ctl =
-	    cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH |
-			(seq_nr == 3 ? IEEE80211_FCTL_PROTECTED : 0));
-
-	mgmt->duration_id = cpu_to_le16(0x8000);
-	memcpy(mgmt->addr1, bss->bssid, ETH_ALEN);
-	memcpy(mgmt->addr2, priv->netdev->dev_addr, ETH_ALEN);
-	memcpy(mgmt->addr3, bss->bssid, ETH_ALEN);
-	mgmt->seq_ctl = cpu_to_le16(0);
-
-	req->algorithm = cpu_to_le16(priv->auth_mode);
-	req->transaction = cpu_to_le16(seq_nr);
-	req->status = cpu_to_le16(0);
-
-	if (seq_nr == 3)
-		memcpy(req->info_element, challenge, 1 + 1 + challenge->len);
-
-	/* init. at76_priv tx header */
-	tx_buffer->wlength = cpu_to_le16(buf_len - AT76_TX_HDRLEN);
-	at76_dbg(DBG_TX_MGMT, "%s: AuthReq bssid %s alg %d seq_nr %d",
-		 priv->netdev->name, mac2str(mgmt->addr3),
-		 le16_to_cpu(req->algorithm), le16_to_cpu(req->transaction));
-	if (seq_nr == 3)
-		at76_dbg(DBG_TX_MGMT, "%s: AuthReq challenge: %s ...",
-			 priv->netdev->name, hex2str(req->info_element, 18));
-
-	/* either send immediately (if no data tx is pending
-	   or put it in pending list */
-	return at76_tx_mgmt(priv, tx_buffer);
-}
-
-static int at76_assoc_req(struct at76_priv *priv, struct bss_info *bss)
-{
-	struct at76_tx_buffer *tx_buffer;
-	struct ieee80211_hdr_3addr *mgmt;
-	struct ieee80211_assoc_request *req;
-	struct ieee80211_info_element *ie;
-	char *essid;
-	int essid_len;
-	u16 capa;
-
-	BUG_ON(!bss);
-
-	tx_buffer = kmalloc(ASSOCREQ_MAX_SIZE + MAX_PADDING_SIZE, GFP_ATOMIC);
-	if (!tx_buffer)
-		return -ENOMEM;
-
-	req = (struct ieee80211_assoc_request *)tx_buffer->packet;
-	mgmt = &req->header;
-	ie = req->info_element;
-
-	/* make wireless header */
-	mgmt->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
-				      IEEE80211_STYPE_ASSOC_REQ);
-
-	mgmt->duration_id = cpu_to_le16(0x8000);
-	memcpy(mgmt->addr1, bss->bssid, ETH_ALEN);
-	memcpy(mgmt->addr2, priv->netdev->dev_addr, ETH_ALEN);
-	memcpy(mgmt->addr3, bss->bssid, ETH_ALEN);
-	mgmt->seq_ctl = cpu_to_le16(0);
-
-	/* we must set the Privacy bit in the capabilities to assure an
-	   Agere-based AP with optional WEP transmits encrypted frames
-	   to us.  AP only set the Privacy bit in their capabilities
-	   if WEP is mandatory in the BSS! */
-	capa = bss->capa;
-	if (priv->wep_enabled)
-		capa |= WLAN_CAPABILITY_PRIVACY;
-	if (priv->preamble_type != PREAMBLE_TYPE_LONG)
-		capa |= WLAN_CAPABILITY_SHORT_PREAMBLE;
-	req->capability = cpu_to_le16(capa);
-
-	req->listen_interval = cpu_to_le16(2 * bss->beacon_interval);
-
-	/* write TLV data elements */
-
-	ie->id = WLAN_EID_SSID;
-	ie->len = bss->ssid_len;
-	memcpy(ie->data, bss->ssid, bss->ssid_len);
-	next_ie(&ie);
-
-	ie->id = WLAN_EID_SUPP_RATES;
-	ie->len = sizeof(hw_rates);
-	memcpy(ie->data, hw_rates, sizeof(hw_rates));
-	next_ie(&ie);		/* ie points behind the supp_rates field */
-
-	/* init. at76_priv tx header */
-	tx_buffer->wlength = cpu_to_le16((u8 *)ie - (u8 *)mgmt);
-
-	ie = req->info_element;
-	essid = ie->data;
-	essid_len = min_t(int, IW_ESSID_MAX_SIZE, ie->len);
-
-	next_ie(&ie);		/* points to IE of rates now */
-	at76_dbg(DBG_TX_MGMT,
-		 "%s: AssocReq bssid %s capa 0x%04x ssid %.*s rates %s",
-		 priv->netdev->name, mac2str(mgmt->addr3),
-		 le16_to_cpu(req->capability), essid_len, essid,
-		 hex2str(ie->data, ie->len));
-
-	/* either send immediately (if no data tx is pending
-	   or put it in pending list */
-	return at76_tx_mgmt(priv, tx_buffer);
-}
-
-/* We got to check the bss_list for old entries */
-static void at76_bss_list_timeout(unsigned long par)
-{
-	struct at76_priv *priv = (struct at76_priv *)par;
-	unsigned long flags;
-	struct list_head *lptr, *nptr;
-	struct bss_info *ptr;
-
-	spin_lock_irqsave(&priv->bss_list_spinlock, flags);
-
-	list_for_each_safe(lptr, nptr, &priv->bss_list) {
-
-		ptr = list_entry(lptr, struct bss_info, list);
-
-		if (ptr != priv->curr_bss
-		    && time_after(jiffies, ptr->last_rx + BSS_LIST_TIMEOUT)) {
-			at76_dbg(DBG_BSS_TABLE_RM,
-				 "%s: bss_list: removing old BSS %s ch %d",
-				 priv->netdev->name, mac2str(ptr->bssid),
-				 ptr->channel);
-			list_del(&ptr->list);
-			kfree(ptr);
-		}
-	}
-	spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
-	/* restart the timer */
-	mod_timer(&priv->bss_list_timer, jiffies + BSS_LIST_TIMEOUT);
-}
-
-static inline void at76_set_mac_state(struct at76_priv *priv,
-				      enum mac_state mac_state)
-{
-	at76_dbg(DBG_MAC_STATE, "%s state: %s", priv->netdev->name,
-		 mac_states[mac_state]);
-	priv->mac_state = mac_state;
-}
-
-static void at76_dump_bss_table(struct at76_priv *priv)
-{
-	struct bss_info *ptr;
-	unsigned long flags;
-	struct list_head *lptr;
-
-	spin_lock_irqsave(&priv->bss_list_spinlock, flags);
-
-	at76_dbg(DBG_BSS_TABLE, "%s BSS table (curr=%p):", priv->netdev->name,
-		 priv->curr_bss);
-
-	list_for_each(lptr, &priv->bss_list) {
-		ptr = list_entry(lptr, struct bss_info, list);
-		at76_dbg(DBG_BSS_TABLE, "0x%p: bssid %s channel %d ssid %.*s "
-			 "(%s) capa 0x%04x rates %s rssi %d link %d noise %d",
-			 ptr, mac2str(ptr->bssid), ptr->channel, ptr->ssid_len,
-			 ptr->ssid, hex2str(ptr->ssid, ptr->ssid_len),
-			 ptr->capa, hex2str(ptr->rates, ptr->rates_len),
-			 ptr->rssi, ptr->link_qual, ptr->noise_level);
-	}
-	spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
-}
-
-/* Called upon successful association to mark interface as connected */
-static void at76_work_assoc_done(struct work_struct *work)
-{
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      work_assoc_done);
-
-	mutex_lock(&priv->mtx);
-
-	WARN_ON(priv->mac_state != MAC_ASSOC);
-	WARN_ON(!priv->curr_bss);
-	if (priv->mac_state != MAC_ASSOC || !priv->curr_bss)
-		goto exit;
-
-	if (priv->iw_mode == IW_MODE_INFRA) {
-		if (priv->pm_mode != AT76_PM_OFF) {
-			/* calculate the listen interval in units of
-			   beacon intervals of the curr_bss */
-			u32 pm_period_beacon = (priv->pm_period >> 10) /
-			    priv->curr_bss->beacon_interval;
-
-			pm_period_beacon = max(pm_period_beacon, 2u);
-			pm_period_beacon = min(pm_period_beacon, 0xffffu);
-
-			at76_dbg(DBG_PM,
-				 "%s: pm_mode %d assoc id 0x%x listen int %d",
-				 priv->netdev->name, priv->pm_mode,
-				 priv->assoc_id, pm_period_beacon);
-
-			at76_set_associd(priv, priv->assoc_id);
-			at76_set_listen_interval(priv, (u16)pm_period_beacon);
-		}
-		schedule_delayed_work(&priv->dwork_beacon, BEACON_TIMEOUT);
-	}
-	at76_set_pm_mode(priv);
-
-	netif_carrier_on(priv->netdev);
-	netif_wake_queue(priv->netdev);
-	at76_set_mac_state(priv, MAC_CONNECTED);
-	at76_iwevent_bss_connect(priv->netdev, priv->curr_bss->bssid);
-	at76_dbg(DBG_PROGRESS, "%s: connected to BSSID %s",
-		 priv->netdev->name, mac2str(priv->curr_bss->bssid));
-
-exit:
-	mutex_unlock(&priv->mtx);
-}
-
-/* We only store the new mac address in netdev struct,
-   it gets set when the netdev is opened. */
-static int at76_set_mac_address(struct net_device *netdev, void *addr)
-{
-	struct sockaddr *mac = addr;
-	memcpy(netdev->dev_addr, mac->sa_data, ETH_ALEN);
-	return 1;
-}
-
-static struct net_device_stats *at76_get_stats(struct net_device *netdev)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	return &priv->stats;
-}
-
-static struct iw_statistics *at76_get_wireless_stats(struct net_device *netdev)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	at76_dbg(DBG_IOCTL, "RETURN qual %d level %d noise %d updated %d",
-		 priv->wstats.qual.qual, priv->wstats.qual.level,
-		 priv->wstats.qual.noise, priv->wstats.qual.updated);
-
-	return &priv->wstats;
-}
-
-static void at76_set_multicast(struct net_device *netdev)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int promisc;
-
-	promisc = ((netdev->flags & IFF_PROMISC) != 0);
-	if (promisc != priv->promisc) {
-		/* This gets called in interrupt, must reschedule */
-		priv->promisc = promisc;
-		schedule_work(&priv->work_set_promisc);
-	}
-}
-
-/* Stop all network activity, flush all pending tasks */
-static void at76_quiesce(struct at76_priv *priv)
-{
-	unsigned long flags;
-
-	netif_stop_queue(priv->netdev);
-	netif_carrier_off(priv->netdev);
-
-	at76_set_mac_state(priv, MAC_INIT);
-
-	cancel_delayed_work(&priv->dwork_get_scan);
-	cancel_delayed_work(&priv->dwork_beacon);
-	cancel_delayed_work(&priv->dwork_auth);
-	cancel_delayed_work(&priv->dwork_assoc);
-	cancel_delayed_work(&priv->dwork_restart);
-
-	spin_lock_irqsave(&priv->mgmt_spinlock, flags);
-	kfree(priv->next_mgmt_bulk);
-	priv->next_mgmt_bulk = NULL;
-	spin_unlock_irqrestore(&priv->mgmt_spinlock, flags);
-}
-
-/*******************************************************************************
- * at76_priv implementations of iw_handler functions:
- */
-static int at76_iw_handler_commit(struct net_device *netdev,
-				  struct iw_request_info *info,
-				  void *null, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	at76_dbg(DBG_IOCTL, "%s %s: restarting the device", netdev->name,
-		 __func__);
-
-	if (priv->mac_state != MAC_INIT)
-		at76_quiesce(priv);
-
-	/* Wait half second before the restart to process subsequent
-	 * requests from the same iwconfig in a single restart */
-	schedule_delayed_work(&priv->dwork_restart, HZ / 2);
-
-	return 0;
-}
-
-static int at76_iw_handler_get_name(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    char *name, char *extra)
-{
-	strcpy(name, "IEEE 802.11b");
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWNAME - name %s", netdev->name, name);
-	return 0;
-}
-
-static int at76_iw_handler_set_freq(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    struct iw_freq *freq, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int chan = -1;
-	int ret = -EIWCOMMIT;
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWFREQ - freq.m %d freq.e %d",
-		 netdev->name, freq->m, freq->e);
-
-	if ((freq->e == 0) && (freq->m <= 1000))
-		/* Setting by channel number */
-		chan = freq->m;
-	else {
-		/* Setting by frequency - search the table */
-		int mult = 1;
-		int i;
-
-		for (i = 0; i < (6 - freq->e); i++)
-			mult *= 10;
-
-		for (i = 0; i < NUM_CHANNELS; i++) {
-			if (freq->m == (channel_frequency[i] * mult))
-				chan = i + 1;
-		}
-	}
-
-	if (chan < 1 || !priv->domain)
-		/* non-positive channels are invalid
-		 * we need a domain info to set the channel
-		 * either that or an invalid frequency was
-		 * provided by the user */
-		ret = -EINVAL;
-	else if (!(priv->domain->channel_map & (1 << (chan - 1)))) {
-		printk(KERN_INFO "%s: channel %d not allowed for domain %s\n",
-		       priv->netdev->name, chan, priv->domain->name);
-		ret = -EINVAL;
-	}
-
-	if (ret == -EIWCOMMIT) {
-		priv->channel = chan;
-		at76_dbg(DBG_IOCTL, "%s: SIOCSIWFREQ - ch %d", netdev->name,
-			 chan);
-	}
-
-	return ret;
-}
-
-static int at76_iw_handler_get_freq(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    struct iw_freq *freq, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	freq->m = priv->channel;
-	freq->e = 0;
-
-	if (priv->channel)
-		at76_dbg(DBG_IOCTL, "%s: SIOCGIWFREQ - freq %ld x 10e%d",
-			 netdev->name, channel_frequency[priv->channel - 1], 6);
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWFREQ - ch %d", netdev->name,
-		 priv->channel);
-
-	return 0;
-}
-
-static int at76_iw_handler_set_mode(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    __u32 *mode, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWMODE - %d", netdev->name, *mode);
-
-	if ((*mode != IW_MODE_ADHOC) && (*mode != IW_MODE_INFRA) &&
-	    (*mode != IW_MODE_MONITOR))
-		return -EINVAL;
-
-	priv->iw_mode = *mode;
-	if (priv->iw_mode != IW_MODE_INFRA)
-		priv->pm_mode = AT76_PM_OFF;
-
-	return -EIWCOMMIT;
-}
-
-static int at76_iw_handler_get_mode(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    __u32 *mode, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	*mode = priv->iw_mode;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWMODE - %d", netdev->name, *mode);
-
-	return 0;
-}
-
-static int at76_iw_handler_get_range(struct net_device *netdev,
-				     struct iw_request_info *info,
-				     struct iw_point *data, char *extra)
-{
-	/* inspired by atmel.c */
-	struct at76_priv *priv = netdev_priv(netdev);
-	struct iw_range *range = (struct iw_range *)extra;
-	int i;
-
-	data->length = sizeof(struct iw_range);
-	memset(range, 0, sizeof(struct iw_range));
-
-	/* TODO: range->throughput = xxxxxx; */
-
-	range->min_nwid = 0x0000;
-	range->max_nwid = 0x0000;
-
-	/* this driver doesn't maintain sensitivity information */
-	range->sensitivity = 0;
-
-	range->max_qual.qual = 100;
-	range->max_qual.level = 100;
-	range->max_qual.noise = 0;
-	range->max_qual.updated = IW_QUAL_NOISE_INVALID;
-
-	range->avg_qual.qual = 50;
-	range->avg_qual.level = 50;
-	range->avg_qual.noise = 0;
-	range->avg_qual.updated = IW_QUAL_NOISE_INVALID;
-
-	range->bitrate[0] = 1000000;
-	range->bitrate[1] = 2000000;
-	range->bitrate[2] = 5500000;
-	range->bitrate[3] = 11000000;
-	range->num_bitrates = 4;
-
-	range->min_rts = 0;
-	range->max_rts = MAX_RTS_THRESHOLD;
-
-	range->min_frag = MIN_FRAG_THRESHOLD;
-	range->max_frag = MAX_FRAG_THRESHOLD;
-
-	range->pmp_flags = IW_POWER_PERIOD;
-	range->pmt_flags = IW_POWER_ON;
-	range->pm_capa = IW_POWER_PERIOD | IW_POWER_ALL_R;
-
-	range->encoding_size[0] = WEP_SMALL_KEY_LEN;
-	range->encoding_size[1] = WEP_LARGE_KEY_LEN;
-	range->num_encoding_sizes = 2;
-	range->max_encoding_tokens = WEP_KEYS;
-
-	/* both WL-240U and Linksys WUSB11 v2.6 specify 15 dBm as output power
-	   - take this for all (ignore antenna gains) */
-	range->txpower[0] = 15;
-	range->num_txpower = 1;
-	range->txpower_capa = IW_TXPOW_DBM;
-
-	range->we_version_source = WIRELESS_EXT;
-	range->we_version_compiled = WIRELESS_EXT;
-
-	/* same as the values used in atmel.c */
-	range->retry_capa = IW_RETRY_LIMIT;
-	range->retry_flags = IW_RETRY_LIMIT;
-	range->r_time_flags = 0;
-	range->min_retry = 1;
-	range->max_retry = 255;
-
-	range->num_channels = NUM_CHANNELS;
-	range->num_frequency = 0;
-
-	for (i = 0; i < NUM_CHANNELS; i++) {
-		/* test if channel map bit is raised */
-		if (priv->domain->channel_map & (0x1 << i)) {
-			range->num_frequency += 1;
-
-			range->freq[i].i = i + 1;
-			range->freq[i].m = channel_frequency[i] * 100000;
-			range->freq[i].e = 1;	/* freq * 10^1 */
-		}
-	}
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWRANGE", netdev->name);
-
-	return 0;
-}
-
-static int at76_iw_handler_set_spy(struct net_device *netdev,
-				   struct iw_request_info *info,
-				   struct iw_point *data, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret = 0;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWSPY - number of addresses %d",
-		 netdev->name, data->length);
-
-	spin_lock_bh(&priv->spy_spinlock);
-	ret = iw_handler_set_spy(priv->netdev, info, (union iwreq_data *)data,
-				 extra);
-	spin_unlock_bh(&priv->spy_spinlock);
-
-	return ret;
-}
-
-static int at76_iw_handler_get_spy(struct net_device *netdev,
-				   struct iw_request_info *info,
-				   struct iw_point *data, char *extra)
-{
-
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret = 0;
-
-	spin_lock_bh(&priv->spy_spinlock);
-	ret = iw_handler_get_spy(priv->netdev, info,
-				 (union iwreq_data *)data, extra);
-	spin_unlock_bh(&priv->spy_spinlock);
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWSPY - number of addresses %d",
-		 netdev->name, data->length);
-
-	return ret;
-}
-
-static int at76_iw_handler_set_thrspy(struct net_device *netdev,
-				      struct iw_request_info *info,
-				      struct iw_point *data, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWTHRSPY - number of addresses %d)",
-		 netdev->name, data->length);
-
-	spin_lock_bh(&priv->spy_spinlock);
-	ret = iw_handler_set_thrspy(netdev, info, (union iwreq_data *)data,
-				    extra);
-	spin_unlock_bh(&priv->spy_spinlock);
-
-	return ret;
-}
-
-static int at76_iw_handler_get_thrspy(struct net_device *netdev,
-				      struct iw_request_info *info,
-				      struct iw_point *data, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret;
-
-	spin_lock_bh(&priv->spy_spinlock);
-	ret = iw_handler_get_thrspy(netdev, info, (union iwreq_data *)data,
-				    extra);
-	spin_unlock_bh(&priv->spy_spinlock);
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWTHRSPY - number of addresses %d)",
-		 netdev->name, data->length);
-
-	return ret;
-}
-
-static int at76_iw_handler_set_wap(struct net_device *netdev,
-				   struct iw_request_info *info,
-				   struct sockaddr *ap_addr, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWAP - wap/bssid %s", netdev->name,
-		 mac2str(ap_addr->sa_data));
-
-	/* if the incoming address == ff:ff:ff:ff:ff:ff, the user has
-	   chosen any or auto AP preference */
-	if (is_broadcast_ether_addr(ap_addr->sa_data)
-	    || is_zero_ether_addr(ap_addr->sa_data))
-		priv->wanted_bssid_valid = 0;
-	else {
-		/* user wants to set a preferred AP address */
-		priv->wanted_bssid_valid = 1;
-		memcpy(priv->wanted_bssid, ap_addr->sa_data, ETH_ALEN);
-	}
-
-	return -EIWCOMMIT;
-}
-
-static int at76_iw_handler_get_wap(struct net_device *netdev,
-				   struct iw_request_info *info,
-				   struct sockaddr *ap_addr, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	ap_addr->sa_family = ARPHRD_ETHER;
-	memcpy(ap_addr->sa_data, priv->bssid, ETH_ALEN);
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWAP - wap/bssid %s", netdev->name,
-		 mac2str(ap_addr->sa_data));
-
-	return 0;
-}
-
-static int at76_iw_handler_set_scan(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    union iwreq_data *wrqu, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret = 0;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWSCAN", netdev->name);
-
-	if (mutex_lock_interruptible(&priv->mtx))
-		return -EINTR;
-
-	if (!netif_running(netdev)) {
-		ret = -ENETDOWN;
-		goto exit;
-	}
-
-	/* jal: we don't allow "iwlist ethX scan" while we are
-	   in monitor mode */
-	if (priv->iw_mode == IW_MODE_MONITOR) {
-		ret = -EBUSY;
-		goto exit;
-	}
-
-	/* Discard old scan results */
-	if ((jiffies - priv->last_scan) > (20 * HZ))
-		priv->scan_state = SCAN_IDLE;
-	priv->last_scan = jiffies;
-
-	/* Initiate a scan command */
-	if (priv->scan_state == SCAN_IN_PROGRESS) {
-		ret = -EBUSY;
-		goto exit;
-	}
-
-	priv->scan_state = SCAN_IN_PROGRESS;
-
-	at76_quiesce(priv);
-
-	/* Try to do passive or active scan if WE asks as. */
-	if (wrqu->data.length
-	    && wrqu->data.length == sizeof(struct iw_scan_req)) {
-		struct iw_scan_req *req = (struct iw_scan_req *)extra;
-
-		if (req->scan_type == IW_SCAN_TYPE_PASSIVE)
-			priv->scan_mode = SCAN_TYPE_PASSIVE;
-		else if (req->scan_type == IW_SCAN_TYPE_ACTIVE)
-			priv->scan_mode = SCAN_TYPE_ACTIVE;
-
-		/* Sanity check values? */
-		if (req->min_channel_time > 0)
-			priv->scan_min_time = req->min_channel_time;
-
-		if (req->max_channel_time > 0)
-			priv->scan_max_time = req->max_channel_time;
-	}
-
-	/* change to scanning state */
-	at76_set_mac_state(priv, MAC_SCANNING);
-	schedule_work(&priv->work_start_scan);
-
-exit:
-	mutex_unlock(&priv->mtx);
-	return ret;
-}
-
-static int at76_iw_handler_get_scan(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    struct iw_point *data, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	unsigned long flags;
-	struct list_head *lptr, *nptr;
-	struct bss_info *curr_bss;
-	struct iw_event *iwe = kmalloc(sizeof(struct iw_event), GFP_KERNEL);
-	char *curr_val, *curr_pos = extra;
-	int i;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWSCAN", netdev->name);
-
-	if (!iwe)
-		return -ENOMEM;
-
-	if (priv->scan_state != SCAN_COMPLETED) {
-		/* scan not yet finished */
-		kfree(iwe);
-		return -EAGAIN;
-	}
-
-	spin_lock_irqsave(&priv->bss_list_spinlock, flags);
-
-	list_for_each_safe(lptr, nptr, &priv->bss_list) {
-		curr_bss = list_entry(lptr, struct bss_info, list);
-
-		iwe->cmd = SIOCGIWAP;
-		iwe->u.ap_addr.sa_family = ARPHRD_ETHER;
-		memcpy(iwe->u.ap_addr.sa_data, curr_bss->bssid, 6);
-		curr_pos = iwe_stream_add_event(info, curr_pos,
-						extra + IW_SCAN_MAX_DATA, iwe,
-						IW_EV_ADDR_LEN);
-
-		iwe->u.data.length = curr_bss->ssid_len;
-		iwe->cmd = SIOCGIWESSID;
-		iwe->u.data.flags = 1;
-
-		curr_pos = iwe_stream_add_point(info, curr_pos,
-						extra + IW_SCAN_MAX_DATA, iwe,
-						curr_bss->ssid);
-
-		iwe->cmd = SIOCGIWMODE;
-		iwe->u.mode = (curr_bss->capa & WLAN_CAPABILITY_IBSS) ?
-		    IW_MODE_ADHOC :
-		    (curr_bss->capa & WLAN_CAPABILITY_ESS) ?
-		    IW_MODE_MASTER : IW_MODE_AUTO;
-		/* IW_MODE_AUTO = 0 which I thought is
-		 * the most logical value to return in this case */
-		curr_pos = iwe_stream_add_event(info, curr_pos,
-						extra + IW_SCAN_MAX_DATA, iwe,
-						IW_EV_UINT_LEN);
-
-		iwe->cmd = SIOCGIWFREQ;
-		iwe->u.freq.m = curr_bss->channel;
-		iwe->u.freq.e = 0;
-		curr_pos = iwe_stream_add_event(info, curr_pos,
-						extra + IW_SCAN_MAX_DATA, iwe,
-						IW_EV_FREQ_LEN);
-
-		iwe->cmd = SIOCGIWENCODE;
-		if (curr_bss->capa & WLAN_CAPABILITY_PRIVACY)
-			iwe->u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-		else
-			iwe->u.data.flags = IW_ENCODE_DISABLED;
-
-		iwe->u.data.length = 0;
-		curr_pos = iwe_stream_add_point(info, curr_pos,
-						extra + IW_SCAN_MAX_DATA, iwe,
-						NULL);
-
-		/* Add quality statistics */
-		iwe->cmd = IWEVQUAL;
-		iwe->u.qual.noise = 0;
-		iwe->u.qual.updated =
-		    IW_QUAL_NOISE_INVALID | IW_QUAL_LEVEL_UPDATED;
-		iwe->u.qual.level = (curr_bss->rssi * 100 / 42);
-		if (iwe->u.qual.level > 100)
-			iwe->u.qual.level = 100;
-		if (at76_is_intersil(priv->board_type))
-			iwe->u.qual.qual = curr_bss->link_qual;
-		else {
-			iwe->u.qual.qual = 0;
-			iwe->u.qual.updated |= IW_QUAL_QUAL_INVALID;
-		}
-		/* Add new value to event */
-		curr_pos = iwe_stream_add_event(info, curr_pos,
-						extra + IW_SCAN_MAX_DATA, iwe,
-						IW_EV_QUAL_LEN);
-
-		/* Rate: stuffing multiple values in a single event requires
-		 * a bit more of magic - Jean II */
-		curr_val = curr_pos + IW_EV_LCP_LEN;
-
-		iwe->cmd = SIOCGIWRATE;
-		/* Those two flags are ignored... */
-		iwe->u.bitrate.fixed = 0;
-		iwe->u.bitrate.disabled = 0;
-		/* Max 8 values */
-		for (i = 0; i < curr_bss->rates_len; i++) {
-			/* Bit rate given in 500 kb/s units (+ 0x80) */
-			iwe->u.bitrate.value =
-			    ((curr_bss->rates[i] & 0x7f) * 500000);
-			/* Add new value to event */
-			curr_val = iwe_stream_add_value(info, curr_pos,
-							curr_val,
-							extra +
-							IW_SCAN_MAX_DATA, iwe,
-							IW_EV_PARAM_LEN);
-		}
-
-		/* Check if we added any event */
-		if ((curr_val - curr_pos) > IW_EV_LCP_LEN)
-			curr_pos = curr_val;
-
-		/* more information may be sent back using IWECUSTOM */
-
-	}
-
-	spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
-
-	data->length = (curr_pos - extra);
-	data->flags = 0;
-
-	kfree(iwe);
-	return 0;
-}
-
-static int at76_iw_handler_set_essid(struct net_device *netdev,
-				     struct iw_request_info *info,
-				     struct iw_point *data, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWESSID - %s", netdev->name, extra);
-
-	if (data->flags) {
-		memcpy(priv->essid, extra, data->length);
-		priv->essid_size = data->length;
-	} else
-		priv->essid_size = 0;	/* Use any SSID */
-
-	return -EIWCOMMIT;
-}
-
-static int at76_iw_handler_get_essid(struct net_device *netdev,
-				     struct iw_request_info *info,
-				     struct iw_point *data, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	if (priv->essid_size) {
-		/* not the ANY ssid in priv->essid */
-		data->flags = 1;
-		data->length = priv->essid_size;
-		memcpy(extra, priv->essid, data->length);
-	} else {
-		/* the ANY ssid was specified */
-		if (priv->mac_state == MAC_CONNECTED && priv->curr_bss) {
-			/* report the SSID we have found */
-			data->flags = 1;
-			data->length = priv->curr_bss->ssid_len;
-			memcpy(extra, priv->curr_bss->ssid, data->length);
-		} else {
-			/* report ANY back */
-			data->flags = 0;
-			data->length = 0;
-		}
-	}
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWESSID - %.*s", netdev->name,
-		 data->length, extra);
-
-	return 0;
-}
-
-static int at76_iw_handler_set_rate(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    struct iw_param *bitrate, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret = -EIWCOMMIT;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWRATE - %d", netdev->name,
-		 bitrate->value);
-
-	switch (bitrate->value) {
-	case -1:
-		priv->txrate = TX_RATE_AUTO;
-		break;		/* auto rate */
-	case 1000000:
-		priv->txrate = TX_RATE_1MBIT;
-		break;
-	case 2000000:
-		priv->txrate = TX_RATE_2MBIT;
-		break;
-	case 5500000:
-		priv->txrate = TX_RATE_5_5MBIT;
-		break;
-	case 11000000:
-		priv->txrate = TX_RATE_11MBIT;
-		break;
-	default:
-		ret = -EINVAL;
-	}
-
-	return ret;
-}
-
-static int at76_iw_handler_get_rate(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    struct iw_param *bitrate, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret = 0;
-
-	switch (priv->txrate) {
-		/* return max rate if RATE_AUTO */
-	case TX_RATE_AUTO:
-		bitrate->value = 11000000;
-		break;
-	case TX_RATE_1MBIT:
-		bitrate->value = 1000000;
-		break;
-	case TX_RATE_2MBIT:
-		bitrate->value = 2000000;
-		break;
-	case TX_RATE_5_5MBIT:
-		bitrate->value = 5500000;
-		break;
-	case TX_RATE_11MBIT:
-		bitrate->value = 11000000;
-		break;
-	default:
-		ret = -EINVAL;
-	}
-
-	bitrate->fixed = (priv->txrate != TX_RATE_AUTO);
-	bitrate->disabled = 0;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWRATE - %d", netdev->name,
-		 bitrate->value);
-
-	return ret;
-}
-
-static int at76_iw_handler_set_rts(struct net_device *netdev,
-				   struct iw_request_info *info,
-				   struct iw_param *rts, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret = -EIWCOMMIT;
-	int rthr = rts->value;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWRTS - value %d disabled %s",
-		 netdev->name, rts->value, (rts->disabled) ? "true" : "false");
-
-	if (rts->disabled)
-		rthr = MAX_RTS_THRESHOLD;
-
-	if ((rthr < 0) || (rthr > MAX_RTS_THRESHOLD))
-		ret = -EINVAL;
-	else
-		priv->rts_threshold = rthr;
-
-	return ret;
-}
-
-static int at76_iw_handler_get_rts(struct net_device *netdev,
-				   struct iw_request_info *info,
-				   struct iw_param *rts, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	rts->value = priv->rts_threshold;
-	rts->disabled = (rts->value >= MAX_RTS_THRESHOLD);
-	rts->fixed = 1;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWRTS - value %d disabled %s",
-		 netdev->name, rts->value, (rts->disabled) ? "true" : "false");
-
-	return 0;
-}
-
-static int at76_iw_handler_set_frag(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    struct iw_param *frag, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret = -EIWCOMMIT;
-	int fthr = frag->value;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWFRAG - value %d, disabled %s",
-		 netdev->name, frag->value,
-		 (frag->disabled) ? "true" : "false");
-
-	if (frag->disabled)
-		fthr = MAX_FRAG_THRESHOLD;
-
-	if ((fthr < MIN_FRAG_THRESHOLD) || (fthr > MAX_FRAG_THRESHOLD))
-		ret = -EINVAL;
-	else
-		priv->frag_threshold = fthr & ~0x1;	/* get an even value */
-
-	return ret;
-}
-
-static int at76_iw_handler_get_frag(struct net_device *netdev,
-				    struct iw_request_info *info,
-				    struct iw_param *frag, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	frag->value = priv->frag_threshold;
-	frag->disabled = (frag->value >= MAX_FRAG_THRESHOLD);
-	frag->fixed = 1;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWFRAG - value %d, disabled %s",
-		 netdev->name, frag->value,
-		 (frag->disabled) ? "true" : "false");
-
-	return 0;
-}
-
-static int at76_iw_handler_get_txpow(struct net_device *netdev,
-				     struct iw_request_info *info,
-				     struct iw_param *power, char *extra)
-{
-	power->value = 15;
-	power->fixed = 1;	/* No power control */
-	power->disabled = 0;
-	power->flags = IW_TXPOW_DBM;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWTXPOW - txpow %d dBm", netdev->name,
-		 power->value);
-
-	return 0;
-}
-
-/* jal: short retry is handled by the firmware (at least 0.90.x),
-   while long retry is not (?) */
-static int at76_iw_handler_set_retry(struct net_device *netdev,
-				     struct iw_request_info *info,
-				     struct iw_param *retry, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret = -EIWCOMMIT;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWRETRY disabled %d flags 0x%x val %d",
-		 netdev->name, retry->disabled, retry->flags, retry->value);
-
-	if (!retry->disabled && (retry->flags & IW_RETRY_LIMIT)) {
-		if ((retry->flags & IW_RETRY_MIN) ||
-		    !(retry->flags & IW_RETRY_MAX))
-			priv->short_retry_limit = retry->value;
-		else
-			ret = -EINVAL;
-	} else
-		ret = -EINVAL;
-
-	return ret;
-}
-
-/* Adapted (ripped) from atmel.c */
-static int at76_iw_handler_get_retry(struct net_device *netdev,
-				     struct iw_request_info *info,
-				     struct iw_param *retry, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWRETRY", netdev->name);
-
-	retry->disabled = 0;	/* Can't be disabled */
-	retry->flags = IW_RETRY_LIMIT;
-	retry->value = priv->short_retry_limit;
-
-	return 0;
-}
-
-static int at76_iw_handler_set_encode(struct net_device *netdev,
-				      struct iw_request_info *info,
-				      struct iw_point *encoding, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int index = (encoding->flags & IW_ENCODE_INDEX) - 1;
-	int len = encoding->length;
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCSIWENCODE - enc.flags %08x "
-		 "pointer %p len %d", netdev->name, encoding->flags,
-		 encoding->pointer, encoding->length);
-	at76_dbg(DBG_IOCTL,
-		 "%s: SIOCSIWENCODE - old wepstate: enabled %s key_id %d "
-		 "auth_mode %s", netdev->name,
-		 (priv->wep_enabled) ? "true" : "false", priv->wep_key_id,
-		 (priv->auth_mode ==
-		  WLAN_AUTH_SHARED_KEY) ? "restricted" : "open");
-
-	/* take the old default key if index is invalid */
-	if ((index < 0) || (index >= WEP_KEYS))
-		index = priv->wep_key_id;
-
-	if (len > 0) {
-		if (len > WEP_LARGE_KEY_LEN)
-			len = WEP_LARGE_KEY_LEN;
-
-		memset(priv->wep_keys[index], 0, WEP_KEY_LEN);
-		memcpy(priv->wep_keys[index], extra, len);
-		priv->wep_keys_len[index] = (len <= WEP_SMALL_KEY_LEN) ?
-		    WEP_SMALL_KEY_LEN : WEP_LARGE_KEY_LEN;
-		priv->wep_enabled = 1;
-	}
-
-	priv->wep_key_id = index;
-	priv->wep_enabled = ((encoding->flags & IW_ENCODE_DISABLED) == 0);
-
-	if (encoding->flags & IW_ENCODE_RESTRICTED)
-		priv->auth_mode = WLAN_AUTH_SHARED_KEY;
-	if (encoding->flags & IW_ENCODE_OPEN)
-		priv->auth_mode = WLAN_AUTH_OPEN;
-
-	at76_dbg(DBG_IOCTL,
-		 "%s: SIOCSIWENCODE - new wepstate: enabled %s key_id %d "
-		 "key_len %d auth_mode %s", netdev->name,
-		 (priv->wep_enabled) ? "true" : "false", priv->wep_key_id + 1,
-		 priv->wep_keys_len[priv->wep_key_id],
-		 (priv->auth_mode ==
-		  WLAN_AUTH_SHARED_KEY) ? "restricted" : "open");
-
-	return -EIWCOMMIT;
-}
-
-static int at76_iw_handler_get_encode(struct net_device *netdev,
-				      struct iw_request_info *info,
-				      struct iw_point *encoding, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int index = (encoding->flags & IW_ENCODE_INDEX) - 1;
-
-	if ((index < 0) || (index >= WEP_KEYS))
-		index = priv->wep_key_id;
-
-	encoding->flags =
-	    (priv->auth_mode == WLAN_AUTH_SHARED_KEY) ?
-	    IW_ENCODE_RESTRICTED : IW_ENCODE_OPEN;
-
-	if (!priv->wep_enabled)
-		encoding->flags |= IW_ENCODE_DISABLED;
-
-	if (encoding->pointer) {
-		encoding->length = priv->wep_keys_len[index];
-
-		memcpy(extra, priv->wep_keys[index], priv->wep_keys_len[index]);
-
-		encoding->flags |= (index + 1);
-	}
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWENCODE - enc.flags %08x "
-		 "pointer %p len %d", netdev->name, encoding->flags,
-		 encoding->pointer, encoding->length);
-	at76_dbg(DBG_IOCTL,
-		 "%s: SIOCGIWENCODE - wepstate: enabled %s key_id %d "
-		 "key_len %d auth_mode %s", netdev->name,
-		 (priv->wep_enabled) ? "true" : "false", priv->wep_key_id + 1,
-		 priv->wep_keys_len[priv->wep_key_id],
-		 (priv->auth_mode ==
-		  WLAN_AUTH_SHARED_KEY) ? "restricted" : "open");
-
-	return 0;
-}
-
-static int at76_iw_handler_set_power(struct net_device *netdev,
-				     struct iw_request_info *info,
-				     struct iw_param *prq, char *extra)
-{
-	int err = -EIWCOMMIT;
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	at76_dbg(DBG_IOCTL,
-		 "%s: SIOCSIWPOWER - disabled %s flags 0x%x value 0x%x",
-		 netdev->name, (prq->disabled) ? "true" : "false", prq->flags,
-		 prq->value);
-
-	if (prq->disabled)
-		priv->pm_mode = AT76_PM_OFF;
-	else {
-		switch (prq->flags & IW_POWER_MODE) {
-		case IW_POWER_ALL_R:
-		case IW_POWER_ON:
-			break;
-		default:
-			err = -EINVAL;
-			goto exit;
-		}
-		if (prq->flags & IW_POWER_PERIOD)
-			priv->pm_period = prq->value;
-
-		if (prq->flags & IW_POWER_TIMEOUT) {
-			err = -EINVAL;
-			goto exit;
-		}
-		priv->pm_mode = AT76_PM_ON;
-	}
-exit:
-	return err;
-}
-
-static int at76_iw_handler_get_power(struct net_device *netdev,
-				     struct iw_request_info *info,
-				     struct iw_param *power, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	power->disabled = (priv->pm_mode == AT76_PM_OFF);
-	if (!power->disabled) {
-		power->flags = IW_POWER_PERIOD | IW_POWER_ALL_R;
-		power->value = priv->pm_period;
-	}
-
-	at76_dbg(DBG_IOCTL, "%s: SIOCGIWPOWER - %s flags 0x%x value 0x%x",
-		 netdev->name, power->disabled ? "disabled" : "enabled",
-		 power->flags, power->value);
-
-	return 0;
-}
-
-/*******************************************************************************
- * Private IOCTLS
- */
-static int at76_iw_set_short_preamble(struct net_device *netdev,
-				      struct iw_request_info *info, char *name,
-				      char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int val = *((int *)name);
-	int ret = -EIWCOMMIT;
-
-	at76_dbg(DBG_IOCTL, "%s: AT76_SET_SHORT_PREAMBLE, %d",
-		 netdev->name, val);
-
-	if (val < PREAMBLE_TYPE_LONG || val > PREAMBLE_TYPE_AUTO)
-		ret = -EINVAL;
-	else
-		priv->preamble_type = val;
-
-	return ret;
-}
-
-static int at76_iw_get_short_preamble(struct net_device *netdev,
-				      struct iw_request_info *info,
-				      union iwreq_data *wrqu, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	snprintf(wrqu->name, sizeof(wrqu->name), "%s (%d)",
-		 preambles[priv->preamble_type], priv->preamble_type);
-	return 0;
-}
-
-static int at76_iw_set_debug(struct net_device *netdev,
-			     struct iw_request_info *info,
-			     struct iw_point *data, char *extra)
-{
-	char *ptr;
-	u32 val;
-
-	if (data->length > 0) {
-		val = simple_strtol(extra, &ptr, 0);
-
-		if (ptr == extra)
-			val = DBG_DEFAULTS;
-
-		at76_dbg(DBG_IOCTL, "%s: AT76_SET_DEBUG input %d: %s -> 0x%x",
-			 netdev->name, data->length, extra, val);
-	} else
-		val = DBG_DEFAULTS;
-
-	at76_dbg(DBG_IOCTL, "%s: AT76_SET_DEBUG, old 0x%x, new 0x%x",
-		 netdev->name, at76_debug, val);
-
-	/* jal: some more output to pin down lockups */
-	at76_dbg(DBG_IOCTL, "%s: netif running %d queue_stopped %d "
-		 "carrier_ok %d", netdev->name, netif_running(netdev),
-		 netif_queue_stopped(netdev), netif_carrier_ok(netdev));
-
-	at76_debug = val;
-
-	return 0;
-}
-
-static int at76_iw_get_debug(struct net_device *netdev,
-			     struct iw_request_info *info,
-			     union iwreq_data *wrqu, char *extra)
-{
-	snprintf(wrqu->name, sizeof(wrqu->name), "0x%08x", at76_debug);
-	return 0;
-}
-
-static int at76_iw_set_powersave_mode(struct net_device *netdev,
-				      struct iw_request_info *info, char *name,
-				      char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int val = *((int *)name);
-	int ret = -EIWCOMMIT;
-
-	at76_dbg(DBG_IOCTL, "%s: AT76_SET_POWERSAVE_MODE, %d (%s)",
-		 netdev->name, val,
-		 val == AT76_PM_OFF ? "active" : val == AT76_PM_ON ? "save" :
-		 val == AT76_PM_SMART ? "smart save" : "<invalid>");
-	if (val < AT76_PM_OFF || val > AT76_PM_SMART)
-		ret = -EINVAL;
-	else
-		priv->pm_mode = val;
-
-	return ret;
-}
-
-static int at76_iw_get_powersave_mode(struct net_device *netdev,
-				      struct iw_request_info *info,
-				      union iwreq_data *wrqu, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int *param = (int *)extra;
-
-	param[0] = priv->pm_mode;
-	return 0;
-}
-
-static int at76_iw_set_scan_times(struct net_device *netdev,
-				  struct iw_request_info *info, char *name,
-				  char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int mint = *((int *)name);
-	int maxt = *((int *)name + 1);
-	int ret = -EIWCOMMIT;
-
-	at76_dbg(DBG_IOCTL, "%s: AT76_SET_SCAN_TIMES - min %d max %d",
-		 netdev->name, mint, maxt);
-	if (mint <= 0 || maxt <= 0 || mint > maxt)
-		ret = -EINVAL;
-	else {
-		priv->scan_min_time = mint;
-		priv->scan_max_time = maxt;
-	}
-
-	return ret;
-}
-
-static int at76_iw_get_scan_times(struct net_device *netdev,
-				  struct iw_request_info *info,
-				  union iwreq_data *wrqu, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int *param = (int *)extra;
-
-	param[0] = priv->scan_min_time;
-	param[1] = priv->scan_max_time;
-	return 0;
-}
-
-static int at76_iw_set_scan_mode(struct net_device *netdev,
-				 struct iw_request_info *info, char *name,
-				 char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int val = *((int *)name);
-	int ret = -EIWCOMMIT;
-
-	at76_dbg(DBG_IOCTL, "%s: AT76_SET_SCAN_MODE - mode %s",
-		 netdev->name, (val = SCAN_TYPE_ACTIVE) ? "active" :
-		 (val = SCAN_TYPE_PASSIVE) ? "passive" : "<invalid>");
-
-	if (val != SCAN_TYPE_ACTIVE && val != SCAN_TYPE_PASSIVE)
-		ret = -EINVAL;
-	else
-		priv->scan_mode = val;
-
-	return ret;
-}
-
-static int at76_iw_get_scan_mode(struct net_device *netdev,
-				 struct iw_request_info *info,
-				 union iwreq_data *wrqu, char *extra)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int *param = (int *)extra;
-
-	param[0] = priv->scan_mode;
-	return 0;
-}
-
-#define AT76_SET_HANDLER(h, f) [h - SIOCIWFIRST] = (iw_handler) f
-
-/* Standard wireless handlers */
-static const iw_handler at76_handlers[] = {
-	AT76_SET_HANDLER(SIOCSIWCOMMIT, at76_iw_handler_commit),
-	AT76_SET_HANDLER(SIOCGIWNAME, at76_iw_handler_get_name),
-	AT76_SET_HANDLER(SIOCSIWFREQ, at76_iw_handler_set_freq),
-	AT76_SET_HANDLER(SIOCGIWFREQ, at76_iw_handler_get_freq),
-	AT76_SET_HANDLER(SIOCSIWMODE, at76_iw_handler_set_mode),
-	AT76_SET_HANDLER(SIOCGIWMODE, at76_iw_handler_get_mode),
-	AT76_SET_HANDLER(SIOCGIWRANGE, at76_iw_handler_get_range),
-	AT76_SET_HANDLER(SIOCSIWSPY, at76_iw_handler_set_spy),
-	AT76_SET_HANDLER(SIOCGIWSPY, at76_iw_handler_get_spy),
-	AT76_SET_HANDLER(SIOCSIWTHRSPY, at76_iw_handler_set_thrspy),
-	AT76_SET_HANDLER(SIOCGIWTHRSPY, at76_iw_handler_get_thrspy),
-	AT76_SET_HANDLER(SIOCSIWAP, at76_iw_handler_set_wap),
-	AT76_SET_HANDLER(SIOCGIWAP, at76_iw_handler_get_wap),
-	AT76_SET_HANDLER(SIOCSIWSCAN, at76_iw_handler_set_scan),
-	AT76_SET_HANDLER(SIOCGIWSCAN, at76_iw_handler_get_scan),
-	AT76_SET_HANDLER(SIOCSIWESSID, at76_iw_handler_set_essid),
-	AT76_SET_HANDLER(SIOCGIWESSID, at76_iw_handler_get_essid),
-	AT76_SET_HANDLER(SIOCSIWRATE, at76_iw_handler_set_rate),
-	AT76_SET_HANDLER(SIOCGIWRATE, at76_iw_handler_get_rate),
-	AT76_SET_HANDLER(SIOCSIWRTS, at76_iw_handler_set_rts),
-	AT76_SET_HANDLER(SIOCGIWRTS, at76_iw_handler_get_rts),
-	AT76_SET_HANDLER(SIOCSIWFRAG, at76_iw_handler_set_frag),
-	AT76_SET_HANDLER(SIOCGIWFRAG, at76_iw_handler_get_frag),
-	AT76_SET_HANDLER(SIOCGIWTXPOW, at76_iw_handler_get_txpow),
-	AT76_SET_HANDLER(SIOCSIWRETRY, at76_iw_handler_set_retry),
-	AT76_SET_HANDLER(SIOCGIWRETRY, at76_iw_handler_get_retry),
-	AT76_SET_HANDLER(SIOCSIWENCODE, at76_iw_handler_set_encode),
-	AT76_SET_HANDLER(SIOCGIWENCODE, at76_iw_handler_get_encode),
-	AT76_SET_HANDLER(SIOCSIWPOWER, at76_iw_handler_set_power),
-	AT76_SET_HANDLER(SIOCGIWPOWER, at76_iw_handler_get_power)
-};
-
-#define AT76_SET_PRIV(h, f) [h - SIOCIWFIRSTPRIV] = (iw_handler) f
-
-/* Private wireless handlers */
-static const iw_handler at76_priv_handlers[] = {
-	AT76_SET_PRIV(AT76_SET_SHORT_PREAMBLE, at76_iw_set_short_preamble),
-	AT76_SET_PRIV(AT76_GET_SHORT_PREAMBLE, at76_iw_get_short_preamble),
-	AT76_SET_PRIV(AT76_SET_DEBUG, at76_iw_set_debug),
-	AT76_SET_PRIV(AT76_GET_DEBUG, at76_iw_get_debug),
-	AT76_SET_PRIV(AT76_SET_POWERSAVE_MODE, at76_iw_set_powersave_mode),
-	AT76_SET_PRIV(AT76_GET_POWERSAVE_MODE, at76_iw_get_powersave_mode),
-	AT76_SET_PRIV(AT76_SET_SCAN_TIMES, at76_iw_set_scan_times),
-	AT76_SET_PRIV(AT76_GET_SCAN_TIMES, at76_iw_get_scan_times),
-	AT76_SET_PRIV(AT76_SET_SCAN_MODE, at76_iw_set_scan_mode),
-	AT76_SET_PRIV(AT76_GET_SCAN_MODE, at76_iw_get_scan_mode),
-};
-
-/* Names and arguments of private wireless handlers */
-static const struct iw_priv_args at76_priv_args[] = {
-	/* 0 - long, 1 - short */
-	{AT76_SET_SHORT_PREAMBLE,
-	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble"},
-
-	{AT76_GET_SHORT_PREAMBLE,
-	 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 10, "get_preamble"},
-
-	/* we must pass the new debug mask as a string, because iwpriv cannot
-	 * parse hex numbers starting with 0x :-(  */
-	{AT76_SET_DEBUG,
-	 IW_PRIV_TYPE_CHAR | 10, 0, "set_debug"},
-
-	{AT76_GET_DEBUG,
-	 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 10, "get_debug"},
-
-	/* 1 - active, 2 - power save, 3 - smart power save */
-	{AT76_SET_POWERSAVE_MODE,
-	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_powersave"},
-
-	{AT76_GET_POWERSAVE_MODE,
-	 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_powersave"},
-
-	/* min_channel_time, max_channel_time */
-	{AT76_SET_SCAN_TIMES,
-	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "set_scan_times"},
-
-	{AT76_GET_SCAN_TIMES,
-	 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, "get_scan_times"},
-
-	/* 0 - active, 1 - passive scan */
-	{AT76_SET_SCAN_MODE,
-	 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_scan_mode"},
-
-	{AT76_GET_SCAN_MODE,
-	 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_scan_mode"},
-};
-
-static const struct iw_handler_def at76_handler_def = {
-	.num_standard = ARRAY_SIZE(at76_handlers),
-	.num_private = ARRAY_SIZE(at76_priv_handlers),
-	.num_private_args = ARRAY_SIZE(at76_priv_args),
-	.standard = at76_handlers,
-	.private = at76_priv_handlers,
-	.private_args = at76_priv_args,
-	.get_wireless_stats = at76_get_wireless_stats,
-};
-
-static const u8 snapsig[] = { 0xaa, 0xaa, 0x03 };
-
-/* RFC 1042 encapsulates Ethernet frames in 802.2 SNAP (0xaa, 0xaa, 0x03) with
- * a SNAP OID of 0 (0x00, 0x00, 0x00) */
-static const u8 rfc1042sig[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
-
-static int at76_tx(struct sk_buff *skb, struct net_device *netdev)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	struct net_device_stats *stats = &priv->stats;
-	int ret = 0;
-	int wlen;
-	int submit_len;
-	struct at76_tx_buffer *tx_buffer = priv->bulk_out_buffer;
-	struct ieee80211_hdr_3addr *i802_11_hdr =
-	    (struct ieee80211_hdr_3addr *)tx_buffer->packet;
-	u8 *payload = i802_11_hdr->payload;
-	struct ethhdr *eh = (struct ethhdr *)skb->data;
-
-	if (netif_queue_stopped(netdev)) {
-		printk(KERN_ERR "%s: %s called while netdev is stopped\n",
-		       netdev->name, __func__);
-		/* skip this packet */
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
-
-	if (priv->tx_urb->status == -EINPROGRESS) {
-		printk(KERN_ERR "%s: %s called while tx urb is pending\n",
-		       netdev->name, __func__);
-		/* skip this packet */
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
-
-	if (skb->len < ETH_HLEN) {
-		printk(KERN_ERR "%s: %s: skb too short (%d)\n",
-		       netdev->name, __func__, skb->len);
-		dev_kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
-
-	at76_ledtrig_tx_activity();	/* tell ledtrigger we send a packet */
-
-	/* we can get rid of memcpy if we set netdev->hard_header_len to
-	   reserve enough space, but we would need to keep the skb around */
-
-	if (ntohs(eh->h_proto) <= ETH_DATA_LEN) {
-		/* this is a 802.3 packet */
-		if (skb->len >= ETH_HLEN + sizeof(rfc1042sig)
-		    && skb->data[ETH_HLEN] == rfc1042sig[0]
-		    && skb->data[ETH_HLEN + 1] == rfc1042sig[1]) {
-			/* higher layer delivered SNAP header - keep it */
-			memcpy(payload, skb->data + ETH_HLEN,
-			       skb->len - ETH_HLEN);
-			wlen = IEEE80211_3ADDR_LEN + skb->len - ETH_HLEN;
-		} else {
-			printk(KERN_ERR "%s: dropping non-SNAP 802.2 packet "
-			       "(DSAP 0x%02x SSAP 0x%02x cntrl 0x%02x)\n",
-			       priv->netdev->name, skb->data[ETH_HLEN],
-			       skb->data[ETH_HLEN + 1],
-			       skb->data[ETH_HLEN + 2]);
-			dev_kfree_skb(skb);
-			return NETDEV_TX_OK;
-		}
-	} else {
-		/* add RFC 1042 header in front */
-		memcpy(payload, rfc1042sig, sizeof(rfc1042sig));
-		memcpy(payload + sizeof(rfc1042sig), &eh->h_proto,
-		       skb->len - offsetof(struct ethhdr, h_proto));
-		wlen = IEEE80211_3ADDR_LEN + sizeof(rfc1042sig) + skb->len -
-		    offsetof(struct ethhdr, h_proto);
-	}
-
-	/* make wireless header */
-	i802_11_hdr->frame_ctl =
-	    cpu_to_le16(IEEE80211_FTYPE_DATA |
-			(priv->wep_enabled ? IEEE80211_FCTL_PROTECTED : 0) |
-			(priv->iw_mode ==
-			 IW_MODE_INFRA ? IEEE80211_FCTL_TODS : 0));
-
-	if (priv->iw_mode == IW_MODE_ADHOC) {
-		memcpy(i802_11_hdr->addr1, eh->h_dest, ETH_ALEN);
-		memcpy(i802_11_hdr->addr2, eh->h_source, ETH_ALEN);
-		memcpy(i802_11_hdr->addr3, priv->bssid, ETH_ALEN);
-	} else if (priv->iw_mode == IW_MODE_INFRA) {
-		memcpy(i802_11_hdr->addr1, priv->bssid, ETH_ALEN);
-		memcpy(i802_11_hdr->addr2, eh->h_source, ETH_ALEN);
-		memcpy(i802_11_hdr->addr3, eh->h_dest, ETH_ALEN);
-	}
-
-	i802_11_hdr->duration_id = cpu_to_le16(0);
-	i802_11_hdr->seq_ctl = cpu_to_le16(0);
-
-	/* setup 'Atmel' header */
-	tx_buffer->wlength = cpu_to_le16(wlen);
-	tx_buffer->tx_rate = priv->txrate;
-	/* for broadcast destination addresses, the firmware 0.100.x
-	   seems to choose the highest rate set with CMD_STARTUP in
-	   basic_rate_set replacing this value */
-
-	memset(tx_buffer->reserved, 0, sizeof(tx_buffer->reserved));
-
-	tx_buffer->padding = at76_calc_padding(wlen);
-	submit_len = wlen + AT76_TX_HDRLEN + tx_buffer->padding;
-
-	at76_dbg(DBG_TX_DATA_CONTENT, "%s skb->data %s", priv->netdev->name,
-		 hex2str(skb->data, 32));
-	at76_dbg(DBG_TX_DATA, "%s tx: wlen 0x%x pad 0x%x rate %d hdr %s",
-		 priv->netdev->name,
-		 le16_to_cpu(tx_buffer->wlength),
-		 tx_buffer->padding, tx_buffer->tx_rate,
-		 hex2str(i802_11_hdr, sizeof(*i802_11_hdr)));
-	at76_dbg(DBG_TX_DATA_CONTENT, "%s payload %s", priv->netdev->name,
-		 hex2str(payload, 48));
-
-	/* send stuff */
-	netif_stop_queue(netdev);
-	netdev->trans_start = jiffies;
-
-	usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe, tx_buffer,
-			  submit_len, at76_tx_callback, priv);
-	ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
-	if (ret) {
-		stats->tx_errors++;
-		printk(KERN_ERR "%s: error in tx submit urb: %d\n",
-		       netdev->name, ret);
-		if (ret == -EINVAL)
-			printk(KERN_ERR
-			       "%s: -EINVAL: tx urb %p hcpriv %p complete %p\n",
-			       priv->netdev->name, priv->tx_urb,
-			       priv->tx_urb->hcpriv, priv->tx_urb->complete);
-	} else
-		stats->tx_bytes += skb->len;
-
-	dev_kfree_skb(skb);
-	return NETDEV_TX_OK;
-}
-
-static void at76_tx_timeout(struct net_device *netdev)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	if (!priv)
-		return;
-	dev_warn(&netdev->dev, "tx timeout.");
-
-	usb_unlink_urb(priv->tx_urb);
-	priv->stats.tx_errors++;
-}
-
-static int at76_submit_rx_urb(struct at76_priv *priv)
-{
-	int ret;
-	int size;
-	struct sk_buff *skb = priv->rx_skb;
-
-	if (!priv->rx_urb) {
-		printk(KERN_ERR "%s: %s: priv->rx_urb is NULL\n",
-		       priv->netdev->name, __func__);
-		return -EFAULT;
-	}
-
-	if (!skb) {
-		skb = dev_alloc_skb(sizeof(struct at76_rx_buffer));
-		if (!skb) {
-			printk(KERN_ERR "%s: cannot allocate rx skbuff\n",
-			       priv->netdev->name);
-			ret = -ENOMEM;
-			goto exit;
-		}
-		priv->rx_skb = skb;
-	} else {
-		skb_push(skb, skb_headroom(skb));
-		skb_trim(skb, 0);
-	}
-
-	size = skb_tailroom(skb);
-	usb_fill_bulk_urb(priv->rx_urb, priv->udev, priv->rx_pipe,
-			  skb_put(skb, size), size, at76_rx_callback, priv);
-	ret = usb_submit_urb(priv->rx_urb, GFP_ATOMIC);
-	if (ret < 0) {
-		if (ret == -ENODEV)
-			at76_dbg(DBG_DEVSTART,
-				 "usb_submit_urb returned -ENODEV");
-		else
-			printk(KERN_ERR "%s: rx, usb_submit_urb failed: %d\n",
-			       priv->netdev->name, ret);
-	}
-
-exit:
-	if (ret < 0 && ret != -ENODEV)
-		printk(KERN_ERR "%s: cannot submit rx urb - please unload the "
-		       "driver and/or power cycle the device\n",
-		       priv->netdev->name);
-
-	return ret;
-}
-
-static int at76_open(struct net_device *netdev)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	int ret = 0;
-
-	at76_dbg(DBG_PROC_ENTRY, "%s(): entry", __func__);
-
-	if (mutex_lock_interruptible(&priv->mtx))
-		return -EINTR;
-
-	/* if netdev->dev_addr != priv->mac_addr we must
-	   set the mac address in the device ! */
-	if (compare_ether_addr(netdev->dev_addr, priv->mac_addr)) {
-		if (at76_add_mac_address(priv, netdev->dev_addr) >= 0)
-			at76_dbg(DBG_PROGRESS, "%s: set new MAC addr %s",
-				 netdev->name, mac2str(netdev->dev_addr));
-	}
-
-	priv->scan_state = SCAN_IDLE;
-	priv->last_scan = jiffies;
-
-	ret = at76_submit_rx_urb(priv);
-	if (ret < 0) {
-		printk(KERN_ERR "%s: open: submit_rx_urb failed: %d\n",
-		       netdev->name, ret);
-		goto error;
-	}
-
-	schedule_delayed_work(&priv->dwork_restart, 0);
-
-	at76_dbg(DBG_PROC_ENTRY, "%s(): end", __func__);
-error:
-	mutex_unlock(&priv->mtx);
-	return ret < 0 ? ret : 0;
-}
-
-static int at76_stop(struct net_device *netdev)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	at76_dbg(DBG_DEVSTART, "%s: ENTER", __func__);
-
-	if (mutex_lock_interruptible(&priv->mtx))
-		return -EINTR;
-
-	at76_quiesce(priv);
-
-	if (!priv->device_unplugged) {
-		/* We are called by "ifconfig ethX down", not because the
-		 * device is not available anymore. */
-		at76_set_radio(priv, 0);
-
-		/* We unlink rx_urb because at76_open() re-submits it.
-		 * If unplugged, at76_delete_device() takes care of it. */
-		usb_kill_urb(priv->rx_urb);
-	}
-
-	/* free the bss_list */
-	at76_free_bss_list(priv);
-
-	mutex_unlock(&priv->mtx);
-	at76_dbg(DBG_DEVSTART, "%s: EXIT", __func__);
-
-	return 0;
-}
-
-static void at76_ethtool_get_drvinfo(struct net_device *netdev,
-				     struct ethtool_drvinfo *info)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-
-	strncpy(info->driver, DRIVER_NAME, sizeof(info->driver));
-	strncpy(info->version, DRIVER_VERSION, sizeof(info->version));
-
-	usb_make_path(priv->udev, info->bus_info, sizeof(info->bus_info));
-
-	snprintf(info->fw_version, sizeof(info->fw_version), "%d.%d.%d-%d",
-		 priv->fw_version.major, priv->fw_version.minor,
-		 priv->fw_version.patch, priv->fw_version.build);
-}
-
-static u32 at76_ethtool_get_link(struct net_device *netdev)
-{
-	struct at76_priv *priv = netdev_priv(netdev);
-	return priv->mac_state == MAC_CONNECTED;
-}
-
-static const struct ethtool_ops at76_ethtool_ops = {
-	.get_drvinfo = at76_ethtool_get_drvinfo,
-	.get_link = at76_ethtool_get_link,
-};
-
-/* Download external firmware */
-static int at76_load_external_fw(struct usb_device *udev, struct fwentry *fwe)
-{
-	int ret;
-	int op_mode;
-	int blockno = 0;
-	int bsize;
-	u8 *block;
-	u8 *buf = fwe->extfw;
-	int size = fwe->extfw_size;
-
-	if (!buf || !size)
-		return -ENOENT;
-
-	op_mode = at76_get_op_mode(udev);
-	at76_dbg(DBG_DEVSTART, "opmode %d", op_mode);
-
-	if (op_mode != OPMODE_NORMAL_NIC_WITHOUT_FLASH) {
-		dev_printk(KERN_ERR, &udev->dev, "unexpected opmode %d\n",
-			   op_mode);
-		return -EINVAL;
-	}
-
-	block = kmalloc(FW_BLOCK_SIZE, GFP_KERNEL);
-	if (!block)
-		return -ENOMEM;
-
-	at76_dbg(DBG_DEVSTART, "downloading external firmware");
-
-	/* for fw >= 0.100, the device needs an extra empty block */
-	do {
-		bsize = min_t(int, size, FW_BLOCK_SIZE);
-		memcpy(block, buf, bsize);
-		at76_dbg(DBG_DEVSTART,
-			 "ext fw, size left = %5d, bsize = %4d, blockno = %2d",
-			 size, bsize, blockno);
-		ret = at76_load_ext_fw_block(udev, blockno, block, bsize);
-		if (ret != bsize) {
-			dev_printk(KERN_ERR, &udev->dev,
-				   "loading %dth firmware block failed: %d\n",
-				   blockno, ret);
-			goto exit;
-		}
-		buf += bsize;
-		size -= bsize;
-		blockno++;
-	} while (bsize > 0);
-
-	if (at76_is_505a(fwe->board_type)) {
-		at76_dbg(DBG_DEVSTART, "200 ms delay for 505a");
-		schedule_timeout_interruptible(HZ / 5 + 1);
-	}
-
-exit:
-	kfree(block);
-	if (ret < 0)
-		dev_printk(KERN_ERR, &udev->dev,
-			   "downloading external firmware failed: %d\n", ret);
-	return ret;
-}
-
-/* Download internal firmware */
-static int at76_load_internal_fw(struct usb_device *udev, struct fwentry *fwe)
-{
-	int ret;
-	int need_remap = !at76_is_505a(fwe->board_type);
-
-	ret = at76_usbdfu_download(udev, fwe->intfw, fwe->intfw_size,
-				   need_remap ? 0 : 2 * HZ);
-
-	if (ret < 0) {
-		dev_printk(KERN_ERR, &udev->dev,
-			   "downloading internal fw failed with %d\n", ret);
-		goto exit;
-	}
-
-	at76_dbg(DBG_DEVSTART, "sending REMAP");
-
-	/* no REMAP for 505A (see SF driver) */
-	if (need_remap) {
-		ret = at76_remap(udev);
-		if (ret < 0) {
-			dev_printk(KERN_ERR, &udev->dev,
-				   "sending REMAP failed with %d\n", ret);
-			goto exit;
-		}
-	}
-
-	at76_dbg(DBG_DEVSTART, "sleeping for 2 seconds");
-	schedule_timeout_interruptible(2 * HZ + 1);
-	usb_reset_device(udev);
-
-exit:
-	return ret;
-}
-
-static int at76_match_essid(struct at76_priv *priv, struct bss_info *ptr)
-{
-	/* common criteria for both modi */
-
-	int ret = (priv->essid_size == 0 /* ANY ssid */  ||
-		   (priv->essid_size == ptr->ssid_len &&
-		    !memcmp(priv->essid, ptr->ssid, ptr->ssid_len)));
-	if (!ret)
-		at76_dbg(DBG_BSS_MATCH,
-			 "%s bss table entry %p: essid didn't match",
-			 priv->netdev->name, ptr);
-	return ret;
-}
-
-static inline int at76_match_mode(struct at76_priv *priv, struct bss_info *ptr)
-{
-	int ret;
-
-	if (priv->iw_mode == IW_MODE_ADHOC)
-		ret = ptr->capa & WLAN_CAPABILITY_IBSS;
-	else
-		ret = ptr->capa & WLAN_CAPABILITY_ESS;
-	if (!ret)
-		at76_dbg(DBG_BSS_MATCH,
-			 "%s bss table entry %p: mode didn't match",
-			 priv->netdev->name, ptr);
-	return ret;
-}
-
-static int at76_match_rates(struct at76_priv *priv, struct bss_info *ptr)
-{
-	int i;
-
-	for (i = 0; i < ptr->rates_len; i++) {
-		u8 rate = ptr->rates[i];
-
-		if (!(rate & 0x80))
-			continue;
-
-		/* this is a basic rate we have to support
-		   (see IEEE802.11, ch. 7.3.2.2) */
-		if (rate != (0x80 | hw_rates[0])
-		    && rate != (0x80 | hw_rates[1])
-		    && rate != (0x80 | hw_rates[2])
-		    && rate != (0x80 | hw_rates[3])) {
-			at76_dbg(DBG_BSS_MATCH,
-				 "%s: bss table entry %p: basic rate %02x not "
-				 "supported", priv->netdev->name, ptr, rate);
-			return 0;
-		}
-	}
-
-	/* if we use short preamble, the bss must support it */
-	if (priv->preamble_type == PREAMBLE_TYPE_SHORT &&
-	    !(ptr->capa & WLAN_CAPABILITY_SHORT_PREAMBLE)) {
-		at76_dbg(DBG_BSS_MATCH,
-			 "%s: %p does not support short preamble",
-			 priv->netdev->name, ptr);
-		return 0;
-	} else
-		return 1;
-}
-
-static inline int at76_match_wep(struct at76_priv *priv, struct bss_info *ptr)
-{
-	if (!priv->wep_enabled && ptr->capa & WLAN_CAPABILITY_PRIVACY) {
-		/* we have disabled WEP, but the BSS signals privacy */
-		at76_dbg(DBG_BSS_MATCH,
-			 "%s: bss table entry %p: requires encryption",
-			 priv->netdev->name, ptr);
-		return 0;
-	}
-	/* otherwise if the BSS does not signal privacy it may well
-	   accept encrypted packets from us ... */
-	return 1;
-}
-
-static inline int at76_match_bssid(struct at76_priv *priv, struct bss_info *ptr)
-{
-	if (!priv->wanted_bssid_valid ||
-	    !compare_ether_addr(ptr->bssid, priv->wanted_bssid))
-		return 1;
-
-	at76_dbg(DBG_BSS_MATCH,
-		 "%s: requested bssid - %s does not match",
-		 priv->netdev->name, mac2str(priv->wanted_bssid));
-	at76_dbg(DBG_BSS_MATCH,
-		 "      AP bssid - %s of bss table entry %p",
-		 mac2str(ptr->bssid), ptr);
-	return 0;
-}
-
-/**
- * at76_match_bss - try to find a matching bss in priv->bss
- *
- * last - last bss tried
- *
- * last == NULL signals a new round starting with priv->bss_list.next
- * this function must be called inside an acquired priv->bss_list_spinlock
- * otherwise the timeout on bss may remove the newly chosen entry
- */
-static struct bss_info *at76_match_bss(struct at76_priv *priv,
-				       struct bss_info *last)
-{
-	struct bss_info *ptr = NULL;
-	struct list_head *curr;
-
-	curr = last ? last->list.next : priv->bss_list.next;
-	while (curr != &priv->bss_list) {
-		ptr = list_entry(curr, struct bss_info, list);
-		if (at76_match_essid(priv, ptr) && at76_match_mode(priv, ptr)
-		    && at76_match_wep(priv, ptr) && at76_match_rates(priv, ptr)
-		    && at76_match_bssid(priv, ptr))
-			break;
-		curr = curr->next;
-	}
-
-	if (curr == &priv->bss_list)
-		ptr = NULL;
-	/* otherwise ptr points to the struct bss_info we have chosen */
-
-	at76_dbg(DBG_BSS_TABLE, "%s %s: returned %p", priv->netdev->name,
-		 __func__, ptr);
-	return ptr;
-}
-
-/* Start joining a matching BSS, or create own IBSS */
-static void at76_work_join(struct work_struct *work)
-{
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      work_join);
-	int ret;
-	unsigned long flags;
-
-	mutex_lock(&priv->mtx);
-
-	WARN_ON(priv->mac_state != MAC_JOINING);
-	if (priv->mac_state != MAC_JOINING)
-		goto exit;
-
-	/* secure the access to priv->curr_bss ! */
-	spin_lock_irqsave(&priv->bss_list_spinlock, flags);
-	priv->curr_bss = at76_match_bss(priv, priv->curr_bss);
-	spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
-
-	if (!priv->curr_bss) {
-		/* here we haven't found a matching (i)bss ... */
-		if (priv->iw_mode == IW_MODE_ADHOC) {
-			at76_set_mac_state(priv, MAC_OWN_IBSS);
-			at76_start_ibss(priv);
-			goto exit;
-		}
-		/* haven't found a matching BSS in infra mode - try again */
-		at76_set_mac_state(priv, MAC_SCANNING);
-		schedule_work(&priv->work_start_scan);
-		goto exit;
-	}
-
-	ret = at76_join_bss(priv, priv->curr_bss);
-	if (ret < 0) {
-		printk(KERN_ERR "%s: join_bss failed with %d\n",
-		       priv->netdev->name, ret);
-		goto exit;
-	}
-
-	ret = at76_wait_completion(priv, CMD_JOIN);
-	if (ret != CMD_STATUS_COMPLETE) {
-		if (ret != CMD_STATUS_TIME_OUT)
-			printk(KERN_ERR "%s: join_bss completed with %d\n",
-			       priv->netdev->name, ret);
-		else
-			printk(KERN_INFO "%s: join_bss ssid %s timed out\n",
-			       priv->netdev->name,
-			       mac2str(priv->curr_bss->bssid));
-
-		/* retry next BSS immediately */
-		schedule_work(&priv->work_join);
-		goto exit;
-	}
-
-	/* here we have joined the (I)BSS */
-	if (priv->iw_mode == IW_MODE_ADHOC) {
-		struct bss_info *bptr = priv->curr_bss;
-		at76_set_mac_state(priv, MAC_CONNECTED);
-		/* get ESSID, BSSID and channel for priv->curr_bss */
-		priv->essid_size = bptr->ssid_len;
-		memcpy(priv->essid, bptr->ssid, bptr->ssid_len);
-		memcpy(priv->bssid, bptr->bssid, ETH_ALEN);
-		priv->channel = bptr->channel;
-		at76_iwevent_bss_connect(priv->netdev, bptr->bssid);
-		netif_carrier_on(priv->netdev);
-		netif_start_queue(priv->netdev);
-		/* just to be sure */
-		cancel_delayed_work(&priv->dwork_get_scan);
-		cancel_delayed_work(&priv->dwork_auth);
-		cancel_delayed_work(&priv->dwork_assoc);
-	} else {
-		/* send auth req */
-		priv->retries = AUTH_RETRIES;
-		at76_set_mac_state(priv, MAC_AUTH);
-		at76_auth_req(priv, priv->curr_bss, 1, NULL);
-		at76_dbg(DBG_MGMT_TIMER,
-			 "%s:%d: starting mgmt_timer + HZ", __func__, __LINE__);
-		schedule_delayed_work(&priv->dwork_auth, AUTH_TIMEOUT);
-	}
-
-exit:
-	mutex_unlock(&priv->mtx);
-}
-
-/* Reap scan results */
-static void at76_dwork_get_scan(struct work_struct *work)
-{
-	int status;
-	int ret;
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      dwork_get_scan.work);
-
-	mutex_lock(&priv->mtx);
-	WARN_ON(priv->mac_state != MAC_SCANNING);
-	if (priv->mac_state != MAC_SCANNING)
-		goto exit;
-
-	status = at76_get_cmd_status(priv->udev, CMD_SCAN);
-	if (status < 0) {
-		printk(KERN_ERR "%s: %s: at76_get_cmd_status failed with %d\n",
-		       priv->netdev->name, __func__, status);
-		status = CMD_STATUS_IN_PROGRESS;
-		/* INFO: Hope it was a one off error - if not, scanning
-		   further down the line and stop this cycle */
-	}
-	at76_dbg(DBG_PROGRESS,
-		 "%s %s: got cmd_status %d (state %s, need_any %d)",
-		 priv->netdev->name, __func__, status,
-		 mac_states[priv->mac_state], priv->scan_need_any);
-
-	if (status != CMD_STATUS_COMPLETE) {
-		if ((status != CMD_STATUS_IN_PROGRESS) &&
-		    (status != CMD_STATUS_IDLE))
-			printk(KERN_ERR "%s: %s: Bad scan status: %s\n",
-			       priv->netdev->name, __func__,
-			       at76_get_cmd_status_string(status));
-
-		/* the first cmd status after scan start is always a IDLE ->
-		   start the timer to poll again until COMPLETED */
-		at76_dbg(DBG_MGMT_TIMER,
-			 "%s:%d: starting mgmt_timer for %d ticks",
-			 __func__, __LINE__, SCAN_POLL_INTERVAL);
-		schedule_delayed_work(&priv->dwork_get_scan,
-				      SCAN_POLL_INTERVAL);
-		goto exit;
-	}
-
-	if (at76_debug & DBG_BSS_TABLE)
-		at76_dump_bss_table(priv);
-
-	if (priv->scan_need_any) {
-		ret = at76_start_scan(priv, 0);
-		if (ret < 0)
-			printk(KERN_ERR
-			       "%s: %s: start_scan (ANY) failed with %d\n",
-			       priv->netdev->name, __func__, ret);
-		at76_dbg(DBG_MGMT_TIMER,
-			 "%s:%d: starting mgmt_timer for %d ticks", __func__,
-			 __LINE__, SCAN_POLL_INTERVAL);
-		schedule_delayed_work(&priv->dwork_get_scan,
-				      SCAN_POLL_INTERVAL);
-		priv->scan_need_any = 0;
-	} else {
-		priv->scan_state = SCAN_COMPLETED;
-		/* report the end of scan to user space */
-		at76_iwevent_scan_complete(priv->netdev);
-		at76_set_mac_state(priv, MAC_JOINING);
-		schedule_work(&priv->work_join);
-	}
-
-exit:
-	mutex_unlock(&priv->mtx);
-}
-
-/* Handle loss of beacons from the AP */
-static void at76_dwork_beacon(struct work_struct *work)
-{
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      dwork_beacon.work);
-
-	mutex_lock(&priv->mtx);
-	if (priv->mac_state != MAC_CONNECTED || priv->iw_mode != IW_MODE_INFRA)
-		goto exit;
-
-	/* We haven't received any beacons from out AP for BEACON_TIMEOUT */
-	printk(KERN_INFO "%s: lost beacon bssid %s\n",
-	       priv->netdev->name, mac2str(priv->curr_bss->bssid));
-
-	netif_carrier_off(priv->netdev);
-	netif_stop_queue(priv->netdev);
-	at76_iwevent_bss_disconnect(priv->netdev);
-	at76_set_mac_state(priv, MAC_SCANNING);
-	schedule_work(&priv->work_start_scan);
-
-exit:
-	mutex_unlock(&priv->mtx);
-}
-
-/* Handle authentication response timeout */
-static void at76_dwork_auth(struct work_struct *work)
-{
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      dwork_auth.work);
-
-	mutex_lock(&priv->mtx);
-	WARN_ON(priv->mac_state != MAC_AUTH);
-	if (priv->mac_state != MAC_AUTH)
-		goto exit;
-
-	at76_dbg(DBG_PROGRESS, "%s: authentication response timeout",
-		 priv->netdev->name);
-
-	if (priv->retries-- >= 0) {
-		at76_auth_req(priv, priv->curr_bss, 1, NULL);
-		at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer + HZ",
-			 __func__, __LINE__);
-		schedule_delayed_work(&priv->dwork_auth, AUTH_TIMEOUT);
-	} else {
-		/* try to get next matching BSS */
-		at76_set_mac_state(priv, MAC_JOINING);
-		schedule_work(&priv->work_join);
-	}
-
-exit:
-	mutex_unlock(&priv->mtx);
-}
-
-/* Handle association response timeout */
-static void at76_dwork_assoc(struct work_struct *work)
-{
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      dwork_assoc.work);
-
-	mutex_lock(&priv->mtx);
-	WARN_ON(priv->mac_state != MAC_ASSOC);
-	if (priv->mac_state != MAC_ASSOC)
-		goto exit;
-
-	at76_dbg(DBG_PROGRESS, "%s: association response timeout",
-		 priv->netdev->name);
-
-	if (priv->retries-- >= 0) {
-		at76_assoc_req(priv, priv->curr_bss);
-		at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer + HZ",
-			 __func__, __LINE__);
-		schedule_delayed_work(&priv->dwork_assoc, ASSOC_TIMEOUT);
-	} else {
-		/* try to get next matching BSS */
-		at76_set_mac_state(priv, MAC_JOINING);
-		schedule_work(&priv->work_join);
-	}
-
-exit:
-	mutex_unlock(&priv->mtx);
-}
-
-/* Read new bssid in ad-hoc mode */
-static void at76_work_new_bss(struct work_struct *work)
-{
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      work_new_bss);
-	int ret;
-	struct mib_mac_mgmt mac_mgmt;
-
-	mutex_lock(&priv->mtx);
-
-	ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, &mac_mgmt,
-			   sizeof(struct mib_mac_mgmt));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_get_mib failed: %d\n",
-		       priv->netdev->name, ret);
-		goto exit;
-	}
-
-	at76_dbg(DBG_PROGRESS, "ibss_change = 0x%2x", mac_mgmt.ibss_change);
-	memcpy(priv->bssid, mac_mgmt.current_bssid, ETH_ALEN);
-	at76_dbg(DBG_PROGRESS, "using BSSID %s", mac2str(priv->bssid));
-
-	at76_iwevent_bss_connect(priv->netdev, priv->bssid);
-
-	priv->mib_buf.type = MIB_MAC_MGMT;
-	priv->mib_buf.size = 1;
-	priv->mib_buf.index = offsetof(struct mib_mac_mgmt, ibss_change);
-	priv->mib_buf.data.byte = 0;
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0)
-		printk(KERN_ERR "%s: set_mib (ibss change ok) failed: %d\n",
-		       priv->netdev->name, ret);
-
-exit:
-	mutex_unlock(&priv->mtx);
-}
-
-static int at76_startup_device(struct at76_priv *priv)
-{
-	struct at76_card_config *ccfg = &priv->card_config;
-	int ret;
-
-	at76_dbg(DBG_PARAMS,
-		 "%s param: ssid %.*s (%s) mode %s ch %d wep %s key %d "
-		 "keylen %d", priv->netdev->name, priv->essid_size, priv->essid,
-		 hex2str(priv->essid, IW_ESSID_MAX_SIZE),
-		 priv->iw_mode == IW_MODE_ADHOC ? "adhoc" : "infra",
-		 priv->channel, priv->wep_enabled ? "enabled" : "disabled",
-		 priv->wep_key_id, priv->wep_keys_len[priv->wep_key_id]);
-	at76_dbg(DBG_PARAMS,
-		 "%s param: preamble %s rts %d retry %d frag %d "
-		 "txrate %s auth_mode %d", priv->netdev->name,
-		 preambles[priv->preamble_type], priv->rts_threshold,
-		 priv->short_retry_limit, priv->frag_threshold,
-		 priv->txrate == TX_RATE_1MBIT ? "1MBit" : priv->txrate ==
-		 TX_RATE_2MBIT ? "2MBit" : priv->txrate ==
-		 TX_RATE_5_5MBIT ? "5.5MBit" : priv->txrate ==
-		 TX_RATE_11MBIT ? "11MBit" : priv->txrate ==
-		 TX_RATE_AUTO ? "auto" : "<invalid>", priv->auth_mode);
-	at76_dbg(DBG_PARAMS,
-		 "%s param: pm_mode %d pm_period %d auth_mode %s "
-		 "scan_times %d %d scan_mode %s",
-		 priv->netdev->name, priv->pm_mode, priv->pm_period,
-		 priv->auth_mode == WLAN_AUTH_OPEN ? "open" : "shared_secret",
-		 priv->scan_min_time, priv->scan_max_time,
-		 priv->scan_mode == SCAN_TYPE_ACTIVE ? "active" : "passive");
-
-	memset(ccfg, 0, sizeof(struct at76_card_config));
-	ccfg->promiscuous_mode = 0;
-	ccfg->short_retry_limit = priv->short_retry_limit;
-
-	if (priv->wep_enabled) {
-		if (priv->wep_keys_len[priv->wep_key_id] > WEP_SMALL_KEY_LEN)
-			ccfg->encryption_type = 2;
-		else
-			ccfg->encryption_type = 1;
-
-		/* jal: always exclude unencrypted if WEP is active */
-		ccfg->exclude_unencrypted = 1;
-	} else {
-		ccfg->exclude_unencrypted = 0;
-		ccfg->encryption_type = 0;
-	}
-
-	ccfg->rts_threshold = cpu_to_le16(priv->rts_threshold);
-	ccfg->fragmentation_threshold = cpu_to_le16(priv->frag_threshold);
-
-	memcpy(ccfg->basic_rate_set, hw_rates, 4);
-	/* jal: really needed, we do a set_mib for autorate later ??? */
-	ccfg->auto_rate_fallback = (priv->txrate == TX_RATE_AUTO ? 1 : 0);
-	ccfg->channel = priv->channel;
-	ccfg->privacy_invoked = priv->wep_enabled;
-	memcpy(ccfg->current_ssid, priv->essid, IW_ESSID_MAX_SIZE);
-	ccfg->ssid_len = priv->essid_size;
-
-	ccfg->wep_default_key_id = priv->wep_key_id;
-	memcpy(ccfg->wep_default_key_value, priv->wep_keys, 4 * WEP_KEY_LEN);
-
-	ccfg->short_preamble = priv->preamble_type;
-	ccfg->beacon_period = cpu_to_le16(priv->beacon_period);
-
-	ret = at76_set_card_command(priv->udev, CMD_STARTUP, &priv->card_config,
-				    sizeof(struct at76_card_config));
-	if (ret < 0) {
-		printk(KERN_ERR "%s: at76_set_card_command failed: %d\n",
-		       priv->netdev->name, ret);
-		return ret;
-	}
-
-	at76_wait_completion(priv, CMD_STARTUP);
-
-	/* remove BSSID from previous run */
-	memset(priv->bssid, 0, ETH_ALEN);
-
-	if (at76_set_radio(priv, 1) == 1)
-		at76_wait_completion(priv, CMD_RADIO_ON);
-
-	ret = at76_set_preamble(priv, priv->preamble_type);
-	if (ret < 0)
-		return ret;
-
-	ret = at76_set_frag(priv, priv->frag_threshold);
-	if (ret < 0)
-		return ret;
-
-	ret = at76_set_rts(priv, priv->rts_threshold);
-	if (ret < 0)
-		return ret;
-
-	ret = at76_set_autorate_fallback(priv,
-					 priv->txrate == TX_RATE_AUTO ? 1 : 0);
-	if (ret < 0)
-		return ret;
-
-	ret = at76_set_pm_mode(priv);
-	if (ret < 0)
-		return ret;
-
-	if (at76_debug & DBG_MIB) {
-		at76_dump_mib_mac(priv);
-		at76_dump_mib_mac_addr(priv);
-		at76_dump_mib_mac_mgmt(priv);
-		at76_dump_mib_mac_wep(priv);
-		at76_dump_mib_mdomain(priv);
-		at76_dump_mib_phy(priv);
-		at76_dump_mib_local(priv);
-	}
-
-	return 0;
-}
-
-/* Restart the interface */
-static void at76_dwork_restart(struct work_struct *work)
-{
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      dwork_restart.work);
-
-	mutex_lock(&priv->mtx);
-
-	netif_carrier_off(priv->netdev);	/* stop netdev watchdog */
-	netif_stop_queue(priv->netdev);	/* stop tx data packets */
-
-	at76_startup_device(priv);
-
-	if (priv->iw_mode != IW_MODE_MONITOR) {
-		priv->netdev->type = ARPHRD_ETHER;
-		at76_set_mac_state(priv, MAC_SCANNING);
-		schedule_work(&priv->work_start_scan);
-	} else {
-		priv->netdev->type = ARPHRD_IEEE80211_RADIOTAP;
-		at76_start_monitor(priv);
-	}
-
-	mutex_unlock(&priv->mtx);
-}
-
-/* Initiate scanning */
-static void at76_work_start_scan(struct work_struct *work)
-{
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      work_start_scan);
-	int ret;
-
-	mutex_lock(&priv->mtx);
-
-	WARN_ON(priv->mac_state != MAC_SCANNING);
-	if (priv->mac_state != MAC_SCANNING)
-		goto exit;
-
-	/* only clear the bss list when a scan is actively initiated,
-	 * otherwise simply rely on at76_bss_list_timeout */
-	if (priv->scan_state == SCAN_IN_PROGRESS) {
-		at76_free_bss_list(priv);
-		priv->scan_need_any = 1;
-	} else
-		priv->scan_need_any = 0;
-
-	ret = at76_start_scan(priv, 1);
-
-	if (ret < 0)
-		printk(KERN_ERR "%s: %s: start_scan failed with %d\n",
-		       priv->netdev->name, __func__, ret);
-	else {
-		at76_dbg(DBG_MGMT_TIMER,
-			 "%s:%d: starting mgmt_timer for %d ticks",
-			 __func__, __LINE__, SCAN_POLL_INTERVAL);
-		schedule_delayed_work(&priv->dwork_get_scan,
-				      SCAN_POLL_INTERVAL);
-	}
-
-exit:
-	mutex_unlock(&priv->mtx);
-}
-
-/* Enable or disable promiscuous mode */
-static void at76_work_set_promisc(struct work_struct *work)
-{
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      work_set_promisc);
-	int ret = 0;
-
-	mutex_lock(&priv->mtx);
-
-	priv->mib_buf.type = MIB_LOCAL;
-	priv->mib_buf.size = 1;
-	priv->mib_buf.index = offsetof(struct mib_local, promiscuous_mode);
-	priv->mib_buf.data.byte = priv->promisc ? 1 : 0;
-
-	ret = at76_set_mib(priv, &priv->mib_buf);
-	if (ret < 0)
-		printk(KERN_ERR "%s: set_mib (promiscuous_mode) failed: %d\n",
-		       priv->netdev->name, ret);
-
-	mutex_unlock(&priv->mtx);
-}
-
-/* Submit Rx urb back to the device */
-static void at76_work_submit_rx(struct work_struct *work)
-{
-	struct at76_priv *priv = container_of(work, struct at76_priv,
-					      work_submit_rx);
-
-	mutex_lock(&priv->mtx);
-	at76_submit_rx_urb(priv);
-	mutex_unlock(&priv->mtx);
-}
-
-/* We got an association response */
-static void at76_rx_mgmt_assoc(struct at76_priv *priv,
-			       struct at76_rx_buffer *buf)
-{
-	struct ieee80211_assoc_response *resp =
-	    (struct ieee80211_assoc_response *)buf->packet;
-	u16 assoc_id = le16_to_cpu(resp->aid);
-	u16 status = le16_to_cpu(resp->status);
-
-	at76_dbg(DBG_RX_MGMT, "%s: rx AssocResp bssid %s capa 0x%04x status "
-		 "0x%04x assoc_id 0x%04x rates %s", priv->netdev->name,
-		 mac2str(resp->header.addr3), le16_to_cpu(resp->capability),
-		 status, assoc_id, hex2str(resp->info_element->data,
-					   resp->info_element->len));
-
-	if (priv->mac_state != MAC_ASSOC) {
-		printk(KERN_INFO "%s: AssocResp in state %s ignored\n",
-		       priv->netdev->name, mac_states[priv->mac_state]);
-		return;
-	}
-
-	BUG_ON(!priv->curr_bss);
-
-	cancel_delayed_work(&priv->dwork_assoc);
-	if (status == WLAN_STATUS_SUCCESS) {
-		struct bss_info *ptr = priv->curr_bss;
-		priv->assoc_id = assoc_id & 0x3fff;
-		/* update iwconfig params */
-		memcpy(priv->bssid, ptr->bssid, ETH_ALEN);
-		memcpy(priv->essid, ptr->ssid, ptr->ssid_len);
-		priv->essid_size = ptr->ssid_len;
-		priv->channel = ptr->channel;
-		schedule_work(&priv->work_assoc_done);
-	} else {
-		at76_set_mac_state(priv, MAC_JOINING);
-		schedule_work(&priv->work_join);
-	}
-}
-
-/* Process disassociation request from the AP */
-static void at76_rx_mgmt_disassoc(struct at76_priv *priv,
-				  struct at76_rx_buffer *buf)
-{
-	struct ieee80211_disassoc *resp =
-	    (struct ieee80211_disassoc *)buf->packet;
-	struct ieee80211_hdr_3addr *mgmt = &resp->header;
-
-	at76_dbg(DBG_RX_MGMT,
-		 "%s: rx DisAssoc bssid %s reason 0x%04x destination %s",
-		 priv->netdev->name, mac2str(mgmt->addr3),
-		 le16_to_cpu(resp->reason), mac2str(mgmt->addr1));
-
-	/* We are not connected, ignore */
-	if (priv->mac_state == MAC_SCANNING || priv->mac_state == MAC_INIT
-	    || !priv->curr_bss)
-		return;
-
-	/* Not our BSSID, ignore */
-	if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid))
-		return;
-
-	/* Not for our STA and not broadcast, ignore */
-	if (compare_ether_addr(priv->netdev->dev_addr, mgmt->addr1)
-	    && !is_broadcast_ether_addr(mgmt->addr1))
-		return;
-
-	if (priv->mac_state != MAC_ASSOC && priv->mac_state != MAC_CONNECTED
-	    && priv->mac_state != MAC_JOINING) {
-		printk(KERN_INFO "%s: DisAssoc in state %s ignored\n",
-		       priv->netdev->name, mac_states[priv->mac_state]);
-		return;
-	}
-
-	if (priv->mac_state == MAC_CONNECTED) {
-		netif_carrier_off(priv->netdev);
-		netif_stop_queue(priv->netdev);
-		at76_iwevent_bss_disconnect(priv->netdev);
-	}
-	cancel_delayed_work(&priv->dwork_get_scan);
-	cancel_delayed_work(&priv->dwork_beacon);
-	cancel_delayed_work(&priv->dwork_auth);
-	cancel_delayed_work(&priv->dwork_assoc);
-	at76_set_mac_state(priv, MAC_JOINING);
-	schedule_work(&priv->work_join);
-}
-
-static void at76_rx_mgmt_auth(struct at76_priv *priv,
-			      struct at76_rx_buffer *buf)
-{
-	struct ieee80211_auth *resp = (struct ieee80211_auth *)buf->packet;
-	struct ieee80211_hdr_3addr *mgmt = &resp->header;
-	int seq_nr = le16_to_cpu(resp->transaction);
-	int alg = le16_to_cpu(resp->algorithm);
-	int status = le16_to_cpu(resp->status);
-
-	at76_dbg(DBG_RX_MGMT,
-		 "%s: rx AuthFrame bssid %s alg %d seq_nr %d status %d "
-		 "destination %s", priv->netdev->name, mac2str(mgmt->addr3),
-		 alg, seq_nr, status, mac2str(mgmt->addr1));
-
-	if (alg == WLAN_AUTH_SHARED_KEY && seq_nr == 2)
-		at76_dbg(DBG_RX_MGMT, "%s: AuthFrame challenge %s ...",
-			 priv->netdev->name, hex2str(resp->info_element, 18));
-
-	if (priv->mac_state != MAC_AUTH) {
-		printk(KERN_INFO "%s: ignored AuthFrame in state %s\n",
-		       priv->netdev->name, mac_states[priv->mac_state]);
-		return;
-	}
-	if (priv->auth_mode != alg) {
-		printk(KERN_INFO "%s: ignored AuthFrame for alg %d\n",
-		       priv->netdev->name, alg);
-		return;
-	}
-
-	BUG_ON(!priv->curr_bss);
-
-	/* Not our BSSID or not for our STA, ignore */
-	if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid)
-	    || compare_ether_addr(priv->netdev->dev_addr, mgmt->addr1))
-		return;
-
-	cancel_delayed_work(&priv->dwork_auth);
-	if (status != WLAN_STATUS_SUCCESS) {
-		/* try to join next bss */
-		at76_set_mac_state(priv, MAC_JOINING);
-		schedule_work(&priv->work_join);
-		return;
-	}
-
-	if (priv->auth_mode == WLAN_AUTH_OPEN || seq_nr == 4) {
-		priv->retries = ASSOC_RETRIES;
-		at76_set_mac_state(priv, MAC_ASSOC);
-		at76_assoc_req(priv, priv->curr_bss);
-		at76_dbg(DBG_MGMT_TIMER,
-			 "%s:%d: starting mgmt_timer + HZ", __func__, __LINE__);
-		schedule_delayed_work(&priv->dwork_assoc, ASSOC_TIMEOUT);
-		return;
-	}
-
-	WARN_ON(seq_nr != 2);
-	at76_auth_req(priv, priv->curr_bss, seq_nr + 1, resp->info_element);
-	at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer + HZ", __func__,
-		 __LINE__);
-	schedule_delayed_work(&priv->dwork_auth, AUTH_TIMEOUT);
-}
-
-static void at76_rx_mgmt_deauth(struct at76_priv *priv,
-				struct at76_rx_buffer *buf)
-{
-	struct ieee80211_disassoc *resp =
-	    (struct ieee80211_disassoc *)buf->packet;
-	struct ieee80211_hdr_3addr *mgmt = &resp->header;
-
-	at76_dbg(DBG_RX_MGMT | DBG_PROGRESS,
-		 "%s: rx DeAuth bssid %s reason 0x%04x destination %s",
-		 priv->netdev->name, mac2str(mgmt->addr3),
-		 le16_to_cpu(resp->reason), mac2str(mgmt->addr1));
-
-	if (priv->mac_state != MAC_AUTH && priv->mac_state != MAC_ASSOC
-	    && priv->mac_state != MAC_CONNECTED) {
-		printk(KERN_INFO "%s: DeAuth in state %s ignored\n",
-		       priv->netdev->name, mac_states[priv->mac_state]);
-		return;
-	}
-
-	BUG_ON(!priv->curr_bss);
-
-	/* Not our BSSID, ignore */
-	if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid))
-		return;
-
-	/* Not for our STA and not broadcast, ignore */
-	if (compare_ether_addr(priv->netdev->dev_addr, mgmt->addr1)
-	    && !is_broadcast_ether_addr(mgmt->addr1))
-		return;
-
-	if (priv->mac_state == MAC_CONNECTED)
-		at76_iwevent_bss_disconnect(priv->netdev);
-
-	at76_set_mac_state(priv, MAC_JOINING);
-	schedule_work(&priv->work_join);
-	cancel_delayed_work(&priv->dwork_get_scan);
-	cancel_delayed_work(&priv->dwork_beacon);
-	cancel_delayed_work(&priv->dwork_auth);
-	cancel_delayed_work(&priv->dwork_assoc);
-}
-
-static void at76_rx_mgmt_beacon(struct at76_priv *priv,
-				struct at76_rx_buffer *buf)
-{
-	int varpar_len;
-	/* beacon content */
-	struct ieee80211_beacon *bdata = (struct ieee80211_beacon *)buf->packet;
-	struct ieee80211_hdr_3addr *mgmt = &bdata->header;
-
-	struct list_head *lptr;
-	struct bss_info *match;	/* entry matching addr3 with its bssid */
-	int new_entry = 0;
-	int len;
-	struct ieee80211_info_element *ie;
-	int have_ssid = 0;
-	int have_rates = 0;
-	int have_channel = 0;
-	int keep_going = 1;
-	unsigned long flags;
-
-	spin_lock_irqsave(&priv->bss_list_spinlock, flags);
-	if (priv->mac_state == MAC_CONNECTED) {
-		/* in state MAC_CONNECTED we use the mgmt_timer to control
-		   the beacon of the BSS */
-		BUG_ON(!priv->curr_bss);
-
-		if (!compare_ether_addr(priv->curr_bss->bssid, mgmt->addr3)) {
-			/* We got our AP's beacon, defer the timeout handler.
-			   Kill pending work first, as schedule_delayed_work()
-			   won't do it. */
-			cancel_delayed_work(&priv->dwork_beacon);
-			schedule_delayed_work(&priv->dwork_beacon,
-					      BEACON_TIMEOUT);
-			priv->curr_bss->rssi = buf->rssi;
-			priv->beacons_received++;
-			goto exit;
-		}
-	}
-
-	/* look if we have this BSS already in the list */
-	match = NULL;
-
-	if (!list_empty(&priv->bss_list)) {
-		list_for_each(lptr, &priv->bss_list) {
-			struct bss_info *bss_ptr =
-			    list_entry(lptr, struct bss_info, list);
-			if (!compare_ether_addr(bss_ptr->bssid, mgmt->addr3)) {
-				match = bss_ptr;
-				break;
-			}
-		}
-	}
-
-	if (!match) {
-		/* BSS not in the list - append it */
-		match = kzalloc(sizeof(struct bss_info), GFP_ATOMIC);
-		if (!match) {
-			at76_dbg(DBG_BSS_TABLE,
-				 "%s: cannot kmalloc new bss info (%zd byte)",
-				 priv->netdev->name, sizeof(struct bss_info));
-			goto exit;
-		}
-		new_entry = 1;
-		list_add_tail(&match->list, &priv->bss_list);
-	}
-
-	match->capa = le16_to_cpu(bdata->capability);
-	match->beacon_interval = le16_to_cpu(bdata->beacon_interval);
-	match->rssi = buf->rssi;
-	match->link_qual = buf->link_quality;
-	match->noise_level = buf->noise_level;
-	memcpy(match->bssid, mgmt->addr3, ETH_ALEN);
-	at76_dbg(DBG_RX_BEACON, "%s: bssid %s", priv->netdev->name,
-		 mac2str(match->bssid));
-
-	ie = bdata->info_element;
-
-	/* length of var length beacon parameters */
-	varpar_len = min_t(int, le16_to_cpu(buf->wlength) -
-			   sizeof(struct ieee80211_beacon),
-			   BEACON_MAX_DATA_LENGTH);
-
-	/* This routine steps through the bdata->data array to get
-	 * some useful information about the access point.
-	 * Currently, this implementation supports receipt of: SSID,
-	 * supported transfer rates and channel, in any order, with some
-	 * tolerance for intermittent unknown codes (although this
-	 * functionality may not be necessary as the useful information will
-	 * usually arrive in consecutively, but there have been some
-	 * reports of some of the useful information fields arriving in a
-	 * different order).
-	 * It does not support any more IE types although MFIE_TYPE_TIM may
-	 * be supported (on my AP at least).
-	 * The bdata->data array is about 1500 bytes long but only ~36 of those
-	 * bytes are useful, hence the have_ssid etc optimizations. */
-
-	while (keep_going &&
-	       ((&ie->data[ie->len] - (u8 *)bdata->info_element) <=
-		varpar_len)) {
-
-		switch (ie->id) {
-
-		case WLAN_EID_SSID:
-			if (have_ssid)
-				break;
-
-			len = min_t(int, IW_ESSID_MAX_SIZE, ie->len);
-
-			/* we copy only if this is a new entry,
-			   or the incoming SSID is not a hidden SSID. This
-			   will protect us from overwriting a real SSID read
-			   in a ProbeResponse with a hidden one from a
-			   following beacon. */
-			if (!new_entry && at76_is_hidden_ssid(ie->data, len)) {
-				have_ssid = 1;
-				break;
-			}
-
-			match->ssid_len = len;
-			memcpy(match->ssid, ie->data, len);
-			at76_dbg(DBG_RX_BEACON, "%s: SSID - %.*s",
-				 priv->netdev->name, len, match->ssid);
-			have_ssid = 1;
-			break;
-
-		case WLAN_EID_SUPP_RATES:
-			if (have_rates)
-				break;
-
-			match->rates_len =
-			    min_t(int, sizeof(match->rates), ie->len);
-			memcpy(match->rates, ie->data, match->rates_len);
-			have_rates = 1;
-			at76_dbg(DBG_RX_BEACON, "%s: SUPPORTED RATES %s",
-				 priv->netdev->name,
-				 hex2str(ie->data, ie->len));
-			break;
-
-		case WLAN_EID_DS_PARAMS:
-			if (have_channel)
-				break;
-
-			match->channel = ie->data[0];
-			have_channel = 1;
-			at76_dbg(DBG_RX_BEACON, "%s: CHANNEL - %d",
-				 priv->netdev->name, match->channel);
-			break;
-
-		case WLAN_EID_CF_PARAMS:
-		case WLAN_EID_TIM:
-		case WLAN_EID_IBSS_PARAMS:
-		default:
-			at76_dbg(DBG_RX_BEACON, "%s: beacon IE id %d len %d %s",
-				 priv->netdev->name, ie->id, ie->len,
-				 hex2str(ie->data, ie->len));
-			break;
-		}
-
-		/* advance to the next informational element */
-		next_ie(&ie);
-
-		/* Optimization: after all, the bdata->data array is
-		 * varpar_len bytes long, whereas we get all of the useful
-		 * information after only ~36 bytes, this saves us a lot of
-		 * time (and trouble as the remaining portion of the array
-		 * could be full of junk)
-		 * Comment this out if you want to see what other information
-		 * comes from the AP - although little of it may be useful */
-	}
-
-	at76_dbg(DBG_RX_BEACON, "%s: Finished processing beacon data",
-		 priv->netdev->name);
-
-	match->last_rx = jiffies;	/* record last rx of beacon */
-
-exit:
-	spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
-}
-
-/* Calculate the link level from a given rx_buffer */
-static void at76_calc_level(struct at76_priv *priv, struct at76_rx_buffer *buf,
-			    struct iw_quality *qual)
-{
-	/* just a guess for now, might be different for other chips */
-	int max_rssi = 42;
-
-	qual->level = (buf->rssi * 100 / max_rssi);
-	if (qual->level > 100)
-		qual->level = 100;
-	qual->updated |= IW_QUAL_LEVEL_UPDATED;
-}
-
-/* Calculate the link quality from a given rx_buffer */
-static void at76_calc_qual(struct at76_priv *priv, struct at76_rx_buffer *buf,
-			   struct iw_quality *qual)
-{
-	if (at76_is_intersil(priv->board_type))
-		qual->qual = buf->link_quality;
-	else {
-		unsigned long elapsed;
-
-		/* Update qual at most once a second */
-		elapsed = jiffies - priv->beacons_last_qual;
-		if (elapsed < 1 * HZ)
-			return;
-
-		qual->qual = qual->level * priv->beacons_received *
-		    msecs_to_jiffies(priv->beacon_period) / elapsed;
-
-		priv->beacons_last_qual = jiffies;
-		priv->beacons_received = 0;
-	}
-	qual->qual = (qual->qual > 100) ? 100 : qual->qual;
-	qual->updated |= IW_QUAL_QUAL_UPDATED;
-}
-
-/* Calculate the noise quality from a given rx_buffer */
-static void at76_calc_noise(struct at76_priv *priv, struct at76_rx_buffer *buf,
-			    struct iw_quality *qual)
-{
-	qual->noise = 0;
-	qual->updated |= IW_QUAL_NOISE_INVALID;
-}
-
-static void at76_update_wstats(struct at76_priv *priv,
-			       struct at76_rx_buffer *buf)
-{
-	struct iw_quality *qual = &priv->wstats.qual;
-
-	if (buf->rssi && priv->mac_state == MAC_CONNECTED) {
-		qual->updated = 0;
-		at76_calc_level(priv, buf, qual);
-		at76_calc_qual(priv, buf, qual);
-		at76_calc_noise(priv, buf, qual);
-	} else {
-		qual->qual = 0;
-		qual->level = 0;
-		qual->noise = 0;
-		qual->updated = IW_QUAL_ALL_INVALID;
-	}
-}
-
-static void at76_rx_mgmt(struct at76_priv *priv, struct at76_rx_buffer *buf)
-{
-	struct ieee80211_hdr_3addr *mgmt =
-	    (struct ieee80211_hdr_3addr *)buf->packet;
-	u16 framectl = le16_to_cpu(mgmt->frame_ctl);
-
-	/* update wstats */
-	if (priv->mac_state != MAC_INIT && priv->mac_state != MAC_SCANNING) {
-		/* jal: this is a dirty hack needed by Tim in ad-hoc mode */
-		/* Data packets always seem to have a 0 link level, so we
-		   only read link quality info from management packets.
-		   Atmel driver actually averages the present, and previous
-		   values, we just present the raw value at the moment - TJS */
-		if (priv->iw_mode == IW_MODE_ADHOC
-		    || (priv->curr_bss
-			&& !compare_ether_addr(mgmt->addr3,
-					       priv->curr_bss->bssid)))
-			at76_update_wstats(priv, buf);
-	}
-
-	at76_dbg(DBG_RX_MGMT_CONTENT, "%s rx mgmt framectl 0x%x %s",
-		 priv->netdev->name, framectl,
-		 hex2str(mgmt, le16_to_cpu(buf->wlength)));
-
-	switch (framectl & IEEE80211_FCTL_STYPE) {
-	case IEEE80211_STYPE_BEACON:
-	case IEEE80211_STYPE_PROBE_RESP:
-		at76_rx_mgmt_beacon(priv, buf);
-		break;
-
-	case IEEE80211_STYPE_ASSOC_RESP:
-		at76_rx_mgmt_assoc(priv, buf);
-		break;
-
-	case IEEE80211_STYPE_DISASSOC:
-		at76_rx_mgmt_disassoc(priv, buf);
-		break;
-
-	case IEEE80211_STYPE_AUTH:
-		at76_rx_mgmt_auth(priv, buf);
-		break;
-
-	case IEEE80211_STYPE_DEAUTH:
-		at76_rx_mgmt_deauth(priv, buf);
-		break;
-
-	default:
-		printk(KERN_DEBUG "%s: ignoring frame with framectl 0x%04x\n",
-		       priv->netdev->name, framectl);
-	}
-
-	return;
-}
-
-/* Convert the 802.11 header into an ethernet-style header, make skb
- * ready for consumption by netif_rx() */
-static void at76_ieee80211_to_eth(struct sk_buff *skb, int iw_mode)
-{
-	struct ieee80211_hdr_3addr *i802_11_hdr;
-	struct ethhdr *eth_hdr_p;
-	u8 *src_addr;
-	u8 *dest_addr;
-
-	i802_11_hdr = (struct ieee80211_hdr_3addr *)skb->data;
-
-	/* That would be the ethernet header if the hardware converted
-	 * the frame for us.  Make sure the source and the destination
-	 * match the 802.11 header.  Which hardware does it? */
-	eth_hdr_p = (struct ethhdr *)skb_pull(skb, IEEE80211_3ADDR_LEN);
-
-	dest_addr = i802_11_hdr->addr1;
-	if (iw_mode == IW_MODE_ADHOC)
-		src_addr = i802_11_hdr->addr2;
-	else
-		src_addr = i802_11_hdr->addr3;
-
-	if (!compare_ether_addr(eth_hdr_p->h_source, src_addr) &&
-	    !compare_ether_addr(eth_hdr_p->h_dest, dest_addr))
-		/* Yes, we already have an ethernet header */
-		skb_reset_mac_header(skb);
-	else {
-		u16 len;
-
-		/* Need to build an ethernet header */
-		if (!memcmp(skb->data, snapsig, sizeof(snapsig))) {
-			/* SNAP frame - decapsulate, keep proto */
-			skb_push(skb, offsetof(struct ethhdr, h_proto) -
-				 sizeof(rfc1042sig));
-			len = 0;
-		} else {
-			/* 802.3 frame, proto is length */
-			len = skb->len;
-			skb_push(skb, ETH_HLEN);
-		}
-
-		skb_reset_mac_header(skb);
-		eth_hdr_p = eth_hdr(skb);
-		/* This needs to be done in this order (eth_hdr_p->h_dest may
-		 * overlap src_addr) */
-		memcpy(eth_hdr_p->h_source, src_addr, ETH_ALEN);
-		memcpy(eth_hdr_p->h_dest, dest_addr, ETH_ALEN);
-		if (len)
-			eth_hdr_p->h_proto = htons(len);
-	}
-
-	skb->protocol = eth_type_trans(skb, skb->dev);
-}
-
-/* Check for fragmented data in priv->rx_skb. If the packet was no fragment
-   or it was the last of a fragment set a skb containing the whole packet
-   is returned for further processing. Otherwise we get NULL and are
-   done and the packet is either stored inside the fragment buffer
-   or thrown away.  Every returned skb starts with the ieee802_11 header
-   and contains _no_ FCS at the end */
-static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
-{
-	struct sk_buff *skb = priv->rx_skb;
-	struct at76_rx_buffer *buf = (struct at76_rx_buffer *)skb->data;
-	struct ieee80211_hdr_3addr *i802_11_hdr =
-	    (struct ieee80211_hdr_3addr *)buf->packet;
-	/* seq_ctrl, fragment_number, sequence number of new packet */
-	u16 sctl = le16_to_cpu(i802_11_hdr->seq_ctl);
-	u16 fragnr = sctl & 0xf;
-	u16 seqnr = sctl >> 4;
-	u16 frame_ctl = le16_to_cpu(i802_11_hdr->frame_ctl);
-
-	/* Length including the IEEE802.11 header, but without the trailing
-	 * FCS and without the Atmel Rx header */
-	int length = le16_to_cpu(buf->wlength) - IEEE80211_FCS_LEN;
-
-	/* where does the data payload start in skb->data ? */
-	u8 *data = i802_11_hdr->payload;
-
-	/* length of payload, excl. the trailing FCS */
-	int data_len = length - IEEE80211_3ADDR_LEN;
-
-	int i;
-	struct rx_data_buf *bptr, *optr;
-	unsigned long oldest = ~0UL;
-
-	at76_dbg(DBG_RX_FRAGS,
-		 "%s: rx data frame_ctl %04x addr2 %s seq/frag %d/%d "
-		 "length %d data %d: %s ...", priv->netdev->name, frame_ctl,
-		 mac2str(i802_11_hdr->addr2), seqnr, fragnr, length, data_len,
-		 hex2str(data, 32));
-
-	at76_dbg(DBG_RX_FRAGS_SKB, "%s: incoming skb: head %p data %p "
-		 "tail %p end %p len %d", priv->netdev->name, skb->head,
-		 skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
-		 skb->len);
-
-	if (data_len < 0) {
-		/* make sure data starts in the buffer */
-		printk(KERN_INFO "%s: data frame too short\n",
-		       priv->netdev->name);
-		return NULL;
-	}
-
-	WARN_ON(length <= AT76_RX_HDRLEN);
-	if (length <= AT76_RX_HDRLEN)
-		return NULL;
-
-	/* remove the at76_rx_buffer header - we don't need it anymore */
-	/* we need the IEEE802.11 header (for the addresses) if this packet
-	   is the first of a chain */
-	skb_pull(skb, AT76_RX_HDRLEN);
-
-	/* remove FCS at end */
-	skb_trim(skb, length);
-
-	at76_dbg(DBG_RX_FRAGS_SKB, "%s: trimmed skb: head %p data %p tail %p "
-		 "end %p len %d data %p data_len %d", priv->netdev->name,
-		 skb->head, skb->data, skb_tail_pointer(skb),
-		 skb_end_pointer(skb), skb->len, data, data_len);
-
-	if (fragnr == 0 && !(frame_ctl & IEEE80211_FCTL_MOREFRAGS)) {
-		/* unfragmented packet received */
-		/* Use a new skb for the next receive */
-		priv->rx_skb = NULL;
-		at76_dbg(DBG_RX_FRAGS, "%s: unfragmented", priv->netdev->name);
-		return skb;
-	}
-
-	/* look if we've got a chain for the sender address.
-	   afterwards optr points to first free or the oldest entry,
-	   or, if i < NR_RX_DATA_BUF, bptr points to the entry for the
-	   sender address */
-	/* determining the oldest entry doesn't cope with jiffies wrapping
-	   but I don't care to delete a young entry at these rare moments ... */
-
-	bptr = priv->rx_data;
-	optr = NULL;
-	for (i = 0; i < NR_RX_DATA_BUF; i++, bptr++) {
-		if (!bptr->skb) {
-			optr = bptr;
-			oldest = 0UL;
-			continue;
-		}
-
-		if (!compare_ether_addr(i802_11_hdr->addr2, bptr->sender))
-			break;
-
-		if (!optr) {
-			optr = bptr;
-			oldest = bptr->last_rx;
-		} else if (bptr->last_rx < oldest)
-			optr = bptr;
-	}
-
-	if (i < NR_RX_DATA_BUF) {
-
-		at76_dbg(DBG_RX_FRAGS, "%s: %d. cacheentry (seq/frag = %d/%d) "
-			 "matched sender addr",
-			 priv->netdev->name, i, bptr->seqnr, bptr->fragnr);
-
-		/* bptr points to an entry for the sender address */
-		if (bptr->seqnr == seqnr) {
-			int left;
-			/* the fragment has the current sequence number */
-			if (((bptr->fragnr + 1) & 0xf) != fragnr) {
-				/* wrong fragment number -> ignore it */
-				/* is & 0xf necessary above ??? */
-				at76_dbg(DBG_RX_FRAGS,
-					 "%s: frag nr mismatch: %d + 1 != %d",
-					 priv->netdev->name, bptr->fragnr,
-					 fragnr);
-				return NULL;
-			}
-			bptr->last_rx = jiffies;
-			/* the next following fragment number ->
-			   add the data at the end */
-
-			/* for test only ??? */
-			left = skb_tailroom(bptr->skb);
-			if (left < data_len)
-				printk(KERN_INFO
-				       "%s: only %d byte free (need %d)\n",
-				       priv->netdev->name, left, data_len);
-			else
-				memcpy(skb_put(bptr->skb, data_len), data,
-				       data_len);
-
-			bptr->fragnr = fragnr;
-			if (frame_ctl & IEEE80211_FCTL_MOREFRAGS)
-				return NULL;
-
-			/* this was the last fragment - send it */
-			skb = bptr->skb;
-			bptr->skb = NULL;	/* free the entry */
-			at76_dbg(DBG_RX_FRAGS, "%s: last frag of seq %d",
-				 priv->netdev->name, seqnr);
-			return skb;
-		}
-
-		/* got another sequence number */
-		if (fragnr == 0) {
-			/* it's the start of a new chain - replace the
-			   old one by this */
-			/* bptr->sender has the correct value already */
-			at76_dbg(DBG_RX_FRAGS,
-				 "%s: start of new seq %d, removing old seq %d",
-				 priv->netdev->name, seqnr, bptr->seqnr);
-			bptr->seqnr = seqnr;
-			bptr->fragnr = 0;
-			bptr->last_rx = jiffies;
-			/* swap bptr->skb and priv->rx_skb */
-			skb = bptr->skb;
-			bptr->skb = priv->rx_skb;
-			priv->rx_skb = skb;
-		} else {
-			/* it from the middle of a new chain ->
-			   delete the old entry and skip the new one */
-			at76_dbg(DBG_RX_FRAGS,
-				 "%s: middle of new seq %d (%d) "
-				 "removing old seq %d",
-				 priv->netdev->name, seqnr, fragnr,
-				 bptr->seqnr);
-			dev_kfree_skb(bptr->skb);
-			bptr->skb = NULL;
-		}
-		return NULL;
-	}
-
-	/* if we didn't find a chain for the sender address, optr
-	   points either to the first free or the oldest entry */
-
-	if (fragnr != 0) {
-		/* this is not the begin of a fragment chain ... */
-		at76_dbg(DBG_RX_FRAGS,
-			 "%s: no chain for non-first fragment (%d)",
-			 priv->netdev->name, fragnr);
-		return NULL;
-	}
-
-	BUG_ON(!optr);
-	if (optr->skb) {
-		/* swap the skb's */
-		skb = optr->skb;
-		optr->skb = priv->rx_skb;
-		priv->rx_skb = skb;
-
-		at76_dbg(DBG_RX_FRAGS,
-			 "%s: free old contents: sender %s seq/frag %d/%d",
-			 priv->netdev->name, mac2str(optr->sender),
-			 optr->seqnr, optr->fragnr);
-
-	} else {
-		/* take the skb from priv->rx_skb */
-		optr->skb = priv->rx_skb;
-		/* let at76_submit_rx_urb() allocate a new skb */
-		priv->rx_skb = NULL;
-
-		at76_dbg(DBG_RX_FRAGS, "%s: use a free entry",
-			 priv->netdev->name);
-	}
-	memcpy(optr->sender, i802_11_hdr->addr2, ETH_ALEN);
-	optr->seqnr = seqnr;
-	optr->fragnr = 0;
-	optr->last_rx = jiffies;
-
-	return NULL;
-}
-
-/* Rx interrupt: we expect the complete data buffer in priv->rx_skb */
-static void at76_rx_data(struct at76_priv *priv)
-{
-	struct net_device *netdev = priv->netdev;
-	struct net_device_stats *stats = &priv->stats;
-	struct sk_buff *skb = priv->rx_skb;
-	struct at76_rx_buffer *buf = (struct at76_rx_buffer *)skb->data;
-	struct ieee80211_hdr_3addr *i802_11_hdr;
-	int length = le16_to_cpu(buf->wlength);
-
-	at76_dbg(DBG_RX_DATA, "%s received data packet: %s", netdev->name,
-		 hex2str(skb->data, AT76_RX_HDRLEN));
-
-	at76_dbg(DBG_RX_DATA_CONTENT, "rx packet: %s",
-		 hex2str(skb->data + AT76_RX_HDRLEN, length));
-
-	skb = at76_check_for_rx_frags(priv);
-	if (!skb)
-		return;
-
-	/* Atmel header and the FCS are already removed */
-	i802_11_hdr = (struct ieee80211_hdr_3addr *)skb->data;
-
-	skb->dev = netdev;
-	skb->ip_summed = CHECKSUM_NONE;	/* TODO: should check CRC */
-
-	if (is_broadcast_ether_addr(i802_11_hdr->addr1)) {
-		if (!compare_ether_addr(i802_11_hdr->addr1, netdev->broadcast))
-			skb->pkt_type = PACKET_BROADCAST;
-		else
-			skb->pkt_type = PACKET_MULTICAST;
-	} else if (compare_ether_addr(i802_11_hdr->addr1, netdev->dev_addr))
-		skb->pkt_type = PACKET_OTHERHOST;
-
-	at76_ieee80211_to_eth(skb, priv->iw_mode);
-
-	netdev->last_rx = jiffies;
-	netif_rx(skb);
-	stats->rx_packets++;
-	stats->rx_bytes += length;
-
-	return;
-}
-
-static void at76_rx_monitor_mode(struct at76_priv *priv)
-{
-	struct at76_rx_radiotap *rt;
-	u8 *payload;
-	int skblen;
-	struct net_device *netdev = priv->netdev;
-	struct at76_rx_buffer *buf =
-	    (struct at76_rx_buffer *)priv->rx_skb->data;
-	/* length including the IEEE802.11 header and the trailing FCS,
-	   but not at76_rx_buffer */
-	int length = le16_to_cpu(buf->wlength);
-	struct sk_buff *skb = priv->rx_skb;
-	struct net_device_stats *stats = &priv->stats;
-
-	if (length < IEEE80211_FCS_LEN) {
-		/* buffer contains no data */
-		at76_dbg(DBG_MONITOR_MODE,
-			 "%s: MONITOR MODE: rx skb without data",
-			 priv->netdev->name);
-		return;
-	}
-
-	skblen = sizeof(struct at76_rx_radiotap) + length;
-
-	skb = dev_alloc_skb(skblen);
-	if (!skb) {
-		printk(KERN_ERR "%s: MONITOR MODE: dev_alloc_skb for radiotap "
-		       "header returned NULL\n", priv->netdev->name);
-		return;
-	}
-
-	skb_put(skb, skblen);
-
-	rt = (struct at76_rx_radiotap *)skb->data;
-	payload = skb->data + sizeof(struct at76_rx_radiotap);
-
-	rt->rt_hdr.it_version = 0;
-	rt->rt_hdr.it_pad = 0;
-	rt->rt_hdr.it_len = cpu_to_le16(sizeof(struct at76_rx_radiotap));
-	rt->rt_hdr.it_present = cpu_to_le32(AT76_RX_RADIOTAP_PRESENT);
-
-	rt->rt_tsft = cpu_to_le64(le32_to_cpu(buf->rx_time));
-	rt->rt_rate = hw_rates[buf->rx_rate] & (~0x80);
-	rt->rt_signal = buf->rssi;
-	rt->rt_noise = buf->noise_level;
-	rt->rt_flags = IEEE80211_RADIOTAP_F_FCS;
-	if (buf->fragmentation)
-		rt->rt_flags |= IEEE80211_RADIOTAP_F_FRAG;
-
-	memcpy(payload, buf->packet, length);
-	skb->dev = netdev;
-	skb->ip_summed = CHECKSUM_NONE;
-	skb_reset_mac_header(skb);
-	skb->pkt_type = PACKET_OTHERHOST;
-	skb->protocol = htons(ETH_P_802_2);
-
-	netdev->last_rx = jiffies;
-	netif_rx(skb);
-	stats->rx_packets++;
-	stats->rx_bytes += length;
-}
-
-/* Check if we spy on the sender address in buf and update stats */
-static void at76_iwspy_update(struct at76_priv *priv,
-			      struct at76_rx_buffer *buf)
-{
-	struct ieee80211_hdr_3addr *hdr =
-	    (struct ieee80211_hdr_3addr *)buf->packet;
-	struct iw_quality qual;
-
-	/* We can only set the level here */
-	qual.updated = IW_QUAL_QUAL_INVALID | IW_QUAL_NOISE_INVALID;
-	qual.level = 0;
-	qual.noise = 0;
-	at76_calc_level(priv, buf, &qual);
-
-	spin_lock_bh(&priv->spy_spinlock);
-
-	if (priv->spy_data.spy_number > 0)
-		wireless_spy_update(priv->netdev, hdr->addr2, &qual);
-
-	spin_unlock_bh(&priv->spy_spinlock);
-}
-
-static void at76_rx_tasklet(unsigned long param)
-{
-	struct urb *urb = (struct urb *)param;
-	struct at76_priv *priv = urb->context;
-	struct net_device *netdev = priv->netdev;
-	struct at76_rx_buffer *buf;
-	struct ieee80211_hdr_3addr *i802_11_hdr;
-	u16 frame_ctl;
-
-	if (priv->device_unplugged) {
-		at76_dbg(DBG_DEVSTART, "device unplugged");
-		if (urb)
-			at76_dbg(DBG_DEVSTART, "urb status %d", urb->status);
-		return;
-	}
-
-	if (!priv->rx_skb || !netdev || !priv->rx_skb->data)
-		return;
-
-	buf = (struct at76_rx_buffer *)priv->rx_skb->data;
-
-	i802_11_hdr = (struct ieee80211_hdr_3addr *)buf->packet;
-
-	frame_ctl = le16_to_cpu(i802_11_hdr->frame_ctl);
-
-	if (urb->status != 0) {
-		if (urb->status != -ENOENT && urb->status != -ECONNRESET)
-			at76_dbg(DBG_URB,
-				 "%s %s: - nonzero Rx bulk status received: %d",
-				 __func__, netdev->name, urb->status);
-		return;
-	}
-
-	at76_dbg(DBG_RX_ATMEL_HDR,
-		 "%s: rx frame: rate %d rssi %d noise %d link %d %s",
-		 priv->netdev->name, buf->rx_rate, buf->rssi, buf->noise_level,
-		 buf->link_quality, hex2str(i802_11_hdr, 48));
-	if (priv->iw_mode == IW_MODE_MONITOR) {
-		at76_rx_monitor_mode(priv);
-		goto exit;
-	}
-
-	/* there is a new bssid around, accept it: */
-	if (buf->newbss && priv->iw_mode == IW_MODE_ADHOC) {
-		at76_dbg(DBG_PROGRESS, "%s: rx newbss", netdev->name);
-		schedule_work(&priv->work_new_bss);
-	}
-
-	switch (frame_ctl & IEEE80211_FCTL_FTYPE) {
-	case IEEE80211_FTYPE_DATA:
-		at76_rx_data(priv);
-		break;
-
-	case IEEE80211_FTYPE_MGMT:
-		/* jal: TODO: find out if we can update iwspy also on
-		   other frames than management (might depend on the
-		   radio chip / firmware version !) */
-
-		at76_iwspy_update(priv, buf);
-
-		at76_rx_mgmt(priv, buf);
-		break;
-
-	case IEEE80211_FTYPE_CTL:
-		at76_dbg(DBG_RX_CTRL, "%s: ignored ctrl frame: %04x",
-			 priv->netdev->name, frame_ctl);
-		break;
-
-	default:
-		printk(KERN_DEBUG "%s: ignoring frame with framectl 0x%04x\n",
-		       priv->netdev->name, frame_ctl);
-	}
-exit:
-	at76_submit_rx_urb(priv);
-}
-
-/* Load firmware into kernel memory and parse it */
-static struct fwentry *at76_load_firmware(struct usb_device *udev,
-					  enum board_type board_type)
-{
-	int ret;
-	char *str;
-	struct at76_fw_header *fwh;
-	struct fwentry *fwe = &firmwares[board_type];
-
-	mutex_lock(&fw_mutex);
-
-	if (fwe->loaded) {
-		at76_dbg(DBG_FW, "re-using previously loaded fw");
-		goto exit;
-	}
-
-	at76_dbg(DBG_FW, "downloading firmware %s", fwe->fwname);
-	ret = request_firmware(&fwe->fw, fwe->fwname, &udev->dev);
-	if (ret < 0) {
-		dev_printk(KERN_ERR, &udev->dev, "firmware %s not found!\n",
-			   fwe->fwname);
-		dev_printk(KERN_ERR, &udev->dev,
-			   "you may need to download the firmware from "
-			   "http://developer.berlios.de/projects/at76c503a/");
-		goto exit;
-	}
-
-	at76_dbg(DBG_FW, "got it.");
-	fwh = (struct at76_fw_header *)(fwe->fw->data);
-
-	if (fwe->fw->size <= sizeof(*fwh)) {
-		dev_printk(KERN_ERR, &udev->dev,
-			   "firmware is too short (0x%zx)\n", fwe->fw->size);
-		goto exit;
-	}
-
-	/* CRC currently not checked */
-	fwe->board_type = le32_to_cpu(fwh->board_type);
-	if (fwe->board_type != board_type) {
-		dev_printk(KERN_ERR, &udev->dev,
-			   "board type mismatch, requested %u, got %u\n",
-			   board_type, fwe->board_type);
-		goto exit;
-	}
-
-	fwe->fw_version.major = fwh->major;
-	fwe->fw_version.minor = fwh->minor;
-	fwe->fw_version.patch = fwh->patch;
-	fwe->fw_version.build = fwh->build;
-
-	str = (char *)fwh + le32_to_cpu(fwh->str_offset);
-	fwe->intfw = (u8 *)fwh + le32_to_cpu(fwh->int_fw_offset);
-	fwe->intfw_size = le32_to_cpu(fwh->int_fw_len);
-	fwe->extfw = (u8 *)fwh + le32_to_cpu(fwh->ext_fw_offset);
-	fwe->extfw_size = le32_to_cpu(fwh->ext_fw_len);
-
-	fwe->loaded = 1;
-
-	dev_printk(KERN_DEBUG, &udev->dev,
-		   "using firmware %s (version %d.%d.%d-%d)\n",
-		   fwe->fwname, fwh->major, fwh->minor, fwh->patch, fwh->build);
-
-	at76_dbg(DBG_DEVSTART, "board %u, int %d:%d, ext %d:%d", board_type,
-		 le32_to_cpu(fwh->int_fw_offset), le32_to_cpu(fwh->int_fw_len),
-		 le32_to_cpu(fwh->ext_fw_offset), le32_to_cpu(fwh->ext_fw_len));
-	at76_dbg(DBG_DEVSTART, "firmware id %s", str);
-
-exit:
-	mutex_unlock(&fw_mutex);
-
-	if (fwe->loaded)
-		return fwe;
-	else
-		return NULL;
-}
-
-/* Allocate network device and initialize private data */
-static struct at76_priv *at76_alloc_new_device(struct usb_device *udev)
-{
-	struct net_device *netdev;
-	struct at76_priv *priv;
-	int i;
-
-	/* allocate memory for our device state and initialize it */
-	netdev = alloc_etherdev(sizeof(struct at76_priv));
-	if (!netdev) {
-		dev_printk(KERN_ERR, &udev->dev, "out of memory\n");
-		return NULL;
-	}
-
-	priv = netdev_priv(netdev);
-
-	priv->udev = udev;
-	priv->netdev = netdev;
-
-	mutex_init(&priv->mtx);
-	INIT_WORK(&priv->work_assoc_done, at76_work_assoc_done);
-	INIT_WORK(&priv->work_join, at76_work_join);
-	INIT_WORK(&priv->work_new_bss, at76_work_new_bss);
-	INIT_WORK(&priv->work_start_scan, at76_work_start_scan);
-	INIT_WORK(&priv->work_set_promisc, at76_work_set_promisc);
-	INIT_WORK(&priv->work_submit_rx, at76_work_submit_rx);
-	INIT_DELAYED_WORK(&priv->dwork_restart, at76_dwork_restart);
-	INIT_DELAYED_WORK(&priv->dwork_get_scan, at76_dwork_get_scan);
-	INIT_DELAYED_WORK(&priv->dwork_beacon, at76_dwork_beacon);
-	INIT_DELAYED_WORK(&priv->dwork_auth, at76_dwork_auth);
-	INIT_DELAYED_WORK(&priv->dwork_assoc, at76_dwork_assoc);
-
-	spin_lock_init(&priv->mgmt_spinlock);
-	priv->next_mgmt_bulk = NULL;
-	priv->mac_state = MAC_INIT;
-
-	/* initialize empty BSS list */
-	priv->curr_bss = NULL;
-	INIT_LIST_HEAD(&priv->bss_list);
-	spin_lock_init(&priv->bss_list_spinlock);
-
-	init_timer(&priv->bss_list_timer);
-	priv->bss_list_timer.data = (unsigned long)priv;
-	priv->bss_list_timer.function = at76_bss_list_timeout;
-
-	spin_lock_init(&priv->spy_spinlock);
-
-	/* mark all rx data entries as unused */
-	for (i = 0; i < NR_RX_DATA_BUF; i++)
-		priv->rx_data[i].skb = NULL;
-
-	priv->rx_tasklet.func = at76_rx_tasklet;
-	priv->rx_tasklet.data = 0;
-
-	priv->pm_mode = AT76_PM_OFF;
-	priv->pm_period = 0;
-
-	return priv;
-}
-
-static int at76_alloc_urbs(struct at76_priv *priv,
-			   struct usb_interface *interface)
-{
-	struct usb_endpoint_descriptor *endpoint, *ep_in, *ep_out;
-	int i;
-	int buffer_size;
-	struct usb_host_interface *iface_desc;
-
-	at76_dbg(DBG_PROC_ENTRY, "%s: ENTER", __func__);
-
-	at76_dbg(DBG_URB, "%s: NumEndpoints %d ", __func__,
-		 interface->altsetting[0].desc.bNumEndpoints);
-
-	ep_in = NULL;
-	ep_out = NULL;
-	iface_desc = interface->cur_altsetting;
-	for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
-		endpoint = &iface_desc->endpoint[i].desc;
-
-		at76_dbg(DBG_URB, "%s: %d. endpoint: addr 0x%x attr 0x%x",
-			 __func__, i, endpoint->bEndpointAddress,
-			 endpoint->bmAttributes);
-
-		if (!ep_in && usb_endpoint_is_bulk_in(endpoint))
-			ep_in = endpoint;
-
-		if (!ep_out && usb_endpoint_is_bulk_out(endpoint))
-			ep_out = endpoint;
-	}
-
-	if (!ep_in || !ep_out) {
-		dev_printk(KERN_ERR, &interface->dev,
-			   "bulk endpoints missing\n");
-		return -ENXIO;
-	}
-
-	priv->rx_pipe = usb_rcvbulkpipe(priv->udev, ep_in->bEndpointAddress);
-	priv->tx_pipe = usb_sndbulkpipe(priv->udev, ep_out->bEndpointAddress);
-
-	priv->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
-	priv->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
-	if (!priv->rx_urb || !priv->tx_urb) {
-		dev_printk(KERN_ERR, &interface->dev, "cannot allocate URB\n");
-		return -ENOMEM;
-	}
-
-	buffer_size = sizeof(struct at76_tx_buffer) + MAX_PADDING_SIZE;
-	priv->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
-	if (!priv->bulk_out_buffer) {
-		dev_printk(KERN_ERR, &interface->dev,
-			   "cannot allocate output buffer\n");
-		return -ENOMEM;
-	}
-
-	at76_dbg(DBG_PROC_ENTRY, "%s: EXIT", __func__);
-
-	return 0;
-}
-
-static const struct net_device_ops at76_netdev_ops = {
-	.ndo_open		= at76_open,
-	.ndo_stop		= at76_stop,
-	.ndo_get_stats		= at76_get_stats,
-	.ndo_start_xmit		= at76_tx,
-	.ndo_tx_timeout		= at76_tx_timeout,
-	.ndo_set_multicast_list	= at76_set_multicast,
-	.ndo_set_mac_address	= at76_set_mac_address,
-	.ndo_validate_addr	= eth_validate_addr,
-	.ndo_change_mtu		= eth_change_mtu,
-};
-
-/* Register network device and initialize the hardware */
-static int at76_init_new_device(struct at76_priv *priv,
-				struct usb_interface *interface)
-{
-	struct net_device *netdev = priv->netdev;
-	int ret;
-
-	/* set up the endpoint information */
-	/* check out the endpoints */
-
-	at76_dbg(DBG_DEVSTART, "USB interface: %d endpoints",
-		 interface->cur_altsetting->desc.bNumEndpoints);
-
-	ret = at76_alloc_urbs(priv, interface);
-	if (ret < 0)
-		goto exit;
-
-	/* MAC address */
-	ret = at76_get_hw_config(priv);
-	if (ret < 0) {
-		dev_printk(KERN_ERR, &interface->dev,
-			   "cannot get MAC address\n");
-		goto exit;
-	}
-
-	priv->domain = at76_get_reg_domain(priv->regulatory_domain);
-	/* init. netdev->dev_addr */
-	memcpy(netdev->dev_addr, priv->mac_addr, ETH_ALEN);
-
-	priv->channel = DEF_CHANNEL;
-	priv->iw_mode = IW_MODE_INFRA;
-	priv->rts_threshold = DEF_RTS_THRESHOLD;
-	priv->frag_threshold = DEF_FRAG_THRESHOLD;
-	priv->short_retry_limit = DEF_SHORT_RETRY_LIMIT;
-	priv->txrate = TX_RATE_AUTO;
-	priv->preamble_type = PREAMBLE_TYPE_LONG;
-	priv->beacon_period = 100;
-	priv->beacons_last_qual = jiffies;
-	priv->auth_mode = WLAN_AUTH_OPEN;
-	priv->scan_min_time = DEF_SCAN_MIN_TIME;
-	priv->scan_max_time = DEF_SCAN_MAX_TIME;
-	priv->scan_mode = SCAN_TYPE_ACTIVE;
-
-	netdev->flags &= ~IFF_MULTICAST;	/* not yet or never */
-	netdev->netdev_ops = &at76_netdev_ops;
-	netdev->ethtool_ops = &at76_ethtool_ops;
-
-	/* Add pointers to enable iwspy support. */
-	priv->wireless_data.spy_data = &priv->spy_data;
-	netdev->wireless_data = &priv->wireless_data;
-
-	netdev->watchdog_timeo = 2 * HZ;
-	netdev->wireless_handlers = &at76_handler_def;
-	dev_alloc_name(netdev, "wlan%d");
-
-	ret = register_netdev(priv->netdev);
-	if (ret) {
-		dev_printk(KERN_ERR, &interface->dev,
-			   "cannot register netdevice (status %d)!\n", ret);
-		goto exit;
-	}
-	priv->netdev_registered = 1;
-
-	printk(KERN_INFO "%s: USB %s, MAC %s, firmware %d.%d.%d-%d\n",
-	       netdev->name, dev_name(&interface->dev), mac2str(priv->mac_addr),
-	       priv->fw_version.major, priv->fw_version.minor,
-	       priv->fw_version.patch, priv->fw_version.build);
-	printk(KERN_INFO "%s: regulatory domain 0x%02x: %s\n", netdev->name,
-	       priv->regulatory_domain, priv->domain->name);
-
-	/* we let this timer run the whole time this driver instance lives */
-	mod_timer(&priv->bss_list_timer, jiffies + BSS_LIST_TIMEOUT);
-
-exit:
-	return ret;
-}
-
-static void at76_delete_device(struct at76_priv *priv)
-{
-	int i;
-
-	at76_dbg(DBG_PROC_ENTRY, "%s: ENTER", __func__);
-
-	/* The device is gone, don't bother turning it off */
-	priv->device_unplugged = 1;
-
-	if (priv->netdev_registered)
-		unregister_netdev(priv->netdev);
-
-	/* assuming we used keventd, it must quiesce too */
-	flush_scheduled_work();
-
-	kfree(priv->bulk_out_buffer);
-
-	if (priv->tx_urb) {
-		usb_kill_urb(priv->tx_urb);
-		usb_free_urb(priv->tx_urb);
-	}
-	if (priv->rx_urb) {
-		usb_kill_urb(priv->rx_urb);
-		usb_free_urb(priv->rx_urb);
-	}
-
-	at76_dbg(DBG_PROC_ENTRY, "%s: unlinked urbs", __func__);
-
-	kfree_skb(priv->rx_skb);
-
-	at76_free_bss_list(priv);
-	del_timer_sync(&priv->bss_list_timer);
-	cancel_delayed_work(&priv->dwork_get_scan);
-	cancel_delayed_work(&priv->dwork_beacon);
-	cancel_delayed_work(&priv->dwork_auth);
-	cancel_delayed_work(&priv->dwork_assoc);
-
-	if (priv->mac_state == MAC_CONNECTED)
-		at76_iwevent_bss_disconnect(priv->netdev);
-
-	for (i = 0; i < NR_RX_DATA_BUF; i++)
-		if (priv->rx_data[i].skb) {
-			dev_kfree_skb(priv->rx_data[i].skb);
-			priv->rx_data[i].skb = NULL;
-		}
-	usb_put_dev(priv->udev);
-
-	at76_dbg(DBG_PROC_ENTRY, "%s: before freeing priv/netdev", __func__);
-	free_netdev(priv->netdev);	/* priv is in netdev */
-
-	at76_dbg(DBG_PROC_ENTRY, "%s: EXIT", __func__);
-}
-
-static int at76_probe(struct usb_interface *interface,
-		      const struct usb_device_id *id)
-{
-	int ret;
-	struct at76_priv *priv;
-	struct fwentry *fwe;
-	struct usb_device *udev;
-	int op_mode;
-	int need_ext_fw = 0;
-	struct mib_fw_version fwv;
-	int board_type = (int)id->driver_info;
-
-	udev = usb_get_dev(interface_to_usbdev(interface));
-
-	/* Load firmware into kernel memory */
-	fwe = at76_load_firmware(udev, board_type);
-	if (!fwe) {
-		ret = -ENOENT;
-		goto error;
-	}
-
-	op_mode = at76_get_op_mode(udev);
-
-	at76_dbg(DBG_DEVSTART, "opmode %d", op_mode);
-
-	/* we get OPMODE_NONE with 2.4.23, SMC2662W-AR ???
-	   we get 204 with 2.4.23, Fiberline FL-WL240u (505A+RFMD2958) ??? */
-
-	if (op_mode == OPMODE_HW_CONFIG_MODE) {
-		dev_printk(KERN_ERR, &interface->dev,
-			   "cannot handle a device in HW_CONFIG_MODE\n");
-		ret = -EBUSY;
-		goto error;
-	}
-
-	if (op_mode != OPMODE_NORMAL_NIC_WITH_FLASH
-	    && op_mode != OPMODE_NORMAL_NIC_WITHOUT_FLASH) {
-		/* download internal firmware part */
-		dev_printk(KERN_DEBUG, &interface->dev,
-			   "downloading internal firmware\n");
-		ret = at76_load_internal_fw(udev, fwe);
-		if (ret < 0) {
-			dev_printk(KERN_ERR, &interface->dev,
-				   "error %d downloading internal firmware\n",
-				   ret);
-			goto error;
-		}
-		usb_put_dev(udev);
-		return ret;
-	}
-
-	/* Internal firmware already inside the device.  Get firmware
-	 * version to test if external firmware is loaded.
-	 * This works only for newer firmware, e.g. the Intersil 0.90.x
-	 * says "control timeout on ep0in" and subsequent
-	 * at76_get_op_mode() fail too :-( */
-
-	/* if version >= 0.100.x.y or device with built-in flash we can
-	 * query the device for the fw version */
-	if ((fwe->fw_version.major > 0 || fwe->fw_version.minor >= 100)
-	    || (op_mode == OPMODE_NORMAL_NIC_WITH_FLASH)) {
-		ret = at76_get_mib(udev, MIB_FW_VERSION, &fwv, sizeof(fwv));
-		if (ret < 0 || (fwv.major | fwv.minor) == 0)
-			need_ext_fw = 1;
-	} else
-		/* No way to check firmware version, reload to be sure */
-		need_ext_fw = 1;
-
-	if (need_ext_fw) {
-		dev_printk(KERN_DEBUG, &interface->dev,
-			   "downloading external firmware\n");
-
-		ret = at76_load_external_fw(udev, fwe);
-		if (ret)
-			goto error;
-
-		/* Re-check firmware version */
-		ret = at76_get_mib(udev, MIB_FW_VERSION, &fwv, sizeof(fwv));
-		if (ret < 0) {
-			dev_printk(KERN_ERR, &interface->dev,
-				   "error %d getting firmware version\n", ret);
-			goto error;
-		}
-	}
-
-	priv = at76_alloc_new_device(udev);
-	if (!priv) {
-		ret = -ENOMEM;
-		goto error;
-	}
-
-	SET_NETDEV_DEV(priv->netdev, &interface->dev);
-	usb_set_intfdata(interface, priv);
-
-	memcpy(&priv->fw_version, &fwv, sizeof(struct mib_fw_version));
-	priv->board_type = board_type;
-
-	ret = at76_init_new_device(priv, interface);
-	if (ret < 0)
-		at76_delete_device(priv);
-
-	return ret;
-
-error:
-	usb_put_dev(udev);
-	return ret;
-}
-
-static void at76_disconnect(struct usb_interface *interface)
-{
-	struct at76_priv *priv;
-
-	priv = usb_get_intfdata(interface);
-	usb_set_intfdata(interface, NULL);
-
-	/* Disconnect after loading internal firmware */
-	if (!priv)
-		return;
-
-	printk(KERN_INFO "%s: disconnecting\n", priv->netdev->name);
-	at76_delete_device(priv);
-	dev_printk(KERN_INFO, &interface->dev, "disconnected\n");
-}
-
-/* Structure for registering this driver with the USB subsystem */
-static struct usb_driver at76_driver = {
-	.name = DRIVER_NAME,
-	.probe = at76_probe,
-	.disconnect = at76_disconnect,
-	.id_table = dev_table,
-};
-
-static int __init at76_mod_init(void)
-{
-	int result;
-
-	printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION " loading\n");
-
-	mutex_init(&fw_mutex);
-
-	/* register this driver with the USB subsystem */
-	result = usb_register(&at76_driver);
-	if (result < 0)
-		printk(KERN_ERR DRIVER_NAME
-		       ": usb_register failed (status %d)\n", result);
-
-	led_trigger_register_simple("at76_usb-tx", &ledtrig_tx);
-	return result;
-}
-
-static void __exit at76_mod_exit(void)
-{
-	int i;
-
-	printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION " unloading\n");
-	usb_deregister(&at76_driver);
-	for (i = 0; i < ARRAY_SIZE(firmwares); i++) {
-		if (firmwares[i].fw)
-			release_firmware(firmwares[i].fw);
-	}
-	led_trigger_unregister_simple(ledtrig_tx);
-}
-
-module_param_named(debug, at76_debug, int, 0600);
-MODULE_PARM_DESC(debug, "Debugging level");
-
-module_init(at76_mod_init);
-module_exit(at76_mod_exit);
-
-MODULE_AUTHOR("Oliver Kurth <oku@masqmail.cx>");
-MODULE_AUTHOR("Joerg Albert <joerg.albert@gmx.de>");
-MODULE_AUTHOR("Alex <alex@foogod.com>");
-MODULE_AUTHOR("Nick Jones");
-MODULE_AUTHOR("Balint Seeber <n0_5p4m_p13453@hotmail.com>");
-MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>");
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");

+ 0 - 706
drivers/staging/at76_usb/at76_usb.h

@@ -1,706 +0,0 @@
-/*
- * Copyright (c) 2002,2003 Oliver Kurth
- *	     (c) 2003,2004 Joerg Albert <joerg.albert@gmx.de>
- *	     (c) 2007 Guido Guenther <agx@sigxcpu.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 driver was based on information from the Sourceforge driver
- * released and maintained by Atmel:
- *
- *  http://sourceforge.net/projects/atmelwlandriver/
- *
- * Although the code was completely re-written,
- * it would have been impossible without Atmel's decision to
- * release an Open Source driver (unfortunately the firmware was
- * kept binary only). Thanks for that decision to Atmel!
- */
-
-#ifndef _AT76_USB_H
-#define _AT76_USB_H
-
-/*
- * ieee80211 definitions copied from net/ieee80211.h
- */
-
-#define WEP_KEY_LEN		13
-#define WEP_KEYS		4
-
-#define IEEE80211_DATA_LEN		2304
-/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
-   6.2.1.1.2.
-
-   The figure in section 7.1.2 suggests a body size of up to 2312
-   bytes is allowed, which is a bit confusing, I suspect this
-   represents the 2304 bytes of real data, plus a possible 8 bytes of
-   WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
-
-#define IEEE80211_1ADDR_LEN 10
-#define IEEE80211_2ADDR_LEN 16
-#define IEEE80211_3ADDR_LEN 24
-#define IEEE80211_4ADDR_LEN 30
-#define IEEE80211_FCS_LEN    4
-#define IEEE80211_HLEN			(IEEE80211_4ADDR_LEN)
-#define IEEE80211_FRAME_LEN		(IEEE80211_DATA_LEN + IEEE80211_HLEN)
-
-#define MIN_FRAG_THRESHOLD     256U
-#define	MAX_FRAG_THRESHOLD     2346U
-
-struct ieee80211_info_element {
-	u8 id;
-	u8 len;
-	u8 data[0];
-} __attribute__ ((packed));
-
-struct ieee80211_hdr_3addr {
-	__le16 frame_ctl;
-	__le16 duration_id;
-	u8 addr1[ETH_ALEN];
-	u8 addr2[ETH_ALEN];
-	u8 addr3[ETH_ALEN];
-	__le16 seq_ctl;
-	u8 payload[0];
-} __attribute__ ((packed));
-
-struct ieee80211_auth {
-	struct ieee80211_hdr_3addr header;
-	__le16 algorithm;
-	__le16 transaction;
-	__le16 status;
-	/* challenge */
-	struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
-
-struct ieee80211_assoc_request {
-	struct ieee80211_hdr_3addr header;
-	__le16 capability;
-	__le16 listen_interval;
-	/* SSID, supported rates, RSN */
-	struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
-
-struct ieee80211_probe_response {
-	struct ieee80211_hdr_3addr header;
-	__le32 time_stamp[2];
-	__le16 beacon_interval;
-	__le16 capability;
-	/* SSID, supported rates, FH params, DS params,
-	 * CF params, IBSS params, TIM (if beacon), RSN */
-	struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
-
-/* Alias beacon for probe_response */
-#define ieee80211_beacon ieee80211_probe_response
-
-struct ieee80211_assoc_response {
-	struct ieee80211_hdr_3addr header;
-	__le16 capability;
-	__le16 status;
-	__le16 aid;
-	/* supported rates */
-	struct ieee80211_info_element info_element[0];
-} __attribute__ ((packed));
-
-struct ieee80211_disassoc {
-	struct ieee80211_hdr_3addr header;
-	__le16 reason;
-} __attribute__ ((packed));
-
-/* Board types */
-enum board_type {
-	BOARD_503_ISL3861 = 1,
-	BOARD_503_ISL3863 = 2,
-	BOARD_503 = 3,
-	BOARD_503_ACC = 4,
-	BOARD_505 = 5,
-	BOARD_505_2958 = 6,
-	BOARD_505A = 7,
-	BOARD_505AMX = 8
-};
-
-/* our private ioctl's */
-/* preamble length (0 - long, 1 - short, 2 - auto) */
-#define AT76_SET_SHORT_PREAMBLE		(SIOCIWFIRSTPRIV + 0)
-#define AT76_GET_SHORT_PREAMBLE		(SIOCIWFIRSTPRIV + 1)
-/* which debug channels are enabled */
-#define AT76_SET_DEBUG			(SIOCIWFIRSTPRIV + 2)
-#define AT76_GET_DEBUG			(SIOCIWFIRSTPRIV + 3)
-/* power save mode (incl. the Atmel proprietary smart save mode) */
-#define AT76_SET_POWERSAVE_MODE		(SIOCIWFIRSTPRIV + 4)
-#define AT76_GET_POWERSAVE_MODE		(SIOCIWFIRSTPRIV + 5)
-/* min and max channel times for scan */
-#define AT76_SET_SCAN_TIMES		(SIOCIWFIRSTPRIV + 6)
-#define AT76_GET_SCAN_TIMES		(SIOCIWFIRSTPRIV + 7)
-/* scan mode (0 - active, 1 - passive) */
-#define AT76_SET_SCAN_MODE		(SIOCIWFIRSTPRIV + 8)
-#define AT76_GET_SCAN_MODE		(SIOCIWFIRSTPRIV + 9)
-
-#define CMD_STATUS_IDLE				0x00
-#define CMD_STATUS_COMPLETE			0x01
-#define CMD_STATUS_UNKNOWN			0x02
-#define CMD_STATUS_INVALID_PARAMETER		0x03
-#define CMD_STATUS_FUNCTION_NOT_SUPPORTED	0x04
-#define CMD_STATUS_TIME_OUT			0x07
-#define CMD_STATUS_IN_PROGRESS			0x08
-#define CMD_STATUS_HOST_FAILURE			0xff
-#define CMD_STATUS_SCAN_FAILED			0xf0
-
-/* answers to get op mode */
-#define OPMODE_NONE				0x00
-#define OPMODE_NORMAL_NIC_WITH_FLASH		0x01
-#define OPMODE_HW_CONFIG_MODE			0x02
-#define OPMODE_DFU_MODE_WITH_FLASH		0x03
-#define OPMODE_NORMAL_NIC_WITHOUT_FLASH		0x04
-
-#define CMD_SET_MIB		0x01
-#define CMD_GET_MIB		0x02
-#define CMD_SCAN		0x03
-#define CMD_JOIN		0x04
-#define CMD_START_IBSS		0x05
-#define CMD_RADIO_ON		0x06
-#define CMD_RADIO_OFF		0x07
-#define CMD_STARTUP		0x0B
-
-#define MIB_LOCAL		0x01
-#define MIB_MAC_ADDR		0x02
-#define MIB_MAC			0x03
-#define MIB_MAC_MGMT		0x05
-#define MIB_MAC_WEP		0x06
-#define MIB_PHY			0x07
-#define MIB_FW_VERSION		0x08
-#define MIB_MDOMAIN		0x09
-
-#define ADHOC_MODE		1
-#define INFRASTRUCTURE_MODE	2
-
-/* values for struct mib_local, field preamble_type */
-#define PREAMBLE_TYPE_LONG	0
-#define PREAMBLE_TYPE_SHORT	1
-#define PREAMBLE_TYPE_AUTO	2
-
-/* values for tx_rate */
-#define TX_RATE_1MBIT		0
-#define TX_RATE_2MBIT		1
-#define TX_RATE_5_5MBIT 	2
-#define TX_RATE_11MBIT		3
-#define TX_RATE_AUTO		4
-
-/* power management modes */
-#define AT76_PM_OFF		1
-#define AT76_PM_ON		2
-#define AT76_PM_SMART		3
-
-struct hwcfg_r505 {
-	u8 cr39_values[14];
-	u8 reserved1[14];
-	u8 bb_cr[14];
-	u8 pidvid[4];
-	u8 mac_addr[ETH_ALEN];
-	u8 regulatory_domain;
-	u8 reserved2[14];
-	u8 cr15_values[14];
-	u8 reserved3[3];
-} __attribute__((packed));
-
-struct hwcfg_rfmd {
-	u8 cr20_values[14];
-	u8 cr21_values[14];
-	u8 bb_cr[14];
-	u8 pidvid[4];
-	u8 mac_addr[ETH_ALEN];
-	u8 regulatory_domain;
-	u8 low_power_values[14];
-	u8 normal_power_values[14];
-	u8 reserved1[3];
-} __attribute__((packed));
-
-struct hwcfg_intersil {
-	u8 mac_addr[ETH_ALEN];
-	u8 cr31_values[14];
-	u8 cr58_values[14];
-	u8 pidvid[4];
-	u8 regulatory_domain;
-	u8 reserved[1];
-} __attribute__((packed));
-
-union at76_hwcfg {
-	struct hwcfg_intersil i;
-	struct hwcfg_rfmd r3;
-	struct hwcfg_r505 r5;
-};
-
-#define WEP_SMALL_KEY_LEN	(40 / 8)
-#define WEP_LARGE_KEY_LEN	(104 / 8)
-
-struct at76_card_config {
-	u8 exclude_unencrypted;
-	u8 promiscuous_mode;
-	u8 short_retry_limit;
-	u8 encryption_type;
-	__le16 rts_threshold;
-	__le16 fragmentation_threshold;	/* 256..2346 */
-	u8 basic_rate_set[4];
-	u8 auto_rate_fallback;	/* 0,1 */
-	u8 channel;
-	u8 privacy_invoked;
-	u8 wep_default_key_id;	/* 0..3 */
-	u8 current_ssid[32];
-	u8 wep_default_key_value[4][WEP_KEY_LEN];
-	u8 ssid_len;
-	u8 short_preamble;
-	__le16 beacon_period;
-} __attribute__((packed));
-
-struct at76_command {
-	u8 cmd;
-	u8 reserved;
-	__le16 size;
-	u8 data[0];
-} __attribute__((packed));
-
-/* Length of Atmel-specific Rx header before 802.11 frame */
-#define AT76_RX_HDRLEN offsetof(struct at76_rx_buffer, packet)
-
-struct at76_rx_buffer {
-	__le16 wlength;
-	u8 rx_rate;
-	u8 newbss;
-	u8 fragmentation;
-	u8 rssi;
-	u8 link_quality;
-	u8 noise_level;
-	__le32 rx_time;
-	u8 packet[IEEE80211_FRAME_LEN + IEEE80211_FCS_LEN];
-} __attribute__((packed));
-
-/* Length of Atmel-specific Tx header before 802.11 frame */
-#define AT76_TX_HDRLEN offsetof(struct at76_tx_buffer, packet)
-
-struct at76_tx_buffer {
-	__le16 wlength;
-	u8 tx_rate;
-	u8 padding;
-	u8 reserved[4];
-	u8 packet[IEEE80211_FRAME_LEN + IEEE80211_FCS_LEN];
-} __attribute__((packed));
-
-/* defines for scan_type below */
-#define SCAN_TYPE_ACTIVE	0
-#define SCAN_TYPE_PASSIVE	1
-
-struct at76_req_scan {
-	u8 bssid[ETH_ALEN];
-	u8 essid[32];
-	u8 scan_type;
-	u8 channel;
-	__le16 probe_delay;
-	__le16 min_channel_time;
-	__le16 max_channel_time;
-	u8 essid_size;
-	u8 international_scan;
-} __attribute__((packed));
-
-struct at76_req_ibss {
-	u8 bssid[ETH_ALEN];
-	u8 essid[32];
-	u8 bss_type;
-	u8 channel;
-	u8 essid_size;
-	u8 reserved[3];
-} __attribute__((packed));
-
-struct at76_req_join {
-	u8 bssid[ETH_ALEN];
-	u8 essid[32];
-	u8 bss_type;
-	u8 channel;
-	__le16 timeout;
-	u8 essid_size;
-	u8 reserved;
-} __attribute__((packed));
-
-struct set_mib_buffer {
-	u8 type;
-	u8 size;
-	u8 index;
-	u8 reserved;
-	union {
-		u8 byte;
-		__le16 word;
-		u8 addr[ETH_ALEN];
-	} data;
-} __attribute__((packed));
-
-struct mib_local {
-	u16 reserved0;
-	u8 beacon_enable;
-	u8 txautorate_fallback;
-	u8 reserved1;
-	u8 ssid_size;
-	u8 promiscuous_mode;
-	u16 reserved2;
-	u8 preamble_type;
-	u16 reserved3;
-} __attribute__((packed));
-
-struct mib_mac_addr {
-	u8 mac_addr[ETH_ALEN];
-	u8 res[2];		/* ??? */
-	u8 group_addr[4][ETH_ALEN];
-	u8 group_addr_status[4];
-} __attribute__((packed));
-
-struct mib_mac {
-	__le32 max_tx_msdu_lifetime;
-	__le32 max_rx_lifetime;
-	__le16 frag_threshold;
-	__le16 rts_threshold;
-	__le16 cwmin;
-	__le16 cwmax;
-	u8 short_retry_time;
-	u8 long_retry_time;
-	u8 scan_type;		/* active or passive */
-	u8 scan_channel;
-	__le16 probe_delay;	/* delay before ProbeReq in active scan, RO */
-	__le16 min_channel_time;
-	__le16 max_channel_time;
-	__le16 listen_interval;
-	u8 desired_ssid[32];
-	u8 desired_bssid[ETH_ALEN];
-	u8 desired_bsstype;	/* ad-hoc or infrastructure */
-	u8 reserved2;
-} __attribute__((packed));
-
-struct mib_mac_mgmt {
-	__le16 beacon_period;
-	__le16 CFP_max_duration;
-	__le16 medium_occupancy_limit;
-	__le16 station_id;	/* assoc id */
-	__le16 ATIM_window;
-	u8 CFP_mode;
-	u8 privacy_option_implemented;
-	u8 DTIM_period;
-	u8 CFP_period;
-	u8 current_bssid[ETH_ALEN];
-	u8 current_essid[32];
-	u8 current_bss_type;
-	u8 power_mgmt_mode;
-	/* rfmd and 505 */
-	u8 ibss_change;
-	u8 res;
-	u8 multi_domain_capability_implemented;
-	u8 multi_domain_capability_enabled;
-	u8 country_string[3];
-	u8 reserved[3];
-} __attribute__((packed));
-
-struct mib_mac_wep {
-	u8 privacy_invoked;	/* 0 disable encr., 1 enable encr */
-	u8 wep_default_key_id;
-	u8 wep_key_mapping_len;
-	u8 exclude_unencrypted;
-	__le32 wep_icv_error_count;
-	__le32 wep_excluded_count;
-	u8 wep_default_keyvalue[WEP_KEYS][WEP_KEY_LEN];
-	u8 encryption_level;	/* 1 for 40bit, 2 for 104bit encryption */
-} __attribute__((packed));
-
-struct mib_phy {
-	__le32 ed_threshold;
-
-	__le16 slot_time;
-	__le16 sifs_time;
-	__le16 preamble_length;
-	__le16 plcp_header_length;
-	__le16 mpdu_max_length;
-	__le16 cca_mode_supported;
-
-	u8 operation_rate_set[4];
-	u8 channel_id;
-	u8 current_cca_mode;
-	u8 phy_type;
-	u8 current_reg_domain;
-} __attribute__((packed));
-
-struct mib_fw_version {
-	u8 major;
-	u8 minor;
-	u8 patch;
-	u8 build;
-} __attribute__((packed));
-
-struct mib_mdomain {
-	u8 tx_powerlevel[14];
-	u8 channel_list[14];	/* 0 for invalid channels */
-} __attribute__((packed));
-
-struct at76_fw_header {
-	__le32 crc;		/* CRC32 of the whole image */
-	__le32 board_type;	/* firmware compatibility code */
-	u8 build;		/* firmware build number */
-	u8 patch;		/* firmware patch level */
-	u8 minor;		/* firmware minor version */
-	u8 major;		/* firmware major version */
-	__le32 str_offset;	/* offset of the copyright string */
-	__le32 int_fw_offset;	/* internal firmware image offset */
-	__le32 int_fw_len;	/* internal firmware image length */
-	__le32 ext_fw_offset;	/* external firmware image offset */
-	__le32 ext_fw_len;	/* external firmware image length */
-} __attribute__((packed));
-
-enum mac_state {
-	MAC_INIT,
-	MAC_SCANNING,
-	MAC_AUTH,
-	MAC_ASSOC,
-	MAC_JOINING,
-	MAC_CONNECTED,
-	MAC_OWN_IBSS
-};
-
-/* a description of a regulatory domain and the allowed channels */
-struct reg_domain {
-	u16 code;
-	char const *name;
-	u32 channel_map;	/* if bit N is set, channel (N+1) is allowed */
-};
-
-/* how long do we keep a (I)BSS in the bss_list in jiffies
-   this should be long enough for the user to retrieve the table
-   (by iwlist ?) after the device started, because all entries from
-   other channels than the one the device locks on get removed, too */
-#define BSS_LIST_TIMEOUT	(120 * HZ)
-/* struct to store BSS info found during scan */
-#define BSS_LIST_MAX_RATE_LEN	32	/* 32 rates should be enough ... */
-
-struct bss_info {
-	struct list_head list;
-
-	u8 bssid[ETH_ALEN];	/* bssid */
-	u8 ssid[IW_ESSID_MAX_SIZE];	/* essid */
-	u8 ssid_len;		/* length of ssid above */
-	u8 channel;
-	u16 capa;		/* BSS capabilities */
-	u16 beacon_interval;	/* beacon interval, Kus (1024 microseconds) */
-	u8 rates[BSS_LIST_MAX_RATE_LEN];	/* supported rates in units of
-						   500 kbps, ORed with 0x80 for
-						   basic rates */
-	u8 rates_len;
-
-	/* quality of received beacon */
-	u8 rssi;
-	u8 link_qual;
-	u8 noise_level;
-
-	unsigned long last_rx;	/* time (jiffies) of last beacon received */
-};
-
-/* a rx data buffer to collect rx fragments */
-struct rx_data_buf {
-	u8 sender[ETH_ALEN];	/* sender address */
-	u16 seqnr;		/* sequence number */
-	u16 fragnr;		/* last fragment received */
-	unsigned long last_rx;	/* jiffies of last rx */
-	struct sk_buff *skb;	/* == NULL if entry is free */
-};
-
-#define NR_RX_DATA_BUF		8
-
-/* Data for one loaded firmware file */
-struct fwentry {
-	const char *const fwname;
-	const struct firmware *fw;
-	int extfw_size;
-	int intfw_size;
-	/* pointer to loaded firmware, no need to free */
-	u8 *extfw;		/* external firmware, extfw_size bytes long */
-	u8 *intfw;		/* internal firmware, intfw_size bytes long */
-	enum board_type board_type;	/* board type */
-	struct mib_fw_version fw_version;
-	int loaded;		/* Loaded and parsed successfully */
-};
-
-struct at76_priv {
-	struct usb_device *udev;	/* USB device pointer */
-	struct net_device *netdev;	/* net device pointer */
-	struct net_device_stats stats;	/* net device stats */
-	struct iw_statistics wstats;	/* wireless stats */
-
-	struct sk_buff *rx_skb;	/* skbuff for receiving data */
-	void *bulk_out_buffer;	/* buffer for sending data */
-
-	struct urb *tx_urb;	/* URB for sending data */
-	struct urb *rx_urb;	/* URB for receiving data */
-
-	unsigned int tx_pipe;	/* bulk out pipe */
-	unsigned int rx_pipe;	/* bulk in pipe */
-
-	struct mutex mtx;	/* locks this structure */
-
-	/* work queues */
-	struct work_struct work_assoc_done;
-	struct work_struct work_join;
-	struct work_struct work_new_bss;
-	struct work_struct work_start_scan;
-	struct work_struct work_set_promisc;
-	struct work_struct work_submit_rx;
-	struct delayed_work dwork_restart;
-	struct delayed_work dwork_get_scan;
-	struct delayed_work dwork_beacon;
-	struct delayed_work dwork_auth;
-	struct delayed_work dwork_assoc;
-
-	struct tasklet_struct rx_tasklet;
-
-	/* the WEP stuff */
-	int wep_enabled;	/* 1 if WEP is enabled */
-	int wep_key_id;		/* key id to be used */
-	u8 wep_keys[WEP_KEYS][WEP_KEY_LEN];	/* the four WEP keys,
-						   5 or 13 bytes are used */
-	u8 wep_keys_len[WEP_KEYS];	/* the length of the above keys */
-
-	int channel;
-	int iw_mode;
-	u8 bssid[ETH_ALEN];
-	u8 essid[IW_ESSID_MAX_SIZE];
-	int essid_size;
-	int radio_on;
-	int promisc;
-
-	int preamble_type;	/* 0 - long, 1 - short, 2 - auto */
-	int auth_mode;		/* authentication type: 0 open, 1 shared key */
-	int txrate;		/* 0,1,2,3 = 1,2,5.5,11 Mbps, 4 is auto */
-	int frag_threshold;	/* threshold for fragmentation of tx packets */
-	int rts_threshold;	/* threshold for RTS mechanism */
-	int short_retry_limit;
-
-	int scan_min_time;	/* scan min channel time */
-	int scan_max_time;	/* scan max channel time */
-	int scan_mode;		/* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */
-	int scan_need_any;	/* if set, need to scan for any ESSID */
-
-	/* the list we got from scanning */
-	spinlock_t bss_list_spinlock;	/* protects bss_list operations */
-	struct list_head bss_list;	/* list of BSS we got beacons from */
-	struct timer_list bss_list_timer;	/* timer to purge old entries
-						   from bss_list */
-	struct bss_info *curr_bss;	/* current BSS */
-	u16 assoc_id;		/* current association ID, if associated */
-
-	u8 wanted_bssid[ETH_ALEN];
-	int wanted_bssid_valid;	/* != 0 if wanted_bssid is to be used */
-
-	/* some data for infrastructure mode only */
-	spinlock_t mgmt_spinlock;	/* this spinlock protects access to
-					   next_mgmt_bulk */
-
-	struct at76_tx_buffer *next_mgmt_bulk;	/* pending management msg to
-						   send via bulk out */
-	enum mac_state mac_state;
-	enum {
-		SCAN_IDLE,
-		SCAN_IN_PROGRESS,
-		SCAN_COMPLETED
-	} scan_state;
-	time_t last_scan;
-
-	int retries;		/* remaining retries in case of timeout when
-				 * sending AuthReq or AssocReq */
-	u8 pm_mode;		/* power management mode */
-	u32 pm_period;		/* power management period in microseconds */
-
-	struct reg_domain const *domain;	/* reg domain description */
-
-	/* iwspy support */
-	spinlock_t spy_spinlock;
-	struct iw_spy_data spy_data;
-
-	struct iw_public_data wireless_data;
-
-	/* These fields contain HW config provided by the device (not all of
-	 * these fields are used by all board types) */
-	u8 mac_addr[ETH_ALEN];
-	u8 regulatory_domain;
-
-	struct at76_card_config card_config;
-
-	/* store rx fragments until complete */
-	struct rx_data_buf rx_data[NR_RX_DATA_BUF];
-
-	enum board_type board_type;
-	struct mib_fw_version fw_version;
-
-	unsigned int device_unplugged:1;
-	unsigned int netdev_registered:1;
-	struct set_mib_buffer mib_buf;	/* global buffer for set_mib calls */
-
-	/* beacon counting */
-	int beacon_period;	/* period of mgmt beacons, Kus */
-	int beacons_received;
-	unsigned long beacons_last_qual;	/* time we restarted counting
-						   beacons */
-};
-
-struct at76_rx_radiotap {
-	struct ieee80211_radiotap_header rt_hdr;
-	__le64 rt_tsft;
-	u8 rt_flags;
-	u8 rt_rate;
-	s8 rt_signal;
-	s8 rt_noise;
-};
-
-#define AT76_RX_RADIOTAP_PRESENT		  \
-	((1 << IEEE80211_RADIOTAP_TSFT)		| \
-	(1 << IEEE80211_RADIOTAP_FLAGS)		| \
-	(1 << IEEE80211_RADIOTAP_RATE)		| \
-	(1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL)	| \
-	(1 << IEEE80211_RADIOTAP_DB_ANTNOISE))
-
-#define BEACON_MAX_DATA_LENGTH	1500
-
-/* the maximum size of an AssocReq packet */
-#define ASSOCREQ_MAX_SIZE \
-  (AT76_TX_HDRLEN + sizeof(struct ieee80211_assoc_request) + \
-   1 + 1 + IW_ESSID_MAX_SIZE + 1 + 1 + 4)
-
-/* for shared secret auth, add the challenge text size */
-#define AUTH_FRAME_SIZE (AT76_TX_HDRLEN + sizeof(struct ieee80211_auth))
-
-/* Maximal number of AuthReq retries */
-#define AUTH_RETRIES		3
-
-/* Maximal number of AssocReq retries */
-#define ASSOC_RETRIES		3
-
-/* Beacon timeout in managed mode when we are connected */
-#define BEACON_TIMEOUT		(10 * HZ)
-
-/* Timeout for authentication response */
-#define AUTH_TIMEOUT		(1 * HZ)
-
-/* Timeout for association response */
-#define ASSOC_TIMEOUT		(1 * HZ)
-
-/* Polling interval when scan is running */
-#define SCAN_POLL_INTERVAL	(HZ / 4)
-
-/* Command completion timeout */
-#define CMD_COMPLETION_TIMEOUT	(5 * HZ)
-
-#define DEF_RTS_THRESHOLD	1536
-#define DEF_FRAG_THRESHOLD	1536
-#define DEF_SHORT_RETRY_LIMIT	8
-#define DEF_CHANNEL		10
-#define DEF_SCAN_MIN_TIME	10
-#define DEF_SCAN_MAX_TIME	120
-
-#define MAX_RTS_THRESHOLD	(MAX_FRAG_THRESHOLD + 1)
-
-/* the max padding size for tx in bytes (see calc_padding) */
-#define MAX_PADDING_SIZE	53
-
-#endif				/* _AT76_USB_H */

+ 17 - 24
drivers/staging/b3dfg/b3dfg.c

@@ -632,18 +632,15 @@ static void transfer_complete(struct b3dfg_dev *fgdev)
 	fgdev->cur_dma_frame_addr = 0;
 	fgdev->cur_dma_frame_addr = 0;
 
 
 	buf = list_entry(fgdev->buffer_queue.next, struct b3dfg_buffer, list);
 	buf = list_entry(fgdev->buffer_queue.next, struct b3dfg_buffer, list);
-	if (buf) {
-		dev_dbg(dev, "handle frame completion\n");
-		if (fgdev->cur_dma_frame_idx == B3DFG_FRAMES_PER_BUFFER - 1) {
-
-			/* last frame of that triplet completed */
-			dev_dbg(dev, "triplet completed\n");
-			buf->state = B3DFG_BUFFER_POPULATED;
-			list_del_init(&buf->list);
-			wake_up_interruptible(&fgdev->buffer_waitqueue);
-		}
-	} else {
-		dev_err(dev, "got frame but no buffer!\n");
+
+	dev_dbg(dev, "handle frame completion\n");
+	if (fgdev->cur_dma_frame_idx == B3DFG_FRAMES_PER_BUFFER - 1) {
+
+		/* last frame of that triplet completed */
+		dev_dbg(dev, "triplet completed\n");
+		buf->state = B3DFG_BUFFER_POPULATED;
+		list_del_init(&buf->list);
+		wake_up_interruptible(&fgdev->buffer_waitqueue);
 	}
 	}
 }
 }
 
 
@@ -663,19 +660,15 @@ static bool setup_next_frame_transfer(struct b3dfg_dev *fgdev, int idx)
 	dev_dbg(dev, "program DMA transfer for next frame: %d\n", idx);
 	dev_dbg(dev, "program DMA transfer for next frame: %d\n", idx);
 
 
 	buf = list_entry(fgdev->buffer_queue.next, struct b3dfg_buffer, list);
 	buf = list_entry(fgdev->buffer_queue.next, struct b3dfg_buffer, list);
-	if (buf) {
-		if (idx == fgdev->cur_dma_frame_idx + 2) {
-			if (setup_frame_transfer(fgdev, buf, idx - 1))
-				dev_err(dev, "unable to map DMA buffer\n");
-			need_ack = 0;
-		} else {
-			dev_err(dev, "frame mismatch, got %d, expected %d\n",
-				idx, fgdev->cur_dma_frame_idx + 2);
-
-			/* FIXME: handle dropped triplets here */
-		}
+	if (idx == fgdev->cur_dma_frame_idx + 2) {
+		if (setup_frame_transfer(fgdev, buf, idx - 1))
+			dev_err(dev, "unable to map DMA buffer\n");
+		need_ack = 0;
 	} else {
 	} else {
-		dev_err(dev, "cannot setup DMA, no buffer\n");
+		dev_err(dev, "frame mismatch, got %d, expected %d\n",
+			idx, fgdev->cur_dma_frame_idx + 2);
+
+		/* FIXME: handle dropped triplets here */
 	}
 	}
 
 
 	return need_ack;
 	return need_ack;

+ 490 - 512
drivers/staging/comedi/comedi.h

@@ -121,10 +121,10 @@ extern "C" {
 #define TRIG_BOGUS	0x0001	/* do the motions */
 #define TRIG_BOGUS	0x0001	/* do the motions */
 #define TRIG_DITHER	0x0002	/* enable dithering */
 #define TRIG_DITHER	0x0002	/* enable dithering */
 #define TRIG_DEGLITCH	0x0004	/* enable deglitching */
 #define TRIG_DEGLITCH	0x0004	/* enable deglitching */
-/*#define TRIG_RT       0x0008 */	/* perform op in real time */
+	/*#define TRIG_RT       0x0008 *//* perform op in real time */
 #define TRIG_CONFIG	0x0010	/* perform configuration, not triggering */
 #define TRIG_CONFIG	0x0010	/* perform configuration, not triggering */
 #define TRIG_WAKE_EOS	0x0020	/* wake up on end-of-scan events */
 #define TRIG_WAKE_EOS	0x0020	/* wake up on end-of-scan events */
-/*#define TRIG_WRITE    0x0040*/	/* write to bidirectional devices */
+	/*#define TRIG_WRITE    0x0040*//* write to bidirectional devices */
 
 
 /* command flags */
 /* command flags */
 /* These flags are used in comedi_cmd structures */
 /* These flags are used in comedi_cmd structures */
@@ -199,93 +199,91 @@ extern "C" {
 #define SDF_LSAMPL	0x10000000	/* subdevice uses 32-bit samples */
 #define SDF_LSAMPL	0x10000000	/* subdevice uses 32-bit samples */
 #define SDF_PACKED	0x20000000	/* subdevice can do packed DIO */
 #define SDF_PACKED	0x20000000	/* subdevice can do packed DIO */
 /* re recyle these flags for PWM */
 /* re recyle these flags for PWM */
-#define SDF_PWM_COUNTER SDF_MODE0       /* PWM can automatically switch off */
-#define SDF_PWM_HBRIDGE SDF_MODE1       /* PWM is signed (H-bridge) */
-
-
+#define SDF_PWM_COUNTER SDF_MODE0	/* PWM can automatically switch off */
+#define SDF_PWM_HBRIDGE SDF_MODE1	/* PWM is signed (H-bridge) */
 
 
 /* subdevice types */
 /* subdevice types */
 
 
-enum comedi_subdevice_type {
-	COMEDI_SUBD_UNUSED,	/* unused by driver */
-	COMEDI_SUBD_AI,	/* analog input */
-	COMEDI_SUBD_AO,	/* analog output */
-	COMEDI_SUBD_DI,	/* digital input */
-	COMEDI_SUBD_DO,	/* digital output */
-	COMEDI_SUBD_DIO,	/* digital input/output */
-	COMEDI_SUBD_COUNTER,	/* counter */
-	COMEDI_SUBD_TIMER,	/* timer */
-	COMEDI_SUBD_MEMORY,	/* memory, EEPROM, DPRAM */
-	COMEDI_SUBD_CALIB,	/* calibration DACs */
-	COMEDI_SUBD_PROC,	/* processor, DSP */
-	COMEDI_SUBD_SERIAL,	/* serial IO */
-	COMEDI_SUBD_PWM         /* PWM */
-};
+	enum comedi_subdevice_type {
+		COMEDI_SUBD_UNUSED,	/* unused by driver */
+		COMEDI_SUBD_AI,	/* analog input */
+		COMEDI_SUBD_AO,	/* analog output */
+		COMEDI_SUBD_DI,	/* digital input */
+		COMEDI_SUBD_DO,	/* digital output */
+		COMEDI_SUBD_DIO,	/* digital input/output */
+		COMEDI_SUBD_COUNTER,	/* counter */
+		COMEDI_SUBD_TIMER,	/* timer */
+		COMEDI_SUBD_MEMORY,	/* memory, EEPROM, DPRAM */
+		COMEDI_SUBD_CALIB,	/* calibration DACs */
+		COMEDI_SUBD_PROC,	/* processor, DSP */
+		COMEDI_SUBD_SERIAL,	/* serial IO */
+		COMEDI_SUBD_PWM	/* PWM */
+	};
 
 
 /* configuration instructions */
 /* configuration instructions */
 
 
-enum configuration_ids {
-	INSN_CONFIG_DIO_INPUT = 0,
-	INSN_CONFIG_DIO_OUTPUT = 1,
-	INSN_CONFIG_DIO_OPENDRAIN = 2,
-	INSN_CONFIG_ANALOG_TRIG = 16,
+	enum configuration_ids {
+		INSN_CONFIG_DIO_INPUT = 0,
+		INSN_CONFIG_DIO_OUTPUT = 1,
+		INSN_CONFIG_DIO_OPENDRAIN = 2,
+		INSN_CONFIG_ANALOG_TRIG = 16,
 /*	INSN_CONFIG_WAVEFORM = 17, */
 /*	INSN_CONFIG_WAVEFORM = 17, */
 /*	INSN_CONFIG_TRIG = 18, */
 /*	INSN_CONFIG_TRIG = 18, */
 /*	INSN_CONFIG_COUNTER = 19, */
 /*	INSN_CONFIG_COUNTER = 19, */
-	INSN_CONFIG_ALT_SOURCE = 20,
-	INSN_CONFIG_DIGITAL_TRIG = 21,
-	INSN_CONFIG_BLOCK_SIZE = 22,
-	INSN_CONFIG_TIMER_1 = 23,
-	INSN_CONFIG_FILTER = 24,
-	INSN_CONFIG_CHANGE_NOTIFY = 25,
-
-	 /*ALPHA*/ INSN_CONFIG_SERIAL_CLOCK = 26,
-	INSN_CONFIG_BIDIRECTIONAL_DATA = 27,
-	INSN_CONFIG_DIO_QUERY = 28,
-	INSN_CONFIG_PWM_OUTPUT = 29,
-	INSN_CONFIG_GET_PWM_OUTPUT = 30,
-	INSN_CONFIG_ARM = 31,
-	INSN_CONFIG_DISARM = 32,
-	INSN_CONFIG_GET_COUNTER_STATUS = 33,
-	INSN_CONFIG_RESET = 34,
-	INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001,	/* Use CTR as single pulsegenerator */
-	INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002,	/* Use CTR as pulsetraingenerator */
-	INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003,	/* Use the counter as encoder */
-	INSN_CONFIG_SET_GATE_SRC = 2001,	/* Set gate source */
-	INSN_CONFIG_GET_GATE_SRC = 2002,	/* Get gate source */
-	INSN_CONFIG_SET_CLOCK_SRC = 2003,	/* Set master clock source */
-	INSN_CONFIG_GET_CLOCK_SRC = 2004,	/* Get master clock source */
-	INSN_CONFIG_SET_OTHER_SRC = 2005,	/* Set other source */
-/*	INSN_CONFIG_GET_OTHER_SRC = 2006,*/	/* Get other source */
-	INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006,	/* Get size in bytes of
-							   subdevice's on-board
-							   fifos used during
-							   streaming
-							   input/output */
-	INSN_CONFIG_SET_COUNTER_MODE = 4097,
-	INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE,	/* deprecated */
-	INSN_CONFIG_8254_READ_STATUS = 4098,
-	INSN_CONFIG_SET_ROUTING = 4099,
-	INSN_CONFIG_GET_ROUTING = 4109,
+		INSN_CONFIG_ALT_SOURCE = 20,
+		INSN_CONFIG_DIGITAL_TRIG = 21,
+		INSN_CONFIG_BLOCK_SIZE = 22,
+		INSN_CONFIG_TIMER_1 = 23,
+		INSN_CONFIG_FILTER = 24,
+		INSN_CONFIG_CHANGE_NOTIFY = 25,
+
+		 /*ALPHA*/ INSN_CONFIG_SERIAL_CLOCK = 26,
+		INSN_CONFIG_BIDIRECTIONAL_DATA = 27,
+		INSN_CONFIG_DIO_QUERY = 28,
+		INSN_CONFIG_PWM_OUTPUT = 29,
+		INSN_CONFIG_GET_PWM_OUTPUT = 30,
+		INSN_CONFIG_ARM = 31,
+		INSN_CONFIG_DISARM = 32,
+		INSN_CONFIG_GET_COUNTER_STATUS = 33,
+		INSN_CONFIG_RESET = 34,
+		INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001,	/* Use CTR as single pulsegenerator */
+		INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002,	/* Use CTR as pulsetraingenerator */
+		INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003,	/* Use the counter as encoder */
+		INSN_CONFIG_SET_GATE_SRC = 2001,	/* Set gate source */
+		INSN_CONFIG_GET_GATE_SRC = 2002,	/* Get gate source */
+		INSN_CONFIG_SET_CLOCK_SRC = 2003,	/* Set master clock source */
+		INSN_CONFIG_GET_CLOCK_SRC = 2004,	/* Get master clock source */
+		INSN_CONFIG_SET_OTHER_SRC = 2005,	/* Set other source */
+		/*	INSN_CONFIG_GET_OTHER_SRC = 2006,*//* Get other source */
+		INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006,	/* Get size in bytes of
+								   subdevice's on-board
+								   fifos used during
+								   streaming
+								   input/output */
+		INSN_CONFIG_SET_COUNTER_MODE = 4097,
+		INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE,	/* deprecated */
+		INSN_CONFIG_8254_READ_STATUS = 4098,
+		INSN_CONFIG_SET_ROUTING = 4099,
+		INSN_CONFIG_GET_ROUTING = 4109,
 /* PWM */
 /* PWM */
-	INSN_CONFIG_PWM_SET_PERIOD = 5000,   /* sets frequency */
-	INSN_CONFIG_PWM_GET_PERIOD = 5001,   /* gets frequency */
-	INSN_CONFIG_GET_PWM_STATUS = 5002,          /* is it running? */
-	INSN_CONFIG_PWM_SET_H_BRIDGE = 5003, /* sets H bridge: duty cycle and sign bit for a relay  at the same time*/
-	INSN_CONFIG_PWM_GET_H_BRIDGE = 5004  /* gets H bridge data: duty cycle and the sign bit */
-};
-
-enum comedi_io_direction {
-	COMEDI_INPUT = 0,
-	COMEDI_OUTPUT = 1,
-	COMEDI_OPENDRAIN = 2
-};
-
-enum comedi_support_level {
-	COMEDI_UNKNOWN_SUPPORT = 0,
-	COMEDI_SUPPORTED,
-	COMEDI_UNSUPPORTED
-};
+		INSN_CONFIG_PWM_SET_PERIOD = 5000,	/* sets frequency */
+		INSN_CONFIG_PWM_GET_PERIOD = 5001,	/* gets frequency */
+		INSN_CONFIG_GET_PWM_STATUS = 5002,	/* is it running? */
+		INSN_CONFIG_PWM_SET_H_BRIDGE = 5003,	/* sets H bridge: duty cycle and sign bit for a relay  at the same time */
+		INSN_CONFIG_PWM_GET_H_BRIDGE = 5004	/* gets H bridge data: duty cycle and the sign bit */
+	};
+
+	enum comedi_io_direction {
+		COMEDI_INPUT = 0,
+		COMEDI_OUTPUT = 1,
+		COMEDI_OPENDRAIN = 2
+	};
+
+	enum comedi_support_level {
+		COMEDI_UNKNOWN_SUPPORT = 0,
+		COMEDI_SUPPORTED,
+		COMEDI_UNSUPPORTED
+	};
 
 
 /* ioctls */
 /* ioctls */
 
 
@@ -309,133 +307,132 @@ enum comedi_support_level {
 
 
 /* structures */
 /* structures */
 
 
-struct comedi_trig {
-	unsigned int subdev;	/* subdevice */
-	unsigned int mode;	/* mode */
-	unsigned int flags;
-	unsigned int n_chan;	/* number of channels */
-	unsigned int *chanlist;	/* channel/range list */
-	short *data;	/* data list, size depends on subd flags */
-	unsigned int n;	/* number of scans */
-	unsigned int trigsrc;
-	unsigned int trigvar;
-	unsigned int trigvar1;
-	unsigned int data_len;
-	unsigned int unused[3];
-};
-
-struct comedi_insn {
-	unsigned int insn;
-	unsigned int n;
-	unsigned int *data;
-	unsigned int subdev;
-	unsigned int chanspec;
-	unsigned int unused[3];
-};
-
-struct comedi_insnlist {
-	unsigned int n_insns;
-	struct comedi_insn *insns;
-};
-
-struct comedi_cmd {
-	unsigned int subdev;
-	unsigned int flags;
-
-	unsigned int start_src;
-	unsigned int start_arg;
-
-	unsigned int scan_begin_src;
-	unsigned int scan_begin_arg;
-
-	unsigned int convert_src;
-	unsigned int convert_arg;
-
-	unsigned int scan_end_src;
-	unsigned int scan_end_arg;
-
-	unsigned int stop_src;
-	unsigned int stop_arg;
-
-	unsigned int *chanlist;	/* channel/range list */
-	unsigned int chanlist_len;
-
-	short *data;	/* data list, size depends on subd flags */
-	unsigned int data_len;
-};
-
-struct comedi_chaninfo {
-	unsigned int subdev;
-	unsigned int *maxdata_list;
-	unsigned int *flaglist;
-	unsigned int *rangelist;
-	unsigned int unused[4];
-};
-
-struct comedi_rangeinfo {
-	unsigned int range_type;
-	void *range_ptr;
-};
-
-struct comedi_krange {
-	int min;	/* fixed point, multiply by 1e-6 */
-	int max;	/* fixed point, multiply by 1e-6 */
-	unsigned int flags;
-};
-
-
-struct comedi_subdinfo {
-	unsigned int type;
-	unsigned int n_chan;
-	unsigned int subd_flags;
-	unsigned int timer_type;
-	unsigned int len_chanlist;
-	unsigned int maxdata;
-	unsigned int flags;	/* channel flags */
-	unsigned int range_type;	/* lookup in kernel */
-	unsigned int settling_time_0;
-	unsigned insn_bits_support;	/* see support_level enum for values*/
-	unsigned int unused[8];
-};
-
-struct comedi_devinfo {
-	unsigned int version_code;
-	unsigned int n_subdevs;
-	char driver_name[COMEDI_NAMELEN];
-	char board_name[COMEDI_NAMELEN];
-	int read_subdevice;
-	int write_subdevice;
-	int unused[30];
-};
-
-struct comedi_devconfig {
-	char board_name[COMEDI_NAMELEN];
-	int options[COMEDI_NDEVCONFOPTS];
-};
-
-struct comedi_bufconfig {
-	unsigned int subdevice;
-	unsigned int flags;
-
-	unsigned int maximum_size;
-	unsigned int size;
-
-	unsigned int unused[4];
-};
-
-struct comedi_bufinfo {
-	unsigned int subdevice;
-	unsigned int bytes_read;
-
-	unsigned int buf_write_ptr;
-	unsigned int buf_read_ptr;
-	unsigned int buf_write_count;
-	unsigned int buf_read_count;
-
-	unsigned int bytes_written;
-
-	unsigned int unused[4];
-};
+	struct comedi_trig {
+		unsigned int subdev;	/* subdevice */
+		unsigned int mode;	/* mode */
+		unsigned int flags;
+		unsigned int n_chan;	/* number of channels */
+		unsigned int *chanlist;	/* channel/range list */
+		short *data;	/* data list, size depends on subd flags */
+		unsigned int n;	/* number of scans */
+		unsigned int trigsrc;
+		unsigned int trigvar;
+		unsigned int trigvar1;
+		unsigned int data_len;
+		unsigned int unused[3];
+	};
+
+	struct comedi_insn {
+		unsigned int insn;
+		unsigned int n;
+		unsigned int *data;
+		unsigned int subdev;
+		unsigned int chanspec;
+		unsigned int unused[3];
+	};
+
+	struct comedi_insnlist {
+		unsigned int n_insns;
+		struct comedi_insn *insns;
+	};
+
+	struct comedi_cmd {
+		unsigned int subdev;
+		unsigned int flags;
+
+		unsigned int start_src;
+		unsigned int start_arg;
+
+		unsigned int scan_begin_src;
+		unsigned int scan_begin_arg;
+
+		unsigned int convert_src;
+		unsigned int convert_arg;
+
+		unsigned int scan_end_src;
+		unsigned int scan_end_arg;
+
+		unsigned int stop_src;
+		unsigned int stop_arg;
+
+		unsigned int *chanlist;	/* channel/range list */
+		unsigned int chanlist_len;
+
+		short *data;	/* data list, size depends on subd flags */
+		unsigned int data_len;
+	};
+
+	struct comedi_chaninfo {
+		unsigned int subdev;
+		unsigned int *maxdata_list;
+		unsigned int *flaglist;
+		unsigned int *rangelist;
+		unsigned int unused[4];
+	};
+
+	struct comedi_rangeinfo {
+		unsigned int range_type;
+		void *range_ptr;
+	};
+
+	struct comedi_krange {
+		int min;	/* fixed point, multiply by 1e-6 */
+		int max;	/* fixed point, multiply by 1e-6 */
+		unsigned int flags;
+	};
+
+	struct comedi_subdinfo {
+		unsigned int type;
+		unsigned int n_chan;
+		unsigned int subd_flags;
+		unsigned int timer_type;
+		unsigned int len_chanlist;
+		unsigned int maxdata;
+		unsigned int flags;	/* channel flags */
+		unsigned int range_type;	/* lookup in kernel */
+		unsigned int settling_time_0;
+		unsigned insn_bits_support;	/* see support_level enum for values */
+		unsigned int unused[8];
+	};
+
+	struct comedi_devinfo {
+		unsigned int version_code;
+		unsigned int n_subdevs;
+		char driver_name[COMEDI_NAMELEN];
+		char board_name[COMEDI_NAMELEN];
+		int read_subdevice;
+		int write_subdevice;
+		int unused[30];
+	};
+
+	struct comedi_devconfig {
+		char board_name[COMEDI_NAMELEN];
+		int options[COMEDI_NDEVCONFOPTS];
+	};
+
+	struct comedi_bufconfig {
+		unsigned int subdevice;
+		unsigned int flags;
+
+		unsigned int maximum_size;
+		unsigned int size;
+
+		unsigned int unused[4];
+	};
+
+	struct comedi_bufinfo {
+		unsigned int subdevice;
+		unsigned int bytes_read;
+
+		unsigned int buf_write_ptr;
+		unsigned int buf_read_ptr;
+		unsigned int buf_write_count;
+		unsigned int buf_read_count;
+
+		unsigned int bytes_written;
+
+		unsigned int unused[4];
+	};
 
 
 /* range stuff */
 /* range stuff */
 
 
@@ -486,298 +483,284 @@ struct comedi_bufinfo {
 
 
 */
 */
 
 
-enum i8254_mode {
-	I8254_MODE0 = (0 << 1),	/* Interrupt on terminal count */
-	I8254_MODE1 = (1 << 1),	/* Hardware retriggerable one-shot */
-	I8254_MODE2 = (2 << 1),	/* Rate generator */
-	I8254_MODE3 = (3 << 1),	/* Square wave mode */
-	I8254_MODE4 = (4 << 1),	/* Software triggered strobe */
-	I8254_MODE5 = (5 << 1),	/* Hardware triggered strobe (retriggerable) */
-	I8254_BCD = 1,	/* use binary-coded decimal instead of binary (pretty useless) */
-	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;
-}
+	enum i8254_mode {
+		I8254_MODE0 = (0 << 1),	/* Interrupt on terminal count */
+		I8254_MODE1 = (1 << 1),	/* Hardware retriggerable one-shot */
+		I8254_MODE2 = (2 << 1),	/* Rate generator */
+		I8254_MODE3 = (3 << 1),	/* Square wave mode */
+		I8254_MODE4 = (4 << 1),	/* Software triggered strobe */
+		I8254_MODE5 = (5 << 1),	/* Hardware triggered strobe (retriggerable) */
+		I8254_BCD = 1,	/* use binary-coded decimal instead of binary (pretty useless) */
+		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;
+	}
 /* mode bits for NI general-purpose counters, set with
 /* mode bits for NI general-purpose counters, set with
  * INSN_CONFIG_SET_COUNTER_MODE */
  * INSN_CONFIG_SET_COUNTER_MODE */
 #define NI_GPCT_COUNTING_MODE_SHIFT 16
 #define NI_GPCT_COUNTING_MODE_SHIFT 16
 #define NI_GPCT_INDEX_PHASE_BITSHIFT 20
 #define NI_GPCT_INDEX_PHASE_BITSHIFT 20
 #define NI_GPCT_COUNTING_DIRECTION_SHIFT 24
 #define NI_GPCT_COUNTING_DIRECTION_SHIFT 24
-enum ni_gpct_mode_bits {
-	NI_GPCT_GATE_ON_BOTH_EDGES_BIT = 0x4,
-	NI_GPCT_EDGE_GATE_MODE_MASK = 0x18,
-	NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS = 0x0,
-	NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS = 0x8,
-	NI_GPCT_EDGE_GATE_STARTS_BITS = 0x10,
-	NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS = 0x18,
-	NI_GPCT_STOP_MODE_MASK = 0x60,
-	NI_GPCT_STOP_ON_GATE_BITS = 0x00,
-	NI_GPCT_STOP_ON_GATE_OR_TC_BITS = 0x20,
-	NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS = 0x40,
-	NI_GPCT_LOAD_B_SELECT_BIT = 0x80,
-	NI_GPCT_OUTPUT_MODE_MASK = 0x300,
-	NI_GPCT_OUTPUT_TC_PULSE_BITS = 0x100,
-	NI_GPCT_OUTPUT_TC_TOGGLE_BITS = 0x200,
-	NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS = 0x300,
-	NI_GPCT_HARDWARE_DISARM_MASK = 0xc00,
-	NI_GPCT_NO_HARDWARE_DISARM_BITS = 0x000,
-	NI_GPCT_DISARM_AT_TC_BITS = 0x400,
-	NI_GPCT_DISARM_AT_GATE_BITS = 0x800,
-	NI_GPCT_DISARM_AT_TC_OR_GATE_BITS = 0xc00,
-	NI_GPCT_LOADING_ON_TC_BIT = 0x1000,
-	NI_GPCT_LOADING_ON_GATE_BIT = 0x4000,
-	NI_GPCT_COUNTING_MODE_MASK = 0x7 << NI_GPCT_COUNTING_MODE_SHIFT,
-	NI_GPCT_COUNTING_MODE_NORMAL_BITS =
-		0x0 << NI_GPCT_COUNTING_MODE_SHIFT,
-	NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS =
-		0x1 << NI_GPCT_COUNTING_MODE_SHIFT,
-	NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS =
-		0x2 << NI_GPCT_COUNTING_MODE_SHIFT,
-	NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS =
-		0x3 << NI_GPCT_COUNTING_MODE_SHIFT,
-	NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS =
-		0x4 << NI_GPCT_COUNTING_MODE_SHIFT,
-	NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS =
-		0x6 << NI_GPCT_COUNTING_MODE_SHIFT,
-	NI_GPCT_INDEX_PHASE_MASK = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
-	NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS =
-		0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT,
-	NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS =
-		0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT,
-	NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS =
-		0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT,
-	NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS =
-		0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
-	NI_GPCT_INDEX_ENABLE_BIT = 0x400000,
-	NI_GPCT_COUNTING_DIRECTION_MASK =
-		0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
-	NI_GPCT_COUNTING_DIRECTION_DOWN_BITS =
-		0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
-	NI_GPCT_COUNTING_DIRECTION_UP_BITS =
-		0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
-	NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS =
-		0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
-	NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS =
-		0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
-	NI_GPCT_RELOAD_SOURCE_MASK = 0xc000000,
-	NI_GPCT_RELOAD_SOURCE_FIXED_BITS = 0x0,
-	NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS = 0x4000000,
-	NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS = 0x8000000,
-	NI_GPCT_OR_GATE_BIT = 0x10000000,
-	NI_GPCT_INVERT_OUTPUT_BIT = 0x20000000
-};
+	enum ni_gpct_mode_bits {
+		NI_GPCT_GATE_ON_BOTH_EDGES_BIT = 0x4,
+		NI_GPCT_EDGE_GATE_MODE_MASK = 0x18,
+		NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS = 0x0,
+		NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS = 0x8,
+		NI_GPCT_EDGE_GATE_STARTS_BITS = 0x10,
+		NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS = 0x18,
+		NI_GPCT_STOP_MODE_MASK = 0x60,
+		NI_GPCT_STOP_ON_GATE_BITS = 0x00,
+		NI_GPCT_STOP_ON_GATE_OR_TC_BITS = 0x20,
+		NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS = 0x40,
+		NI_GPCT_LOAD_B_SELECT_BIT = 0x80,
+		NI_GPCT_OUTPUT_MODE_MASK = 0x300,
+		NI_GPCT_OUTPUT_TC_PULSE_BITS = 0x100,
+		NI_GPCT_OUTPUT_TC_TOGGLE_BITS = 0x200,
+		NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS = 0x300,
+		NI_GPCT_HARDWARE_DISARM_MASK = 0xc00,
+		NI_GPCT_NO_HARDWARE_DISARM_BITS = 0x000,
+		NI_GPCT_DISARM_AT_TC_BITS = 0x400,
+		NI_GPCT_DISARM_AT_GATE_BITS = 0x800,
+		NI_GPCT_DISARM_AT_TC_OR_GATE_BITS = 0xc00,
+		NI_GPCT_LOADING_ON_TC_BIT = 0x1000,
+		NI_GPCT_LOADING_ON_GATE_BIT = 0x4000,
+		NI_GPCT_COUNTING_MODE_MASK = 0x7 << NI_GPCT_COUNTING_MODE_SHIFT,
+		NI_GPCT_COUNTING_MODE_NORMAL_BITS =
+		    0x0 << NI_GPCT_COUNTING_MODE_SHIFT,
+		NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS =
+		    0x1 << NI_GPCT_COUNTING_MODE_SHIFT,
+		NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS =
+		    0x2 << NI_GPCT_COUNTING_MODE_SHIFT,
+		NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS =
+		    0x3 << NI_GPCT_COUNTING_MODE_SHIFT,
+		NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS =
+		    0x4 << NI_GPCT_COUNTING_MODE_SHIFT,
+		NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS =
+		    0x6 << NI_GPCT_COUNTING_MODE_SHIFT,
+		NI_GPCT_INDEX_PHASE_MASK = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+		NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS =
+		    0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+		NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS =
+		    0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+		NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS =
+		    0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+		NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS =
+		    0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+		NI_GPCT_INDEX_ENABLE_BIT = 0x400000,
+		NI_GPCT_COUNTING_DIRECTION_MASK =
+		    0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+		NI_GPCT_COUNTING_DIRECTION_DOWN_BITS =
+		    0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+		NI_GPCT_COUNTING_DIRECTION_UP_BITS =
+		    0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+		NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS =
+		    0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+		NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS =
+		    0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+		NI_GPCT_RELOAD_SOURCE_MASK = 0xc000000,
+		NI_GPCT_RELOAD_SOURCE_FIXED_BITS = 0x0,
+		NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS = 0x4000000,
+		NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS = 0x8000000,
+		NI_GPCT_OR_GATE_BIT = 0x10000000,
+		NI_GPCT_INVERT_OUTPUT_BIT = 0x20000000
+	};
 
 
 /* Bits for setting a clock source with
 /* Bits for setting a clock source with
  * INSN_CONFIG_SET_CLOCK_SRC when using NI general-purpose counters. */
  * INSN_CONFIG_SET_CLOCK_SRC when using NI general-purpose counters. */
-enum ni_gpct_clock_source_bits {
-	NI_GPCT_CLOCK_SRC_SELECT_MASK = 0x3f,
-	NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS = 0x0,
-	NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS = 0x1,
-	NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS = 0x2,
-	NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS = 0x3,
-	NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS = 0x4,
-	NI_GPCT_NEXT_TC_CLOCK_SRC_BITS = 0x5,
-	NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS = 0x6,	/* NI 660x-specific */
-	NI_GPCT_PXI10_CLOCK_SRC_BITS = 0x7,
-	NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS = 0x8,
-	NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS = 0x9,
-	NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK = 0x30000000,
-	NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS = 0x0,
-	NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS = 0x10000000, /* divide source by 2 */
-	NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000, /* divide source by 8 */
-	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;
-}
+	enum ni_gpct_clock_source_bits {
+		NI_GPCT_CLOCK_SRC_SELECT_MASK = 0x3f,
+		NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS = 0x0,
+		NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS = 0x1,
+		NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS = 0x2,
+		NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS = 0x3,
+		NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS = 0x4,
+		NI_GPCT_NEXT_TC_CLOCK_SRC_BITS = 0x5,
+		NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS = 0x6,	/* NI 660x-specific */
+		NI_GPCT_PXI10_CLOCK_SRC_BITS = 0x7,
+		NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS = 0x8,
+		NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS = 0x9,
+		NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK = 0x30000000,
+		NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS = 0x0,
+		NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS = 0x10000000,	/* divide source by 2 */
+		NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000,	/* divide source by 8 */
+		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;
+	}
 
 
 /* Possibilities for setting a gate source with
 /* Possibilities for setting a gate source with
 INSN_CONFIG_SET_GATE_SRC when using NI general-purpose counters.
 INSN_CONFIG_SET_GATE_SRC when using NI general-purpose counters.
 May be bitwise-or'd with CR_EDGE or CR_INVERT. */
 May be bitwise-or'd with CR_EDGE or CR_INVERT. */
-enum ni_gpct_gate_select {
-	/* m-series gates */
-	NI_GPCT_TIMESTAMP_MUX_GATE_SELECT = 0x0,
-	NI_GPCT_AI_START2_GATE_SELECT = 0x12,
-	NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT = 0x13,
-	NI_GPCT_NEXT_OUT_GATE_SELECT = 0x14,
-	NI_GPCT_AI_START1_GATE_SELECT = 0x1c,
-	NI_GPCT_NEXT_SOURCE_GATE_SELECT = 0x1d,
-	NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT = 0x1e,
-	NI_GPCT_LOGIC_LOW_GATE_SELECT = 0x1f,
-	/* more gates for 660x */
-	NI_GPCT_SOURCE_PIN_i_GATE_SELECT = 0x100,
-	NI_GPCT_GATE_PIN_i_GATE_SELECT = 0x101,
-	/* more gates for 660x "second gate" */
-	NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT = 0x201,
-	NI_GPCT_SELECTED_GATE_GATE_SELECT = 0x21e,
-	/* m-series "second gate" sources are unknown,
-	   we should add them here with an offset of 0x300 when 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;
-}
+	enum ni_gpct_gate_select {
+		/* m-series gates */
+		NI_GPCT_TIMESTAMP_MUX_GATE_SELECT = 0x0,
+		NI_GPCT_AI_START2_GATE_SELECT = 0x12,
+		NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT = 0x13,
+		NI_GPCT_NEXT_OUT_GATE_SELECT = 0x14,
+		NI_GPCT_AI_START1_GATE_SELECT = 0x1c,
+		NI_GPCT_NEXT_SOURCE_GATE_SELECT = 0x1d,
+		NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT = 0x1e,
+		NI_GPCT_LOGIC_LOW_GATE_SELECT = 0x1f,
+		/* more gates for 660x */
+		NI_GPCT_SOURCE_PIN_i_GATE_SELECT = 0x100,
+		NI_GPCT_GATE_PIN_i_GATE_SELECT = 0x101,
+		/* more gates for 660x "second gate" */
+		NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT = 0x201,
+		NI_GPCT_SELECTED_GATE_GATE_SELECT = 0x21e,
+		/* m-series "second gate" sources are unknown,
+		   we should add them here with an offset of 0x300 when 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;
+	}
 
 
 /* Possibilities for setting a source with
 /* Possibilities for setting a source with
 INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters. */
 INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters. */
-enum ni_gpct_other_index {
-	NI_GPCT_SOURCE_ENCODER_A,
-	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);
-}
+	enum ni_gpct_other_index {
+		NI_GPCT_SOURCE_ENCODER_A,
+		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);
+	}
 
 
 /* start sources for ni general-purpose counters for use with
 /* start sources for ni general-purpose counters for use with
 INSN_CONFIG_ARM */
 INSN_CONFIG_ARM */
-enum ni_gpct_arm_source {
-	NI_GPCT_ARM_IMMEDIATE = 0x0,
-	NI_GPCT_ARM_PAIRED_IMMEDIATE = 0x1,	/* Start both the counter and
-						   the adjacent paired counter
-						   simultaneously */
-	/* NI doesn't document bits for selecting hardware arm triggers.  If
-	 * the NI_GPCT_ARM_UNKNOWN bit is set, we will pass the least
-	 * significant bits (3 bits for 660x or 5 bits for m-series) through to
-	 * the hardware.  This will at least allow someone to figure out what
-	 * the bits do later. */
-	NI_GPCT_ARM_UNKNOWN = 0x1000,
-};
+	enum ni_gpct_arm_source {
+		NI_GPCT_ARM_IMMEDIATE = 0x0,
+		NI_GPCT_ARM_PAIRED_IMMEDIATE = 0x1,	/* Start both the counter and
+							   the adjacent paired counter
+							   simultaneously */
+		/* NI doesn't document bits for selecting hardware arm triggers.  If
+		 * the NI_GPCT_ARM_UNKNOWN bit is set, we will pass the least
+		 * significant bits (3 bits for 660x or 5 bits for m-series) through to
+		 * the hardware.  This will at least allow someone to figure out what
+		 * the bits do later. */
+		NI_GPCT_ARM_UNKNOWN = 0x1000,
+	};
 
 
 /* digital filtering options for ni 660x for use with INSN_CONFIG_FILTER. */
 /* digital filtering options for ni 660x for use with INSN_CONFIG_FILTER. */
-enum ni_gpct_filter_select {
-	NI_GPCT_FILTER_OFF = 0x0,
-	NI_GPCT_FILTER_TIMEBASE_3_SYNC = 0x1,
-	NI_GPCT_FILTER_100x_TIMEBASE_1 = 0x2,
-	NI_GPCT_FILTER_20x_TIMEBASE_1 = 0x3,
-	NI_GPCT_FILTER_10x_TIMEBASE_1 = 0x4,
-	NI_GPCT_FILTER_2x_TIMEBASE_1 = 0x5,
-	NI_GPCT_FILTER_2x_TIMEBASE_3 = 0x6
-};
+	enum ni_gpct_filter_select {
+		NI_GPCT_FILTER_OFF = 0x0,
+		NI_GPCT_FILTER_TIMEBASE_3_SYNC = 0x1,
+		NI_GPCT_FILTER_100x_TIMEBASE_1 = 0x2,
+		NI_GPCT_FILTER_20x_TIMEBASE_1 = 0x3,
+		NI_GPCT_FILTER_10x_TIMEBASE_1 = 0x4,
+		NI_GPCT_FILTER_2x_TIMEBASE_1 = 0x5,
+		NI_GPCT_FILTER_2x_TIMEBASE_3 = 0x6
+	};
 
 
 /* PFI digital filtering options for ni m-series for use with
 /* PFI digital filtering options for ni m-series for use with
  * INSN_CONFIG_FILTER. */
  * INSN_CONFIG_FILTER. */
-enum ni_pfi_filter_select {
-	NI_PFI_FILTER_OFF = 0x0,
-	NI_PFI_FILTER_125ns = 0x1,
-	NI_PFI_FILTER_6425ns = 0x2,
-	NI_PFI_FILTER_2550us = 0x3
-};
+	enum ni_pfi_filter_select {
+		NI_PFI_FILTER_OFF = 0x0,
+		NI_PFI_FILTER_125ns = 0x1,
+		NI_PFI_FILTER_6425ns = 0x2,
+		NI_PFI_FILTER_2550us = 0x3
+	};
 
 
 /* master clock sources for ni mio boards and INSN_CONFIG_SET_CLOCK_SRC */
 /* master clock sources for ni mio boards and INSN_CONFIG_SET_CLOCK_SRC */
-enum ni_mio_clock_source {
-	NI_MIO_INTERNAL_CLOCK = 0,
-	NI_MIO_RTSI_CLOCK = 1,	/* doesn't work for m-series, use
-				   NI_MIO_PLL_RTSI_CLOCK() */
-	/* the NI_MIO_PLL_* sources are m-series only */
-	NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK = 2,
-	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;
-}
+	enum ni_mio_clock_source {
+		NI_MIO_INTERNAL_CLOCK = 0,
+		NI_MIO_RTSI_CLOCK = 1,	/* doesn't work for m-series, use
+					   NI_MIO_PLL_RTSI_CLOCK() */
+		/* the NI_MIO_PLL_* sources are m-series only */
+		NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK = 2,
+		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;
+	}
 
 
 /* Signals which can be routed to an NI RTSI pin with INSN_CONFIG_SET_ROUTING.
 /* 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
  The numbers assigned are not arbitrary, they correspond to the bits required
  to program the board. */
  to program the board. */
-enum ni_rtsi_routing {
-	NI_RTSI_OUTPUT_ADR_START1 = 0,
-	NI_RTSI_OUTPUT_ADR_START2 = 1,
-	NI_RTSI_OUTPUT_SCLKG = 2,
-	NI_RTSI_OUTPUT_DACUPDN = 3,
-	NI_RTSI_OUTPUT_DA_START1 = 4,
-	NI_RTSI_OUTPUT_G_SRC0 = 5,
-	NI_RTSI_OUTPUT_G_GATE0 = 6,
-	NI_RTSI_OUTPUT_RGOUT0 = 7,
-	NI_RTSI_OUTPUT_RTSI_BRD_0 = 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;
-}
+	enum ni_rtsi_routing {
+		NI_RTSI_OUTPUT_ADR_START1 = 0,
+		NI_RTSI_OUTPUT_ADR_START2 = 1,
+		NI_RTSI_OUTPUT_SCLKG = 2,
+		NI_RTSI_OUTPUT_DACUPDN = 3,
+		NI_RTSI_OUTPUT_DA_START1 = 4,
+		NI_RTSI_OUTPUT_G_SRC0 = 5,
+		NI_RTSI_OUTPUT_G_GATE0 = 6,
+		NI_RTSI_OUTPUT_RGOUT0 = 7,
+		NI_RTSI_OUTPUT_RTSI_BRD_0 = 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;
+	}
 
 
 /* Signals which can be routed to an NI PFI pin on an m-series board with
 /* 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
  * INSN_CONFIG_SET_ROUTING.  These numbers are also returned by
  * INSN_CONFIG_GET_ROUTING on pre-m-series boards, even though their routing
  * INSN_CONFIG_GET_ROUTING on pre-m-series boards, even though their routing
  * cannot be changed.  The numbers assigned are not arbitrary, they correspond
  * cannot be changed.  The numbers assigned are not arbitrary, they correspond
  * to the bits required to program the board. */
  * to the bits required to program the board. */
-enum ni_pfi_routing {
-	NI_PFI_OUTPUT_PFI_DEFAULT = 0,
-	NI_PFI_OUTPUT_AI_START1 = 1,
-	NI_PFI_OUTPUT_AI_START2 = 2,
-	NI_PFI_OUTPUT_AI_CONVERT = 3,
-	NI_PFI_OUTPUT_G_SRC1 = 4,
-	NI_PFI_OUTPUT_G_GATE1 = 5,
-	NI_PFI_OUTPUT_AO_UPDATE_N = 6,
-	NI_PFI_OUTPUT_AO_START1 = 7,
-	NI_PFI_OUTPUT_AI_START_PULSE = 8,
-	NI_PFI_OUTPUT_G_SRC0 = 9,
-	NI_PFI_OUTPUT_G_GATE0 = 10,
-	NI_PFI_OUTPUT_EXT_STROBE = 11,
-	NI_PFI_OUTPUT_AI_EXT_MUX_CLK = 12,
-	NI_PFI_OUTPUT_GOUT0 = 13,
-	NI_PFI_OUTPUT_GOUT1 = 14,
-	NI_PFI_OUTPUT_FREQ_OUT = 15,
-	NI_PFI_OUTPUT_PFI_DO = 16,
-	NI_PFI_OUTPUT_I_ATRIG = 17,
-	NI_PFI_OUTPUT_RTSI0 = 18,
-	NI_PFI_OUTPUT_PXI_STAR_TRIGGER_IN = 26,
-	NI_PFI_OUTPUT_SCXI_TRIG1 = 27,
-	NI_PFI_OUTPUT_DIO_CHANGE_DETECT_RTSI = 28,
-	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;
-}
+	enum ni_pfi_routing {
+		NI_PFI_OUTPUT_PFI_DEFAULT = 0,
+		NI_PFI_OUTPUT_AI_START1 = 1,
+		NI_PFI_OUTPUT_AI_START2 = 2,
+		NI_PFI_OUTPUT_AI_CONVERT = 3,
+		NI_PFI_OUTPUT_G_SRC1 = 4,
+		NI_PFI_OUTPUT_G_GATE1 = 5,
+		NI_PFI_OUTPUT_AO_UPDATE_N = 6,
+		NI_PFI_OUTPUT_AO_START1 = 7,
+		NI_PFI_OUTPUT_AI_START_PULSE = 8,
+		NI_PFI_OUTPUT_G_SRC0 = 9,
+		NI_PFI_OUTPUT_G_GATE0 = 10,
+		NI_PFI_OUTPUT_EXT_STROBE = 11,
+		NI_PFI_OUTPUT_AI_EXT_MUX_CLK = 12,
+		NI_PFI_OUTPUT_GOUT0 = 13,
+		NI_PFI_OUTPUT_GOUT1 = 14,
+		NI_PFI_OUTPUT_FREQ_OUT = 15,
+		NI_PFI_OUTPUT_PFI_DO = 16,
+		NI_PFI_OUTPUT_I_ATRIG = 17,
+		NI_PFI_OUTPUT_RTSI0 = 18,
+		NI_PFI_OUTPUT_PXI_STAR_TRIGGER_IN = 26,
+		NI_PFI_OUTPUT_SCXI_TRIG1 = 27,
+		NI_PFI_OUTPUT_DIO_CHANGE_DETECT_RTSI = 28,
+		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;
+	}
 
 
 /* Signals which can be routed to output on a NI PFI pin on a 660x board
 /* 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
  with INSN_CONFIG_SET_ROUTING.  The numbers assigned are
@@ -785,72 +768,67 @@ static inline unsigned NI_PFI_OUTPUT_RTSI(unsigned rtsi_channel)
  to program the board.  Lines 0 to 7 can only be set to
  to program the board.  Lines 0 to 7 can only be set to
  NI_660X_PFI_OUTPUT_DIO.  Lines 32 to 39 can only be set to
  NI_660X_PFI_OUTPUT_DIO.  Lines 32 to 39 can only be set to
  NI_660X_PFI_OUTPUT_COUNTER. */
  NI_660X_PFI_OUTPUT_COUNTER. */
-enum ni_660x_pfi_routing {
-	NI_660X_PFI_OUTPUT_COUNTER = 1,	/* counter */
-	NI_660X_PFI_OUTPUT_DIO = 2,	/* static digital output */
-};
+	enum ni_660x_pfi_routing {
+		NI_660X_PFI_OUTPUT_COUNTER = 1,	/* counter */
+		NI_660X_PFI_OUTPUT_DIO = 2,	/* static digital output */
+	};
 
 
 /* NI External Trigger lines.  These values are not arbitrary, but are related
 /* 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
  * to the bits required to program the board (offset by 1 for historical
  * reasons). */
  * 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;
-}
+	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;
+	}
 
 
 /* status bits for INSN_CONFIG_GET_COUNTER_STATUS */
 /* status bits for INSN_CONFIG_GET_COUNTER_STATUS */
-enum comedi_counter_status_flags {
-	COMEDI_COUNTER_ARMED = 0x1,
-	COMEDI_COUNTER_COUNTING = 0x2,
-	COMEDI_COUNTER_TERMINAL_COUNT = 0x4,
-};
+	enum comedi_counter_status_flags {
+		COMEDI_COUNTER_ARMED = 0x1,
+		COMEDI_COUNTER_COUNTING = 0x2,
+		COMEDI_COUNTER_TERMINAL_COUNT = 0x4,
+	};
 
 
 /* Clock sources for CDIO subdevice on NI m-series boards.  Used as the
 /* Clock sources for CDIO subdevice on NI m-series boards.  Used as the
  * scan_begin_arg for a comedi_command. These sources may also be bitwise-or'd
  * scan_begin_arg for a comedi_command. These sources may also be bitwise-or'd
  * with CR_INVERT to change polarity. */
  * with CR_INVERT to change polarity. */
-enum ni_m_series_cdio_scan_begin_src {
-	NI_CDIO_SCAN_BEGIN_SRC_GROUND = 0,
-	NI_CDIO_SCAN_BEGIN_SRC_AI_START = 18,
-	NI_CDIO_SCAN_BEGIN_SRC_AI_CONVERT = 19,
-	NI_CDIO_SCAN_BEGIN_SRC_PXI_STAR_TRIGGER = 20,
-	NI_CDIO_SCAN_BEGIN_SRC_G0_OUT = 28,
-	NI_CDIO_SCAN_BEGIN_SRC_G1_OUT = 29,
-	NI_CDIO_SCAN_BEGIN_SRC_ANALOG_TRIGGER = 30,
-	NI_CDIO_SCAN_BEGIN_SRC_AO_UPDATE = 31,
-	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);
-}
+	enum ni_m_series_cdio_scan_begin_src {
+		NI_CDIO_SCAN_BEGIN_SRC_GROUND = 0,
+		NI_CDIO_SCAN_BEGIN_SRC_AI_START = 18,
+		NI_CDIO_SCAN_BEGIN_SRC_AI_CONVERT = 19,
+		NI_CDIO_SCAN_BEGIN_SRC_PXI_STAR_TRIGGER = 20,
+		NI_CDIO_SCAN_BEGIN_SRC_G0_OUT = 28,
+		NI_CDIO_SCAN_BEGIN_SRC_G1_OUT = 29,
+		NI_CDIO_SCAN_BEGIN_SRC_ANALOG_TRIGGER = 30,
+		NI_CDIO_SCAN_BEGIN_SRC_AO_UPDATE = 31,
+		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);
+	}
 
 
 /* scan_begin_src for scan_begin_arg==TRIG_EXT with analog output command on NI
 /* 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
  * boards.  These scan begin sources can also be bitwise-or'd with CR_INVERT to
  * change polarity. */
  * 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);
-}
+	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);
+	}
 
 
 /* Bits for setting a clock source with
 /* Bits for setting a clock source with
  * INSN_CONFIG_SET_CLOCK_SRC when using NI frequency output subdevice. */
  * INSN_CONFIG_SET_CLOCK_SRC when using NI frequency output subdevice. */
-enum ni_freq_out_clock_source_bits {
-	NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC,	/* 10 MHz */
-	NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC	/* 100 KHz */
-};
+	enum ni_freq_out_clock_source_bits {
+		NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC,	/* 10 MHz */
+		NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC	/* 100 KHz */
+	};
 
 
 /* Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for
 /* Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for
  * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver). */
  * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver). */

+ 57 - 58
drivers/staging/comedi/comedi_compat32.c

@@ -51,7 +51,7 @@
 struct comedi32_chaninfo_struct {
 struct comedi32_chaninfo_struct {
 	unsigned int subdev;
 	unsigned int subdev;
 	compat_uptr_t maxdata_list;	/* 32-bit 'unsigned int *' */
 	compat_uptr_t maxdata_list;	/* 32-bit 'unsigned int *' */
-	compat_uptr_t flaglist;		/* 32-bit 'unsigned int *' */
+	compat_uptr_t flaglist;	/* 32-bit 'unsigned int *' */
 	compat_uptr_t rangelist;	/* 32-bit 'unsigned int *' */
 	compat_uptr_t rangelist;	/* 32-bit 'unsigned int *' */
 	unsigned int unused[4];
 	unsigned int unused[4];
 };
 };
@@ -74,16 +74,16 @@ struct comedi32_cmd_struct {
 	unsigned int scan_end_arg;
 	unsigned int scan_end_arg;
 	unsigned int stop_src;
 	unsigned int stop_src;
 	unsigned int stop_arg;
 	unsigned int stop_arg;
-	compat_uptr_t chanlist;		/* 32-bit 'unsigned int *' */
+	compat_uptr_t chanlist;	/* 32-bit 'unsigned int *' */
 	unsigned int chanlist_len;
 	unsigned int chanlist_len;
-	compat_uptr_t data;		/* 32-bit 'short *' */
+	compat_uptr_t data;	/* 32-bit 'short *' */
 	unsigned int data_len;
 	unsigned int data_len;
 };
 };
 
 
 struct comedi32_insn_struct {
 struct comedi32_insn_struct {
 	unsigned int insn;
 	unsigned int insn;
 	unsigned int n;
 	unsigned int n;
-	compat_uptr_t data;		/* 32-bit 'unsigned int *' */
+	compat_uptr_t data;	/* 32-bit 'unsigned int *' */
 	unsigned int subdev;
 	unsigned int subdev;
 	unsigned int chanspec;
 	unsigned int chanspec;
 	unsigned int unused[3];
 	unsigned int unused[3];
@@ -91,19 +91,19 @@ struct comedi32_insn_struct {
 
 
 struct comedi32_insnlist_struct {
 struct comedi32_insnlist_struct {
 	unsigned int n_insns;
 	unsigned int n_insns;
-	compat_uptr_t insns;		/* 32-bit 'struct comedi_insn *' */
+	compat_uptr_t insns;	/* 32-bit 'struct comedi_insn *' */
 };
 };
 
 
 /* Handle translated ioctl. */
 /* Handle translated ioctl. */
 static int translated_ioctl(struct file *file, unsigned int cmd,
 static int translated_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
+			    unsigned long arg)
 {
 {
 	if (!file->f_op)
 	if (!file->f_op)
 		return -ENOTTY;
 		return -ENOTTY;
 
 
 #ifdef HAVE_UNLOCKED_IOCTL
 #ifdef HAVE_UNLOCKED_IOCTL
 	if (file->f_op->unlocked_ioctl) {
 	if (file->f_op->unlocked_ioctl) {
-		int rc = (int)(*file->f_op->unlocked_ioctl)(file, cmd, arg);
+		int rc = (int)(*file->f_op->unlocked_ioctl) (file, cmd, arg);
 		if (rc == -ENOIOCTLCMD)
 		if (rc == -ENOIOCTLCMD)
 			rc = -ENOTTY;
 			rc = -ENOTTY;
 		return rc;
 		return rc;
@@ -112,8 +112,8 @@ static int translated_ioctl(struct file *file, unsigned int cmd,
 	if (file->f_op->ioctl) {
 	if (file->f_op->ioctl) {
 		int rc;
 		int rc;
 		lock_kernel();
 		lock_kernel();
-		rc = (*file->f_op->ioctl)(file->f_dentry->d_inode,
-				file, cmd, arg);
+		rc = (*file->f_op->ioctl) (file->f_dentry->d_inode,
+					   file, cmd, arg);
 		unlock_kernel();
 		unlock_kernel();
 		return rc;
 		return rc;
 	}
 	}
@@ -136,8 +136,7 @@ static int compat_chaninfo(struct file *file, unsigned long arg)
 
 
 	/* Copy chaninfo structure.  Ignore unused members. */
 	/* Copy chaninfo structure.  Ignore unused members. */
 	if (!access_ok(VERIFY_READ, chaninfo32, sizeof(*chaninfo32))
 	if (!access_ok(VERIFY_READ, chaninfo32, sizeof(*chaninfo32))
-			|| !access_ok(VERIFY_WRITE, chaninfo,
-				sizeof(*chaninfo))) {
+	    || !access_ok(VERIFY_WRITE, chaninfo, sizeof(*chaninfo))) {
 		return -EFAULT;
 		return -EFAULT;
 	}
 	}
 	err = 0;
 	err = 0;
@@ -171,8 +170,7 @@ static int compat_rangeinfo(struct file *file, unsigned long arg)
 
 
 	/* Copy rangeinfo structure. */
 	/* Copy rangeinfo structure. */
 	if (!access_ok(VERIFY_READ, rangeinfo32, sizeof(*rangeinfo32))
 	if (!access_ok(VERIFY_READ, rangeinfo32, sizeof(*rangeinfo32))
-			|| !access_ok(VERIFY_WRITE, rangeinfo,
-				sizeof(*rangeinfo))) {
+	    || !access_ok(VERIFY_WRITE, rangeinfo, sizeof(*rangeinfo))) {
 		return -EFAULT;
 		return -EFAULT;
 	}
 	}
 	err = 0;
 	err = 0;
@@ -184,12 +182,12 @@ static int compat_rangeinfo(struct file *file, unsigned long arg)
 		return -EFAULT;
 		return -EFAULT;
 
 
 	return translated_ioctl(file, COMEDI_RANGEINFO,
 	return translated_ioctl(file, COMEDI_RANGEINFO,
-			(unsigned long)rangeinfo);
+				(unsigned long)rangeinfo);
 }
 }
 
 
 /* Copy 32-bit cmd structure to native cmd structure. */
 /* Copy 32-bit cmd structure to native cmd structure. */
-static int get_compat_cmd(struct comedi_cmd __user *cmd,
-		struct comedi32_cmd_struct __user *cmd32)
+static int get_compat_cmd(struct comedi_cmd __user * cmd,
+			  struct comedi32_cmd_struct __user * cmd32)
 {
 {
 	int err;
 	int err;
 	union {
 	union {
@@ -199,7 +197,7 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
 
 
 	/* Copy cmd structure. */
 	/* Copy cmd structure. */
 	if (!access_ok(VERIFY_READ, cmd32, sizeof(*cmd32))
 	if (!access_ok(VERIFY_READ, cmd32, sizeof(*cmd32))
-			|| !access_ok(VERIFY_WRITE, cmd, sizeof(*cmd))) {
+	    || !access_ok(VERIFY_WRITE, cmd, sizeof(*cmd))) {
 		return -EFAULT;
 		return -EFAULT;
 	}
 	}
 	err = 0;
 	err = 0;
@@ -239,7 +237,8 @@ static int get_compat_cmd(struct comedi_cmd __user *cmd,
 }
 }
 
 
 /* Copy native cmd structure to 32-bit cmd structure. */
 /* Copy native cmd structure to 32-bit cmd structure. */
-static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32, struct comedi_cmd __user *cmd)
+static int put_compat_cmd(struct comedi32_cmd_struct __user * cmd32,
+			  struct comedi_cmd __user * cmd)
 {
 {
 	int err;
 	int err;
 	unsigned int temp;
 	unsigned int temp;
@@ -249,7 +248,7 @@ static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32, struct comed
 	/* (Could use ptr_to_compat() to set them, but that wasn't implemented
 	/* (Could use ptr_to_compat() to set them, but that wasn't implemented
 	 * until kernel version 2.6.11.) */
 	 * until kernel version 2.6.11.) */
 	if (!access_ok(VERIFY_READ, cmd, sizeof(*cmd))
 	if (!access_ok(VERIFY_READ, cmd, sizeof(*cmd))
-			|| !access_ok(VERIFY_WRITE, cmd32, sizeof(*cmd32))) {
+	    || !access_ok(VERIFY_WRITE, cmd32, sizeof(*cmd32))) {
 		return -EFAULT;
 		return -EFAULT;
 	}
 	}
 	err = 0;
 	err = 0;
@@ -329,8 +328,8 @@ static int compat_cmdtest(struct file *file, unsigned long arg)
 }
 }
 
 
 /* Copy 32-bit insn structure to native insn structure. */
 /* Copy 32-bit insn structure to native insn structure. */
-static int get_compat_insn(struct comedi_insn __user *insn,
-		struct comedi32_insn_struct __user *insn32)
+static int get_compat_insn(struct comedi_insn __user * insn,
+			   struct comedi32_insn_struct __user * insn32)
 {
 {
 	int err;
 	int err;
 	union {
 	union {
@@ -341,7 +340,7 @@ static int get_compat_insn(struct comedi_insn __user *insn,
 	/* Copy insn structure.  Ignore the unused members. */
 	/* Copy insn structure.  Ignore the unused members. */
 	err = 0;
 	err = 0;
 	if (!access_ok(VERIFY_READ, insn32, sizeof(*insn32))
 	if (!access_ok(VERIFY_READ, insn32, sizeof(*insn32))
-			|| !access_ok(VERIFY_WRITE, insn, sizeof(*insn)))
+	    || !access_ok(VERIFY_WRITE, insn, sizeof(*insn)))
 		return -EFAULT;
 		return -EFAULT;
 
 
 	err |= __get_user(temp.uint, &insn32->insn);
 	err |= __get_user(temp.uint, &insn32->insn);
@@ -385,7 +384,7 @@ static int compat_insnlist(struct file *file, unsigned long arg)
 
 
 	/* Allocate user memory to copy insnlist and insns into. */
 	/* Allocate user memory to copy insnlist and insns into. */
 	s = compat_alloc_user_space(offsetof(struct combined_insnlist,
 	s = compat_alloc_user_space(offsetof(struct combined_insnlist,
-				insn[n_insns]));
+					     insn[n_insns]));
 
 
 	/* Set native insnlist structure. */
 	/* Set native insnlist structure. */
 	if (!access_ok(VERIFY_WRITE, &s->insnlist, sizeof(s->insnlist))) {
 	if (!access_ok(VERIFY_WRITE, &s->insnlist, sizeof(s->insnlist))) {
@@ -404,7 +403,7 @@ static int compat_insnlist(struct file *file, unsigned long arg)
 	}
 	}
 
 
 	return translated_ioctl(file, COMEDI_INSNLIST,
 	return translated_ioctl(file, COMEDI_INSNLIST,
-			(unsigned long)&s->insnlist);
+				(unsigned long)&s->insnlist);
 }
 }
 
 
 /* Handle 32-bit COMEDI_INSN ioctl. */
 /* Handle 32-bit COMEDI_INSN ioctl. */
@@ -427,7 +426,7 @@ static int compat_insn(struct file *file, unsigned long arg)
 /* Process untranslated ioctl. */
 /* Process untranslated ioctl. */
 /* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */
 /* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */
 static inline int raw_ioctl(struct file *file, unsigned int cmd,
 static inline int raw_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
+			    unsigned long arg)
 {
 {
 	int rc;
 	int rc;
 
 
@@ -477,8 +476,7 @@ static inline int raw_ioctl(struct file *file, unsigned int cmd,
 
 
 /* compat_ioctl file operation. */
 /* compat_ioctl file operation. */
 /* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */
 /* Returns -ENOIOCTLCMD for unrecognised ioctl codes. */
-long comedi_compat_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
+long comedi_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 {
 	return raw_ioctl(file, cmd, arg);
 	return raw_ioctl(file, cmd, arg);
 }
 }
@@ -497,7 +495,7 @@ long comedi_compat_ioctl(struct file *file, unsigned int cmd,
 
 
 /* Handler for all 32-bit ioctl codes registered by this driver. */
 /* Handler for all 32-bit ioctl codes registered by this driver. */
 static int mapped_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
 static int mapped_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
-		struct file *file)
+			struct file *file)
 {
 {
 	int rc;
 	int rc;
 
 
@@ -515,27 +513,27 @@ static int mapped_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
 
 
 struct ioctl32_map {
 struct ioctl32_map {
 	unsigned int cmd;
 	unsigned int cmd;
-	int (*handler)(unsigned int, unsigned int, unsigned long,
+	int (*handler) (unsigned int, unsigned int, unsigned long,
 			struct file *);
 			struct file *);
 	int registered;
 	int registered;
 };
 };
 
 
 static struct ioctl32_map comedi_ioctl32_map[] = {
 static struct ioctl32_map comedi_ioctl32_map[] = {
-	{ COMEDI_DEVCONFIG, mapped_ioctl, 0 },
-	{ COMEDI_DEVINFO, mapped_ioctl, 0 },
-	{ COMEDI_SUBDINFO, mapped_ioctl, 0 },
-	{ COMEDI_BUFCONFIG, mapped_ioctl, 0 },
-	{ COMEDI_BUFINFO, mapped_ioctl, 0 },
-	{ COMEDI_LOCK, mapped_ioctl, 0 },
-	{ COMEDI_UNLOCK, mapped_ioctl, 0 },
-	{ COMEDI_CANCEL, mapped_ioctl, 0 },
-	{ COMEDI_POLL, mapped_ioctl, 0 },
-	{ COMEDI32_CHANINFO, mapped_ioctl, 0 },
-	{ COMEDI32_RANGEINFO, mapped_ioctl, 0 },
-	{ COMEDI32_CMD, mapped_ioctl, 0 },
-	{ COMEDI32_CMDTEST, mapped_ioctl, 0 },
-	{ COMEDI32_INSNLIST, mapped_ioctl, 0 },
-	{ COMEDI32_INSN, mapped_ioctl, 0 },
+	{COMEDI_DEVCONFIG, mapped_ioctl, 0},
+	{COMEDI_DEVINFO, mapped_ioctl, 0},
+	{COMEDI_SUBDINFO, mapped_ioctl, 0},
+	{COMEDI_BUFCONFIG, mapped_ioctl, 0},
+	{COMEDI_BUFINFO, mapped_ioctl, 0},
+	{COMEDI_LOCK, mapped_ioctl, 0},
+	{COMEDI_UNLOCK, mapped_ioctl, 0},
+	{COMEDI_CANCEL, mapped_ioctl, 0},
+	{COMEDI_POLL, mapped_ioctl, 0},
+	{COMEDI32_CHANINFO, mapped_ioctl, 0},
+	{COMEDI32_RANGEINFO, mapped_ioctl, 0},
+	{COMEDI32_CMD, mapped_ioctl, 0},
+	{COMEDI32_CMDTEST, mapped_ioctl, 0},
+	{COMEDI32_INSNLIST, mapped_ioctl, 0},
+	{COMEDI32_INSN, mapped_ioctl, 0},
 };
 };
 
 
 #define NUM_IOCTL32_MAPS ARRAY_SIZE(comedi_ioctl32_map)
 #define NUM_IOCTL32_MAPS ARRAY_SIZE(comedi_ioctl32_map)
@@ -547,13 +545,13 @@ void comedi_register_ioctl32(void)
 
 
 	for (n = 0; n < NUM_IOCTL32_MAPS; n++) {
 	for (n = 0; n < NUM_IOCTL32_MAPS; n++) {
 		rc = register_ioctl32_conversion(comedi_ioctl32_map[n].cmd,
 		rc = register_ioctl32_conversion(comedi_ioctl32_map[n].cmd,
-				comedi_ioctl32_map[n].handler);
+						 comedi_ioctl32_map[n].handler);
 		if (rc) {
 		if (rc) {
 			printk(KERN_WARNING
 			printk(KERN_WARNING
-					"comedi: failed to register 32-bit "
-					"compatible ioctl handler for 0x%X - "
-					"expect bad things to happen!\n",
-					comedi_ioctl32_map[n].cmd);
+			       "comedi: failed to register 32-bit "
+			       "compatible ioctl handler for 0x%X - "
+			       "expect bad things to happen!\n",
+			       comedi_ioctl32_map[n].cmd);
 		}
 		}
 		comedi_ioctl32_map[n].registered = !rc;
 		comedi_ioctl32_map[n].registered = !rc;
 	}
 	}
@@ -566,15 +564,16 @@ void comedi_unregister_ioctl32(void)
 
 
 	for (n = 0; n < NUM_IOCTL32_MAPS; n++) {
 	for (n = 0; n < NUM_IOCTL32_MAPS; n++) {
 		if (comedi_ioctl32_map[n].registered) {
 		if (comedi_ioctl32_map[n].registered) {
-			rc = unregister_ioctl32_conversion(
-					comedi_ioctl32_map[n].cmd,
-					comedi_ioctl32_map[n].handler);
+			rc = unregister_ioctl32_conversion(comedi_ioctl32_map
+							   [n].cmd,
+							   comedi_ioctl32_map
+							   [n].handler);
 			if (rc) {
 			if (rc) {
 				printk(KERN_ERR
 				printk(KERN_ERR
-					"comedi: failed to unregister 32-bit "
-					"compatible ioctl handler for 0x%X - "
-					"expect kernel Oops!\n",
-					comedi_ioctl32_map[n].cmd);
+				       "comedi: failed to unregister 32-bit "
+				       "compatible ioctl handler for 0x%X - "
+				       "expect kernel Oops!\n",
+				       comedi_ioctl32_map[n].cmd);
 			} else {
 			} else {
 				comedi_ioctl32_map[n].registered = 0;
 				comedi_ioctl32_map[n].registered = 0;
 			}
 			}
@@ -582,6 +581,6 @@ void comedi_unregister_ioctl32(void)
 	}
 	}
 }
 }
 
 
-#endif	/* HAVE_COMPAT_IOCTL */
+#endif /* HAVE_COMPAT_IOCTL */
 
 
-#endif	/* CONFIG_COMPAT */
+#endif /* CONFIG_COMPAT */

+ 2 - 2
drivers/staging/comedi/comedi_compat32.h

@@ -28,14 +28,14 @@
 #define _COMEDI_COMPAT32_H
 #define _COMEDI_COMPAT32_H
 
 
 #include <linux/compat.h>
 #include <linux/compat.h>
-#include <linux/fs.h>	/* For HAVE_COMPAT_IOCTL and HAVE_UNLOCKED_IOCTL */
+#include <linux/fs.h>		/* For HAVE_COMPAT_IOCTL and HAVE_UNLOCKED_IOCTL */
 
 
 #ifdef CONFIG_COMPAT
 #ifdef CONFIG_COMPAT
 
 
 #ifdef HAVE_COMPAT_IOCTL
 #ifdef HAVE_COMPAT_IOCTL
 
 
 extern long comedi_compat_ioctl(struct file *file, unsigned int cmd,
 extern long comedi_compat_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg);
+				unsigned long arg);
 #define comedi_register_ioctl32() do {} while (0)
 #define comedi_register_ioctl32() do {} while (0)
 #define comedi_unregister_ioctl32() do {} while (0)
 #define comedi_unregister_ioctl32() do {} while (0)
 
 

+ 151 - 127
drivers/staging/comedi/comedi_fops.c

@@ -68,26 +68,33 @@ module_param(comedi_num_legacy_minors, int, 0444);
 
 
 static DEFINE_SPINLOCK(comedi_file_info_table_lock);
 static DEFINE_SPINLOCK(comedi_file_info_table_lock);
 static struct comedi_device_file_info
 static struct comedi_device_file_info
-    *comedi_file_info_table[COMEDI_NUM_MINORS];
+*comedi_file_info_table[COMEDI_NUM_MINORS];
 
 
-static int do_devconfig_ioctl(struct comedi_device *dev, struct comedi_devconfig *arg);
+static int do_devconfig_ioctl(struct comedi_device *dev,
+			      struct comedi_devconfig *arg);
 static int do_bufconfig_ioctl(struct comedi_device *dev, void *arg);
 static int do_bufconfig_ioctl(struct comedi_device *dev, void *arg);
-static int do_devinfo_ioctl(struct comedi_device *dev, struct comedi_devinfo *arg,
-			    struct file *file);
-static int do_subdinfo_ioctl(struct comedi_device *dev, struct comedi_subdinfo *arg,
-			     void *file);
-static int do_chaninfo_ioctl(struct comedi_device *dev, struct comedi_chaninfo *arg);
+static int do_devinfo_ioctl(struct comedi_device *dev,
+			    struct comedi_devinfo *arg, struct file *file);
+static int do_subdinfo_ioctl(struct comedi_device *dev,
+			     struct comedi_subdinfo *arg, void *file);
+static int do_chaninfo_ioctl(struct comedi_device *dev,
+			     struct comedi_chaninfo *arg);
 static int do_bufinfo_ioctl(struct comedi_device *dev, void *arg);
 static int do_bufinfo_ioctl(struct comedi_device *dev, void *arg);
 static int do_cmd_ioctl(struct comedi_device *dev, void *arg, void *file);
 static int do_cmd_ioctl(struct comedi_device *dev, void *arg, void *file);
-static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, void *file);
-static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, void *file);
-static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, void *file);
+static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg,
+			 void *file);
+static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg,
+			   void *file);
+static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
+			   void *file);
 static int do_cmdtest_ioctl(struct comedi_device *dev, void *arg, void *file);
 static int do_cmdtest_ioctl(struct comedi_device *dev, void *arg, void *file);
 static int do_insnlist_ioctl(struct comedi_device *dev, void *arg, void *file);
 static int do_insnlist_ioctl(struct comedi_device *dev, void *arg, void *file);
 static int do_insn_ioctl(struct comedi_device *dev, void *arg, void *file);
 static int do_insn_ioctl(struct comedi_device *dev, void *arg, void *file);
-static int do_poll_ioctl(struct comedi_device *dev, unsigned int subd, void *file);
+static int do_poll_ioctl(struct comedi_device *dev, unsigned int subd,
+			 void *file);
 
 
-extern void do_become_nonbusy(struct comedi_device *dev, struct comedi_subdevice *s);
+extern void do_become_nonbusy(struct comedi_device *dev,
+			      struct comedi_subdevice *s);
 static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
 static int do_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
 
 
 static int comedi_fasync(int fd, struct file *file, int on);
 static int comedi_fasync(int fd, struct file *file, int on);
@@ -202,7 +209,8 @@ done:
 	writes:
 	writes:
 		none
 		none
 */
 */
-static int do_devconfig_ioctl(struct comedi_device *dev, struct comedi_devconfig *arg)
+static int do_devconfig_ioctl(struct comedi_device *dev,
+			      struct comedi_devconfig *arg)
 {
 {
 	struct comedi_devconfig it;
 	struct comedi_devconfig it;
 	int ret;
 	int ret;
@@ -342,8 +350,8 @@ copyback:
 		devinfo structure
 		devinfo structure
 
 
 */
 */
-static int do_devinfo_ioctl(struct comedi_device *dev, struct comedi_devinfo *arg,
-			    struct file *file)
+static int do_devinfo_ioctl(struct comedi_device *dev,
+			    struct comedi_devinfo *arg, struct file *file)
 {
 {
 	struct comedi_devinfo devinfo;
 	struct comedi_devinfo devinfo;
 	const unsigned minor = iminor(file->f_dentry->d_inode);
 	const unsigned minor = iminor(file->f_dentry->d_inode);
@@ -392,14 +400,16 @@ static int do_devinfo_ioctl(struct comedi_device *dev, struct comedi_devinfo *ar
 		array of subdevice info structures at arg
 		array of subdevice info structures at arg
 
 
 */
 */
-static int do_subdinfo_ioctl(struct comedi_device *dev, struct comedi_subdinfo *arg,
-			     void *file)
+static int do_subdinfo_ioctl(struct comedi_device *dev,
+			     struct comedi_subdinfo *arg, void *file)
 {
 {
 	int ret, i;
 	int ret, i;
 	struct comedi_subdinfo *tmp, *us;
 	struct comedi_subdinfo *tmp, *us;
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 
 
-	tmp = kcalloc(dev->n_subdevices, sizeof(struct comedi_subdinfo), GFP_KERNEL);
+	tmp =
+	    kcalloc(dev->n_subdevices, sizeof(struct comedi_subdinfo),
+		    GFP_KERNEL);
 	if (!tmp)
 	if (!tmp)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
@@ -472,7 +482,8 @@ static int do_subdinfo_ioctl(struct comedi_device *dev, struct comedi_subdinfo *
 		arrays at elements of chaninfo structure
 		arrays at elements of chaninfo structure
 
 
 */
 */
-static int do_chaninfo_ioctl(struct comedi_device *dev, struct comedi_chaninfo *arg)
+static int do_chaninfo_ioctl(struct comedi_device *dev,
+			     struct comedi_chaninfo *arg)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	struct comedi_chaninfo it;
 	struct comedi_chaninfo it;
@@ -514,7 +525,7 @@ static int do_chaninfo_ioctl(struct comedi_device *dev, struct comedi_chaninfo *
 		}
 		}
 #if 0
 #if 0
 		if (copy_to_user(it.rangelist, s->range_type_list,
 		if (copy_to_user(it.rangelist, s->range_type_list,
-				 s->n_chan*sizeof(unsigned int)))
+				 s->n_chan * sizeof(unsigned int)))
 			return -EFAULT;
 			return -EFAULT;
 #endif
 #endif
 	}
 	}
@@ -589,8 +600,8 @@ copyback:
 	return 0;
 	return 0;
 }
 }
 
 
-static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data,
-		      void *file);
+static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn,
+		      unsigned int *data, void *file);
 /*
 /*
  * 	COMEDI_INSNLIST
  * 	COMEDI_INSNLIST
  * 	synchronous instructions
  * 	synchronous instructions
@@ -626,7 +637,8 @@ static int do_insnlist_ioctl(struct comedi_device *dev, void *arg, void *file)
 		goto error;
 		goto error;
 	}
 	}
 
 
-	insns = kmalloc(sizeof(struct comedi_insn) * insnlist.n_insns, GFP_KERNEL);
+	insns =
+	    kmalloc(sizeof(struct comedi_insn) * insnlist.n_insns, GFP_KERNEL);
 	if (!insns) {
 	if (!insns) {
 		DPRINTK("kmalloc failed\n");
 		DPRINTK("kmalloc failed\n");
 		ret = -ENOMEM;
 		ret = -ENOMEM;
@@ -678,7 +690,8 @@ error:
 	return i;
 	return i;
 }
 }
 
 
-static int check_insn_config_length(struct comedi_insn *insn, unsigned int *data)
+static int check_insn_config_length(struct comedi_insn *insn,
+				    unsigned int *data)
 {
 {
 	if (insn->n < 1)
 	if (insn->n < 1)
 		return -EINVAL;
 		return -EINVAL;
@@ -725,22 +738,22 @@ static int check_insn_config_length(struct comedi_insn *insn, unsigned int *data
 		if (insn->n == 5)
 		if (insn->n == 5)
 			return 0;
 			return 0;
 		break;
 		break;
-	/* by default we allow the insn since we don't have checks for
-	 * all possible cases yet */
+		/* by default we allow the insn since we don't have checks for
+		 * all possible cases yet */
 	default:
 	default:
 		printk("comedi: no check for data length of config insn id "
 		printk("comedi: no check for data length of config insn id "
-			  "%i is implemented.\n"
-			  " Add a check to %s in %s.\n"
-			  " Assuming n=%i is correct.\n", data[0], __func__,
-			  __FILE__, insn->n);
+		       "%i is implemented.\n"
+		       " Add a check to %s in %s.\n"
+		       " Assuming n=%i is correct.\n", data[0], __func__,
+		       __FILE__, insn->n);
 		return 0;
 		return 0;
 		break;
 		break;
 	}
 	}
 	return -EINVAL;
 	return -EINVAL;
 }
 }
 
 
-static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data,
-		      void *file)
+static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn,
+		      unsigned int *data, void *file)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int ret = 0;
 	int ret = 0;
@@ -920,7 +933,8 @@ static int do_insn_ioctl(struct comedi_device *dev, void *arg, void *file)
 	if (insn.n > MAX_SAMPLES)
 	if (insn.n > MAX_SAMPLES)
 		insn.n = MAX_SAMPLES;
 		insn.n = MAX_SAMPLES;
 	if (insn.insn & INSN_MASK_WRITE) {
 	if (insn.insn & INSN_MASK_WRITE) {
-		if (copy_from_user(data, insn.data, insn.n * sizeof(unsigned int))) {
+		if (copy_from_user
+		    (data, insn.data, insn.n * sizeof(unsigned int))) {
 			ret = -EFAULT;
 			ret = -EFAULT;
 			goto error;
 			goto error;
 		}
 		}
@@ -929,7 +943,8 @@ static int do_insn_ioctl(struct comedi_device *dev, void *arg, void *file)
 	if (ret < 0)
 	if (ret < 0)
 		goto error;
 		goto error;
 	if (insn.insn & INSN_MASK_READ) {
 	if (insn.insn & INSN_MASK_READ) {
-		if (copy_to_user(insn.data, data, insn.n * sizeof(unsigned int))) {
+		if (copy_to_user
+		    (insn.data, data, insn.n * sizeof(unsigned int))) {
 			ret = -EFAULT;
 			ret = -EFAULT;
 			goto error;
 			goto error;
 		}
 		}
@@ -1202,7 +1217,8 @@ cleanup:
 
 
 */
 */
 
 
-static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, void *file)
+static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg,
+			 void *file)
 {
 {
 	int ret = 0;
 	int ret = 0;
 	unsigned long flags;
 	unsigned long flags;
@@ -1246,7 +1262,8 @@ static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, void *file
 	This function isn't protected by the semaphore, since
 	This function isn't protected by the semaphore, since
 	we already own the lock.
 	we already own the lock.
 */
 */
-static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, void *file)
+static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg,
+			   void *file)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 
 
@@ -1286,7 +1303,8 @@ static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, void *fi
 		nothing
 		nothing
 
 
 */
 */
-static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, void *file)
+static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
+			   void *file)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 
 
@@ -1322,7 +1340,8 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, void *fi
 		nothing
 		nothing
 
 
 */
 */
-static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg, void *file)
+static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg,
+			 void *file)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 
 
@@ -1371,7 +1390,7 @@ void comedi_unmap(struct vm_area_struct *area)
 }
 }
 
 
 static struct vm_operations_struct comedi_vm_ops = {
 static struct vm_operations_struct comedi_vm_ops = {
-	.close =	comedi_unmap,
+	.close = comedi_unmap,
 };
 };
 
 
 static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
 static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
@@ -1428,10 +1447,10 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
 	n_pages = size >> PAGE_SHIFT;
 	n_pages = size >> PAGE_SHIFT;
 	for (i = 0; i < n_pages; ++i) {
 	for (i = 0; i < n_pages; ++i) {
 		if (remap_pfn_range(vma, start,
 		if (remap_pfn_range(vma, start,
-				    page_to_pfn(virt_to_page(async->
-							     buf_page_list[i].
-							     virt_addr)),
-				    PAGE_SIZE, PAGE_SHARED)) {
+				    page_to_pfn(virt_to_page
+						(async->buf_page_list
+						 [i].virt_addr)), PAGE_SIZE,
+				    PAGE_SHARED)) {
 			retval = -EAGAIN;
 			retval = -EAGAIN;
 			goto done;
 			goto done;
 		}
 		}
@@ -1449,7 +1468,7 @@ done:
 	return retval;
 	return retval;
 }
 }
 
 
-static unsigned int comedi_poll(struct file *file, poll_table *wait)
+static unsigned int comedi_poll(struct file *file, poll_table * wait)
 {
 {
 	unsigned int mask = 0;
 	unsigned int mask = 0;
 	const unsigned minor = iminor(file->f_dentry->d_inode);
 	const unsigned minor = iminor(file->f_dentry->d_inode);
@@ -1496,7 +1515,7 @@ static unsigned int comedi_poll(struct file *file, poll_table *wait)
 }
 }
 
 
 static ssize_t comedi_write(struct file *file, const char *buf, size_t nbytes,
 static ssize_t comedi_write(struct file *file, const char *buf, size_t nbytes,
-			    loff_t *offset)
+			    loff_t * offset)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	struct comedi_async *async;
 	struct comedi_async *async;
@@ -1598,7 +1617,7 @@ done:
 }
 }
 
 
 static ssize_t comedi_read(struct file *file, char *buf, size_t nbytes,
 static ssize_t comedi_read(struct file *file, char *buf, size_t nbytes,
-			   loff_t *offset)
+			   loff_t * offset)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	struct comedi_async *async;
 	struct comedi_async *async;
@@ -1729,7 +1748,8 @@ static int comedi_open(struct inode *inode, struct file *file)
 	const unsigned minor = iminor(inode);
 	const unsigned minor = iminor(inode);
 	struct comedi_device_file_info *dev_file_info =
 	struct comedi_device_file_info *dev_file_info =
 	    comedi_get_device_file_info(minor);
 	    comedi_get_device_file_info(minor);
-	struct comedi_device *dev = dev_file_info ? dev_file_info->device : NULL;
+	struct comedi_device *dev =
+	    dev_file_info ? dev_file_info->device : NULL;
 
 
 	if (dev == NULL) {
 	if (dev == NULL) {
 		DPRINTK("invalid minor number\n");
 		DPRINTK("invalid minor number\n");
@@ -1846,22 +1866,22 @@ static int comedi_fasync(int fd, struct file *file, int on)
 }
 }
 
 
 const struct file_operations comedi_fops = {
 const struct file_operations comedi_fops = {
-      .owner =		THIS_MODULE,
+	.owner = THIS_MODULE,
 #ifdef HAVE_UNLOCKED_IOCTL
 #ifdef HAVE_UNLOCKED_IOCTL
-      .unlocked_ioctl =	comedi_unlocked_ioctl,
+	.unlocked_ioctl = comedi_unlocked_ioctl,
 #else
 #else
-      .ioctl =		comedi_ioctl,
+	.ioctl = comedi_ioctl,
 #endif
 #endif
 #ifdef HAVE_COMPAT_IOCTL
 #ifdef HAVE_COMPAT_IOCTL
-      .compat_ioctl =	comedi_compat_ioctl,
+	.compat_ioctl = comedi_compat_ioctl,
 #endif
 #endif
-      .open =		comedi_open,
-      .release =	comedi_close,
-      .read =		comedi_read,
-      .write =		comedi_write,
-      .mmap =		comedi_mmap,
-      .poll =		comedi_poll,
-      .fasync =		comedi_fasync,
+	.open = comedi_open,
+	.release = comedi_close,
+	.read = comedi_read,
+	.write = comedi_write,
+	.mmap = comedi_mmap,
+	.poll = comedi_poll,
+	.fasync = comedi_fasync,
 };
 };
 
 
 struct class *comedi_class;
 struct class *comedi_class;
@@ -1952,7 +1972,6 @@ static void __exit comedi_cleanup(void)
 	for (i = 0; i < COMEDI_NUM_MINORS; ++i)
 	for (i = 0; i < COMEDI_NUM_MINORS; ++i)
 		BUG_ON(comedi_file_info_table[i]);
 		BUG_ON(comedi_file_info_table[i]);
 
 
-
 	class_destroy(comedi_class);
 	class_destroy(comedi_class);
 	cdev_del(&comedi_cdev);
 	cdev_del(&comedi_cdev);
 	unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS);
 	unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS);
@@ -1981,8 +2000,9 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
 	if ((comedi_get_subdevice_runflags(s) & SRF_RUNNING) == 0)
 	if ((comedi_get_subdevice_runflags(s) & SRF_RUNNING) == 0)
 		return;
 		return;
 
 
-	if (s->async->
-	    events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) {
+	if (s->
+	    async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
+			     COMEDI_CB_OVERFLOW)) {
 		runflags_mask |= SRF_RUNNING;
 		runflags_mask |= SRF_RUNNING;
 	}
 	}
 	/* remember if an error event has occured, so an error
 	/* remember if an error event has occured, so an error
@@ -2000,12 +2020,10 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
 		if (comedi_get_subdevice_runflags(s) & SRF_USER) {
 		if (comedi_get_subdevice_runflags(s) & SRF_USER) {
 			wake_up_interruptible(&async->wait_head);
 			wake_up_interruptible(&async->wait_head);
 			if (s->subdev_flags & SDF_CMD_READ) {
 			if (s->subdev_flags & SDF_CMD_READ) {
-				kill_fasync(&dev->async_queue, SIGIO,
-					    POLL_IN);
+				kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
 			}
 			}
 			if (s->subdev_flags & SDF_CMD_WRITE) {
 			if (s->subdev_flags & SDF_CMD_WRITE) {
-				kill_fasync(&dev->async_queue, SIGIO,
-					    POLL_OUT);
+				kill_fasync(&dev->async_queue, SIGIO, POLL_OUT);
 			}
 			}
 		} else {
 		} else {
 			if (async->cb_func)
 			if (async->cb_func)
@@ -2103,7 +2121,8 @@ int comedi_alloc_board_minor(struct device *hardware_device)
 		comedi_device_cleanup(info->device);
 		comedi_device_cleanup(info->device);
 		kfree(info->device);
 		kfree(info->device);
 		kfree(info);
 		kfree(info);
-		printk(KERN_ERR "comedi: error: ran out of minor numbers for board device files.\n");
+		printk(KERN_ERR
+		       "comedi: error: ran out of minor numbers for board device files.\n");
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
 	info->device->minor = i;
 	info->device->minor = i;
@@ -2115,29 +2134,33 @@ int comedi_alloc_board_minor(struct device *hardware_device)
 	dev_set_drvdata(csdev, info);
 	dev_set_drvdata(csdev, info);
 	retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb);
 	retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb);
 	if (retval) {
 	if (retval) {
-		printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
-			dev_attr_max_read_buffer_kb.attr.name);
+		printk(KERN_ERR
+		       "comedi: failed to create sysfs attribute file \"%s\".\n",
+		       dev_attr_max_read_buffer_kb.attr.name);
 		comedi_free_board_minor(i);
 		comedi_free_board_minor(i);
 		return retval;
 		return retval;
 	}
 	}
 	retval = device_create_file(csdev, &dev_attr_read_buffer_kb);
 	retval = device_create_file(csdev, &dev_attr_read_buffer_kb);
 	if (retval) {
 	if (retval) {
-		printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
-			dev_attr_read_buffer_kb.attr.name);
+		printk(KERN_ERR
+		       "comedi: failed to create sysfs attribute file \"%s\".\n",
+		       dev_attr_read_buffer_kb.attr.name);
 		comedi_free_board_minor(i);
 		comedi_free_board_minor(i);
 		return retval;
 		return retval;
 	}
 	}
 	retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb);
 	retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb);
 	if (retval) {
 	if (retval) {
-		printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
-			dev_attr_max_write_buffer_kb.attr.name);
+		printk(KERN_ERR
+		       "comedi: failed to create sysfs attribute file \"%s\".\n",
+		       dev_attr_max_write_buffer_kb.attr.name);
 		comedi_free_board_minor(i);
 		comedi_free_board_minor(i);
 		return retval;
 		return retval;
 	}
 	}
 	retval = device_create_file(csdev, &dev_attr_write_buffer_kb);
 	retval = device_create_file(csdev, &dev_attr_write_buffer_kb);
 	if (retval) {
 	if (retval) {
-		printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
-			dev_attr_write_buffer_kb.attr.name);
+		printk(KERN_ERR
+		       "comedi: failed to create sysfs attribute file \"%s\".\n",
+		       dev_attr_write_buffer_kb.attr.name);
 		comedi_free_board_minor(i);
 		comedi_free_board_minor(i);
 		return retval;
 		return retval;
 	}
 	}
@@ -2194,7 +2217,8 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
 	spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
 	spin_unlock_irqrestore(&comedi_file_info_table_lock, flags);
 	if (i == COMEDI_NUM_MINORS) {
 	if (i == COMEDI_NUM_MINORS) {
 		kfree(info);
 		kfree(info);
-		printk(KERN_ERR "comedi: error: ran out of minor numbers for board device files.\n");
+		printk(KERN_ERR
+		       "comedi: error: ran out of minor numbers for board device files.\n");
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
 	s->minor = i;
 	s->minor = i;
@@ -2207,29 +2231,33 @@ int comedi_alloc_subdevice_minor(struct comedi_device *dev,
 	dev_set_drvdata(csdev, info);
 	dev_set_drvdata(csdev, info);
 	retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb);
 	retval = device_create_file(csdev, &dev_attr_max_read_buffer_kb);
 	if (retval) {
 	if (retval) {
-		printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
-			dev_attr_max_read_buffer_kb.attr.name);
+		printk(KERN_ERR
+		       "comedi: failed to create sysfs attribute file \"%s\".\n",
+		       dev_attr_max_read_buffer_kb.attr.name);
 		comedi_free_subdevice_minor(s);
 		comedi_free_subdevice_minor(s);
 		return retval;
 		return retval;
 	}
 	}
 	retval = device_create_file(csdev, &dev_attr_read_buffer_kb);
 	retval = device_create_file(csdev, &dev_attr_read_buffer_kb);
 	if (retval) {
 	if (retval) {
-		printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
-			dev_attr_read_buffer_kb.attr.name);
+		printk(KERN_ERR
+		       "comedi: failed to create sysfs attribute file \"%s\".\n",
+		       dev_attr_read_buffer_kb.attr.name);
 		comedi_free_subdevice_minor(s);
 		comedi_free_subdevice_minor(s);
 		return retval;
 		return retval;
 	}
 	}
 	retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb);
 	retval = device_create_file(csdev, &dev_attr_max_write_buffer_kb);
 	if (retval) {
 	if (retval) {
-		printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
-			dev_attr_max_write_buffer_kb.attr.name);
+		printk(KERN_ERR
+		       "comedi: failed to create sysfs attribute file \"%s\".\n",
+		       dev_attr_max_write_buffer_kb.attr.name);
 		comedi_free_subdevice_minor(s);
 		comedi_free_subdevice_minor(s);
 		return retval;
 		return retval;
 	}
 	}
 	retval = device_create_file(csdev, &dev_attr_write_buffer_kb);
 	retval = device_create_file(csdev, &dev_attr_write_buffer_kb);
 	if (retval) {
 	if (retval) {
-		printk(KERN_ERR "comedi: failed to create sysfs attribute file \"%s\".\n",
-			dev_attr_write_buffer_kb.attr.name);
+		printk(KERN_ERR
+		       "comedi: failed to create sysfs attribute file \"%s\".\n",
+		       dev_attr_write_buffer_kb.attr.name);
 		comedi_free_subdevice_minor(s);
 		comedi_free_subdevice_minor(s);
 		return retval;
 		return retval;
 	}
 	}
@@ -2295,7 +2323,7 @@ static int resize_async_buffer(struct comedi_device *dev,
 		return -EINVAL;
 		return -EINVAL;
 
 
 	/* make sure buffer is an integral number of pages
 	/* make sure buffer is an integral number of pages
-		* (we round up) */
+	 * (we round up) */
 	new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK;
 	new_size = (new_size + PAGE_SIZE - 1) & PAGE_MASK;
 
 
 	retval = comedi_buf_alloc(dev, s, new_size);
 	retval = comedi_buf_alloc(dev, s, new_size);
@@ -2324,16 +2352,16 @@ static ssize_t show_max_read_buffer_kb(struct device *dev,
 	struct comedi_device_file_info *info = dev_get_drvdata(dev);
 	struct comedi_device_file_info *info = dev_get_drvdata(dev);
 	unsigned max_buffer_size_kb = 0;
 	unsigned max_buffer_size_kb = 0;
 	struct comedi_subdevice *const read_subdevice =
 	struct comedi_subdevice *const read_subdevice =
-					comedi_get_read_subdevice(info);
+	    comedi_get_read_subdevice(info);
 
 
 	mutex_lock(&info->device->mutex);
 	mutex_lock(&info->device->mutex);
 	if (read_subdevice &&
 	if (read_subdevice &&
 	    (read_subdevice->subdev_flags & SDF_CMD_READ) &&
 	    (read_subdevice->subdev_flags & SDF_CMD_READ) &&
 	    read_subdevice->async) {
 	    read_subdevice->async) {
 		max_buffer_size_kb = read_subdevice->async->max_bufsize /
 		max_buffer_size_kb = read_subdevice->async->max_bufsize /
-					bytes_per_kibi;
+		    bytes_per_kibi;
 	}
 	}
-	retval =  snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
+	retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
 	mutex_unlock(&info->device->mutex);
 	mutex_unlock(&info->device->mutex);
 
 
 	return retval;
 	return retval;
@@ -2347,14 +2375,14 @@ static ssize_t store_max_read_buffer_kb(struct device *dev,
 	unsigned long new_max_size_kb;
 	unsigned long new_max_size_kb;
 	uint64_t new_max_size;
 	uint64_t new_max_size;
 	struct comedi_subdevice *const read_subdevice =
 	struct comedi_subdevice *const read_subdevice =
-					comedi_get_read_subdevice(info);
+	    comedi_get_read_subdevice(info);
 
 
 	if (strict_strtoul(buf, 10, &new_max_size_kb))
 	if (strict_strtoul(buf, 10, &new_max_size_kb))
 		return -EINVAL;
 		return -EINVAL;
-	if (new_max_size_kb != (uint32_t)new_max_size_kb)
+	if (new_max_size_kb != (uint32_t) new_max_size_kb)
 		return -EINVAL;
 		return -EINVAL;
-	new_max_size = ((uint64_t)new_max_size_kb) * bytes_per_kibi;
-	if (new_max_size != (uint32_t)new_max_size)
+	new_max_size = ((uint64_t) new_max_size_kb) * bytes_per_kibi;
+	if (new_max_size != (uint32_t) new_max_size)
 		return -EINVAL;
 		return -EINVAL;
 
 
 	mutex_lock(&info->device->mutex);
 	mutex_lock(&info->device->mutex);
@@ -2372,9 +2400,8 @@ static ssize_t store_max_read_buffer_kb(struct device *dev,
 
 
 static struct device_attribute dev_attr_max_read_buffer_kb = {
 static struct device_attribute dev_attr_max_read_buffer_kb = {
 	.attr = {
 	.attr = {
-			.name = "max_read_buffer_kb",
-			.mode = S_IRUGO | S_IWUSR
-		},
+		 .name = "max_read_buffer_kb",
+		 .mode = S_IRUGO | S_IWUSR},
 	.show = &show_max_read_buffer_kb,
 	.show = &show_max_read_buffer_kb,
 	.store = &store_max_read_buffer_kb
 	.store = &store_max_read_buffer_kb
 };
 };
@@ -2386,16 +2413,16 @@ static ssize_t show_read_buffer_kb(struct device *dev,
 	struct comedi_device_file_info *info = dev_get_drvdata(dev);
 	struct comedi_device_file_info *info = dev_get_drvdata(dev);
 	unsigned buffer_size_kb = 0;
 	unsigned buffer_size_kb = 0;
 	struct comedi_subdevice *const read_subdevice =
 	struct comedi_subdevice *const read_subdevice =
-					comedi_get_read_subdevice(info);
+	    comedi_get_read_subdevice(info);
 
 
 	mutex_lock(&info->device->mutex);
 	mutex_lock(&info->device->mutex);
 	if (read_subdevice &&
 	if (read_subdevice &&
-		(read_subdevice->subdev_flags & SDF_CMD_READ) &&
-		read_subdevice->async) {
+	    (read_subdevice->subdev_flags & SDF_CMD_READ) &&
+	    read_subdevice->async) {
 		buffer_size_kb = read_subdevice->async->prealloc_bufsz /
 		buffer_size_kb = read_subdevice->async->prealloc_bufsz /
-					bytes_per_kibi;
+		    bytes_per_kibi;
 	}
 	}
-	retval =  snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
+	retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
 	mutex_unlock(&info->device->mutex);
 	mutex_unlock(&info->device->mutex);
 
 
 	return retval;
 	return retval;
@@ -2410,14 +2437,14 @@ static ssize_t store_read_buffer_kb(struct device *dev,
 	uint64_t new_size;
 	uint64_t new_size;
 	int retval;
 	int retval;
 	struct comedi_subdevice *const read_subdevice =
 	struct comedi_subdevice *const read_subdevice =
-					comedi_get_read_subdevice(info);
+	    comedi_get_read_subdevice(info);
 
 
 	if (strict_strtoul(buf, 10, &new_size_kb))
 	if (strict_strtoul(buf, 10, &new_size_kb))
 		return -EINVAL;
 		return -EINVAL;
-	if (new_size_kb != (uint32_t)new_size_kb)
+	if (new_size_kb != (uint32_t) new_size_kb)
 		return -EINVAL;
 		return -EINVAL;
-	new_size = ((uint64_t)new_size_kb) * bytes_per_kibi;
-	if (new_size != (uint32_t)new_size)
+	new_size = ((uint64_t) new_size_kb) * bytes_per_kibi;
+	if (new_size != (uint32_t) new_size)
 		return -EINVAL;
 		return -EINVAL;
 
 
 	mutex_lock(&info->device->mutex);
 	mutex_lock(&info->device->mutex);
@@ -2438,9 +2465,8 @@ static ssize_t store_read_buffer_kb(struct device *dev,
 
 
 static struct device_attribute dev_attr_read_buffer_kb = {
 static struct device_attribute dev_attr_read_buffer_kb = {
 	.attr = {
 	.attr = {
-			.name = "read_buffer_kb",
-			.mode = S_IRUGO | S_IWUSR | S_IWGRP
-		},
+		 .name = "read_buffer_kb",
+		 .mode = S_IRUGO | S_IWUSR | S_IWGRP},
 	.show = &show_read_buffer_kb,
 	.show = &show_read_buffer_kb,
 	.store = &store_read_buffer_kb
 	.store = &store_read_buffer_kb
 };
 };
@@ -2453,16 +2479,16 @@ static ssize_t show_max_write_buffer_kb(struct device *dev,
 	struct comedi_device_file_info *info = dev_get_drvdata(dev);
 	struct comedi_device_file_info *info = dev_get_drvdata(dev);
 	unsigned max_buffer_size_kb = 0;
 	unsigned max_buffer_size_kb = 0;
 	struct comedi_subdevice *const write_subdevice =
 	struct comedi_subdevice *const write_subdevice =
-					comedi_get_write_subdevice(info);
+	    comedi_get_write_subdevice(info);
 
 
 	mutex_lock(&info->device->mutex);
 	mutex_lock(&info->device->mutex);
 	if (write_subdevice &&
 	if (write_subdevice &&
 	    (write_subdevice->subdev_flags & SDF_CMD_WRITE) &&
 	    (write_subdevice->subdev_flags & SDF_CMD_WRITE) &&
 	    write_subdevice->async) {
 	    write_subdevice->async) {
 		max_buffer_size_kb = write_subdevice->async->max_bufsize /
 		max_buffer_size_kb = write_subdevice->async->max_bufsize /
-					bytes_per_kibi;
+		    bytes_per_kibi;
 	}
 	}
-	retval =  snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
+	retval = snprintf(buf, PAGE_SIZE, "%i\n", max_buffer_size_kb);
 	mutex_unlock(&info->device->mutex);
 	mutex_unlock(&info->device->mutex);
 
 
 	return retval;
 	return retval;
@@ -2476,14 +2502,14 @@ static ssize_t store_max_write_buffer_kb(struct device *dev,
 	unsigned long new_max_size_kb;
 	unsigned long new_max_size_kb;
 	uint64_t new_max_size;
 	uint64_t new_max_size;
 	struct comedi_subdevice *const write_subdevice =
 	struct comedi_subdevice *const write_subdevice =
-					comedi_get_write_subdevice(info);
+	    comedi_get_write_subdevice(info);
 
 
 	if (strict_strtoul(buf, 10, &new_max_size_kb))
 	if (strict_strtoul(buf, 10, &new_max_size_kb))
 		return -EINVAL;
 		return -EINVAL;
-	if (new_max_size_kb != (uint32_t)new_max_size_kb)
+	if (new_max_size_kb != (uint32_t) new_max_size_kb)
 		return -EINVAL;
 		return -EINVAL;
-	new_max_size = ((uint64_t)new_max_size_kb) * bytes_per_kibi;
-	if (new_max_size != (uint32_t)new_max_size)
+	new_max_size = ((uint64_t) new_max_size_kb) * bytes_per_kibi;
+	if (new_max_size != (uint32_t) new_max_size)
 		return -EINVAL;
 		return -EINVAL;
 
 
 	mutex_lock(&info->device->mutex);
 	mutex_lock(&info->device->mutex);
@@ -2501,9 +2527,8 @@ static ssize_t store_max_write_buffer_kb(struct device *dev,
 
 
 static struct device_attribute dev_attr_max_write_buffer_kb = {
 static struct device_attribute dev_attr_max_write_buffer_kb = {
 	.attr = {
 	.attr = {
-			.name = "max_write_buffer_kb",
-			.mode = S_IRUGO | S_IWUSR
-		},
+		 .name = "max_write_buffer_kb",
+		 .mode = S_IRUGO | S_IWUSR},
 	.show = &show_max_write_buffer_kb,
 	.show = &show_max_write_buffer_kb,
 	.store = &store_max_write_buffer_kb
 	.store = &store_max_write_buffer_kb
 };
 };
@@ -2515,16 +2540,16 @@ static ssize_t show_write_buffer_kb(struct device *dev,
 	struct comedi_device_file_info *info = dev_get_drvdata(dev);
 	struct comedi_device_file_info *info = dev_get_drvdata(dev);
 	unsigned buffer_size_kb = 0;
 	unsigned buffer_size_kb = 0;
 	struct comedi_subdevice *const write_subdevice =
 	struct comedi_subdevice *const write_subdevice =
-					comedi_get_write_subdevice(info);
+	    comedi_get_write_subdevice(info);
 
 
 	mutex_lock(&info->device->mutex);
 	mutex_lock(&info->device->mutex);
 	if (write_subdevice &&
 	if (write_subdevice &&
 	    (write_subdevice->subdev_flags & SDF_CMD_WRITE) &&
 	    (write_subdevice->subdev_flags & SDF_CMD_WRITE) &&
 	    write_subdevice->async) {
 	    write_subdevice->async) {
 		buffer_size_kb = write_subdevice->async->prealloc_bufsz /
 		buffer_size_kb = write_subdevice->async->prealloc_bufsz /
-					bytes_per_kibi;
+		    bytes_per_kibi;
 	}
 	}
-	retval =  snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
+	retval = snprintf(buf, PAGE_SIZE, "%i\n", buffer_size_kb);
 	mutex_unlock(&info->device->mutex);
 	mutex_unlock(&info->device->mutex);
 
 
 	return retval;
 	return retval;
@@ -2539,14 +2564,14 @@ static ssize_t store_write_buffer_kb(struct device *dev,
 	uint64_t new_size;
 	uint64_t new_size;
 	int retval;
 	int retval;
 	struct comedi_subdevice *const write_subdevice =
 	struct comedi_subdevice *const write_subdevice =
-					comedi_get_write_subdevice(info);
+	    comedi_get_write_subdevice(info);
 
 
 	if (strict_strtoul(buf, 10, &new_size_kb))
 	if (strict_strtoul(buf, 10, &new_size_kb))
 		return -EINVAL;
 		return -EINVAL;
-	if (new_size_kb != (uint32_t)new_size_kb)
+	if (new_size_kb != (uint32_t) new_size_kb)
 		return -EINVAL;
 		return -EINVAL;
-	new_size = ((uint64_t)new_size_kb) * bytes_per_kibi;
-	if (new_size != (uint32_t)new_size)
+	new_size = ((uint64_t) new_size_kb) * bytes_per_kibi;
+	if (new_size != (uint32_t) new_size)
 		return -EINVAL;
 		return -EINVAL;
 
 
 	mutex_lock(&info->device->mutex);
 	mutex_lock(&info->device->mutex);
@@ -2557,7 +2582,7 @@ static ssize_t store_write_buffer_kb(struct device *dev,
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 	retval = resize_async_buffer(info->device, write_subdevice,
 	retval = resize_async_buffer(info->device, write_subdevice,
-		write_subdevice->async, new_size);
+				     write_subdevice->async, new_size);
 	mutex_unlock(&info->device->mutex);
 	mutex_unlock(&info->device->mutex);
 
 
 	if (retval < 0)
 	if (retval < 0)
@@ -2567,9 +2592,8 @@ static ssize_t store_write_buffer_kb(struct device *dev,
 
 
 static struct device_attribute dev_attr_write_buffer_kb = {
 static struct device_attribute dev_attr_write_buffer_kb = {
 	.attr = {
 	.attr = {
-			.name = "write_buffer_kb",
-			.mode = S_IRUGO | S_IWUSR | S_IWGRP
-		},
+		 .name = "write_buffer_kb",
+		 .mode = S_IRUGO | S_IWUSR | S_IWGRP},
 	.show = &show_write_buffer_kb,
 	.show = &show_write_buffer_kb,
 	.store = &store_write_buffer_kb
 	.store = &store_write_buffer_kb
 };
 };

+ 0 - 3
drivers/staging/comedi/comedi_ksyms.c

@@ -22,9 +22,6 @@
 */
 */
 
 
 #define __NO_VERSION__
 #define __NO_VERSION__
-#ifndef EXPORT_SYMTAB
-#define EXPORT_SYMTAB
-#endif
 
 
 #include "comedidev.h"
 #include "comedidev.h"
 
 

+ 48 - 37
drivers/staging/comedi/comedidev.h

@@ -156,28 +156,30 @@ struct comedi_subdevice {
 
 
 	unsigned int *chanlist;	/* driver-owned chanlist (not used) */
 	unsigned int *chanlist;	/* driver-owned chanlist (not used) */
 
 
-	int (*insn_read) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
-		unsigned int *);
-	int (*insn_write) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
-		unsigned int *);
-	int (*insn_bits) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
-		unsigned int *);
-	int (*insn_config) (struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *,
-		unsigned int *);
+	int (*insn_read) (struct comedi_device *, struct comedi_subdevice *,
+			  struct comedi_insn *, unsigned int *);
+	int (*insn_write) (struct comedi_device *, struct comedi_subdevice *,
+			   struct comedi_insn *, unsigned int *);
+	int (*insn_bits) (struct comedi_device *, struct comedi_subdevice *,
+			  struct comedi_insn *, unsigned int *);
+	int (*insn_config) (struct comedi_device *, struct comedi_subdevice *,
+			    struct comedi_insn *, unsigned int *);
 
 
 	int (*do_cmd) (struct comedi_device *, struct comedi_subdevice *);
 	int (*do_cmd) (struct comedi_device *, struct comedi_subdevice *);
-	int (*do_cmdtest) (struct comedi_device *, struct comedi_subdevice *, struct comedi_cmd *);
+	int (*do_cmdtest) (struct comedi_device *, struct comedi_subdevice *,
+			   struct comedi_cmd *);
 	int (*poll) (struct comedi_device *, struct comedi_subdevice *);
 	int (*poll) (struct comedi_device *, struct comedi_subdevice *);
 	int (*cancel) (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_lock)(struct comedi_device *,struct comedi_subdevice *); */
 	/* int (*do_unlock)(struct comedi_device *,struct comedi_subdevice *); */
 	/* int (*do_unlock)(struct comedi_device *,struct comedi_subdevice *); */
 
 
 	/* called when the buffer changes */
 	/* 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 * dev,
+			   struct comedi_subdevice * s, unsigned long new_size);
 
 
-	void (*munge) (struct comedi_device *dev, struct comedi_subdevice *s, void *data,
-		unsigned int num_bytes, unsigned int start_chan_index);
+	void (*munge) (struct comedi_device * dev, struct comedi_subdevice * s,
+		       void *data, unsigned int num_bytes,
+		       unsigned int start_chan_index);
 	enum dma_data_direction async_dma_dir;
 	enum dma_data_direction async_dma_dir;
 
 
 	unsigned int state;
 	unsigned int state;
@@ -231,7 +233,7 @@ struct comedi_async {
 	int (*cb_func) (unsigned int flags, void *);
 	int (*cb_func) (unsigned int flags, void *);
 	void *cb_arg;
 	void *cb_arg;
 
 
-	int (*inttrig) (struct comedi_device *dev, struct comedi_subdevice *s,
+	int (*inttrig) (struct comedi_device * dev, struct comedi_subdevice * s,
 			unsigned int x);
 			unsigned int x);
 };
 };
 
 
@@ -281,8 +283,8 @@ struct comedi_device {
 
 
 	struct fasync_struct *async_queue;
 	struct fasync_struct *async_queue;
 
 
-	void (*open) (struct comedi_device *dev);
-	void (*close) (struct comedi_device *dev);
+	void (*open) (struct comedi_device * dev);
+	void (*close) (struct comedi_device * dev);
 };
 };
 
 
 struct comedi_device_file_info {
 struct comedi_device_file_info {
@@ -316,8 +318,9 @@ static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1;
 
 
 struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor);
 struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor);
 
 
-static inline struct comedi_subdevice *comedi_get_read_subdevice(
-				const struct comedi_device_file_info *info)
+static inline struct comedi_subdevice *comedi_get_read_subdevice(const struct
+								 comedi_device_file_info
+								 *info)
 {
 {
 	if (info->read_subdevice)
 	if (info->read_subdevice)
 		return info->read_subdevice;
 		return info->read_subdevice;
@@ -326,8 +329,9 @@ static inline struct comedi_subdevice *comedi_get_read_subdevice(
 	return info->device->read_subdev;
 	return info->device->read_subdev;
 }
 }
 
 
-static inline struct comedi_subdevice *comedi_get_write_subdevice(
-				const struct comedi_device_file_info *info)
+static inline struct comedi_subdevice *comedi_get_write_subdevice(const struct
+								  comedi_device_file_info
+								  *info)
 {
 {
 	if (info->write_subdevice)
 	if (info->write_subdevice)
 		return info->write_subdevice;
 		return info->write_subdevice;
@@ -337,7 +341,8 @@ static inline struct comedi_subdevice *comedi_get_write_subdevice(
 }
 }
 
 
 void comedi_device_detach(struct comedi_device *dev);
 void comedi_device_detach(struct comedi_device *dev);
-int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+int comedi_device_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 int comedi_driver_register(struct comedi_driver *);
 int comedi_driver_register(struct comedi_driver *);
 int comedi_driver_unregister(struct comedi_driver *);
 int comedi_driver_unregister(struct comedi_driver *);
 
 
@@ -346,8 +351,8 @@ void cleanup_polling(void);
 void start_polling(struct comedi_device *);
 void start_polling(struct comedi_device *);
 void stop_polling(struct comedi_device *);
 void stop_polling(struct comedi_device *);
 
 
-int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, unsigned long
-	new_size);
+int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
+		     unsigned long new_size);
 
 
 #ifdef CONFIG_PROC_FS
 #ifdef CONFIG_PROC_FS
 void comedi_proc_init(void);
 void comedi_proc_init(void);
@@ -356,6 +361,7 @@ void comedi_proc_cleanup(void);
 static inline void comedi_proc_init(void)
 static inline void comedi_proc_init(void)
 {
 {
 }
 }
+
 static inline void comedi_proc_cleanup(void)
 static inline void comedi_proc_cleanup(void)
 {
 {
 }
 }
@@ -378,10 +384,10 @@ enum subdevice_runflags {
 int do_rangeinfo_ioctl(struct comedi_device *dev, struct comedi_rangeinfo *arg);
 int do_rangeinfo_ioctl(struct comedi_device *dev, struct comedi_rangeinfo *arg);
 int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist);
 int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist);
 void comedi_set_subdevice_runflags(struct comedi_subdevice *s, unsigned mask,
 void comedi_set_subdevice_runflags(struct comedi_subdevice *s, unsigned mask,
-	unsigned bits);
+				   unsigned bits);
 unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s);
 unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s);
 int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s,
 int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+	       struct comedi_insn *insn, unsigned int *data);
 
 
 /* range stuff */
 /* range stuff */
 
 
@@ -421,7 +427,8 @@ static inline int alloc_subdevices(struct comedi_device *dev,
 
 
 	dev->n_subdevices = num_subdevices;
 	dev->n_subdevices = num_subdevices;
 	dev->subdevices =
 	dev->subdevices =
-		kcalloc(num_subdevices, sizeof(struct comedi_subdevice), GFP_KERNEL);
+	    kcalloc(num_subdevices, sizeof(struct comedi_subdevice),
+		    GFP_KERNEL);
 	if (!dev->subdevices)
 	if (!dev->subdevices)
 		return -ENOMEM;
 		return -ENOMEM;
 	for (i = 0; i < num_subdevices; ++i) {
 	for (i = 0; i < num_subdevices; ++i) {
@@ -451,7 +458,8 @@ static inline unsigned int bytes_per_sample(const struct comedi_subdevice *subd)
 
 
 /* must be used in attach to set dev->hw_dev if you wish to dma directly
 /* must be used in attach to set dev->hw_dev if you wish to dma directly
 into comedi's buffer */
 into comedi's buffer */
-static inline void comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev)
+static inline void comedi_set_hw_dev(struct comedi_device *dev,
+				     struct device *hw_dev)
 {
 {
 	if (dev->hw_dev)
 	if (dev->hw_dev)
 		put_device(dev->hw_dev);
 		put_device(dev->hw_dev);
@@ -467,21 +475,23 @@ int comedi_buf_put(struct comedi_async *async, short x);
 int comedi_buf_get(struct comedi_async *async, short *x);
 int comedi_buf_get(struct comedi_async *async, short *x);
 
 
 unsigned int comedi_buf_write_n_available(struct comedi_async *async);
 unsigned int comedi_buf_write_n_available(struct comedi_async *async);
-unsigned int comedi_buf_write_alloc(struct comedi_async *async, unsigned int nbytes);
+unsigned int comedi_buf_write_alloc(struct comedi_async *async,
+				    unsigned int nbytes);
 unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
 unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
-	unsigned int nbytes);
+					   unsigned int nbytes);
 unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes);
 unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes);
 unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes);
 unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes);
 unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes);
 unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes);
 unsigned int comedi_buf_read_n_available(struct comedi_async *async);
 unsigned int comedi_buf_read_n_available(struct comedi_async *async);
 void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
 void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
-	const void *source, unsigned int num_bytes);
+			  const void *source, unsigned int num_bytes);
 void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
 void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
-	void *destination, unsigned int num_bytes);
+			    void *destination, unsigned int num_bytes);
 static inline unsigned comedi_buf_write_n_allocated(struct comedi_async *async)
 static inline unsigned comedi_buf_write_n_allocated(struct comedi_async *async)
 {
 {
 	return async->buf_write_alloc_count - async->buf_write_count;
 	return async->buf_write_alloc_count - async->buf_write_count;
 }
 }
+
 static inline unsigned comedi_buf_read_n_allocated(struct comedi_async *async)
 static inline unsigned comedi_buf_read_n_allocated(struct comedi_async *async)
 {
 {
 	return async->buf_read_alloc_count - async->buf_read_count;
 	return async->buf_read_alloc_count - async->buf_read_count;
@@ -516,25 +526,26 @@ static inline void *comedi_aux_data(int options[], int n)
 
 
 int comedi_alloc_board_minor(struct device *hardware_device);
 int comedi_alloc_board_minor(struct device *hardware_device);
 void comedi_free_board_minor(unsigned minor);
 void comedi_free_board_minor(unsigned minor);
-int comedi_alloc_subdevice_minor(struct comedi_device *dev, struct comedi_subdevice *s);
+int comedi_alloc_subdevice_minor(struct comedi_device *dev,
+				 struct comedi_subdevice *s);
 void comedi_free_subdevice_minor(struct comedi_subdevice *s);
 void comedi_free_subdevice_minor(struct comedi_subdevice *s);
 int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name);
 int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name);
 void comedi_pci_auto_unconfig(struct pci_dev *pcidev);
 void comedi_pci_auto_unconfig(struct pci_dev *pcidev);
-struct usb_device;	/* forward declaration */
+struct usb_device;		/* forward declaration */
 int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name);
 int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name);
 void comedi_usb_auto_unconfig(struct usb_device *usbdev);
 void comedi_usb_auto_unconfig(struct usb_device *usbdev);
 
 
 #ifdef CONFIG_COMEDI_PCI_DRIVERS
 #ifdef CONFIG_COMEDI_PCI_DRIVERS
-	#define CONFIG_COMEDI_PCI
+#define CONFIG_COMEDI_PCI
 #endif
 #endif
 #ifdef CONFIG_COMEDI_PCI_DRIVERS_MODULE
 #ifdef CONFIG_COMEDI_PCI_DRIVERS_MODULE
-	#define CONFIG_COMEDI_PCI
+#define CONFIG_COMEDI_PCI
 #endif
 #endif
 #ifdef CONFIG_COMEDI_PCMCIA_DRIVERS
 #ifdef CONFIG_COMEDI_PCMCIA_DRIVERS
-	#define CONFIG_COMEDI_PCMCIA
+#define CONFIG_COMEDI_PCMCIA
 #endif
 #endif
 #ifdef CONFIG_COMEDI_PCMCIA_DRIVERS_MODULE
 #ifdef CONFIG_COMEDI_PCMCIA_DRIVERS_MODULE
-	#define CONFIG_COMEDI_PCMCIA
+#define CONFIG_COMEDI_PCMCIA
 #endif
 #endif
 
 
 #endif /* _COMEDIDEV_H */
 #endif /* _COMEDIDEV_H */

+ 40 - 37
drivers/staging/comedi/comedilib.h

@@ -58,29 +58,31 @@ int comedi_fileno(void *dev);
 
 
 int comedi_cancel(void *dev, unsigned int subdev);
 int comedi_cancel(void *dev, unsigned int subdev);
 int comedi_register_callback(void *dev, unsigned int subdev,
 int comedi_register_callback(void *dev, unsigned int subdev,
-	unsigned int mask, int (*cb) (unsigned int, void *), void *arg);
+			     unsigned int mask, int (*cb) (unsigned int,
+							   void *), void *arg);
 
 
 int comedi_command(void *dev, struct comedi_cmd *cmd);
 int comedi_command(void *dev, struct comedi_cmd *cmd);
 int comedi_command_test(void *dev, struct comedi_cmd *cmd);
 int comedi_command_test(void *dev, struct comedi_cmd *cmd);
 int comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it);
 int comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it);
 int __comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it);
 int __comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it);
 int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan,
 int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan,
-	unsigned int range, unsigned int aref, unsigned int data);
+		      unsigned int range, unsigned int aref, unsigned int data);
 int comedi_data_read(void *dev, unsigned int subdev, unsigned int chan,
 int comedi_data_read(void *dev, unsigned int subdev, unsigned int chan,
-	unsigned int range, unsigned int aref, unsigned int *data);
+		     unsigned int range, unsigned int aref, unsigned int *data);
 int comedi_data_read_hint(void *dev, unsigned int subdev,
 int comedi_data_read_hint(void *dev, unsigned int subdev,
-	unsigned int chan, unsigned int range, unsigned int aref);
-int comedi_data_read_delayed(void *dev, unsigned int subdev,
-	unsigned int chan, unsigned int range, unsigned int aref,
-	unsigned int *data, unsigned int nano_sec);
+			  unsigned int chan, unsigned int range,
+			  unsigned int aref);
+int comedi_data_read_delayed(void *dev, unsigned int subdev, unsigned int chan,
+			     unsigned int range, unsigned int aref,
+			     unsigned int *data, unsigned int nano_sec);
 int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan,
 int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan,
-	unsigned int io);
+		      unsigned int io);
 int comedi_dio_read(void *dev, unsigned int subdev, unsigned int chan,
 int comedi_dio_read(void *dev, unsigned int subdev, unsigned int chan,
-	unsigned int *val);
+		    unsigned int *val);
 int comedi_dio_write(void *dev, unsigned int subdev, unsigned int chan,
 int comedi_dio_write(void *dev, unsigned int subdev, unsigned int chan,
-	unsigned int val);
+		     unsigned int val);
 int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask,
 int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask,
-	unsigned int *bits);
+			unsigned int *bits);
 int comedi_get_n_subdevices(void *dev);
 int comedi_get_n_subdevices(void *dev);
 int comedi_get_version_code(void *dev);
 int comedi_get_version_code(void *dev);
 const char *comedi_get_driver_name(void *dev);
 const char *comedi_get_driver_name(void *dev);
@@ -89,31 +91,29 @@ int comedi_get_subdevice_type(void *dev, unsigned int subdevice);
 int comedi_find_subdevice_by_type(void *dev, int type, unsigned int subd);
 int comedi_find_subdevice_by_type(void *dev, int type, unsigned int subd);
 int comedi_get_n_channels(void *dev, unsigned int subdevice);
 int comedi_get_n_channels(void *dev, unsigned int subdevice);
 unsigned int comedi_get_maxdata(void *dev, unsigned int subdevice, unsigned
 unsigned int comedi_get_maxdata(void *dev, unsigned int subdevice, unsigned
-	int chan);
-int comedi_get_n_ranges(void *dev, unsigned int subdevice, unsigned int
-	chan);
+				int chan);
+int comedi_get_n_ranges(void *dev, unsigned int subdevice, unsigned int chan);
 int comedi_do_insn(void *dev, struct comedi_insn *insn);
 int comedi_do_insn(void *dev, struct comedi_insn *insn);
 int comedi_poll(void *dev, unsigned int subdev);
 int comedi_poll(void *dev, unsigned int subdev);
 
 
 /* DEPRECATED functions */
 /* DEPRECATED functions */
-int comedi_get_rangetype(void *dev, unsigned int subdevice,
-	unsigned int chan);
+int comedi_get_rangetype(void *dev, unsigned int subdevice, unsigned int chan);
 
 
 /* ALPHA functions */
 /* ALPHA functions */
 unsigned int comedi_get_subdevice_flags(void *dev, unsigned int subdevice);
 unsigned int comedi_get_subdevice_flags(void *dev, unsigned int subdevice);
 int comedi_get_len_chanlist(void *dev, unsigned int subdevice);
 int comedi_get_len_chanlist(void *dev, unsigned int subdevice);
 int comedi_get_krange(void *dev, unsigned int subdevice, unsigned int
 int comedi_get_krange(void *dev, unsigned int subdevice, unsigned int
-	chan, unsigned int range, struct comedi_krange *krange);
+		      chan, unsigned int range, struct comedi_krange *krange);
 unsigned int comedi_get_buf_head_pos(void *dev, unsigned int subdevice);
 unsigned int comedi_get_buf_head_pos(void *dev, unsigned int subdevice);
 int comedi_set_user_int_count(void *dev, unsigned int subdevice,
 int comedi_set_user_int_count(void *dev, unsigned int subdevice,
-	unsigned int buf_user_count);
+			      unsigned int buf_user_count);
 int comedi_map(void *dev, unsigned int subdev, void *ptr);
 int comedi_map(void *dev, unsigned int subdev, void *ptr);
 int comedi_unmap(void *dev, unsigned int subdev);
 int comedi_unmap(void *dev, unsigned int subdev);
 int comedi_get_buffer_size(void *dev, unsigned int subdev);
 int comedi_get_buffer_size(void *dev, unsigned int subdev);
 int comedi_mark_buffer_read(void *dev, unsigned int subdevice,
 int comedi_mark_buffer_read(void *dev, unsigned int subdevice,
-	unsigned int num_bytes);
+			    unsigned int num_bytes);
 int comedi_mark_buffer_written(void *d, unsigned int subdevice,
 int comedi_mark_buffer_written(void *d, unsigned int subdevice,
-	unsigned int num_bytes);
+			       unsigned int num_bytes);
 int comedi_get_buffer_contents(void *dev, unsigned int subdevice);
 int comedi_get_buffer_contents(void *dev, unsigned int subdevice);
 int comedi_get_buffer_offset(void *dev, unsigned int subdevice);
 int comedi_get_buffer_offset(void *dev, unsigned int subdevice);
 
 
@@ -135,53 +135,56 @@ int comedi_unlock(unsigned int minor, unsigned int subdev);
 
 
 int comedi_cancel(unsigned int minor, unsigned int subdev);
 int comedi_cancel(unsigned int minor, unsigned int subdev);
 int comedi_register_callback(unsigned int minor, unsigned int subdev,
 int comedi_register_callback(unsigned int minor, unsigned int subdev,
-	unsigned int mask, int (*cb) (unsigned int, void *), void *arg);
+			     unsigned int mask, int (*cb) (unsigned int,
+							   void *), void *arg);
 
 
 int comedi_command(unsigned int minor, struct comedi_cmd *cmd);
 int comedi_command(unsigned int minor, struct comedi_cmd *cmd);
 int comedi_command_test(unsigned int minor, struct comedi_cmd *cmd);
 int comedi_command_test(unsigned int minor, struct comedi_cmd *cmd);
-int comedi_trigger(unsigned int minor, unsigned int subdev, struct comedi_trig *it);
-int __comedi_trigger(unsigned int minor, unsigned int subdev, struct comedi_trig *it);
+int comedi_trigger(unsigned int minor, unsigned int subdev,
+		   struct comedi_trig *it);
+int __comedi_trigger(unsigned int minor, unsigned int subdev,
+		     struct comedi_trig *it);
 int comedi_data_write(unsigned int dev, unsigned int subdev, unsigned int chan,
 int comedi_data_write(unsigned int dev, unsigned int subdev, unsigned int chan,
-	unsigned int range, unsigned int aref, unsigned int data);
+		      unsigned int range, unsigned int aref, unsigned int data);
 int comedi_data_read(unsigned int dev, unsigned int subdev, unsigned int chan,
 int comedi_data_read(unsigned int dev, unsigned int subdev, unsigned int chan,
-	unsigned int range, unsigned int aref, unsigned int *data);
+		     unsigned int range, unsigned int aref, unsigned int *data);
 int comedi_dio_config(unsigned int dev, unsigned int subdev, unsigned int chan,
 int comedi_dio_config(unsigned int dev, unsigned int subdev, unsigned int chan,
-	unsigned int io);
+		      unsigned int io);
 int comedi_dio_read(unsigned int dev, unsigned int subdev, unsigned int chan,
 int comedi_dio_read(unsigned int dev, unsigned int subdev, unsigned int chan,
-	unsigned int *val);
+		    unsigned int *val);
 int comedi_dio_write(unsigned int dev, unsigned int subdev, unsigned int chan,
 int comedi_dio_write(unsigned int dev, unsigned int subdev, unsigned int chan,
-	unsigned int val);
+		     unsigned int val);
 int comedi_dio_bitfield(unsigned int dev, unsigned int subdev,
 int comedi_dio_bitfield(unsigned int dev, unsigned int subdev,
-	unsigned int mask, unsigned int *bits);
+			unsigned int mask, unsigned int *bits);
 int comedi_get_n_subdevices(unsigned int dev);
 int comedi_get_n_subdevices(unsigned int dev);
 int comedi_get_version_code(unsigned int dev);
 int comedi_get_version_code(unsigned int dev);
 char *comedi_get_driver_name(unsigned int dev);
 char *comedi_get_driver_name(unsigned int dev);
 char *comedi_get_board_name(unsigned int minor);
 char *comedi_get_board_name(unsigned int minor);
 int comedi_get_subdevice_type(unsigned int minor, unsigned int subdevice);
 int comedi_get_subdevice_type(unsigned int minor, unsigned int subdevice);
 int comedi_find_subdevice_by_type(unsigned int minor, int type,
 int comedi_find_subdevice_by_type(unsigned int minor, int type,
-	unsigned int subd);
+				  unsigned int subd);
 int comedi_get_n_channels(unsigned int minor, unsigned int subdevice);
 int comedi_get_n_channels(unsigned int minor, unsigned int subdevice);
 unsigned int comedi_get_maxdata(unsigned int minor, unsigned int subdevice, unsigned
 unsigned int comedi_get_maxdata(unsigned int minor, unsigned int subdevice, unsigned
-	int chan);
+				int chan);
 int comedi_get_n_ranges(unsigned int minor, unsigned int subdevice, unsigned int
 int comedi_get_n_ranges(unsigned int minor, unsigned int subdevice, unsigned int
-	chan);
+			chan);
 int comedi_do_insn(unsigned int minor, struct comedi_insn *insn);
 int comedi_do_insn(unsigned int minor, struct comedi_insn *insn);
 int comedi_poll(unsigned int minor, unsigned int subdev);
 int comedi_poll(unsigned int minor, unsigned int subdev);
 
 
 /* DEPRECATED functions */
 /* DEPRECATED functions */
 int comedi_get_rangetype(unsigned int minor, unsigned int subdevice,
 int comedi_get_rangetype(unsigned int minor, unsigned int subdevice,
-	unsigned int chan);
+			 unsigned int chan);
 
 
 /* ALPHA functions */
 /* ALPHA functions */
 unsigned int comedi_get_subdevice_flags(unsigned int minor, unsigned int
 unsigned int comedi_get_subdevice_flags(unsigned int minor, unsigned int
-	subdevice);
+					subdevice);
 int comedi_get_len_chanlist(unsigned int minor, unsigned int subdevice);
 int comedi_get_len_chanlist(unsigned int minor, unsigned int subdevice);
 int comedi_get_krange(unsigned int minor, unsigned int subdevice, unsigned int
 int comedi_get_krange(unsigned int minor, unsigned int subdevice, unsigned int
-	chan, unsigned int range, struct comedi_krange *krange);
+		      chan, unsigned int range, struct comedi_krange *krange);
 unsigned int comedi_get_buf_head_pos(unsigned int minor, unsigned int
 unsigned int comedi_get_buf_head_pos(unsigned int minor, unsigned int
-	subdevice);
+				     subdevice);
 int comedi_set_user_int_count(unsigned int minor, unsigned int subdevice,
 int comedi_set_user_int_count(unsigned int minor, unsigned int subdevice,
-	unsigned int buf_user_count);
+			      unsigned int buf_user_count);
 int comedi_map(unsigned int minor, unsigned int subdev, void **ptr);
 int comedi_map(unsigned int minor, unsigned int subdev, void **ptr);
 int comedi_unmap(unsigned int minor, unsigned int subdev);
 int comedi_unmap(unsigned int minor, unsigned int subdev);
 
 

+ 102 - 82
drivers/staging/comedi/drivers.c

@@ -48,13 +48,14 @@
 #include <asm/system.h>
 #include <asm/system.h>
 
 
 static int postconfig(struct comedi_device *dev);
 static int postconfig(struct comedi_device *dev);
-static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static void *comedi_recognize(struct comedi_driver * driv, const char *name);
+static int insn_rw_emulate_bits(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data);
+static void *comedi_recognize(struct comedi_driver *driv, const char *name);
 static void comedi_report_boards(struct comedi_driver *driv);
 static void comedi_report_boards(struct comedi_driver *driv);
 static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s);
 static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s);
 int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
 int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned long new_size);
+		     unsigned long new_size);
 
 
 struct comedi_driver *comedi_drivers;
 struct comedi_driver *comedi_drivers;
 
 
@@ -123,7 +124,8 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 
 	for (driv = comedi_drivers; driv; driv = driv->next) {
 	for (driv = comedi_drivers; driv; driv = driv->next) {
 		if (!try_module_get(driv->module)) {
 		if (!try_module_get(driv->module)) {
-			printk("comedi: failed to increment module count, skipping\n");
+			printk
+			    ("comedi: failed to increment module count, skipping\n");
 			continue;
 			continue;
 		}
 		}
 		if (driv->num_names) {
 		if (driv->num_names) {
@@ -195,16 +197,20 @@ int comedi_driver_unregister(struct comedi_driver *driver)
 
 
 	/* check for devices using this driver */
 	/* check for devices using this driver */
 	for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
 	for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) {
-		struct comedi_device_file_info *dev_file_info = comedi_get_device_file_info(i);
+		struct comedi_device_file_info *dev_file_info =
+		    comedi_get_device_file_info(i);
 		struct comedi_device *dev;
 		struct comedi_device *dev;
 
 
-		if (dev_file_info == NULL) continue;
+		if (dev_file_info == NULL)
+			continue;
 		dev = dev_file_info->device;
 		dev = dev_file_info->device;
 
 
 		mutex_lock(&dev->mutex);
 		mutex_lock(&dev->mutex);
 		if (dev->attached && dev->driver == driver) {
 		if (dev->attached && dev->driver == driver) {
 			if (dev->use_count)
 			if (dev->use_count)
-				printk("BUG! detaching device with use_count=%d\n", dev->use_count);
+				printk
+				    ("BUG! detaching device with use_count=%d\n",
+				     dev->use_count);
 			comedi_device_detach(dev);
 			comedi_device_detach(dev);
 		}
 		}
 		mutex_unlock(&dev->mutex);
 		mutex_unlock(&dev->mutex);
@@ -242,10 +248,11 @@ static int postconfig(struct comedi_device *dev)
 
 
 		if (s->do_cmd) {
 		if (s->do_cmd) {
 			BUG_ON((s->subdev_flags & (SDF_CMD_READ |
 			BUG_ON((s->subdev_flags & (SDF_CMD_READ |
-				SDF_CMD_WRITE)) == 0);
+						   SDF_CMD_WRITE)) == 0);
 			BUG_ON(!s->do_cmdtest);
 			BUG_ON(!s->do_cmdtest);
 
 
-			async = kzalloc(sizeof(struct comedi_async), GFP_KERNEL);
+			async =
+			    kzalloc(sizeof(struct comedi_async), GFP_KERNEL);
 			if (async == NULL) {
 			if (async == NULL) {
 				printk("failed to allocate async struct\n");
 				printk("failed to allocate async struct\n");
 				return -ENOMEM;
 				return -ENOMEM;
@@ -298,7 +305,7 @@ static int postconfig(struct comedi_device *dev)
 }
 }
 
 
 /*  generic recognize function for drivers that register their supported board names */
 /*  generic recognize function for drivers that register their supported board names */
-void *comedi_recognize(struct comedi_driver * driv, const char *name)
+void *comedi_recognize(struct comedi_driver *driv, const char *name)
 {
 {
 	unsigned i;
 	unsigned i;
 	const char *const *name_ptr = driv->board_name;
 	const char *const *name_ptr = driv->board_name;
@@ -306,8 +313,8 @@ void *comedi_recognize(struct comedi_driver * driv, const char *name)
 		if (strcmp(*name_ptr, name) == 0)
 		if (strcmp(*name_ptr, name) == 0)
 			return (void *)name_ptr;
 			return (void *)name_ptr;
 		name_ptr =
 		name_ptr =
-			(const char *const *)((const char *)name_ptr +
-			driv->offset);
+		    (const char *const *)((const char *)name_ptr +
+					  driv->offset);
 	}
 	}
 
 
 	return NULL;
 	return NULL;
@@ -319,7 +326,7 @@ void comedi_report_boards(struct comedi_driver *driv)
 	const char *const *name_ptr;
 	const char *const *name_ptr;
 
 
 	printk("comedi: valid board names for %s driver are:\n",
 	printk("comedi: valid board names for %s driver are:\n",
-		driv->driver_name);
+	       driv->driver_name);
 
 
 	name_ptr = driv->board_name;
 	name_ptr = driv->board_name;
 	for (i = 0; i < driv->num_names; i++) {
 	for (i = 0; i < driv->num_names; i++) {
@@ -337,13 +344,14 @@ static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s)
 }
 }
 
 
 int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s,
 int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+	       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	return -EINVAL;
 	return -EINVAL;
 }
 }
 
 
-static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int insn_rw_emulate_bits(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	struct comedi_insn new_insn;
 	struct comedi_insn new_insn;
 	int ret;
 	int ret;
@@ -351,7 +359,7 @@ static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevi
 
 
 	unsigned chan = CR_CHAN(insn->chanspec);
 	unsigned chan = CR_CHAN(insn->chanspec);
 	const unsigned base_bitfield_channel =
 	const unsigned base_bitfield_channel =
-		(chan < channels_per_bitfield) ? 0 : chan;
+	    (chan < channels_per_bitfield) ? 0 : chan;
 	unsigned int new_data[2];
 	unsigned int new_data[2];
 	memset(new_data, 0, sizeof(new_data));
 	memset(new_data, 0, sizeof(new_data));
 	memset(&new_insn, 0, sizeof(new_insn));
 	memset(&new_insn, 0, sizeof(new_insn));
@@ -379,7 +387,7 @@ static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevi
 	return 1;
 	return 1;
 }
 }
 
 
-static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr)
+static inline unsigned long uvirt_to_kva(pgd_t * pgd, unsigned long adr)
 {
 {
 	unsigned long ret = 0UL;
 	unsigned long ret = 0UL;
 	pmd_t *pmd;
 	pmd_t *pmd;
@@ -394,7 +402,7 @@ static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr)
 			pte = *ptep;
 			pte = *ptep;
 			if (pte_present(pte)) {
 			if (pte_present(pte)) {
 				ret = (unsigned long)
 				ret = (unsigned long)
-					page_address(pte_page(pte));
+				    page_address(pte_page(pte));
 				ret |= (adr & (PAGE_SIZE - 1));
 				ret |= (adr & (PAGE_SIZE - 1));
 			}
 			}
 		}
 		}
@@ -413,7 +421,7 @@ static inline unsigned long kvirt_to_kva(unsigned long adr)
 }
 }
 
 
 int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
 int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned long new_size)
+		     unsigned long new_size)
 {
 {
 	struct comedi_async *async = s->async;
 	struct comedi_async *async = s->async;
 
 
@@ -434,18 +442,22 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
 		unsigned i;
 		unsigned i;
 		for (i = 0; i < async->n_buf_pages; ++i) {
 		for (i = 0; i < async->n_buf_pages; ++i) {
 			if (async->buf_page_list[i].virt_addr) {
 			if (async->buf_page_list[i].virt_addr) {
-				mem_map_unreserve(virt_to_page(async->
-						buf_page_list[i].virt_addr));
+				mem_map_unreserve(virt_to_page
+						  (async->buf_page_list[i].
+						   virt_addr));
 				if (s->async_dma_dir != DMA_NONE) {
 				if (s->async_dma_dir != DMA_NONE) {
 					dma_free_coherent(dev->hw_dev,
 					dma_free_coherent(dev->hw_dev,
-						PAGE_SIZE,
-						async->buf_page_list[i].
-						virt_addr,
-						async->buf_page_list[i].
-						dma_addr);
+							  PAGE_SIZE,
+							  async->
+							  buf_page_list
+							  [i].virt_addr,
+							  async->
+							  buf_page_list
+							  [i].dma_addr);
 				} else {
 				} else {
-					free_page((unsigned long)async->
-						buf_page_list[i].virt_addr);
+					free_page((unsigned long)
+						  async->buf_page_list[i].
+						  virt_addr);
 				}
 				}
 			}
 			}
 		}
 		}
@@ -460,66 +472,69 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
 		struct page **pages = NULL;
 		struct page **pages = NULL;
 
 
 		async->buf_page_list =
 		async->buf_page_list =
-			vmalloc(sizeof(struct comedi_buf_page) * n_pages);
+		    vmalloc(sizeof(struct comedi_buf_page) * n_pages);
 		if (async->buf_page_list) {
 		if (async->buf_page_list) {
 			memset(async->buf_page_list, 0,
 			memset(async->buf_page_list, 0,
-				sizeof(struct comedi_buf_page) * n_pages);
+			       sizeof(struct comedi_buf_page) * n_pages);
 			pages = vmalloc(sizeof(struct page *) * n_pages);
 			pages = vmalloc(sizeof(struct page *) * n_pages);
 		}
 		}
 		if (pages) {
 		if (pages) {
 			for (i = 0; i < n_pages; i++) {
 			for (i = 0; i < n_pages; i++) {
 				if (s->async_dma_dir != DMA_NONE) {
 				if (s->async_dma_dir != DMA_NONE) {
 					async->buf_page_list[i].virt_addr =
 					async->buf_page_list[i].virt_addr =
-						dma_alloc_coherent(dev->hw_dev,
-						PAGE_SIZE,
-						&async->buf_page_list[i].
-						dma_addr,
-						GFP_KERNEL | __GFP_COMP);
+					    dma_alloc_coherent(dev->hw_dev,
+							       PAGE_SIZE,
+							       &async->
+							       buf_page_list
+							       [i].dma_addr,
+							       GFP_KERNEL |
+							       __GFP_COMP);
 				} else {
 				} else {
 					async->buf_page_list[i].virt_addr =
 					async->buf_page_list[i].virt_addr =
-						(void *)
-						get_zeroed_page(GFP_KERNEL);
+					    (void *)
+					    get_zeroed_page(GFP_KERNEL);
 				}
 				}
 				if (async->buf_page_list[i].virt_addr == NULL) {
 				if (async->buf_page_list[i].virt_addr == NULL) {
 					break;
 					break;
 				}
 				}
-				mem_map_reserve(virt_to_page(async->
-						buf_page_list[i].virt_addr));
+				mem_map_reserve(virt_to_page
+						(async->buf_page_list[i].
+						 virt_addr));
 				pages[i] =
 				pages[i] =
-					virt_to_page(async->buf_page_list[i].
-					virt_addr);
+				    virt_to_page(async->
+						 buf_page_list[i].virt_addr);
 			}
 			}
 		}
 		}
 		if (i == n_pages) {
 		if (i == n_pages) {
 			async->prealloc_buf =
 			async->prealloc_buf =
-				vmap(pages, n_pages, VM_MAP,
-				PAGE_KERNEL_NOCACHE);
-		}
-		if (pages) {
-			vfree(pages);
+			    vmap(pages, n_pages, VM_MAP, PAGE_KERNEL_NOCACHE);
 		}
 		}
+		vfree(pages);
+
 		if (async->prealloc_buf == NULL) {
 		if (async->prealloc_buf == NULL) {
 			/* Some allocation failed above. */
 			/* Some allocation failed above. */
 			if (async->buf_page_list) {
 			if (async->buf_page_list) {
 				for (i = 0; i < n_pages; i++) {
 				for (i = 0; i < n_pages; i++) {
 					if (async->buf_page_list[i].virt_addr ==
 					if (async->buf_page_list[i].virt_addr ==
-						NULL) {
+					    NULL) {
 						break;
 						break;
 					}
 					}
-					mem_map_unreserve(virt_to_page(async->
-							buf_page_list[i].
-							virt_addr));
+					mem_map_unreserve(virt_to_page
+							  (async->buf_page_list
+							   [i].virt_addr));
 					if (s->async_dma_dir != DMA_NONE) {
 					if (s->async_dma_dir != DMA_NONE) {
 						dma_free_coherent(dev->hw_dev,
 						dma_free_coherent(dev->hw_dev,
-							PAGE_SIZE,
-							async->buf_page_list[i].
-							virt_addr,
-							async->buf_page_list[i].
-							dma_addr);
+								  PAGE_SIZE,
+								  async->
+								  buf_page_list
+								  [i].virt_addr,
+								  async->
+								  buf_page_list
+								  [i].dma_addr);
 					} else {
 					} else {
-						free_page((unsigned long)async->
-							buf_page_list[i].
-							virt_addr);
+						free_page((unsigned long)
+							  async->buf_page_list
+							  [i].virt_addr);
 					}
 					}
 				}
 				}
 				vfree(async->buf_page_list);
 				vfree(async->buf_page_list);
@@ -536,7 +551,8 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
 
 
 /* munging is applied to data by core as it passes between user
 /* munging is applied to data by core as it passes between user
  * and kernel space */
  * and kernel space */
-unsigned int comedi_buf_munge(struct comedi_async *async, unsigned int num_bytes)
+unsigned int comedi_buf_munge(struct comedi_async *async,
+			      unsigned int num_bytes)
 {
 {
 	struct comedi_subdevice *s = async->subdevice;
 	struct comedi_subdevice *s = async->subdevice;
 	unsigned int count = 0;
 	unsigned int count = 0;
@@ -555,15 +571,15 @@ unsigned int comedi_buf_munge(struct comedi_async *async, unsigned int num_bytes
 		block_size = num_bytes - count;
 		block_size = num_bytes - count;
 		if (block_size < 0) {
 		if (block_size < 0) {
 			printk("%s: %s: bug! block_size is negative\n",
 			printk("%s: %s: bug! block_size is negative\n",
-				__FILE__, __func__);
+			       __FILE__, __func__);
 			break;
 			break;
 		}
 		}
 		if ((int)(async->munge_ptr + block_size -
 		if ((int)(async->munge_ptr + block_size -
-				async->prealloc_bufsz) > 0)
+			  async->prealloc_bufsz) > 0)
 			block_size = async->prealloc_bufsz - async->munge_ptr;
 			block_size = async->prealloc_bufsz - async->munge_ptr;
 
 
 		s->munge(s->device, s, async->prealloc_buf + async->munge_ptr,
 		s->munge(s->device, s, async->prealloc_buf + async->munge_ptr,
-			block_size, async->munge_chan);
+			 block_size, async->munge_chan);
 
 
 		smp_wmb();	/* barrier insures data is munged in buffer before munge_count is incremented */
 		smp_wmb();	/* barrier insures data is munged in buffer before munge_count is incremented */
 
 
@@ -598,7 +614,8 @@ unsigned int comedi_buf_write_n_available(struct comedi_async *async)
 }
 }
 
 
 /* allocates chunk for the writer from free buffer space */
 /* allocates chunk for the writer from free buffer space */
-unsigned int comedi_buf_write_alloc(struct comedi_async *async, unsigned int nbytes)
+unsigned int comedi_buf_write_alloc(struct comedi_async *async,
+				    unsigned int nbytes)
 {
 {
 	unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
 	unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
 
 
@@ -614,7 +631,7 @@ unsigned int comedi_buf_write_alloc(struct comedi_async *async, unsigned int nby
 
 
 /* allocates nothing unless it can completely fulfill the request */
 /* allocates nothing unless it can completely fulfill the request */
 unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
 unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
-	unsigned int nbytes)
+					   unsigned int nbytes)
 {
 {
 	unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
 	unsigned int free_end = async->buf_read_count + async->prealloc_bufsz;
 
 
@@ -632,8 +649,9 @@ unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async,
 unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes)
 unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes)
 {
 {
 	if ((int)(async->buf_write_count + nbytes -
 	if ((int)(async->buf_write_count + nbytes -
-			async->buf_write_alloc_count) > 0) {
-		printk("comedi: attempted to write-free more bytes than have been write-allocated.\n");
+		  async->buf_write_alloc_count) > 0) {
+		printk
+		    ("comedi: attempted to write-free more bytes than have been write-allocated.\n");
 		nbytes = async->buf_write_alloc_count - async->buf_write_count;
 		nbytes = async->buf_write_alloc_count - async->buf_write_count;
 	}
 	}
 	async->buf_write_count += nbytes;
 	async->buf_write_count += nbytes;
@@ -649,7 +667,7 @@ unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes)
 unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes)
 unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes)
 {
 {
 	if ((int)(async->buf_read_alloc_count + nbytes - async->munge_count) >
 	if ((int)(async->buf_read_alloc_count + nbytes - async->munge_count) >
-		0) {
+	    0) {
 		nbytes = async->munge_count - async->buf_read_alloc_count;
 		nbytes = async->munge_count - async->buf_read_alloc_count;
 	}
 	}
 	async->buf_read_alloc_count += nbytes;
 	async->buf_read_alloc_count += nbytes;
@@ -665,8 +683,9 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes)
 	/*  barrier insures data has been read out of buffer before read count is incremented */
 	/*  barrier insures data has been read out of buffer before read count is incremented */
 	smp_mb();
 	smp_mb();
 	if ((int)(async->buf_read_count + nbytes -
 	if ((int)(async->buf_read_count + nbytes -
-			async->buf_read_alloc_count) > 0) {
-		printk("comedi: attempted to read-free more bytes than have been read-allocated.\n");
+		  async->buf_read_alloc_count) > 0) {
+		printk
+		    ("comedi: attempted to read-free more bytes than have been read-allocated.\n");
 		nbytes = async->buf_read_alloc_count - async->buf_read_count;
 		nbytes = async->buf_read_alloc_count - async->buf_read_count;
 	}
 	}
 	async->buf_read_count += nbytes;
 	async->buf_read_count += nbytes;
@@ -676,7 +695,7 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes)
 }
 }
 
 
 void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
 void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
-	const void *data, unsigned int num_bytes)
+			  const void *data, unsigned int num_bytes)
 {
 {
 	unsigned int write_ptr = async->buf_write_ptr + offset;
 	unsigned int write_ptr = async->buf_write_ptr + offset;
 
 
@@ -701,7 +720,7 @@ void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset,
 }
 }
 
 
 void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
 void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
-	void *dest, unsigned int nbytes)
+			    void *dest, unsigned int nbytes)
 {
 {
 	void *src;
 	void *src;
 	unsigned int read_ptr = async->buf_read_ptr + offset;
 	unsigned int read_ptr = async->buf_read_ptr + offset;
@@ -748,7 +767,7 @@ int comedi_buf_get(struct comedi_async *async, short *x)
 	if (n < sizeof(short))
 	if (n < sizeof(short))
 		return 0;
 		return 0;
 	comedi_buf_read_alloc(async, sizeof(short));
 	comedi_buf_read_alloc(async, sizeof(short));
-	*x = *(short *) (async->prealloc_buf + async->buf_read_ptr);
+	*x = *(short *)(async->prealloc_buf + async->buf_read_ptr);
 	comedi_buf_read_free(async, sizeof(short));
 	comedi_buf_read_free(async, sizeof(short));
 	return 1;
 	return 1;
 }
 }
@@ -761,7 +780,7 @@ int comedi_buf_put(struct comedi_async *async, short x)
 		async->events |= COMEDI_CB_ERROR;
 		async->events |= COMEDI_CB_ERROR;
 		return 0;
 		return 0;
 	}
 	}
-	*(short *) (async->prealloc_buf + async->buf_write_ptr) = x;
+	*(short *)(async->prealloc_buf + async->buf_write_ptr) = x;
 	comedi_buf_write_free(async, sizeof(short));
 	comedi_buf_write_free(async, sizeof(short));
 	return 1;
 	return 1;
 }
 }
@@ -785,7 +804,8 @@ void comedi_reset_async_buf(struct comedi_async *async)
 	async->events = 0;
 	async->events = 0;
 }
 }
 
 
-int comedi_auto_config(struct device *hardware_device, const char *board_name, const int *options, unsigned num_options)
+int comedi_auto_config(struct device *hardware_device, const char *board_name,
+		       const int *options, unsigned num_options)
 {
 {
 	struct comedi_devconfig it;
 	struct comedi_devconfig it;
 	int minor;
 	int minor;
@@ -799,7 +819,8 @@ int comedi_auto_config(struct device *hardware_device, const char *board_name, c
 	}
 	}
 
 
 	minor = comedi_alloc_board_minor(hardware_device);
 	minor = comedi_alloc_board_minor(hardware_device);
-	if (minor < 0) return minor;
+	if (minor < 0)
+		return minor;
 
 
 	private_data = kmalloc(sizeof(unsigned), GFP_KERNEL);
 	private_data = kmalloc(sizeof(unsigned), GFP_KERNEL);
 	if (private_data == NULL) {
 	if (private_data == NULL) {
@@ -822,8 +843,7 @@ int comedi_auto_config(struct device *hardware_device, const char *board_name, c
 	mutex_unlock(&dev_file_info->device->mutex);
 	mutex_unlock(&dev_file_info->device->mutex);
 
 
 cleanup:
 cleanup:
-	if (retval < 0)
-	{
+	if (retval < 0) {
 		kfree(private_data);
 		kfree(private_data);
 		comedi_free_board_minor(minor);
 		comedi_free_board_minor(minor);
 	}
 	}
@@ -833,7 +853,8 @@ cleanup:
 void comedi_auto_unconfig(struct device *hardware_device)
 void comedi_auto_unconfig(struct device *hardware_device)
 {
 {
 	unsigned *minor = (unsigned *)dev_get_drvdata(hardware_device);
 	unsigned *minor = (unsigned *)dev_get_drvdata(hardware_device);
-	if (minor == NULL) return;
+	if (minor == NULL)
+		return;
 
 
 	BUG_ON(*minor >= COMEDI_NUM_BOARD_MINORS);
 	BUG_ON(*minor >= COMEDI_NUM_BOARD_MINORS);
 
 
@@ -860,8 +881,7 @@ void comedi_pci_auto_unconfig(struct pci_dev *pcidev)
 	comedi_auto_unconfig(&pcidev->dev);
 	comedi_auto_unconfig(&pcidev->dev);
 }
 }
 
 
-int comedi_usb_auto_config(struct usb_device *usbdev,
-	const char *board_name)
+int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name)
 {
 {
 	BUG_ON(usbdev == NULL);
 	BUG_ON(usbdev == NULL);
 	return comedi_auto_config(&usbdev->dev, board_name, NULL, 0);
 	return comedi_auto_config(&usbdev->dev, board_name, NULL, 0);

+ 42 - 27
drivers/staging/comedi/drivers/8253.h

@@ -29,8 +29,10 @@
 #define i8253_cascade_ns_to_timer i8253_cascade_ns_to_timer_2div
 #define i8253_cascade_ns_to_timer i8253_cascade_ns_to_timer_2div
 
 
 static inline void i8253_cascade_ns_to_timer_2div_old(int i8253_osc_base,
 static inline void i8253_cascade_ns_to_timer_2div_old(int i8253_osc_base,
-	unsigned int *d1, unsigned int *d2, unsigned int *nanosec,
-	int round_mode)
+						      unsigned int *d1,
+						      unsigned int *d2,
+						      unsigned int *nanosec,
+						      int round_mode)
 {
 {
 	int divider;
 	int divider;
 	int div1, div2;
 	int div1, div2;
@@ -78,8 +80,10 @@ static inline void i8253_cascade_ns_to_timer_2div_old(int i8253_osc_base,
 }
 }
 
 
 static inline void i8253_cascade_ns_to_timer_power(int i8253_osc_base,
 static inline void i8253_cascade_ns_to_timer_power(int i8253_osc_base,
-	unsigned int *d1, unsigned int *d2, unsigned int *nanosec,
-	int round_mode)
+						   unsigned int *d1,
+						   unsigned int *d2,
+						   unsigned int *nanosec,
+						   int round_mode)
 {
 {
 	int div1, div2;
 	int div1, div2;
 	int base;
 	int base;
@@ -118,8 +122,10 @@ static inline void i8253_cascade_ns_to_timer_power(int i8253_osc_base,
 }
 }
 
 
 static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
 static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
-	unsigned int *d1, unsigned int *d2, unsigned int *nanosec,
-	int round_mode)
+						  unsigned int *d1,
+						  unsigned int *d2,
+						  unsigned int *nanosec,
+						  int round_mode)
 {
 {
 	unsigned int divider;
 	unsigned int divider;
 	unsigned int div1, div2;
 	unsigned int div1, div2;
@@ -136,12 +142,11 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
 	div2 = *d2 ? *d2 : max_count;
 	div2 = *d2 ? *d2 : max_count;
 	divider = div1 * div2;
 	divider = div1 * div2;
 	if (div1 * div2 * i8253_osc_base == *nanosec &&
 	if (div1 * div2 * i8253_osc_base == *nanosec &&
-		div1 > 1 && div1 <= max_count &&
-		div2 > 1 && div2 <= max_count &&
-		/* check for overflow */
-		divider > div1 && divider > div2 &&
-		divider * i8253_osc_base > divider &&
-		divider * i8253_osc_base > i8253_osc_base) {
+	    div1 > 1 && div1 <= max_count && div2 > 1 && div2 <= max_count &&
+	    /* check for overflow */
+	    divider > div1 && divider > div2 &&
+	    divider * i8253_osc_base > divider &&
+	    divider * i8253_osc_base > i8253_osc_base) {
 		return;
 		return;
 	}
 	}
 
 
@@ -158,10 +163,10 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
 	if (start < 2)
 	if (start < 2)
 		start = 2;
 		start = 2;
 	for (div1 = start; div1 <= divider / div1 + 1 && div1 <= max_count;
 	for (div1 = start; div1 <= divider / div1 + 1 && div1 <= max_count;
-		div1++) {
+	     div1++) {
 		for (div2 = divider / div1;
 		for (div2 = divider / div1;
-			div1 * div2 <= divider + div1 + 1 && div2 <= max_count;
-			div2++) {
+		     div1 * div2 <= divider + div1 + 1 && div2 <= max_count;
+		     div2++) {
 			ns = i8253_osc_base * div1 * div2;
 			ns = i8253_osc_base * div1 * div2;
 			if (ns <= *nanosec && ns > ns_glb) {
 			if (ns <= *nanosec && ns > ns_glb) {
 				ns_glb = ns;
 				ns_glb = ns;
@@ -229,7 +234,8 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base,
 #define i8254_control_reg	3
 #define i8254_control_reg	3
 
 
 static inline int i8254_load(unsigned long base_address, unsigned int regshift,
 static inline int i8254_load(unsigned long base_address, unsigned int regshift,
-	unsigned int counter_number, unsigned int count, unsigned int mode)
+			     unsigned int counter_number, unsigned int count,
+			     unsigned int mode)
 {
 {
 	unsigned int byte;
 	unsigned int byte;
 
 
@@ -255,7 +261,8 @@ static inline int i8254_load(unsigned long base_address, unsigned int regshift,
 }
 }
 
 
 static inline int i8254_mm_load(void *base_address, unsigned int regshift,
 static inline int i8254_mm_load(void *base_address, unsigned int regshift,
-	unsigned int counter_number, unsigned int count, unsigned int mode)
+				unsigned int counter_number, unsigned int count,
+				unsigned int mode)
 {
 {
 	unsigned int byte;
 	unsigned int byte;
 
 
@@ -282,7 +289,7 @@ static inline int i8254_mm_load(void *base_address, unsigned int regshift,
 
 
 /* Returns 16 bit counter value, should work for 8253 also.*/
 /* Returns 16 bit counter value, should work for 8253 also.*/
 static inline int i8254_read(unsigned long base_address, unsigned int regshift,
 static inline int i8254_read(unsigned long base_address, unsigned int regshift,
-	unsigned int counter_number)
+			     unsigned int counter_number)
 {
 {
 	unsigned int byte;
 	unsigned int byte;
 	int ret;
 	int ret;
@@ -303,7 +310,7 @@ static inline int i8254_read(unsigned long base_address, unsigned int regshift,
 }
 }
 
 
 static inline int i8254_mm_read(void *base_address, unsigned int regshift,
 static inline int i8254_mm_read(void *base_address, unsigned int regshift,
-	unsigned int counter_number)
+				unsigned int counter_number)
 {
 {
 	unsigned int byte;
 	unsigned int byte;
 	int ret;
 	int ret;
@@ -325,7 +332,8 @@ static inline int i8254_mm_read(void *base_address, unsigned int regshift,
 
 
 /* Loads 16 bit initial counter value, should work for 8253 also. */
 /* Loads 16 bit initial counter value, should work for 8253 also. */
 static inline void i8254_write(unsigned long base_address,
 static inline void i8254_write(unsigned long base_address,
-	unsigned int regshift, unsigned int counter_number, unsigned int count)
+			       unsigned int regshift,
+			       unsigned int counter_number, unsigned int count)
 {
 {
 	unsigned int byte;
 	unsigned int byte;
 
 
@@ -339,7 +347,9 @@ static inline void i8254_write(unsigned long base_address,
 }
 }
 
 
 static inline void i8254_mm_write(void *base_address,
 static inline void i8254_mm_write(void *base_address,
-	unsigned int regshift, unsigned int counter_number, unsigned int count)
+				  unsigned int regshift,
+				  unsigned int counter_number,
+				  unsigned int count)
 {
 {
 	unsigned int byte;
 	unsigned int byte;
 
 
@@ -360,7 +370,8 @@ static inline void i8254_mm_write(void *base_address,
  *   I8254_BCD, I8254_BINARY
  *   I8254_BCD, I8254_BINARY
  */
  */
 static inline int i8254_set_mode(unsigned long base_address,
 static inline int i8254_set_mode(unsigned long base_address,
-	unsigned int regshift, unsigned int counter_number, unsigned int mode)
+				 unsigned int regshift,
+				 unsigned int counter_number, unsigned int mode)
 {
 {
 	unsigned int byte;
 	unsigned int byte;
 
 
@@ -378,7 +389,9 @@ static inline int i8254_set_mode(unsigned long base_address,
 }
 }
 
 
 static inline int i8254_mm_set_mode(void *base_address,
 static inline int i8254_mm_set_mode(void *base_address,
-	unsigned int regshift, unsigned int counter_number, unsigned int mode)
+				    unsigned int regshift,
+				    unsigned int counter_number,
+				    unsigned int mode)
 {
 {
 	unsigned int byte;
 	unsigned int byte;
 
 
@@ -396,18 +409,20 @@ static inline int i8254_mm_set_mode(void *base_address,
 }
 }
 
 
 static inline int i8254_status(unsigned long base_address,
 static inline int i8254_status(unsigned long base_address,
-	unsigned int regshift, unsigned int counter_number)
+			       unsigned int regshift,
+			       unsigned int counter_number)
 {
 {
 	outb(0xE0 | (2 << counter_number),
 	outb(0xE0 | (2 << counter_number),
-		base_address + (i8254_control_reg << regshift));
+	     base_address + (i8254_control_reg << regshift));
 	return inb(base_address + (counter_number << regshift));
 	return inb(base_address + (counter_number << regshift));
 }
 }
 
 
 static inline int i8254_mm_status(void *base_address,
 static inline int i8254_mm_status(void *base_address,
-	unsigned int regshift, unsigned int counter_number)
+				  unsigned int regshift,
+				  unsigned int counter_number)
 {
 {
 	writeb(0xE0 | (2 << counter_number),
 	writeb(0xE0 | (2 << counter_number),
-		base_address + (i8254_control_reg << regshift));
+	       base_address + (i8254_control_reg << regshift));
 	return readb(base_address + (counter_number << regshift));
 	return readb(base_address + (counter_number << regshift));
 }
 }
 
 

+ 32 - 22
drivers/staging/comedi/drivers/8255.c

@@ -105,7 +105,8 @@ struct subdev_8255_struct {
 #define CALLBACK_FUNC	(((struct subdev_8255_struct *)s->private)->cb_func)
 #define CALLBACK_FUNC	(((struct subdev_8255_struct *)s->private)->cb_func)
 #define subdevpriv	((struct subdev_8255_struct *)s->private)
 #define subdevpriv	((struct subdev_8255_struct *)s->private)
 
 
-static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig * it);
+static int dev_8255_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it);
 static int dev_8255_detach(struct comedi_device *dev);
 static int dev_8255_detach(struct comedi_device *dev);
 static struct comedi_driver driver_8255 = {
 static struct comedi_driver driver_8255 = {
 	.driver_name = "8255",
 	.driver_name = "8255",
@@ -116,9 +117,10 @@ static struct comedi_driver driver_8255 = {
 
 
 COMEDI_INITCLEANUP(driver_8255);
 COMEDI_INITCLEANUP(driver_8255);
 
 
-static void do_config(struct comedi_device *dev, struct comedi_subdevice * s);
+static void do_config(struct comedi_device *dev, struct comedi_subdevice *s);
 
 
-void subdev_8255_interrupt(struct comedi_device *dev, struct comedi_subdevice * s)
+void subdev_8255_interrupt(struct comedi_device *dev,
+			   struct comedi_subdevice *s)
 {
 {
 	short d;
 	short d;
 
 
@@ -143,8 +145,9 @@ static int subdev_8255_cb(int dir, int port, int data, unsigned long arg)
 	}
 	}
 }
 }
 
 
-static int subdev_8255_insn(struct comedi_device *dev, struct comedi_subdevice * s,
-	struct comedi_insn *insn, unsigned int *data)
+static int subdev_8255_insn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (data[0]) {
 	if (data[0]) {
 		s->state &= ~data[0];
 		s->state &= ~data[0];
@@ -152,13 +155,13 @@ static int subdev_8255_insn(struct comedi_device *dev, struct comedi_subdevice *
 
 
 		if (data[0] & 0xff)
 		if (data[0] & 0xff)
 			CALLBACK_FUNC(1, _8255_DATA, s->state & 0xff,
 			CALLBACK_FUNC(1, _8255_DATA, s->state & 0xff,
-				CALLBACK_ARG);
+				      CALLBACK_ARG);
 		if (data[0] & 0xff00)
 		if (data[0] & 0xff00)
 			CALLBACK_FUNC(1, _8255_DATA + 1, (s->state >> 8) & 0xff,
 			CALLBACK_FUNC(1, _8255_DATA + 1, (s->state >> 8) & 0xff,
-				CALLBACK_ARG);
+				      CALLBACK_ARG);
 		if (data[0] & 0xff0000)
 		if (data[0] & 0xff0000)
 			CALLBACK_FUNC(1, _8255_DATA + 2,
 			CALLBACK_FUNC(1, _8255_DATA + 2,
-				(s->state >> 16) & 0xff, CALLBACK_ARG);
+				      (s->state >> 16) & 0xff, CALLBACK_ARG);
 	}
 	}
 
 
 	data[1] = CALLBACK_FUNC(0, _8255_DATA, 0, CALLBACK_ARG);
 	data[1] = CALLBACK_FUNC(0, _8255_DATA, 0, CALLBACK_ARG);
@@ -168,8 +171,9 @@ static int subdev_8255_insn(struct comedi_device *dev, struct comedi_subdevice *
 	return 2;
 	return 2;
 }
 }
 
 
-static int subdev_8255_insn_config(struct comedi_device *dev, struct comedi_subdevice * s,
-	struct comedi_insn *insn, unsigned int *data)
+static int subdev_8255_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int mask;
 	unsigned int mask;
 	unsigned int bits;
 	unsigned int bits;
@@ -205,7 +209,7 @@ static int subdev_8255_insn_config(struct comedi_device *dev, struct comedi_subd
 	return 1;
 	return 1;
 }
 }
 
 
-static void do_config(struct comedi_device *dev, struct comedi_subdevice * s)
+static void do_config(struct comedi_device *dev, struct comedi_subdevice *s)
 {
 {
 	int config;
 	int config;
 
 
@@ -222,8 +226,9 @@ static void do_config(struct comedi_device *dev, struct comedi_subdevice * s)
 	CALLBACK_FUNC(1, _8255_CR, config, CALLBACK_ARG);
 	CALLBACK_FUNC(1, _8255_CR, config, CALLBACK_ARG);
 }
 }
 
 
-static int subdev_8255_cmdtest(struct comedi_device *dev, struct comedi_subdevice * s,
-	struct comedi_cmd *cmd)
+static int subdev_8255_cmdtest(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	unsigned int tmp;
 	unsigned int tmp;
@@ -297,22 +302,25 @@ static int subdev_8255_cmdtest(struct comedi_device *dev, struct comedi_subdevic
 	return 0;
 	return 0;
 }
 }
 
 
-static int subdev_8255_cmd(struct comedi_device *dev, struct comedi_subdevice * s)
+static int subdev_8255_cmd(struct comedi_device *dev,
+			   struct comedi_subdevice *s)
 {
 {
 	/* FIXME */
 	/* FIXME */
 
 
 	return 0;
 	return 0;
 }
 }
 
 
-static int subdev_8255_cancel(struct comedi_device *dev, struct comedi_subdevice * s)
+static int subdev_8255_cancel(struct comedi_device *dev,
+			      struct comedi_subdevice *s)
 {
 {
 	/* FIXME */
 	/* FIXME */
 
 
 	return 0;
 	return 0;
 }
 }
 
 
-int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice * s, int (*cb) (int,
-		int, int, unsigned long), unsigned long arg)
+int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
+		     int (*cb) (int, int, int, unsigned long),
+		     unsigned long arg)
 {
 {
 	s->type = COMEDI_SUBD_DIO;
 	s->type = COMEDI_SUBD_DIO;
 	s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
 	s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
@@ -340,8 +348,9 @@ int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice * s, int
 	return 0;
 	return 0;
 }
 }
 
 
-int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice * s,
-	int (*cb) (int, int, int, unsigned long), unsigned long arg)
+int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
+			 int (*cb) (int, int, int, unsigned long),
+			 unsigned long arg)
 {
 {
 	int ret;
 	int ret;
 
 
@@ -358,7 +367,7 @@ int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice * s,
 	return 0;
 	return 0;
 }
 }
 
 
-void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice * s)
+void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
 {
 {
 	if (s->private) {
 	if (s->private) {
 		/* this test does nothing, so comment it out
 		/* this test does nothing, so comment it out
@@ -376,7 +385,8 @@ void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice * s)
 
 
  */
  */
 
 
-static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig * it)
+static int dev_8255_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it)
 {
 {
 	int ret;
 	int ret;
 	unsigned long iobase;
 	unsigned long iobase;
@@ -410,7 +420,7 @@ static int dev_8255_attach(struct comedi_device *dev, struct comedi_devconfig *
 			dev->subdevices[i].type = COMEDI_SUBD_UNUSED;
 			dev->subdevices[i].type = COMEDI_SUBD_UNUSED;
 		} else {
 		} else {
 			subdev_8255_init(dev, dev->subdevices + i, NULL,
 			subdev_8255_init(dev, dev->subdevices + i, NULL,
-				iobase);
+					 iobase);
 		}
 		}
 	}
 	}
 
 

+ 10 - 6
drivers/staging/comedi/drivers/8255.h

@@ -29,16 +29,20 @@
 #if defined(CONFIG_COMEDI_8255) || defined(CONFIG_COMEDI_8255_MODULE)
 #if defined(CONFIG_COMEDI_8255) || defined(CONFIG_COMEDI_8255_MODULE)
 
 
 int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
 int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
-	int (*cb) (int, int, int, unsigned long), unsigned long arg);
+		     int (*cb) (int, int, int, unsigned long),
+		     unsigned long arg);
 int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
 int subdev_8255_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
-	int (*cb) (int, int, int, unsigned long), unsigned long arg);
+			 int (*cb) (int, int, int, unsigned long),
+			 unsigned long arg);
 void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s);
 void subdev_8255_cleanup(struct comedi_device *dev, struct comedi_subdevice *s);
-void subdev_8255_interrupt(struct comedi_device *dev, struct comedi_subdevice *s);
+void subdev_8255_interrupt(struct comedi_device *dev,
+			   struct comedi_subdevice *s);
 
 
 #else
 #else
 
 
-static inline int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
-	void *x, unsigned long y)
+static inline int subdev_8255_init(struct comedi_device *dev,
+				   struct comedi_subdevice *s, void *x,
+				   unsigned long y)
 {
 {
 	printk("8255 support not configured -- disabling subdevice\n");
 	printk("8255 support not configured -- disabling subdevice\n");
 
 
@@ -48,7 +52,7 @@ static inline int subdev_8255_init(struct comedi_device *dev, struct comedi_subd
 }
 }
 
 
 static inline void subdev_8255_cleanup(struct comedi_device *dev,
 static inline void subdev_8255_cleanup(struct comedi_device *dev,
-	struct comedi_subdevice *s)
+				       struct comedi_subdevice *s)
 {
 {
 }
 }
 
 

+ 13 - 9
drivers/staging/comedi/drivers/acl7225b.c

@@ -22,7 +22,8 @@ Devices: [Adlink] ACL-7225b (acl7225b), [ICP] P16R16DIO (p16r16dio)
 #define ACL7225_DI_LO  2	/* Digital input low byte (DI0-DI7) */
 #define ACL7225_DI_LO  2	/* Digital input low byte (DI0-DI7) */
 #define ACL7225_DI_HI  3	/* Digital input high byte (DI8-DI15) */
 #define ACL7225_DI_HI  3	/* Digital input high byte (DI8-DI15) */
 
 
-static int acl7225b_attach(struct comedi_device *dev, struct comedi_devconfig * it);
+static int acl7225b_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it);
 static int acl7225b_detach(struct comedi_device *dev);
 static int acl7225b_detach(struct comedi_device *dev);
 
 
 struct boardtype {
 struct boardtype {
@@ -50,8 +51,9 @@ static struct comedi_driver driver_acl7225b = {
 
 
 COMEDI_INITCLEANUP(driver_acl7225b);
 COMEDI_INITCLEANUP(driver_acl7225b);
 
 
-static int acl7225b_do_insn(struct comedi_device *dev, struct comedi_subdevice * s,
-	struct comedi_insn *insn, unsigned int *data)
+static int acl7225b_do_insn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -64,26 +66,28 @@ static int acl7225b_do_insn(struct comedi_device *dev, struct comedi_subdevice *
 		outb(s->state & 0xff, dev->iobase + (unsigned long)s->private);
 		outb(s->state & 0xff, dev->iobase + (unsigned long)s->private);
 	if (data[0] & 0xff00)
 	if (data[0] & 0xff00)
 		outb((s->state >> 8),
 		outb((s->state >> 8),
-			dev->iobase + (unsigned long)s->private + 1);
+		     dev->iobase + (unsigned long)s->private + 1);
 
 
 	data[1] = s->state;
 	data[1] = s->state;
 
 
 	return 2;
 	return 2;
 }
 }
 
 
-static int acl7225b_di_insn(struct comedi_device *dev, struct comedi_subdevice * s,
-	struct comedi_insn *insn, unsigned int *data)
+static int acl7225b_di_insn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
 
 
 	data[1] = inb(dev->iobase + (unsigned long)s->private) |
 	data[1] = inb(dev->iobase + (unsigned long)s->private) |
-		(inb(dev->iobase + (unsigned long)s->private + 1) << 8);
+	    (inb(dev->iobase + (unsigned long)s->private + 1) << 8);
 
 
 	return 2;
 	return 2;
 }
 }
 
 
-static int acl7225b_attach(struct comedi_device *dev, struct comedi_devconfig * it)
+static int acl7225b_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int iobase, iorange;
 	int iobase, iorange;
@@ -91,7 +95,7 @@ static int acl7225b_attach(struct comedi_device *dev, struct comedi_devconfig *
 	iobase = it->options[0];
 	iobase = it->options[0];
 	iorange = this_board->io_range;
 	iorange = this_board->io_range;
 	printk("comedi%d: acl7225b: board=%s 0x%04x ", dev->minor,
 	printk("comedi%d: acl7225b: board=%s 0x%04x ", dev->minor,
-		this_board->name, iobase);
+	       this_board->name, iobase);
 	if (!request_region(iobase, iorange, "acl7225b")) {
 	if (!request_region(iobase, iorange, "acl7225b")) {
 		printk("I/O port conflict\n");
 		printk("I/O port conflict\n");
 		return -EIO;
 		return -EIO;

+ 3 - 0
drivers/staging/comedi/drivers/addi-data/addi_amcc_s5933.h

@@ -261,6 +261,9 @@ void v_pci_card_list_init(unsigned short pci_vendor, char display)
 			pci_vendor = i_ADDIDATADeviceID[i_Count];
 			pci_vendor = i_ADDIDATADeviceID[i_Count];
 			if (pcidev->vendor == pci_vendor) {
 			if (pcidev->vendor == pci_vendor) {
 				amcc = kmalloc(sizeof(*amcc), GFP_KERNEL);
 				amcc = kmalloc(sizeof(*amcc), GFP_KERNEL);
+				if (amcc == NULL)
+					continue;
+
 				memset(amcc, 0, sizeof(*amcc));
 				memset(amcc, 0, sizeof(*amcc));
 
 
 				amcc->pcidev = pcidev;
 				amcc->pcidev = pcidev;

+ 3 - 0
drivers/staging/comedi/drivers/addi-data/amcc_s5933_58.h

@@ -254,6 +254,9 @@ void v_pci_card_list_init(unsigned short pci_vendor, char display)
 	pci_for_each_dev(pcidev) {
 	pci_for_each_dev(pcidev) {
 		if (pcidev->vendor == pci_vendor) {
 		if (pcidev->vendor == pci_vendor) {
 			amcc = kmalloc(sizeof(*amcc), GFP_KERNEL);
 			amcc = kmalloc(sizeof(*amcc), GFP_KERNEL);
+			if (amcc == NULL)
+				continue;
+
 			memset(amcc, 0, sizeof(*amcc));
 			memset(amcc, 0, sizeof(*amcc));
 
 
 			amcc->pcidev = pcidev;
 			amcc->pcidev = pcidev;

+ 1 - 1
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c

@@ -2669,7 +2669,7 @@ int i_APCI3200_CommandTestAnalogInput(struct comedi_device *dev, struct comedi_s
 			err++;
 			err++;
 			printk("\nThe Delay time base selection is in error\n");
 			printk("\nThe Delay time base selection is in error\n");
 		}
 		}
-		if (ui_DelayTime < 1 && ui_DelayTime > 1023) {
+		if (ui_DelayTime < 1 || ui_DelayTime > 1023) {
 			err++;
 			err++;
 			printk("\nThe Delay time value is in error\n");
 			printk("\nThe Delay time value is in error\n");
 		}
 		}

+ 51 - 42
drivers/staging/comedi/drivers/adl_pci6208.c

@@ -66,23 +66,23 @@ struct pci6208_board {
 
 
 static const struct pci6208_board pci6208_boards[] = {
 static const struct pci6208_board pci6208_boards[] = {
 	/*{
 	/*{
-	.name = "pci6208v",
-	.dev_id = 0x6208,      // not sure
-	.ao_chans = 8
-	   // ,	.ao_bits = 16
+	   .name = "pci6208v",
+	   .dev_id = 0x6208,      // not sure
+	   .ao_chans = 8
+	   // , .ao_bits = 16
 	   },
 	   },
 	   {
 	   {
-	.name = "pci6216v",
-	.dev_id = 0x6208,      // not sure
-	.ao_chans = 16
-	   // ,	.ao_bits = 16
+	   .name = "pci6216v",
+	   .dev_id = 0x6208,      // not sure
+	   .ao_chans = 16
+	   // , .ao_bits = 16
 	   }, */
 	   }, */
 	{
 	{
-	.name = "pci6208a",
-	.dev_id = 0x6208,
-	.ao_chans = 8
-			/* ,	.ao_bits = 16 */
-		}
+	 .name = "pci6208a",
+	 .dev_id = 0x6208,
+	 .ao_chans = 8
+	 /* ,    .ao_bits = 16 */
+	 }
 };
 };
 
 
 /* This is used by modprobe to translate PCI IDs to drivers.  Should
 /* This is used by modprobe to translate PCI IDs to drivers.  Should
@@ -90,8 +90,9 @@ static const struct pci6208_board pci6208_boards[] = {
 static DEFINE_PCI_DEVICE_TABLE(pci6208_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(pci6208_pci_table) = {
 	/* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
 	/* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
 	/* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
 	/* { PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
-	{PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_ADLINK, 0x6208, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, pci6208_pci_table);
 MODULE_DEVICE_TABLE(pci, pci6208_pci_table);
@@ -107,7 +108,8 @@ struct pci6208_private {
 
 
 #define devpriv ((struct pci6208_private *)dev->private)
 #define devpriv ((struct pci6208_private *)dev->private)
 
 
-static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci6208_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int pci6208_detach(struct comedi_device *dev);
 static int pci6208_detach(struct comedi_device *dev);
 
 
 static struct comedi_driver driver_pci6208 = {
 static struct comedi_driver driver_pci6208 = {
@@ -122,13 +124,15 @@ COMEDI_PCI_INITCLEANUP(driver_pci6208, pci6208_pci_table);
 static int pci6208_find_device(struct comedi_device *dev, int bus, int slot);
 static int pci6208_find_device(struct comedi_device *dev, int bus, int slot);
 static int
 static int
 pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
 pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
-	int dev_minor);
+		  int dev_minor);
 
 
 /*read/write functions*/
 /*read/write functions*/
-static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int pci6208_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int pci6208_ao_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
 /* static int pci6208_dio_insn_bits(struct comedi_device *dev,struct comedi_subdevice *s, */
 /* static int pci6208_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); */
 /* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */
 /* static int pci6208_dio_insn_config(struct comedi_device *dev,struct comedi_subdevice *s, */
@@ -140,7 +144,8 @@ static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *
  * in the driver structure, dev->board_ptr contains that
  * in the driver structure, dev->board_ptr contains that
  * address.
  * address.
  */
  */
-static int pci6208_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int pci6208_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int retval;
 	int retval;
@@ -217,8 +222,9 @@ static int pci6208_detach(struct comedi_device *dev)
 	return 0;
 	return 0;
 }
 }
 
 
-static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci6208_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i = 0, Data_Read;
 	int i = 0, Data_Read;
 	unsigned short chan = CR_CHAN(insn->chanspec);
 	unsigned short chan = CR_CHAN(insn->chanspec);
@@ -242,8 +248,9 @@ static int pci6208_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *
 
 
 /* AO subdevices should have a read insn as well as a write insn.
 /* AO subdevices should have a read insn as well as a write insn.
  * Usually this means copying a value stored in devpriv. */
  * Usually this means copying a value stored in devpriv. */
-static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci6208_ao_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -309,8 +316,8 @@ static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
 	int i;
 	int i;
 
 
 	for (pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pci_dev != NULL;
-		pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) {
+	     pci_dev != NULL;
+	     pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) {
 		if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) {
 		if (pci_dev->vendor == PCI_VENDOR_ID_ADLINK) {
 			for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) {
 			for (i = 0; i < ARRAY_SIZE(pci6208_boards); i++) {
 				if (pci6208_boards[i].dev_id == pci_dev->device) {
 				if (pci6208_boards[i].dev_id == pci_dev->device) {
@@ -318,9 +325,9 @@ static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
 					if ((bus != 0) || (slot != 0)) {
 					if ((bus != 0) || (slot != 0)) {
 						/*  are we on the wrong bus/slot? */
 						/*  are we on the wrong bus/slot? */
 						if (pci_dev->bus->number
 						if (pci_dev->bus->number
-							!= bus ||
-							PCI_SLOT(pci_dev->devfn)
-							!= slot) {
+						    != bus ||
+						    PCI_SLOT(pci_dev->devfn)
+						    != slot) {
 							continue;
 							continue;
 						}
 						}
 					}
 					}
@@ -332,16 +339,16 @@ static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
 	}
 	}
 
 
 	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
 	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
-		dev->minor, bus, slot);
+	       dev->minor, bus, slot);
 	return -EIO;
 	return -EIO;
 
 
-      found:
+found:
 	printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n",
 	printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n",
-		dev->minor,
-		pci6208_boards[i].name,
-		pci_dev->bus->number,
-		PCI_SLOT(pci_dev->devfn),
-		PCI_FUNC(pci_dev->devfn), pci_dev->irq);
+	       dev->minor,
+	       pci6208_boards[i].name,
+	       pci_dev->bus->number,
+	       PCI_SLOT(pci_dev->devfn),
+	       PCI_FUNC(pci_dev->devfn), pci_dev->irq);
 
 
 	/*  TODO: Warn about non-tested boards. */
 	/*  TODO: Warn about non-tested boards. */
 	/* switch(board->device_id) */
 	/* switch(board->device_id) */
@@ -355,13 +362,15 @@ static int pci6208_find_device(struct comedi_device *dev, int bus, int slot)
 
 
 static int
 static int
 pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
 pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
-	int dev_minor)
+		  int dev_minor)
 {
 {
 	unsigned long io_base, io_range, lcr_io_base, lcr_io_range;
 	unsigned long io_base, io_range, lcr_io_base, lcr_io_range;
 
 
 	/*  Enable PCI device and request regions */
 	/*  Enable PCI device and request regions */
 	if (comedi_pci_enable(pci_dev, PCI6208_DRIVER_NAME) < 0) {
 	if (comedi_pci_enable(pci_dev, PCI6208_DRIVER_NAME) < 0) {
-		printk("comedi%d: Failed to enable PCI device and request regions\n", dev_minor);
+		printk
+		    ("comedi%d: Failed to enable PCI device and request regions\n",
+		     dev_minor);
 		return -EIO;
 		return -EIO;
 	}
 	}
 	/*  Read local configuration register base address [PCI_BASE_ADDRESS #1]. */
 	/*  Read local configuration register base address [PCI_BASE_ADDRESS #1]. */
@@ -369,14 +378,14 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr,
 	lcr_io_range = pci_resource_len(pci_dev, 1);
 	lcr_io_range = pci_resource_len(pci_dev, 1);
 
 
 	printk("comedi%d: local config registers at address 0x%4lx [0x%4lx]\n",
 	printk("comedi%d: local config registers at address 0x%4lx [0x%4lx]\n",
-		dev_minor, lcr_io_base, lcr_io_range);
+	       dev_minor, lcr_io_base, lcr_io_range);
 
 
 	/*  Read PCI6208 register base address [PCI_BASE_ADDRESS #2]. */
 	/*  Read PCI6208 register base address [PCI_BASE_ADDRESS #2]. */
 	io_base = pci_resource_start(pci_dev, 2);
 	io_base = pci_resource_start(pci_dev, 2);
 	io_range = pci_resource_end(pci_dev, 2) - io_base + 1;
 	io_range = pci_resource_end(pci_dev, 2) - io_base + 1;
 
 
 	printk("comedi%d: 6208 registers at address 0x%4lx [0x%4lx]\n",
 	printk("comedi%d: 6208 registers at address 0x%4lx [0x%4lx]\n",
-		dev_minor, io_base, io_range);
+	       dev_minor, io_base, io_range);
 
 
 	*io_base_ptr = io_base;
 	*io_base_ptr = io_base;
 	/* devpriv->io_range = io_range; */
 	/* devpriv->io_range = io_range; */

+ 23 - 16
drivers/staging/comedi/drivers/adl_pci7296.c

@@ -49,9 +49,10 @@ Configuration Options:
 #define PCI_DEVICE_ID_PCI7296 0x7296
 #define PCI_DEVICE_ID_PCI7296 0x7296
 
 
 static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = {
-	{PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296, PCI_ANY_ID, PCI_ANY_ID, 0,
-		0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296, PCI_ANY_ID,
+		    PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table);
 MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table);
@@ -61,10 +62,10 @@ struct adl_pci7296_private {
 	struct pci_dev *pci_dev;
 	struct pci_dev *pci_dev;
 };
 };
 
 
-
 #define devpriv ((struct adl_pci7296_private *)dev->private)
 #define devpriv ((struct adl_pci7296_private *)dev->private)
 
 
-static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int adl_pci7296_attach(struct comedi_device *dev,
+			      struct comedi_devconfig *it);
 static int adl_pci7296_detach(struct comedi_device *dev);
 static int adl_pci7296_detach(struct comedi_device *dev);
 static struct comedi_driver driver_adl_pci7296 = {
 static struct comedi_driver driver_adl_pci7296 = {
 	.driver_name = "adl_pci7296",
 	.driver_name = "adl_pci7296",
@@ -73,7 +74,8 @@ static struct comedi_driver driver_adl_pci7296 = {
 	.detach = adl_pci7296_detach,
 	.detach = adl_pci7296_detach,
 };
 };
 
 
-static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int adl_pci7296_attach(struct comedi_device *dev,
+			      struct comedi_devconfig *it)
 {
 {
 	struct pci_dev *pcidev;
 	struct pci_dev *pcidev;
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
@@ -94,21 +96,23 @@ static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig
 		return -ENOMEM;
 		return -ENOMEM;
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 
 
 		if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
 		if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
-			pcidev->device == PCI_DEVICE_ID_PCI7296) {
+		    pcidev->device == PCI_DEVICE_ID_PCI7296) {
 			if (bus || slot) {
 			if (bus || slot) {
 				/* requested particular bus/slot */
 				/* requested particular bus/slot */
 				if (pcidev->bus->number != bus
 				if (pcidev->bus->number != bus
-					|| PCI_SLOT(pcidev->devfn) != slot) {
+				    || PCI_SLOT(pcidev->devfn) != slot) {
 					continue;
 					continue;
 				}
 				}
 			}
 			}
 			devpriv->pci_dev = pcidev;
 			devpriv->pci_dev = pcidev;
 			if (comedi_pci_enable(pcidev, "adl_pci7296") < 0) {
 			if (comedi_pci_enable(pcidev, "adl_pci7296") < 0) {
-				printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor);
+				printk
+				    ("comedi%d: Failed to enable PCI device and request regions\n",
+				     dev->minor);
 				return -EIO;
 				return -EIO;
 			}
 			}
 
 
@@ -118,23 +122,26 @@ static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig
 			/*  four 8255 digital io subdevices */
 			/*  four 8255 digital io subdevices */
 			s = dev->subdevices + 0;
 			s = dev->subdevices + 0;
 			subdev_8255_init(dev, s, NULL,
 			subdev_8255_init(dev, s, NULL,
-				(unsigned long)(dev->iobase));
+					 (unsigned long)(dev->iobase));
 
 
 			s = dev->subdevices + 1;
 			s = dev->subdevices + 1;
 			ret = subdev_8255_init(dev, s, NULL,
 			ret = subdev_8255_init(dev, s, NULL,
-				(unsigned long)(dev->iobase + PORT2A));
+					       (unsigned long)(dev->iobase +
+							       PORT2A));
 			if (ret < 0)
 			if (ret < 0)
 				return ret;
 				return ret;
 
 
 			s = dev->subdevices + 2;
 			s = dev->subdevices + 2;
 			ret = subdev_8255_init(dev, s, NULL,
 			ret = subdev_8255_init(dev, s, NULL,
-				(unsigned long)(dev->iobase + PORT3A));
+					       (unsigned long)(dev->iobase +
+							       PORT3A));
 			if (ret < 0)
 			if (ret < 0)
 				return ret;
 				return ret;
 
 
 			s = dev->subdevices + 3;
 			s = dev->subdevices + 3;
 			ret = subdev_8255_init(dev, s, NULL,
 			ret = subdev_8255_init(dev, s, NULL,
-				(unsigned long)(dev->iobase + PORT4A));
+					       (unsigned long)(dev->iobase +
+							       PORT4A));
 			if (ret < 0)
 			if (ret < 0)
 				return ret;
 				return ret;
 
 
@@ -145,7 +152,7 @@ static int adl_pci7296_attach(struct comedi_device *dev, struct comedi_devconfig
 	}
 	}
 
 
 	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
 	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
-		dev->minor, bus, slot);
+	       dev->minor, bus, slot);
 	return -EIO;
 	return -EIO;
 }
 }
 
 

+ 35 - 22
drivers/staging/comedi/drivers/adl_pci7432.c

@@ -44,9 +44,10 @@ Configuration Options:
 #define PCI_DEVICE_ID_PCI7432 0x7432
 #define PCI_DEVICE_ID_PCI7432 0x7432
 
 
 static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = {
-	{PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432, PCI_ANY_ID, PCI_ANY_ID, 0,
-		0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432, PCI_ANY_ID,
+		    PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table);
 MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table);
@@ -58,7 +59,8 @@ struct adl_pci7432_private {
 
 
 #define devpriv ((struct adl_pci7432_private *)dev->private)
 #define devpriv ((struct adl_pci7432_private *)dev->private)
 
 
-static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int adl_pci7432_attach(struct comedi_device *dev,
+			      struct comedi_devconfig *it);
 static int adl_pci7432_detach(struct comedi_device *dev);
 static int adl_pci7432_detach(struct comedi_device *dev);
 static struct comedi_driver driver_adl_pci7432 = {
 static struct comedi_driver driver_adl_pci7432 = {
 	.driver_name = "adl_pci7432",
 	.driver_name = "adl_pci7432",
@@ -69,15 +71,20 @@ static struct comedi_driver driver_adl_pci7432 = {
 
 
 /* Digital IO */
 /* Digital IO */
 
 
-static int adl_pci7432_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int adl_pci7432_di_insn_bits(struct comedi_device *dev,
+				    struct comedi_subdevice *s,
+				    struct comedi_insn *insn,
+				    unsigned int *data);
 
 
-static int adl_pci7432_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int adl_pci7432_do_insn_bits(struct comedi_device *dev,
+				    struct comedi_subdevice *s,
+				    struct comedi_insn *insn,
+				    unsigned int *data);
 
 
 /*            */
 /*            */
 
 
-static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int adl_pci7432_attach(struct comedi_device *dev,
+			      struct comedi_devconfig *it)
 {
 {
 	struct pci_dev *pcidev;
 	struct pci_dev *pcidev;
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
@@ -97,21 +104,23 @@ static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig
 		return -ENOMEM;
 		return -ENOMEM;
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 
 
 		if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
 		if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
-			pcidev->device == PCI_DEVICE_ID_PCI7432) {
+		    pcidev->device == PCI_DEVICE_ID_PCI7432) {
 			if (bus || slot) {
 			if (bus || slot) {
 				/* requested particular bus/slot */
 				/* requested particular bus/slot */
 				if (pcidev->bus->number != bus
 				if (pcidev->bus->number != bus
-					|| PCI_SLOT(pcidev->devfn) != slot) {
+				    || PCI_SLOT(pcidev->devfn) != slot) {
 					continue;
 					continue;
 				}
 				}
 			}
 			}
 			devpriv->pci_dev = pcidev;
 			devpriv->pci_dev = pcidev;
 			if (comedi_pci_enable(pcidev, "adl_pci7432") < 0) {
 			if (comedi_pci_enable(pcidev, "adl_pci7432") < 0) {
-				printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor);
+				printk
+				    ("comedi%d: Failed to enable PCI device and request regions\n",
+				     dev->minor);
 				return -EIO;
 				return -EIO;
 			}
 			}
 			dev->iobase = pci_resource_start(pcidev, 2);
 			dev->iobase = pci_resource_start(pcidev, 2);
@@ -120,7 +129,7 @@ static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig
 			s = dev->subdevices + 0;
 			s = dev->subdevices + 0;
 			s->type = COMEDI_SUBD_DI;
 			s->type = COMEDI_SUBD_DI;
 			s->subdev_flags =
 			s->subdev_flags =
-				SDF_READABLE | SDF_GROUND | SDF_COMMON;
+			    SDF_READABLE | SDF_GROUND | SDF_COMMON;
 			s->n_chan = 32;
 			s->n_chan = 32;
 			s->maxdata = 1;
 			s->maxdata = 1;
 			s->len_chanlist = 32;
 			s->len_chanlist = 32;
@@ -131,7 +140,7 @@ static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig
 			s = dev->subdevices + 1;
 			s = dev->subdevices + 1;
 			s->type = COMEDI_SUBD_DO;
 			s->type = COMEDI_SUBD_DO;
 			s->subdev_flags =
 			s->subdev_flags =
-				SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
+			    SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
 			s->n_chan = 32;
 			s->n_chan = 32;
 			s->maxdata = 1;
 			s->maxdata = 1;
 			s->len_chanlist = 32;
 			s->len_chanlist = 32;
@@ -146,7 +155,7 @@ static int adl_pci7432_attach(struct comedi_device *dev, struct comedi_devconfig
 	}
 	}
 
 
 	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
 	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
-		dev->minor, bus, slot);
+	       dev->minor, bus, slot);
 	return -EIO;
 	return -EIO;
 }
 }
 
 
@@ -164,8 +173,10 @@ static int adl_pci7432_detach(struct comedi_device *dev)
 	return 0;
 	return 0;
 }
 }
 
 
-static int adl_pci7432_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int adl_pci7432_do_insn_bits(struct comedi_device *dev,
+				    struct comedi_subdevice *s,
+				    struct comedi_insn *insn,
+				    unsigned int *data)
 {
 {
 	printk("comedi: pci7432_do_insn_bits called\n");
 	printk("comedi: pci7432_do_insn_bits called\n");
 	printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]);
 	printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]);
@@ -178,14 +189,16 @@ static int adl_pci7432_do_insn_bits(struct comedi_device *dev, struct comedi_sub
 		s->state |= (data[0] & data[1]);
 		s->state |= (data[0] & data[1]);
 
 
 		printk("comedi: out: %8x on iobase %4lx\n", s->state,
 		printk("comedi: out: %8x on iobase %4lx\n", s->state,
-			dev->iobase + PCI7432_DO);
+		       dev->iobase + PCI7432_DO);
 		outl(s->state & 0xffffffff, dev->iobase + PCI7432_DO);
 		outl(s->state & 0xffffffff, dev->iobase + PCI7432_DO);
 	}
 	}
 	return 2;
 	return 2;
 }
 }
 
 
-static int adl_pci7432_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int adl_pci7432_di_insn_bits(struct comedi_device *dev,
+				    struct comedi_subdevice *s,
+				    struct comedi_insn *insn,
+				    unsigned int *data)
 {
 {
 	printk("comedi: pci7432_di_insn_bits called\n");
 	printk("comedi: pci7432_di_insn_bits called\n");
 	printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]);
 	printk("comedi: data0: %8x data1: %8x\n", data[0], data[1]);

+ 79 - 47
drivers/staging/comedi/drivers/adl_pci8164.c

@@ -56,9 +56,10 @@ Configuration Options:
 #define PCI_DEVICE_ID_PCI8164 0x8164
 #define PCI_DEVICE_ID_PCI8164 0x8164
 
 
 static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
-	{PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164, PCI_ANY_ID, PCI_ANY_ID, 0,
-		0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164, PCI_ANY_ID,
+		    PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, adl_pci8164_pci_table);
 MODULE_DEVICE_TABLE(pci, adl_pci8164_pci_table);
@@ -70,7 +71,8 @@ struct adl_pci8164_private {
 
 
 #define devpriv ((struct adl_pci8164_private *)dev->private)
 #define devpriv ((struct adl_pci8164_private *)dev->private)
 
 
-static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int adl_pci8164_attach(struct comedi_device *dev,
+			      struct comedi_devconfig *it);
 static int adl_pci8164_detach(struct comedi_device *dev);
 static int adl_pci8164_detach(struct comedi_device *dev);
 static struct comedi_driver driver_adl_pci8164 = {
 static struct comedi_driver driver_adl_pci8164 = {
 	.driver_name = "adl_pci8164",
 	.driver_name = "adl_pci8164",
@@ -79,31 +81,48 @@ static struct comedi_driver driver_adl_pci8164 = {
 	.detach = adl_pci8164_detach,
 	.detach = adl_pci8164_detach,
 };
 };
 
 
-static int adl_pci8164_insn_read_msts(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int adl_pci8164_insn_read_msts(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data);
 
 
-static int adl_pci8164_insn_read_ssts(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int adl_pci8164_insn_read_ssts(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data);
 
 
-static int adl_pci8164_insn_read_buf0(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int adl_pci8164_insn_read_buf0(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data);
 
 
-static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int adl_pci8164_insn_read_buf1(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data);
 
 
-static int adl_pci8164_insn_write_cmd(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int adl_pci8164_insn_write_cmd(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data);
 
 
-static int adl_pci8164_insn_write_otp(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int adl_pci8164_insn_write_otp(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data);
 
 
 static int adl_pci8164_insn_write_buf0(struct comedi_device *dev,
 static int adl_pci8164_insn_write_buf0(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+				       struct comedi_subdevice *s,
+				       struct comedi_insn *insn,
+				       unsigned int *data);
 
 
 static int adl_pci8164_insn_write_buf1(struct comedi_device *dev,
 static int adl_pci8164_insn_write_buf1(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+				       struct comedi_subdevice *s,
+				       struct comedi_insn *insn,
+				       unsigned int *data);
 
 
-static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int adl_pci8164_attach(struct comedi_device *dev,
+			      struct comedi_devconfig *it)
 {
 {
 	struct pci_dev *pcidev;
 	struct pci_dev *pcidev;
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
@@ -123,21 +142,23 @@ static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig
 		return -ENOMEM;
 		return -ENOMEM;
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 
 
 		if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
 		if (pcidev->vendor == PCI_VENDOR_ID_ADLINK &&
-			pcidev->device == PCI_DEVICE_ID_PCI8164) {
+		    pcidev->device == PCI_DEVICE_ID_PCI8164) {
 			if (bus || slot) {
 			if (bus || slot) {
 				/* requested particular bus/slot */
 				/* requested particular bus/slot */
 				if (pcidev->bus->number != bus
 				if (pcidev->bus->number != bus
-					|| PCI_SLOT(pcidev->devfn) != slot) {
+				    || PCI_SLOT(pcidev->devfn) != slot) {
 					continue;
 					continue;
 				}
 				}
 			}
 			}
 			devpriv->pci_dev = pcidev;
 			devpriv->pci_dev = pcidev;
 			if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) {
 			if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) {
-				printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor);
+				printk
+				    ("comedi%d: Failed to enable PCI device and request regions\n",
+				     dev->minor);
 				return -EIO;
 				return -EIO;
 			}
 			}
 			dev->iobase = pci_resource_start(pcidev, 2);
 			dev->iobase = pci_resource_start(pcidev, 2);
@@ -190,7 +211,7 @@ static int adl_pci8164_attach(struct comedi_device *dev, struct comedi_devconfig
 	}
 	}
 
 
 	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
 	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
-		dev->minor, bus, slot);
+	       dev->minor, bus, slot);
 	return -EIO;
 	return -EIO;
 }
 }
 
 
@@ -216,8 +237,7 @@ static void adl_pci8164_insn_read(struct comedi_device *dev,
 				  struct comedi_subdevice *s,
 				  struct comedi_subdevice *s,
 				  struct comedi_insn *insn,
 				  struct comedi_insn *insn,
 				  unsigned int *data,
 				  unsigned int *data,
-				  char *action,
-				  unsigned short offset)
+				  char *action, unsigned short offset)
 {
 {
 	int axis, axis_reg;
 	int axis, axis_reg;
 	char *axisname;
 	char *axisname;
@@ -247,8 +267,8 @@ static void adl_pci8164_insn_read(struct comedi_device *dev,
 	}
 	}
 
 
 	data[0] = inw(dev->iobase + axis_reg + offset);
 	data[0] = inw(dev->iobase + axis_reg + offset);
-	printk("comedi: pci8164 %s read -> %04X:%04X on axis %s\n", action, data[0],
-		data[1], axisname);
+	printk("comedi: pci8164 %s read -> %04X:%04X on axis %s\n", action,
+	       data[0], data[1], axisname);
 }
 }
 
 
 static int adl_pci8164_insn_read_msts(struct comedi_device *dev,
 static int adl_pci8164_insn_read_msts(struct comedi_device *dev,
@@ -260,22 +280,28 @@ static int adl_pci8164_insn_read_msts(struct comedi_device *dev,
 	return 2;
 	return 2;
 }
 }
 
 
-static int adl_pci8164_insn_read_ssts(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int adl_pci8164_insn_read_ssts(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data)
 {
 {
 	adl_pci8164_insn_read(dev, s, insn, data, "SSTS", PCI8164_SSTS);
 	adl_pci8164_insn_read(dev, s, insn, data, "SSTS", PCI8164_SSTS);
 	return 2;
 	return 2;
 }
 }
 
 
-static int adl_pci8164_insn_read_buf0(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int adl_pci8164_insn_read_buf0(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data)
 {
 {
 	adl_pci8164_insn_read(dev, s, insn, data, "BUF0", PCI8164_BUF0);
 	adl_pci8164_insn_read(dev, s, insn, data, "BUF0", PCI8164_BUF0);
 	return 2;
 	return 2;
 }
 }
 
 
-static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int adl_pci8164_insn_read_buf1(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data)
 {
 {
 	adl_pci8164_insn_read(dev, s, insn, data, "BUF1", PCI8164_BUF1);
 	adl_pci8164_insn_read(dev, s, insn, data, "BUF1", PCI8164_BUF1);
 	return 2;
 	return 2;
@@ -286,11 +312,10 @@ static int adl_pci8164_insn_read_buf1(struct comedi_device *dev, struct comedi_s
  * const to the data for outw()
  * const to the data for outw()
  */
  */
 static void adl_pci8164_insn_out(struct comedi_device *dev,
 static void adl_pci8164_insn_out(struct comedi_device *dev,
-					struct comedi_subdevice *s,
-					struct comedi_insn *insn,
-					unsigned int *data,
-					char *action,
-					unsigned short offset)
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn,
+				 unsigned int *data,
+				 char *action, unsigned short offset)
 {
 {
 	unsigned int axis, axis_reg;
 	unsigned int axis, axis_reg;
 
 
@@ -327,30 +352,37 @@ static void adl_pci8164_insn_out(struct comedi_device *dev,
 
 
 }
 }
 
 
-
-static int adl_pci8164_insn_write_cmd(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int adl_pci8164_insn_write_cmd(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data)
 {
 {
 	adl_pci8164_insn_out(dev, s, insn, data, "CMD", PCI8164_CMD);
 	adl_pci8164_insn_out(dev, s, insn, data, "CMD", PCI8164_CMD);
 	return 2;
 	return 2;
 }
 }
 
 
-static int adl_pci8164_insn_write_otp(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int adl_pci8164_insn_write_otp(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data)
 {
 {
 	adl_pci8164_insn_out(dev, s, insn, data, "OTP", PCI8164_OTP);
 	adl_pci8164_insn_out(dev, s, insn, data, "OTP", PCI8164_OTP);
 	return 2;
 	return 2;
 }
 }
 
 
 static int adl_pci8164_insn_write_buf0(struct comedi_device *dev,
 static int adl_pci8164_insn_write_buf0(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+				       struct comedi_subdevice *s,
+				       struct comedi_insn *insn,
+				       unsigned int *data)
 {
 {
 	adl_pci8164_insn_out(dev, s, insn, data, "BUF0", PCI8164_BUF0);
 	adl_pci8164_insn_out(dev, s, insn, data, "BUF0", PCI8164_BUF0);
 	return 2;
 	return 2;
 }
 }
 
 
 static int adl_pci8164_insn_write_buf1(struct comedi_device *dev,
 static int adl_pci8164_insn_write_buf1(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+				       struct comedi_subdevice *s,
+				       struct comedi_insn *insn,
+				       unsigned int *data)
 {
 {
 	adl_pci8164_insn_out(dev, s, insn, data, "BUF1", PCI8164_BUF1);
 	adl_pci8164_insn_out(dev, s, insn, data, "BUF1", PCI8164_BUF1);
 	return 2;
 	return 2;

+ 189 - 172
drivers/staging/comedi/drivers/adl_pci9111.c

@@ -264,27 +264,32 @@ TODO:
 
 
 /*  Function prototypes */
 /*  Function prototypes */
 
 
-static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci9111_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int pci9111_detach(struct comedi_device *dev);
 static int pci9111_detach(struct comedi_device *dev);
-static void pci9111_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
-	void *data, unsigned int num_bytes, unsigned int start_chan_index);
+static void pci9111_ai_munge(struct comedi_device *dev,
+			     struct comedi_subdevice *s, void *data,
+			     unsigned int num_bytes,
+			     unsigned int start_chan_index);
 
 
 static const struct comedi_lrange pci9111_hr_ai_range = {
 static const struct comedi_lrange pci9111_hr_ai_range = {
 	5,
 	5,
 	{
 	{
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-			BIP_RANGE(2.5),
-			BIP_RANGE(1.25),
-			BIP_RANGE(0.625)
-		}
+	 BIP_RANGE(10),
+	 BIP_RANGE(5),
+	 BIP_RANGE(2.5),
+	 BIP_RANGE(1.25),
+	 BIP_RANGE(0.625)
+	 }
 };
 };
 
 
 static DEFINE_PCI_DEVICE_TABLE(pci9111_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(pci9111_pci_table) = {
-	{PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0,
-		0, 0},
-	/* { PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
-	{0}
+	{
+	PCI_VENDOR_ID_ADLINK, PCI9111_HR_DEVICE_ID, PCI_ANY_ID,
+		    PCI_ANY_ID, 0, 0, 0},
+	    /* { PCI_VENDOR_ID_ADLINK, PCI9111_HG_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
+	{
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, pci9111_pci_table);
 MODULE_DEVICE_TABLE(pci, pci9111_pci_table);
@@ -309,17 +314,17 @@ struct pci9111_board {
 
 
 static const struct pci9111_board pci9111_boards[] = {
 static const struct pci9111_board pci9111_boards[] = {
 	{
 	{
-	.name = "pci9111_hr",
-	.device_id = PCI9111_HR_DEVICE_ID,
-	.ai_channel_nbr = PCI9111_AI_CHANNEL_NBR,
-	.ao_channel_nbr = PCI9111_AO_CHANNEL_NBR,
-	.ai_resolution = PCI9111_HR_AI_RESOLUTION,
-	.ai_resolution_mask = PCI9111_HR_AI_RESOLUTION_MASK,
-	.ao_resolution = PCI9111_AO_RESOLUTION,
-	.ao_resolution_mask = PCI9111_AO_RESOLUTION_MASK,
-	.ai_range_list = &pci9111_hr_ai_range,
-	.ao_range_list = &range_bipolar10,
-	.ai_acquisition_period_min_ns = PCI9111_AI_ACQUISITION_PERIOD_MIN_NS}
+	 .name = "pci9111_hr",
+	 .device_id = PCI9111_HR_DEVICE_ID,
+	 .ai_channel_nbr = PCI9111_AI_CHANNEL_NBR,
+	 .ao_channel_nbr = PCI9111_AO_CHANNEL_NBR,
+	 .ai_resolution = PCI9111_HR_AI_RESOLUTION,
+	 .ai_resolution_mask = PCI9111_HR_AI_RESOLUTION_MASK,
+	 .ao_resolution = PCI9111_AO_RESOLUTION,
+	 .ao_resolution_mask = PCI9111_AO_RESOLUTION_MASK,
+	 .ai_range_list = &pci9111_hr_ai_range,
+	 .ao_range_list = &range_bipolar10,
+	 .ai_acquisition_period_min_ns = PCI9111_AI_ACQUISITION_PERIOD_MIN_NS}
 };
 };
 
 
 #define pci9111_board_nbr \
 #define pci9111_board_nbr \
@@ -379,9 +384,11 @@ struct pci9111_private_data {
 #define PLX9050_SOFTWARE_INTERRUPT	(1 << 7)
 #define PLX9050_SOFTWARE_INTERRUPT	(1 << 7)
 
 
 static void plx9050_interrupt_control(unsigned long io_base,
 static void plx9050_interrupt_control(unsigned long io_base,
-	bool LINTi1_enable,
-	bool LINTi1_active_high,
-	bool LINTi2_enable, bool LINTi2_active_high, bool interrupt_enable)
+				      bool LINTi1_enable,
+				      bool LINTi1_active_high,
+				      bool LINTi2_enable,
+				      bool LINTi2_active_high,
+				      bool interrupt_enable)
 {
 {
 	int flags = 0;
 	int flags = 0;
 
 
@@ -409,16 +416,19 @@ static void plx9050_interrupt_control(unsigned long io_base,
 static void pci9111_timer_set(struct comedi_device *dev)
 static void pci9111_timer_set(struct comedi_device *dev)
 {
 {
 	pci9111_8254_control_set(PCI9111_8254_COUNTER_0 |
 	pci9111_8254_control_set(PCI9111_8254_COUNTER_0 |
-		PCI9111_8254_READ_LOAD_LSB_MSB |
-		PCI9111_8254_MODE_0 | PCI9111_8254_BINARY_COUNTER);
+				 PCI9111_8254_READ_LOAD_LSB_MSB |
+				 PCI9111_8254_MODE_0 |
+				 PCI9111_8254_BINARY_COUNTER);
 
 
 	pci9111_8254_control_set(PCI9111_8254_COUNTER_1 |
 	pci9111_8254_control_set(PCI9111_8254_COUNTER_1 |
-		PCI9111_8254_READ_LOAD_LSB_MSB |
-		PCI9111_8254_MODE_2 | PCI9111_8254_BINARY_COUNTER);
+				 PCI9111_8254_READ_LOAD_LSB_MSB |
+				 PCI9111_8254_MODE_2 |
+				 PCI9111_8254_BINARY_COUNTER);
 
 
 	pci9111_8254_control_set(PCI9111_8254_COUNTER_2 |
 	pci9111_8254_control_set(PCI9111_8254_COUNTER_2 |
-		PCI9111_8254_READ_LOAD_LSB_MSB |
-		PCI9111_8254_MODE_2 | PCI9111_8254_BINARY_COUNTER);
+				 PCI9111_8254_READ_LOAD_LSB_MSB |
+				 PCI9111_8254_MODE_2 |
+				 PCI9111_8254_BINARY_COUNTER);
 
 
 	udelay(1);
 	udelay(1);
 
 
@@ -433,7 +443,7 @@ enum pci9111_trigger_sources {
 };
 };
 
 
 static void pci9111_trigger_source_set(struct comedi_device *dev,
 static void pci9111_trigger_source_set(struct comedi_device *dev,
-	enum pci9111_trigger_sources source)
+				       enum pci9111_trigger_sources source)
 {
 {
 	int flags;
 	int flags;
 
 
@@ -491,7 +501,8 @@ enum pci9111_ISC1_sources {
 };
 };
 
 
 static void pci9111_interrupt_source_set(struct comedi_device *dev,
 static void pci9111_interrupt_source_set(struct comedi_device *dev,
-	enum pci9111_ISC0_sources irq_0_source, enum pci9111_ISC1_sources irq_1_source)
+					 enum pci9111_ISC0_sources irq_0_source,
+					 enum pci9111_ISC1_sources irq_1_source)
 {
 {
 	int flags;
 	int flags;
 
 
@@ -514,12 +525,13 @@ static void pci9111_interrupt_source_set(struct comedi_device *dev,
 
 
 #undef AI_DO_CMD_DEBUG
 #undef AI_DO_CMD_DEBUG
 
 
-static int pci9111_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int pci9111_ai_cancel(struct comedi_device *dev,
+			     struct comedi_subdevice *s)
 {
 {
 	/*  Disable interrupts */
 	/*  Disable interrupts */
 
 
 	plx9050_interrupt_control(dev_private->lcr_io_base, true, true, true,
 	plx9050_interrupt_control(dev_private->lcr_io_base, true, true, true,
-		true, false);
+				  true, false);
 
 
 	pci9111_trigger_source_set(dev, software);
 	pci9111_trigger_source_set(dev, software);
 
 
@@ -543,19 +555,19 @@ static int pci9111_ai_cancel(struct comedi_device *dev, struct comedi_subdevice
 
 
 static int
 static int
 pci9111_ai_do_cmd_test(struct comedi_device *dev,
 pci9111_ai_do_cmd_test(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_cmd *cmd)
+		       struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
 {
 	int tmp;
 	int tmp;
 	int error = 0;
 	int error = 0;
 	int range, reference;
 	int range, reference;
 	int i;
 	int i;
-	struct pci9111_board *board = (struct pci9111_board *) dev->board_ptr;
+	struct pci9111_board *board = (struct pci9111_board *)dev->board_ptr;
 
 
 	/*  Step 1 : check if trigger are trivialy valid */
 	/*  Step 1 : check if trigger are trivialy valid */
 
 
 	pci9111_check_trigger_src(cmd->start_src, TRIG_NOW);
 	pci9111_check_trigger_src(cmd->start_src, TRIG_NOW);
 	pci9111_check_trigger_src(cmd->scan_begin_src,
 	pci9111_check_trigger_src(cmd->scan_begin_src,
-		TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT);
+				  TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT);
 	pci9111_check_trigger_src(cmd->convert_src, TRIG_TIMER | TRIG_EXT);
 	pci9111_check_trigger_src(cmd->convert_src, TRIG_TIMER | TRIG_EXT);
 	pci9111_check_trigger_src(cmd->scan_end_src, TRIG_COUNT);
 	pci9111_check_trigger_src(cmd->scan_end_src, TRIG_COUNT);
 	pci9111_check_trigger_src(cmd->stop_src, TRIG_COUNT | TRIG_NONE);
 	pci9111_check_trigger_src(cmd->stop_src, TRIG_COUNT | TRIG_NONE);
@@ -569,21 +581,21 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
 		error++;
 		error++;
 
 
 	if ((cmd->scan_begin_src != TRIG_TIMER) &&
 	if ((cmd->scan_begin_src != TRIG_TIMER) &&
-		(cmd->scan_begin_src != TRIG_FOLLOW) &&
-		(cmd->scan_begin_src != TRIG_EXT))
+	    (cmd->scan_begin_src != TRIG_FOLLOW) &&
+	    (cmd->scan_begin_src != TRIG_EXT))
 		error++;
 		error++;
 
 
 	if ((cmd->convert_src != TRIG_TIMER) && (cmd->convert_src != TRIG_EXT)) {
 	if ((cmd->convert_src != TRIG_TIMER) && (cmd->convert_src != TRIG_EXT)) {
 		error++;
 		error++;
 	}
 	}
 	if ((cmd->convert_src == TRIG_TIMER) &&
 	if ((cmd->convert_src == TRIG_TIMER) &&
-		!((cmd->scan_begin_src == TRIG_TIMER) ||
-			(cmd->scan_begin_src == TRIG_FOLLOW))) {
+	    !((cmd->scan_begin_src == TRIG_TIMER) ||
+	      (cmd->scan_begin_src == TRIG_FOLLOW))) {
 		error++;
 		error++;
 	}
 	}
 	if ((cmd->convert_src == TRIG_EXT) &&
 	if ((cmd->convert_src == TRIG_EXT) &&
-		!((cmd->scan_begin_src == TRIG_EXT) ||
-			(cmd->scan_begin_src == TRIG_FOLLOW))) {
+	    !((cmd->scan_begin_src == TRIG_EXT) ||
+	      (cmd->scan_begin_src == TRIG_FOLLOW))) {
 		error++;
 		error++;
 	}
 	}
 
 
@@ -613,7 +625,7 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
 	}
 	}
 
 
 	if ((cmd->convert_src == TRIG_TIMER) &&
 	if ((cmd->convert_src == TRIG_TIMER) &&
-		(cmd->convert_arg < board->ai_acquisition_period_min_ns)) {
+	    (cmd->convert_arg < board->ai_acquisition_period_min_ns)) {
 		cmd->convert_arg = board->ai_acquisition_period_min_ns;
 		cmd->convert_arg = board->ai_acquisition_period_min_ns;
 		error++;
 		error++;
 	}
 	}
@@ -623,7 +635,7 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
 	}
 	}
 
 
 	if ((cmd->scan_begin_src == TRIG_TIMER) &&
 	if ((cmd->scan_begin_src == TRIG_TIMER) &&
-		(cmd->scan_begin_arg < board->ai_acquisition_period_min_ns)) {
+	    (cmd->scan_begin_arg < board->ai_acquisition_period_min_ns)) {
 		cmd->scan_begin_arg = board->ai_acquisition_period_min_ns;
 		cmd->scan_begin_arg = board->ai_acquisition_period_min_ns;
 		error++;
 		error++;
 	}
 	}
@@ -637,7 +649,7 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
 	}
 	}
 
 
 	if ((cmd->scan_end_src == TRIG_COUNT) &&
 	if ((cmd->scan_end_src == TRIG_COUNT) &&
-		(cmd->scan_end_arg != cmd->chanlist_len)) {
+	    (cmd->scan_end_arg != cmd->chanlist_len)) {
 		cmd->scan_end_arg = cmd->chanlist_len;
 		cmd->scan_end_arg = cmd->chanlist_len;
 		error++;
 		error++;
 	}
 	}
@@ -659,9 +671,10 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
 	if (cmd->convert_src == TRIG_TIMER) {
 	if (cmd->convert_src == TRIG_TIMER) {
 		tmp = cmd->convert_arg;
 		tmp = cmd->convert_arg;
 		i8253_cascade_ns_to_timer_2div(PCI9111_8254_CLOCK_PERIOD_NS,
 		i8253_cascade_ns_to_timer_2div(PCI9111_8254_CLOCK_PERIOD_NS,
-			&(dev_private->timer_divisor_1),
-			&(dev_private->timer_divisor_2),
-			&(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK);
+					       &(dev_private->timer_divisor_1),
+					       &(dev_private->timer_divisor_2),
+					       &(cmd->convert_arg),
+					       cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->convert_arg)
 		if (tmp != cmd->convert_arg)
 			error++;
 			error++;
 	}
 	}
@@ -679,7 +692,7 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
 		if (cmd->scan_begin_arg != scan_begin_min) {
 		if (cmd->scan_begin_arg != scan_begin_min) {
 			if (scan_begin_min < cmd->scan_begin_arg) {
 			if (scan_begin_min < cmd->scan_begin_arg) {
 				scan_factor =
 				scan_factor =
-					cmd->scan_begin_arg / scan_begin_min;
+				    cmd->scan_begin_arg / scan_begin_min;
 				scan_begin_arg = scan_factor * scan_begin_min;
 				scan_begin_arg = scan_factor * scan_begin_min;
 				if (cmd->scan_begin_arg != scan_begin_arg) {
 				if (cmd->scan_begin_arg != scan_begin_arg) {
 					cmd->scan_begin_arg = scan_begin_arg;
 					cmd->scan_begin_arg = scan_begin_arg;
@@ -706,27 +719,27 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
 			for (i = 0; i < cmd->chanlist_len; i++) {
 			for (i = 0; i < cmd->chanlist_len; i++) {
 				if (CR_CHAN(cmd->chanlist[i]) != i) {
 				if (CR_CHAN(cmd->chanlist[i]) != i) {
 					comedi_error(dev,
 					comedi_error(dev,
-						"entries in chanlist must be consecutive "
-						"channels,counting upwards from 0\n");
+						     "entries in chanlist must be consecutive "
+						     "channels,counting upwards from 0\n");
 					error++;
 					error++;
 				}
 				}
 				if (CR_RANGE(cmd->chanlist[i]) != range) {
 				if (CR_RANGE(cmd->chanlist[i]) != range) {
 					comedi_error(dev,
 					comedi_error(dev,
-						"entries in chanlist must all have the same gain\n");
+						     "entries in chanlist must all have the same gain\n");
 					error++;
 					error++;
 				}
 				}
 				if (CR_AREF(cmd->chanlist[i]) != reference) {
 				if (CR_AREF(cmd->chanlist[i]) != reference) {
 					comedi_error(dev,
 					comedi_error(dev,
-						"entries in chanlist must all have the same reference\n");
+						     "entries in chanlist must all have the same reference\n");
 					error++;
 					error++;
 				}
 				}
 			}
 			}
 		} else {
 		} else {
 			if ((CR_CHAN(cmd->chanlist[0]) >
 			if ((CR_CHAN(cmd->chanlist[0]) >
-					(board->ai_channel_nbr - 1))
-				|| (CR_CHAN(cmd->chanlist[0]) < 0)) {
+			     (board->ai_channel_nbr - 1))
+			    || (CR_CHAN(cmd->chanlist[0]) < 0)) {
 				comedi_error(dev,
 				comedi_error(dev,
-					"channel number is out of limits\n");
+					     "channel number is out of limits\n");
 				error++;
 				error++;
 			}
 			}
 		}
 		}
@@ -741,13 +754,14 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev,
 
 
 /*  Analog input command */
 /*  Analog input command */
 
 
-static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *subdevice)
+static int pci9111_ai_do_cmd(struct comedi_device *dev,
+			     struct comedi_subdevice *subdevice)
 {
 {
 	struct comedi_cmd *async_cmd = &subdevice->async->cmd;
 	struct comedi_cmd *async_cmd = &subdevice->async->cmd;
 
 
 	if (!dev->irq) {
 	if (!dev->irq) {
 		comedi_error(dev,
 		comedi_error(dev,
-			"no irq assigned for PCI9111, cannot do hardware conversion");
+			     "no irq assigned for PCI9111, cannot do hardware conversion");
 		return -1;
 		return -1;
 	}
 	}
 	/*  Set channel scan limit */
 	/*  Set channel scan limit */
@@ -772,7 +786,7 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice
 	switch (async_cmd->stop_src) {
 	switch (async_cmd->stop_src) {
 	case TRIG_COUNT:
 	case TRIG_COUNT:
 		dev_private->stop_counter =
 		dev_private->stop_counter =
-			async_cmd->stop_arg * async_cmd->chanlist_len;
+		    async_cmd->stop_arg * async_cmd->chanlist_len;
 		dev_private->stop_is_none = 0;
 		dev_private->stop_is_none = 0;
 		break;
 		break;
 
 
@@ -792,28 +806,29 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice
 	switch (async_cmd->convert_src) {
 	switch (async_cmd->convert_src) {
 	case TRIG_TIMER:
 	case TRIG_TIMER:
 		i8253_cascade_ns_to_timer_2div(PCI9111_8254_CLOCK_PERIOD_NS,
 		i8253_cascade_ns_to_timer_2div(PCI9111_8254_CLOCK_PERIOD_NS,
-			&(dev_private->timer_divisor_1),
-			&(dev_private->timer_divisor_2),
-			&(async_cmd->convert_arg),
-			async_cmd->flags & TRIG_ROUND_MASK);
+					       &(dev_private->timer_divisor_1),
+					       &(dev_private->timer_divisor_2),
+					       &(async_cmd->convert_arg),
+					       async_cmd->
+					       flags & TRIG_ROUND_MASK);
 #ifdef AI_DO_CMD_DEBUG
 #ifdef AI_DO_CMD_DEBUG
 		printk(PCI9111_DRIVER_NAME ": divisors = %d, %d\n",
 		printk(PCI9111_DRIVER_NAME ": divisors = %d, %d\n",
-			dev_private->timer_divisor_1,
-			dev_private->timer_divisor_2);
+		       dev_private->timer_divisor_1,
+		       dev_private->timer_divisor_2);
 #endif
 #endif
 
 
 		pci9111_trigger_source_set(dev, software);
 		pci9111_trigger_source_set(dev, software);
 		pci9111_timer_set(dev);
 		pci9111_timer_set(dev);
 		pci9111_fifo_reset();
 		pci9111_fifo_reset();
 		pci9111_interrupt_source_set(dev, irq_on_fifo_half_full,
 		pci9111_interrupt_source_set(dev, irq_on_fifo_half_full,
-			irq_on_timer_tick);
+					     irq_on_timer_tick);
 		pci9111_trigger_source_set(dev, timer_pacer);
 		pci9111_trigger_source_set(dev, timer_pacer);
 		plx9050_interrupt_control(dev_private->lcr_io_base, true, true,
 		plx9050_interrupt_control(dev_private->lcr_io_base, true, true,
-			false, true, true);
+					  false, true, true);
 
 
 		dev_private->scan_delay =
 		dev_private->scan_delay =
-			(async_cmd->scan_begin_arg / (async_cmd->convert_arg *
-				async_cmd->chanlist_len)) - 1;
+		    (async_cmd->scan_begin_arg / (async_cmd->convert_arg *
+						  async_cmd->chanlist_len)) - 1;
 
 
 		break;
 		break;
 
 
@@ -822,9 +837,9 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice
 		pci9111_trigger_source_set(dev, external);
 		pci9111_trigger_source_set(dev, external);
 		pci9111_fifo_reset();
 		pci9111_fifo_reset();
 		pci9111_interrupt_source_set(dev, irq_on_fifo_half_full,
 		pci9111_interrupt_source_set(dev, irq_on_fifo_half_full,
-			irq_on_timer_tick);
+					     irq_on_timer_tick);
 		plx9050_interrupt_control(dev_private->lcr_io_base, true, true,
 		plx9050_interrupt_control(dev_private->lcr_io_base, true, true,
-			false, true, true);
+					  false, true, true);
 
 
 		break;
 		break;
 
 
@@ -837,45 +852,47 @@ static int pci9111_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice
 	dev_private->chanlist_len = async_cmd->chanlist_len;
 	dev_private->chanlist_len = async_cmd->chanlist_len;
 	dev_private->chunk_counter = 0;
 	dev_private->chunk_counter = 0;
 	dev_private->chunk_num_samples =
 	dev_private->chunk_num_samples =
-		dev_private->chanlist_len * (1 + dev_private->scan_delay);
+	    dev_private->chanlist_len * (1 + dev_private->scan_delay);
 
 
 #ifdef AI_DO_CMD_DEBUG
 #ifdef AI_DO_CMD_DEBUG
 	printk(PCI9111_DRIVER_NAME ": start interruptions!\n");
 	printk(PCI9111_DRIVER_NAME ": start interruptions!\n");
 	printk(PCI9111_DRIVER_NAME ": trigger source = %2x\n",
 	printk(PCI9111_DRIVER_NAME ": trigger source = %2x\n",
-		pci9111_trigger_and_autoscan_get());
+	       pci9111_trigger_and_autoscan_get());
 	printk(PCI9111_DRIVER_NAME ": irq source     = %2x\n",
 	printk(PCI9111_DRIVER_NAME ": irq source     = %2x\n",
-		pci9111_interrupt_and_fifo_get());
+	       pci9111_interrupt_and_fifo_get());
 	printk(PCI9111_DRIVER_NAME ": ai_do_cmd\n");
 	printk(PCI9111_DRIVER_NAME ": ai_do_cmd\n");
 	printk(PCI9111_DRIVER_NAME ": stop counter   = %d\n",
 	printk(PCI9111_DRIVER_NAME ": stop counter   = %d\n",
-		dev_private->stop_counter);
+	       dev_private->stop_counter);
 	printk(PCI9111_DRIVER_NAME ": scan delay     = %d\n",
 	printk(PCI9111_DRIVER_NAME ": scan delay     = %d\n",
-		dev_private->scan_delay);
+	       dev_private->scan_delay);
 	printk(PCI9111_DRIVER_NAME ": chanlist_len   = %d\n",
 	printk(PCI9111_DRIVER_NAME ": chanlist_len   = %d\n",
-		dev_private->chanlist_len);
+	       dev_private->chanlist_len);
 	printk(PCI9111_DRIVER_NAME ": chunk num samples = %d\n",
 	printk(PCI9111_DRIVER_NAME ": chunk num samples = %d\n",
-		dev_private->chunk_num_samples);
+	       dev_private->chunk_num_samples);
 #endif
 #endif
 
 
 	return 0;
 	return 0;
 }
 }
 
 
-static void pci9111_ai_munge(struct comedi_device *dev, struct comedi_subdevice *s,
-	void *data, unsigned int num_bytes, unsigned int start_chan_index)
+static void pci9111_ai_munge(struct comedi_device *dev,
+			     struct comedi_subdevice *s, void *data,
+			     unsigned int num_bytes,
+			     unsigned int start_chan_index)
 {
 {
 	unsigned int i, num_samples = num_bytes / sizeof(short);
 	unsigned int i, num_samples = num_bytes / sizeof(short);
 	short *array = data;
 	short *array = data;
 	int resolution =
 	int resolution =
-		((struct pci9111_board *) dev->board_ptr)->ai_resolution;
+	    ((struct pci9111_board *)dev->board_ptr)->ai_resolution;
 
 
 	for (i = 0; i < num_samples; i++) {
 	for (i = 0; i < num_samples; i++) {
 		if (resolution == PCI9111_HR_AI_RESOLUTION)
 		if (resolution == PCI9111_HR_AI_RESOLUTION)
 			array[i] =
 			array[i] =
-				(array[i] & PCI9111_HR_AI_RESOLUTION_MASK) ^
-				PCI9111_HR_AI_RESOLUTION_2_CMP_BIT;
+			    (array[i] & PCI9111_HR_AI_RESOLUTION_MASK) ^
+			    PCI9111_HR_AI_RESOLUTION_2_CMP_BIT;
 		else
 		else
 			array[i] =
 			array[i] =
-				((array[i] >> 4) & PCI9111_AI_RESOLUTION_MASK) ^
-				PCI9111_AI_RESOLUTION_2_CMP_BIT;
+			    ((array[i] >> 4) & PCI9111_AI_RESOLUTION_MASK) ^
+			    PCI9111_AI_RESOLUTION_2_CMP_BIT;
 	}
 	}
 }
 }
 
 
@@ -905,18 +922,12 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
 
 
 	/*  Check if we are source of interrupt */
 	/*  Check if we are source of interrupt */
 	intcsr = inb(dev_private->lcr_io_base +
 	intcsr = inb(dev_private->lcr_io_base +
-		PLX9050_REGISTER_INTERRUPT_CONTROL);
+		     PLX9050_REGISTER_INTERRUPT_CONTROL);
 	if (!(((intcsr & PLX9050_PCI_INTERRUPT_ENABLE) != 0)
 	if (!(((intcsr & PLX9050_PCI_INTERRUPT_ENABLE) != 0)
-			&& (((intcsr & (PLX9050_LINTI1_ENABLE |
-							PLX9050_LINTI1_STATUS))
-					==
-					(PLX9050_LINTI1_ENABLE |
-						PLX9050_LINTI1_STATUS))
-				|| ((intcsr & (PLX9050_LINTI2_ENABLE |
-							PLX9050_LINTI2_STATUS))
-					==
-					(PLX9050_LINTI2_ENABLE |
-						PLX9050_LINTI2_STATUS))))) {
+	      && (((intcsr & (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS))
+		   == (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS))
+		  || ((intcsr & (PLX9050_LINTI2_ENABLE | PLX9050_LINTI2_STATUS))
+		      == (PLX9050_LINTI2_ENABLE | PLX9050_LINTI2_STATUS))))) {
 		/*  Not the source of the interrupt. */
 		/*  Not the source of the interrupt. */
 		/*  (N.B. not using PLX9050_SOFTWARE_INTERRUPT) */
 		/*  (N.B. not using PLX9050_SOFTWARE_INTERRUPT) */
 		spin_unlock_irqrestore(&dev->spinlock, irq_flags);
 		spin_unlock_irqrestore(&dev->spinlock, irq_flags);
@@ -924,12 +935,11 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
 	}
 	}
 
 
 	if ((intcsr & (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) ==
 	if ((intcsr & (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) ==
-		(PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) {
+	    (PLX9050_LINTI1_ENABLE | PLX9050_LINTI1_STATUS)) {
 		/*  Interrupt comes from fifo_half-full signal */
 		/*  Interrupt comes from fifo_half-full signal */
 
 
 		if (pci9111_is_fifo_full()) {
 		if (pci9111_is_fifo_full()) {
-			spin_unlock_irqrestore(&dev->spinlock,
-				irq_flags);
+			spin_unlock_irqrestore(&dev->spinlock, irq_flags);
 			comedi_error(dev, PCI9111_DRIVER_NAME " fifo overflow");
 			comedi_error(dev, PCI9111_DRIVER_NAME " fifo overflow");
 			pci9111_interrupt_clear();
 			pci9111_interrupt_clear();
 			pci9111_ai_cancel(dev, subdevice);
 			pci9111_ai_cancel(dev, subdevice);
@@ -948,73 +958,70 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
 #endif
 #endif
 
 
 			num_samples =
 			num_samples =
-				PCI9111_FIFO_HALF_SIZE >
-				dev_private->stop_counter
-				&& !dev_private->stop_is_none ? dev_private->
-				stop_counter : PCI9111_FIFO_HALF_SIZE;
+			    PCI9111_FIFO_HALF_SIZE >
+			    dev_private->stop_counter
+			    && !dev_private->
+			    stop_is_none ? dev_private->stop_counter :
+			    PCI9111_FIFO_HALF_SIZE;
 			insw(PCI9111_IO_BASE + PCI9111_REGISTER_AD_FIFO_VALUE,
 			insw(PCI9111_IO_BASE + PCI9111_REGISTER_AD_FIFO_VALUE,
-				dev_private->ai_bounce_buffer, num_samples);
+			     dev_private->ai_bounce_buffer, num_samples);
 
 
 			if (dev_private->scan_delay < 1) {
 			if (dev_private->scan_delay < 1) {
 				bytes_written =
 				bytes_written =
-					cfc_write_array_to_buffer(subdevice,
-					dev_private->ai_bounce_buffer,
-					num_samples * sizeof(short));
+				    cfc_write_array_to_buffer(subdevice,
+							      dev_private->
+							      ai_bounce_buffer,
+							      num_samples *
+							      sizeof(short));
 			} else {
 			} else {
 				int position = 0;
 				int position = 0;
 				int to_read;
 				int to_read;
 
 
 				while (position < num_samples) {
 				while (position < num_samples) {
 					if (dev_private->chunk_counter <
 					if (dev_private->chunk_counter <
-						dev_private->chanlist_len) {
+					    dev_private->chanlist_len) {
 						to_read =
 						to_read =
-							dev_private->
-							chanlist_len -
-							dev_private->
-							chunk_counter;
+						    dev_private->chanlist_len -
+						    dev_private->chunk_counter;
 
 
 						if (to_read >
 						if (to_read >
-							num_samples - position)
+						    num_samples - position)
 							to_read =
 							to_read =
-								num_samples -
-								position;
+							    num_samples -
+							    position;
 
 
 						bytes_written +=
 						bytes_written +=
-							cfc_write_array_to_buffer
-							(subdevice,
-							dev_private->
-							ai_bounce_buffer +
-							position,
-							to_read *
-							sizeof(short));
+						    cfc_write_array_to_buffer
+						    (subdevice,
+						     dev_private->ai_bounce_buffer
+						     + position,
+						     to_read * sizeof(short));
 					} else {
 					} else {
 						to_read =
 						to_read =
-							dev_private->
-							chunk_num_samples -
-							dev_private->
-							chunk_counter;
+						    dev_private->chunk_num_samples
+						    -
+						    dev_private->chunk_counter;
 						if (to_read >
 						if (to_read >
-							num_samples - position)
+						    num_samples - position)
 							to_read =
 							to_read =
-								num_samples -
-								position;
+							    num_samples -
+							    position;
 
 
 						bytes_written +=
 						bytes_written +=
-							sizeof(short) *
-							to_read;
+						    sizeof(short) * to_read;
 					}
 					}
 
 
 					position += to_read;
 					position += to_read;
 					dev_private->chunk_counter += to_read;
 					dev_private->chunk_counter += to_read;
 
 
 					if (dev_private->chunk_counter >=
 					if (dev_private->chunk_counter >=
-						dev_private->chunk_num_samples)
+					    dev_private->chunk_num_samples)
 						dev_private->chunk_counter = 0;
 						dev_private->chunk_counter = 0;
 				}
 				}
 			}
 			}
 
 
 			dev_private->stop_counter -=
 			dev_private->stop_counter -=
-				bytes_written / sizeof(short);
+			    bytes_written / sizeof(short);
 		}
 		}
 	}
 	}
 
 
@@ -1044,17 +1051,18 @@ static irqreturn_t pci9111_interrupt(int irq, void *p_device)
 #undef AI_INSN_DEBUG
 #undef AI_INSN_DEBUG
 
 
 static int pci9111_ai_insn_read(struct comedi_device *dev,
 static int pci9111_ai_insn_read(struct comedi_device *dev,
-	struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data)
+				struct comedi_subdevice *subdevice,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int resolution =
 	int resolution =
-		((struct pci9111_board *) dev->board_ptr)->ai_resolution;
+	    ((struct pci9111_board *)dev->board_ptr)->ai_resolution;
 
 
 	int timeout, i;
 	int timeout, i;
 
 
 #ifdef AI_INSN_DEBUG
 #ifdef AI_INSN_DEBUG
 	printk(PCI9111_DRIVER_NAME ": ai_insn set c/r/n = %2x/%2x/%2x\n",
 	printk(PCI9111_DRIVER_NAME ": ai_insn set c/r/n = %2x/%2x/%2x\n",
-		CR_CHAN((&insn->chanspec)[0]),
-		CR_RANGE((&insn->chanspec)[0]), insn->n);
+	       CR_CHAN((&insn->chanspec)[0]),
+	       CR_RANGE((&insn->chanspec)[0]), insn->n);
 #endif
 #endif
 
 
 	pci9111_ai_channel_set(CR_CHAN((&insn->chanspec)[0]));
 	pci9111_ai_channel_set(CR_CHAN((&insn->chanspec)[0]));
@@ -1080,7 +1088,7 @@ static int pci9111_ai_insn_read(struct comedi_device *dev,
 		pci9111_fifo_reset();
 		pci9111_fifo_reset();
 		return -ETIME;
 		return -ETIME;
 
 
-	      conversion_done:
+conversion_done:
 
 
 		if (resolution == PCI9111_HR_AI_RESOLUTION) {
 		if (resolution == PCI9111_HR_AI_RESOLUTION) {
 			data[i] = pci9111_hr_ai_get_data();
 			data[i] = pci9111_hr_ai_get_data();
@@ -1091,8 +1099,8 @@ static int pci9111_ai_insn_read(struct comedi_device *dev,
 
 
 #ifdef AI_INSN_DEBUG
 #ifdef AI_INSN_DEBUG
 	printk(PCI9111_DRIVER_NAME ": ai_insn get c/r/t = %2x/%2x/%2x\n",
 	printk(PCI9111_DRIVER_NAME ": ai_insn get c/r/t = %2x/%2x/%2x\n",
-		pci9111_ai_channel_get(),
-		pci9111_ai_range_get(), pci9111_trigger_and_autoscan_get());
+	       pci9111_ai_channel_get(),
+	       pci9111_ai_range_get(), pci9111_trigger_and_autoscan_get());
 #endif
 #endif
 
 
 	return i;
 	return i;
@@ -1102,7 +1110,8 @@ static int pci9111_ai_insn_read(struct comedi_device *dev,
 
 
 static int
 static int
 pci9111_ao_insn_write(struct comedi_device *dev,
 pci9111_ao_insn_write(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+		      struct comedi_subdevice *s, struct comedi_insn *insn,
+		      unsigned int *data)
 {
 {
 	int i;
 	int i;
 
 
@@ -1117,7 +1126,8 @@ pci9111_ao_insn_write(struct comedi_device *dev,
 /*  Analog output readback */
 /*  Analog output readback */
 
 
 static int pci9111_ao_insn_read(struct comedi_device *dev,
 static int pci9111_ao_insn_read(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 
 
@@ -1135,7 +1145,8 @@ static int pci9111_ao_insn_read(struct comedi_device *dev,
 /*  Digital inputs */
 /*  Digital inputs */
 
 
 static int pci9111_di_insn_bits(struct comedi_device *dev,
 static int pci9111_di_insn_bits(struct comedi_device *dev,
-	struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data)
+				struct comedi_subdevice *subdevice,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int bits;
 	unsigned int bits;
 
 
@@ -1148,7 +1159,8 @@ static int pci9111_di_insn_bits(struct comedi_device *dev,
 /*  Digital outputs */
 /*  Digital outputs */
 
 
 static int pci9111_do_insn_bits(struct comedi_device *dev,
 static int pci9111_do_insn_bits(struct comedi_device *dev,
-	struct comedi_subdevice *subdevice, struct comedi_insn *insn, unsigned int *data)
+				struct comedi_subdevice *subdevice,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int bits;
 	unsigned int bits;
 
 
@@ -1181,7 +1193,7 @@ static int pci9111_reset(struct comedi_device *dev)
 	/*  Set trigger source to software */
 	/*  Set trigger source to software */
 
 
 	plx9050_interrupt_control(dev_private->lcr_io_base, true, true, true,
 	plx9050_interrupt_control(dev_private->lcr_io_base, true, true, true,
-		true, false);
+				  true, false);
 
 
 	pci9111_trigger_source_set(dev, software);
 	pci9111_trigger_source_set(dev, software);
 	pci9111_pretrigger_set(dev, false);
 	pci9111_pretrigger_set(dev, false);
@@ -1201,7 +1213,8 @@ static int pci9111_reset(struct comedi_device *dev)
 /*       - Register PCI device */
 /*       - Register PCI device */
 /*       - Declare device driver capability */
 /*       - Declare device driver capability */
 
 
-static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int pci9111_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *subdevice;
 	struct comedi_subdevice *subdevice;
 	unsigned long io_base, io_range, lcr_io_base, lcr_io_range;
 	unsigned long io_base, io_range, lcr_io_base, lcr_io_range;
@@ -1217,29 +1230,29 @@ static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	printk("comedi%d: " PCI9111_DRIVER_NAME " driver\n", dev->minor);
 	printk("comedi%d: " PCI9111_DRIVER_NAME " driver\n", dev->minor);
 
 
 	for (pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pci_device != NULL;
-		pci_device =
-		pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
+	     pci_device != NULL;
+	     pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
 		if (pci_device->vendor == PCI_VENDOR_ID_ADLINK) {
 		if (pci_device->vendor == PCI_VENDOR_ID_ADLINK) {
 			for (i = 0; i < pci9111_board_nbr; i++) {
 			for (i = 0; i < pci9111_board_nbr; i++) {
 				if (pci9111_boards[i].device_id ==
 				if (pci9111_boards[i].device_id ==
-					pci_device->device) {
+				    pci_device->device) {
 					/*  was a particular bus/slot requested? */
 					/*  was a particular bus/slot requested? */
 					if ((it->options[0] != 0)
 					if ((it->options[0] != 0)
-						|| (it->options[1] != 0)) {
+					    || (it->options[1] != 0)) {
 						/*  are we on the wrong bus/slot? */
 						/*  are we on the wrong bus/slot? */
 						if (pci_device->bus->number !=
 						if (pci_device->bus->number !=
-							it->options[0]
-							|| PCI_SLOT(pci_device->
-								devfn) !=
-							it->options[1]) {
+						    it->options[0]
+						    ||
+						    PCI_SLOT(pci_device->devfn)
+						    != it->options[1]) {
 							continue;
 							continue;
 						}
 						}
 					}
 					}
 
 
 					dev->board_ptr = pci9111_boards + i;
 					dev->board_ptr = pci9111_boards + i;
-					board = (struct pci9111_board *) dev->
-						board_ptr;
+					board =
+					    (struct pci9111_board *)
+					    dev->board_ptr;
 					dev_private->pci_device = pci_device;
 					dev_private->pci_device = pci_device;
 					goto found;
 					goto found;
 				}
 				}
@@ -1248,17 +1261,17 @@ static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	}
 	}
 
 
 	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
 	printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
-		dev->minor, it->options[0], it->options[1]);
+	       dev->minor, it->options[0], it->options[1]);
 	return -EIO;
 	return -EIO;
 
 
-      found:
+found:
 
 
 	printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n",
 	printk("comedi%d: found %s (b:s:f=%d:%d:%d) , irq=%d\n",
-		dev->minor,
-		pci9111_boards[i].name,
-		pci_device->bus->number,
-		PCI_SLOT(pci_device->devfn),
-		PCI_FUNC(pci_device->devfn), pci_device->irq);
+	       dev->minor,
+	       pci9111_boards[i].name,
+	       pci_device->bus->number,
+	       PCI_SLOT(pci_device->devfn),
+	       PCI_FUNC(pci_device->devfn), pci_device->irq);
 
 
 	/*  TODO: Warn about non-tested boards. */
 	/*  TODO: Warn about non-tested boards. */
 
 
@@ -1270,11 +1283,15 @@ static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	lcr_io_base = pci_resource_start(pci_device, 1);
 	lcr_io_base = pci_resource_start(pci_device, 1);
 	lcr_io_range = pci_resource_len(pci_device, 1);
 	lcr_io_range = pci_resource_len(pci_device, 1);
 
 
-	printk("comedi%d: local configuration registers at address 0x%4lx [0x%4lx]\n", dev->minor, lcr_io_base, lcr_io_range);
+	printk
+	    ("comedi%d: local configuration registers at address 0x%4lx [0x%4lx]\n",
+	     dev->minor, lcr_io_base, lcr_io_range);
 
 
 	/*  Enable PCI device and request regions */
 	/*  Enable PCI device and request regions */
 	if (comedi_pci_enable(pci_device, PCI9111_DRIVER_NAME) < 0) {
 	if (comedi_pci_enable(pci_device, PCI9111_DRIVER_NAME) < 0) {
-		printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor);
+		printk
+		    ("comedi%d: Failed to enable PCI device and request regions\n",
+		     dev->minor);
 		return -EIO;
 		return -EIO;
 	}
 	}
 	/*  Read PCI6308 register base address [PCI_BASE_ADDRESS #2]. */
 	/*  Read PCI6308 register base address [PCI_BASE_ADDRESS #2]. */
@@ -1283,7 +1300,7 @@ static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	io_range = pci_resource_len(pci_device, 2);
 	io_range = pci_resource_len(pci_device, 2);
 
 
 	printk("comedi%d: 6503 registers at address 0x%4lx [0x%4lx]\n",
 	printk("comedi%d: 6503 registers at address 0x%4lx [0x%4lx]\n",
-		dev->minor, io_base, io_range);
+	       dev->minor, io_base, io_range);
 
 
 	dev->iobase = io_base;
 	dev->iobase = io_base;
 	dev->board_name = board->name;
 	dev->board_name = board->name;
@@ -1301,7 +1318,7 @@ static int pci9111_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		if (request_irq(pci_device->irq, pci9111_interrupt,
 		if (request_irq(pci_device->irq, pci9111_interrupt,
 				IRQF_SHARED, PCI9111_DRIVER_NAME, dev) != 0) {
 				IRQF_SHARED, PCI9111_DRIVER_NAME, dev) != 0) {
 			printk("comedi%d: unable to allocate irq  %u\n",
 			printk("comedi%d: unable to allocate irq  %u\n",
-				dev->minor, pci_device->irq);
+			       dev->minor, pci_device->irq);
 			return -EINVAL;
 			return -EINVAL;
 		}
 		}
 	}
 	}

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 250 - 214
drivers/staging/comedi/drivers/adl_pci9118.c


+ 190 - 181
drivers/staging/comedi/drivers/adq12b.c

@@ -62,7 +62,6 @@ If you do not specify any options, they will default to
        single-ended             0                  1-2     1-2 (factory default)
        single-ended             0                  1-2     1-2 (factory default)
        differential             1                  2-3     2-3
        differential             1                  2-3     2-3
 
 
-
    written by jeremy theler <thelerg@ib.cnea.gov.ar>
    written by jeremy theler <thelerg@ib.cnea.gov.ar>
 
 
    instituto balseiro
    instituto balseiro
@@ -101,39 +100,39 @@ If you do not specify any options, they will default to
 
 
 /* available ranges through the PGA gains */
 /* available ranges through the PGA gains */
 static const struct comedi_lrange range_adq12b_ai_bipolar = { 4, {
 static const struct comedi_lrange range_adq12b_ai_bipolar = { 4, {
-        BIP_RANGE(5),
-        BIP_RANGE(2),
-        BIP_RANGE(1),
-        BIP_RANGE(0.5)
-}};
+								  BIP_RANGE(5),
+								  BIP_RANGE(2),
+								  BIP_RANGE(1),
+								  BIP_RANGE(0.5)
+								  }
+};
 
 
 static const struct comedi_lrange range_adq12b_ai_unipolar = { 4, {
 static const struct comedi_lrange range_adq12b_ai_unipolar = { 4, {
-        UNI_RANGE(5),
-        UNI_RANGE(2),
-        UNI_RANGE(1),
-        UNI_RANGE(0.5)
-}};
-
-
+								   UNI_RANGE(5),
+								   UNI_RANGE(2),
+								   UNI_RANGE(1),
+								   UNI_RANGE
+								   (0.5)
+								   }
+};
 
 
 struct adq12b_board {
 struct adq12b_board {
-        const char *name;
-        int ai_se_chans;
-        int ai_diff_chans;
-        int ai_bits;
-        int di_chans;
-        int do_chans;
+	const char *name;
+	int ai_se_chans;
+	int ai_diff_chans;
+	int ai_bits;
+	int di_chans;
+	int do_chans;
 };
 };
 
 
 static const struct adq12b_board adq12b_boards[] = {
 static const struct adq12b_board adq12b_boards[] = {
-        {
-	.name = "adq12b",
-	.ai_se_chans = 16,
-	.ai_diff_chans = 8,
-	.ai_bits = 12,
-	.di_chans = 5,
-	.do_chans = 8
-        }
+	{
+	 .name = "adq12b",
+	 .ai_se_chans = 16,
+	 .ai_diff_chans = 8,
+	 .ai_bits = 12,
+	 .di_chans = 5,
+	 .do_chans = 8}
 /* potentially, more adq-based deviced will be added */
 /* potentially, more adq-based deviced will be added */
 /*,
 /*,
 	.name = "adq12b",
 	.name = "adq12b",
@@ -147,11 +146,11 @@ static const struct adq12b_board adq12b_boards[] = {
 #define thisboard ((const struct adq12b_board *)dev->board_ptr)
 #define thisboard ((const struct adq12b_board *)dev->board_ptr)
 
 
 struct adq12b_private {
 struct adq12b_private {
-        int unipolar;          /* option 2 of comedi_config (1 is iobase) */
-        int differential;      /* option 3 of comedi_config */
-        int last_channel;
-        int last_range;
-        unsigned int digital_state;
+	int unipolar;		/* option 2 of comedi_config (1 is iobase) */
+	int differential;	/* option 3 of comedi_config */
+	int last_channel;
+	int last_range;
+	unsigned int digital_state;
 };
 };
 
 
 #define devpriv ((struct adq12b_private *)dev->private)
 #define devpriv ((struct adq12b_private *)dev->private)
@@ -162,21 +161,28 @@ struct adq12b_private {
  * the board, and also about the kernel module that contains
  * the board, and also about the kernel module that contains
  * the device code.
  * the device code.
  */
  */
-static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int adq12b_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int adq12b_detach(struct comedi_device *dev);
 static int adq12b_detach(struct comedi_device *dev);
-static struct comedi_driver driver_adq12b={
-        driver_name:    "adq12b",
-        module:         THIS_MODULE,
-        attach:         adq12b_attach,
-        detach:         adq12b_detach,
-        board_name:     &adq12b_boards[0].name,
-        offset:         sizeof(struct adq12b_board),
-        num_names:      ARRAY_SIZE(adq12b_boards),
+static struct comedi_driver driver_adq12b = {
+driver_name:"adq12b",
+module:THIS_MODULE,
+attach:adq12b_attach,
+detach:adq12b_detach,
+board_name:&adq12b_boards[0].name,
+offset:sizeof(struct adq12b_board),
+num_names:ARRAY_SIZE(adq12b_boards),
 };
 };
 
 
-static int adq12b_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
-static int adq12b_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
-static int adq12b_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+static int adq12b_ai_rinsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data);
+static int adq12b_di_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
+static int adq12b_do_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
 
 
 /*
 /*
  * Attach is called by the Comedi core to configure the driver
  * Attach is called by the Comedi core to configure the driver
@@ -186,109 +192,108 @@ static int adq12b_do_insn_bits(struct comedi_device *dev, struct comedi_subdevic
  */
  */
 static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
 {
-        struct comedi_subdevice *s;
-        unsigned long iobase;
-        int unipolar, differential;
-
-        iobase = it->options[0];
-        unipolar = it->options[1];
-        differential = it->options[2];
-
-        printk("comedi%d: adq12b called with options base=0x%03lx, %s and %s\n", dev->minor, iobase, (unipolar==1)?"unipolar":"bipolar", (differential==1) ? "differential" : "single-ended");
-
-        /* if no address was specified, try the default 0x300 */
-        if (iobase == 0) {
-          printk("comedi%d: adq12b warning: I/O base address not specified. Trying the default 0x300.\n", dev->minor);
-          iobase = 0x300;
-        }
-
-        printk("comedi%d: adq12b: 0x%04lx ", dev->minor, iobase);
-        if (!request_region(iobase, ADQ12B_SIZE, "adq12b")) {
-          printk("I/O port conflict\n");
-          return -EIO;
-        }
-        dev->iobase = iobase;
+	struct comedi_subdevice *s;
+	unsigned long iobase;
+	int unipolar, differential;
+
+	iobase = it->options[0];
+	unipolar = it->options[1];
+	differential = it->options[2];
+
+	printk("comedi%d: adq12b called with options base=0x%03lx, %s and %s\n",
+	       dev->minor, iobase, (unipolar == 1) ? "unipolar" : "bipolar",
+	       (differential == 1) ? "differential" : "single-ended");
+
+	/* if no address was specified, try the default 0x300 */
+	if (iobase == 0) {
+		printk
+		    ("comedi%d: adq12b warning: I/O base address not specified. Trying the default 0x300.\n",
+		     dev->minor);
+		iobase = 0x300;
+	}
+
+	printk("comedi%d: adq12b: 0x%04lx ", dev->minor, iobase);
+	if (!request_region(iobase, ADQ12B_SIZE, "adq12b")) {
+		printk("I/O port conflict\n");
+		return -EIO;
+	}
+	dev->iobase = iobase;
 
 
 /*
 /*
  * Initialize dev->board_name.  Note that we can use the "thisboard"
  * Initialize dev->board_name.  Note that we can use the "thisboard"
  * macro now, since we just initialized it in the last line.
  * macro now, since we just initialized it in the last line.
  */
  */
-        dev->board_name = thisboard->name;
+	dev->board_name = thisboard->name;
 
 
 /*
 /*
  * Allocate the private structure area.  alloc_private() is a
  * Allocate the private structure area.  alloc_private() is a
  * convenient macro defined in comedidev.h.
  * convenient macro defined in comedidev.h.
  */
  */
-        if (alloc_private (dev, sizeof (struct adq12b_private)) < 0)
-          return -ENOMEM;
+	if (alloc_private(dev, sizeof(struct adq12b_private)) < 0)
+		return -ENOMEM;
 
 
 /* fill in devpriv structure */
 /* fill in devpriv structure */
-        devpriv->unipolar = unipolar;
-        devpriv->differential = differential;
+	devpriv->unipolar = unipolar;
+	devpriv->differential = differential;
 	devpriv->digital_state = 0;
 	devpriv->digital_state = 0;
 /* initialize channel and range to -1 so we make sure we always write
 /* initialize channel and range to -1 so we make sure we always write
    at least once to the CTREG in the instruction */
    at least once to the CTREG in the instruction */
-        devpriv->last_channel = -1;
-        devpriv->last_range = -1;
-
+	devpriv->last_channel = -1;
+	devpriv->last_range = -1;
 
 
 /*
 /*
  * Allocate the subdevice structures.  alloc_subdevice() is a
  * Allocate the subdevice structures.  alloc_subdevice() is a
  * convenient macro defined in comedidev.h.
  * convenient macro defined in comedidev.h.
  */
  */
-        if (alloc_subdevices (dev, 3)<0)
-           return -ENOMEM;
-
-        s = dev->subdevices+0;
-        /* analog input subdevice */
-        s->type = COMEDI_SUBD_AI;
-        if (differential) {
-          s->subdev_flags = SDF_READABLE|SDF_GROUND|SDF_DIFF;
-          s->n_chan = thisboard->ai_diff_chans;
-        } else {
-          s->subdev_flags = SDF_READABLE|SDF_GROUND;
-          s->n_chan = thisboard->ai_se_chans;
-        }
-
-        if (unipolar) {
-          s->range_table = &range_adq12b_ai_unipolar;
-        } else {
-          s->range_table = &range_adq12b_ai_bipolar;
-        }
-
-        s->maxdata = (1 << thisboard->ai_bits)-1;
-
-
-        s->len_chanlist = 4;  /* This is the maximum chanlist length that
-                                 the board can handle */
-        s->insn_read = adq12b_ai_rinsn;
-
-
-        s = dev->subdevices+1;
-        /* digital input subdevice */
-        s->type = COMEDI_SUBD_DI;
-        s->subdev_flags = SDF_READABLE;
-        s->n_chan=thisboard->di_chans;
-        s->maxdata = 1;
-        s->range_table = &range_digital;
-        s->insn_bits = adq12b_di_insn_bits;
-
-        s = dev->subdevices+2;
-        /* digital output subdevice */
-        s->type = COMEDI_SUBD_DO;
-        s->subdev_flags = SDF_WRITABLE;
-        s->n_chan = thisboard->do_chans;
-        s->maxdata = 1;
-        s->range_table = &range_digital;
-        s->insn_bits = adq12b_do_insn_bits;
-
-
-        printk("attached\n");
-
-        return 0;
+	if (alloc_subdevices(dev, 3) < 0)
+		return -ENOMEM;
+
+	s = dev->subdevices + 0;
+	/* analog input subdevice */
+	s->type = COMEDI_SUBD_AI;
+	if (differential) {
+		s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
+		s->n_chan = thisboard->ai_diff_chans;
+	} else {
+		s->subdev_flags = SDF_READABLE | SDF_GROUND;
+		s->n_chan = thisboard->ai_se_chans;
+	}
+
+	if (unipolar) {
+		s->range_table = &range_adq12b_ai_unipolar;
+	} else {
+		s->range_table = &range_adq12b_ai_bipolar;
+	}
+
+	s->maxdata = (1 << thisboard->ai_bits) - 1;
+
+	s->len_chanlist = 4;	/* This is the maximum chanlist length that
+				   the board can handle */
+	s->insn_read = adq12b_ai_rinsn;
+
+	s = dev->subdevices + 1;
+	/* digital input subdevice */
+	s->type = COMEDI_SUBD_DI;
+	s->subdev_flags = SDF_READABLE;
+	s->n_chan = thisboard->di_chans;
+	s->maxdata = 1;
+	s->range_table = &range_digital;
+	s->insn_bits = adq12b_di_insn_bits;
+
+	s = dev->subdevices + 2;
+	/* digital output subdevice */
+	s->type = COMEDI_SUBD_DO;
+	s->subdev_flags = SDF_WRITABLE;
+	s->n_chan = thisboard->do_chans;
+	s->maxdata = 1;
+	s->range_table = &range_digital;
+	s->insn_bits = adq12b_do_insn_bits;
+
+	printk("attached\n");
+
+	return 0;
 }
 }
 
 
-
 /*
 /*
  * _detach is called to deconfigure a device.  It should deallocate
  * _detach is called to deconfigure a device.  It should deallocate
  * resources.
  * resources.
@@ -299,14 +304,14 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)
  */
  */
 static int adq12b_detach(struct comedi_device *dev)
 static int adq12b_detach(struct comedi_device *dev)
 {
 {
-        if (dev->iobase)
-          release_region(dev->iobase, ADQ12B_SIZE);
+	if (dev->iobase)
+		release_region(dev->iobase, ADQ12B_SIZE);
 
 
-        kfree(devpriv);
+	kfree(devpriv);
 
 
-        printk("comedi%d: adq12b: removed\n", dev->minor);
+	printk("comedi%d: adq12b: removed\n", dev->minor);
 
 
-        return 0;
+	return 0;
 }
 }
 
 
 /*
 /*
@@ -314,79 +319,83 @@ static int adq12b_detach(struct comedi_device *dev)
  * mode.
  * mode.
  */
  */
 
 
-static int adq12b_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+static int adq12b_ai_rinsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
-        int n, i;
-        int range, channel;
-        unsigned char hi, lo, status;
-
-        /* change channel and range only if it is different from the previous */
-        range = CR_RANGE(insn->chanspec);
-        channel = CR_CHAN(insn->chanspec);
-        if (channel != devpriv->last_channel || range != devpriv->last_range) {
-          outb((range << 4) | channel, dev->iobase + ADQ12B_CTREG);
-          udelay(50);   /* wait for the mux to settle */
-        }
-
-        /* trigger conversion */
-        status = inb(dev->iobase + ADQ12B_ADLOW);
-
-        /* convert n samples */
-        for (n=0; n < insn->n; n++){
-
-          /* wait for end of convertion */
-	  i = 0;
-          do {
+	int n, i;
+	int range, channel;
+	unsigned char hi, lo, status;
+
+	/* change channel and range only if it is different from the previous */
+	range = CR_RANGE(insn->chanspec);
+	channel = CR_CHAN(insn->chanspec);
+	if (channel != devpriv->last_channel || range != devpriv->last_range) {
+		outb((range << 4) | channel, dev->iobase + ADQ12B_CTREG);
+		udelay(50);	/* wait for the mux to settle */
+	}
+
+	/* trigger conversion */
+	status = inb(dev->iobase + ADQ12B_ADLOW);
+
+	/* convert n samples */
+	for (n = 0; n < insn->n; n++) {
+
+		/* wait for end of convertion */
+		i = 0;
+		do {
 /* udelay(1); */
 /* udelay(1); */
-	    status = inb(dev->iobase + ADQ12B_STINR);
-            status = status & ADQ12B_EOC;
-          } while (status == 0 && ++i < TIMEOUT);
+			status = inb(dev->iobase + ADQ12B_STINR);
+			status = status & ADQ12B_EOC;
+		} while (status == 0 && ++i < TIMEOUT);
 /* } while (++i < 10); */
 /* } while (++i < 10); */
 
 
-          /* read data */
-          hi = inb(dev->iobase + ADQ12B_ADHIG);
-          lo = inb(dev->iobase + ADQ12B_ADLOW);
+		/* read data */
+		hi = inb(dev->iobase + ADQ12B_ADHIG);
+		lo = inb(dev->iobase + ADQ12B_ADLOW);
 
 
-          /* printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n", channel, range, status,  hi, lo); */
-          data[n] = (hi << 8) | lo;
+		/* printk("debug: chan=%d range=%d status=%d hi=%d lo=%d\n", channel, range, status,  hi, lo); */
+		data[n] = (hi << 8) | lo;
 
 
-        }
+	}
 
 
-        /* return the number of samples read/written */
-        return n;
+	/* return the number of samples read/written */
+	return n;
 }
 }
 
 
-
-static int adq12b_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, 	struct comedi_insn *insn, unsigned int *data)
+static int adq12b_di_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 
 
-        /* only bits 0-4 have information about digital inputs */
-        data[1] = (inb(dev->iobase+ADQ12B_STINR) & (0x1f));
+	/* only bits 0-4 have information about digital inputs */
+	data[1] = (inb(dev->iobase + ADQ12B_STINR) & (0x1f));
 
 
-        return 2;
+	return 2;
 }
 }
 
 
-
-static int adq12b_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, 	struct comedi_insn *insn, unsigned int *data)
+static int adq12b_do_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
-        int channel;
+	int channel;
 
 
 	for (channel = 0; channel < 8; channel++)
 	for (channel = 0; channel < 8; channel++)
-	  if (((data[0]>>channel) & 0x01) != 0)
-            outb((((data[1]>>channel)&0x01)<<3) | channel, dev->iobase + ADQ12B_OUTBR);
+		if (((data[0] >> channel) & 0x01) != 0)
+			outb((((data[1] >> channel) & 0x01) << 3) | channel,
+			     dev->iobase + ADQ12B_OUTBR);
 
 
-        /* store information to retrieve when asked for reading */
-        if (data[0]) {
-          devpriv->digital_state &= ~data[0];
-          devpriv->digital_state |= (data[0]&data[1]);
-        }
+	/* store information to retrieve when asked for reading */
+	if (data[0]) {
+		devpriv->digital_state &= ~data[0];
+		devpriv->digital_state |= (data[0] & data[1]);
+	}
 
 
-        data[1] = devpriv->digital_state;
+	data[1] = devpriv->digital_state;
 
 
-        return 2;
+	return 2;
 }
 }
 
 
-
 /*
 /*
  * A convenient macro that defines init_module() and cleanup_module(),
  * A convenient macro that defines init_module() and cleanup_module(),
  * as necessary.
  * as necessary.

+ 229 - 188
drivers/staging/comedi/drivers/adv_pci1710.c

@@ -124,67 +124,69 @@ Configuration options:
 #define Syncont_SC0	 1	/* set synchronous output mode */
 #define Syncont_SC0	 1	/* set synchronous output mode */
 
 
 static const struct comedi_lrange range_pci1710_3 = { 9, {
 static const struct comedi_lrange range_pci1710_3 = { 9, {
-			BIP_RANGE(5),
-			BIP_RANGE(2.5),
-			BIP_RANGE(1.25),
-			BIP_RANGE(0.625),
-			BIP_RANGE(10),
-			UNI_RANGE(10),
-			UNI_RANGE(5),
-			UNI_RANGE(2.5),
-			UNI_RANGE(1.25)
-	}
+							  BIP_RANGE(5),
+							  BIP_RANGE(2.5),
+							  BIP_RANGE(1.25),
+							  BIP_RANGE(0.625),
+							  BIP_RANGE(10),
+							  UNI_RANGE(10),
+							  UNI_RANGE(5),
+							  UNI_RANGE(2.5),
+							  UNI_RANGE(1.25)
+							  }
 };
 };
 
 
 static const char range_codes_pci1710_3[] =
 static const char range_codes_pci1710_3[] =
-	{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x10, 0x11, 0x12, 0x13 };
+    { 0x00, 0x01, 0x02, 0x03, 0x04, 0x10, 0x11, 0x12, 0x13 };
 
 
 static const struct comedi_lrange range_pci1710hg = { 12, {
 static const struct comedi_lrange range_pci1710hg = { 12, {
-			BIP_RANGE(5),
-			BIP_RANGE(0.5),
-			BIP_RANGE(0.05),
-			BIP_RANGE(0.005),
-			BIP_RANGE(10),
-			BIP_RANGE(1),
-			BIP_RANGE(0.1),
-			BIP_RANGE(0.01),
-			UNI_RANGE(10),
-			UNI_RANGE(1),
-			UNI_RANGE(0.1),
-			UNI_RANGE(0.01)
-	}
+							   BIP_RANGE(5),
+							   BIP_RANGE(0.5),
+							   BIP_RANGE(0.05),
+							   BIP_RANGE(0.005),
+							   BIP_RANGE(10),
+							   BIP_RANGE(1),
+							   BIP_RANGE(0.1),
+							   BIP_RANGE(0.01),
+							   UNI_RANGE(10),
+							   UNI_RANGE(1),
+							   UNI_RANGE(0.1),
+							   UNI_RANGE(0.01)
+							   }
 };
 };
 
 
 static const char range_codes_pci1710hg[] =
 static const char range_codes_pci1710hg[] =
-	{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12,
-		0x13 };
+    { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12,
+	0x13
+};
 
 
 static const struct comedi_lrange range_pci17x1 = { 5, {
 static const struct comedi_lrange range_pci17x1 = { 5, {
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-			BIP_RANGE(2.5),
-			BIP_RANGE(1.25),
-			BIP_RANGE(0.625)
-	}
+							BIP_RANGE(10),
+							BIP_RANGE(5),
+							BIP_RANGE(2.5),
+							BIP_RANGE(1.25),
+							BIP_RANGE(0.625)
+							}
 };
 };
 
 
 static const char range_codes_pci17x1[] = { 0x00, 0x01, 0x02, 0x03, 0x04 };
 static const char range_codes_pci17x1[] = { 0x00, 0x01, 0x02, 0x03, 0x04 };
 
 
 static const struct comedi_lrange range_pci1720 = { 4, {
 static const struct comedi_lrange range_pci1720 = { 4, {
-			UNI_RANGE(5),
-			UNI_RANGE(10),
-			BIP_RANGE(5),
-			BIP_RANGE(10)
-	}
+							UNI_RANGE(5),
+							UNI_RANGE(10),
+							BIP_RANGE(5),
+							BIP_RANGE(10)
+							}
 };
 };
 
 
 static const struct comedi_lrange range_pci171x_da = { 2, {
 static const struct comedi_lrange range_pci171x_da = { 2, {
-			UNI_RANGE(5),
-			UNI_RANGE(10),
-	}
+							   UNI_RANGE(5),
+							   UNI_RANGE(10),
+							   }
 };
 };
 
 
-static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci1710_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int pci1710_detach(struct comedi_device *dev);
 static int pci1710_detach(struct comedi_device *dev);
 
 
 struct boardtype {
 struct boardtype {
@@ -209,49 +211,50 @@ struct boardtype {
 };
 };
 
 
 static DEFINE_PCI_DEVICE_TABLE(pci1710_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(pci1710_pci_table) = {
-	{PCI_VENDOR_ID_ADVANTECH, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1731, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_ADVANTECH, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1731, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, pci1710_pci_table);
 MODULE_DEVICE_TABLE(pci, pci1710_pci_table);
 
 
 static const struct boardtype boardtypes[] = {
 static const struct boardtype boardtypes[] = {
 	{"pci1710", 0x1710,
 	{"pci1710", 0x1710,
-		IORANGE_171x, 1, TYPE_PCI171X,
-		16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
-		&range_pci1710_3, range_codes_pci1710_3,
-		&range_pci171x_da,
-		10000, 2048},
+	 IORANGE_171x, 1, TYPE_PCI171X,
+	 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
+	 &range_pci1710_3, range_codes_pci1710_3,
+	 &range_pci171x_da,
+	 10000, 2048},
 	{"pci1710hg", 0x1710,
 	{"pci1710hg", 0x1710,
-		IORANGE_171x, 1, TYPE_PCI171X,
-		16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
-		&range_pci1710hg, range_codes_pci1710hg,
-		&range_pci171x_da,
-		10000, 2048},
+	 IORANGE_171x, 1, TYPE_PCI171X,
+	 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
+	 &range_pci1710hg, range_codes_pci1710hg,
+	 &range_pci171x_da,
+	 10000, 2048},
 	{"pci1711", 0x1711,
 	{"pci1711", 0x1711,
-		IORANGE_171x, 1, TYPE_PCI171X,
-		16, 0, 2, 16, 16, 1, 0x0fff, 0x0fff,
-		&range_pci17x1, range_codes_pci17x1, &range_pci171x_da,
-		10000, 512},
+	 IORANGE_171x, 1, TYPE_PCI171X,
+	 16, 0, 2, 16, 16, 1, 0x0fff, 0x0fff,
+	 &range_pci17x1, range_codes_pci17x1, &range_pci171x_da,
+	 10000, 512},
 	{"pci1713", 0x1713,
 	{"pci1713", 0x1713,
-		IORANGE_171x, 1, TYPE_PCI1713,
-		32, 16, 0, 0, 0, 0, 0x0fff, 0x0000,
-		&range_pci1710_3, range_codes_pci1710_3, NULL,
-		10000, 2048},
+	 IORANGE_171x, 1, TYPE_PCI1713,
+	 32, 16, 0, 0, 0, 0, 0x0fff, 0x0000,
+	 &range_pci1710_3, range_codes_pci1710_3, NULL,
+	 10000, 2048},
 	{"pci1720", 0x1720,
 	{"pci1720", 0x1720,
-		IORANGE_1720, 0, TYPE_PCI1720,
-		0, 0, 4, 0, 0, 0, 0x0000, 0x0fff,
-		NULL, NULL, &range_pci1720,
-		0, 0},
+	 IORANGE_1720, 0, TYPE_PCI1720,
+	 0, 0, 4, 0, 0, 0, 0x0000, 0x0fff,
+	 NULL, NULL, &range_pci1720,
+	 0, 0},
 	{"pci1731", 0x1731,
 	{"pci1731", 0x1731,
-		IORANGE_171x, 1, TYPE_PCI171X,
-		16, 0, 0, 16, 16, 0, 0x0fff, 0x0000,
-		&range_pci17x1, range_codes_pci17x1, NULL,
-		10000, 512},
+	 IORANGE_171x, 1, TYPE_PCI171X,
+	 16, 0, 0, 16, 16, 0, 0x0fff, 0x0000,
+	 &range_pci17x1, range_codes_pci17x1, NULL,
+	 10000, 512},
 	/*  dummy entry corresponding to driver name */
 	/*  dummy entry corresponding to driver name */
 	{.name = DRV_NAME},
 	{.name = DRV_NAME},
 };
 };
@@ -292,7 +295,7 @@ struct pci1710_private {
 	unsigned int *ai_chanlist;	/*  actaul chanlist */
 	unsigned int *ai_chanlist;	/*  actaul chanlist */
 	unsigned int ai_flags;	/*  flaglist */
 	unsigned int ai_flags;	/*  flaglist */
 	unsigned int ai_data_len;	/*  len of data buffer */
 	unsigned int ai_data_len;	/*  len of data buffer */
-	short *ai_data;	/*  data buffer */
+	short *ai_data;		/*  data buffer */
 	unsigned int ai_timer1;	/*  timers */
 	unsigned int ai_timer1;	/*  timers */
 	unsigned int ai_timer2;
 	unsigned int ai_timer2;
 	short ao_data[4];	/*  data output buffer */
 	short ao_data[4];	/*  data output buffer */
@@ -306,14 +309,18 @@ struct pci1710_private {
 ==============================================================================
 ==============================================================================
 */
 */
 
 
-static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int *chanlist, unsigned int n_chan);
-static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int *chanlist, unsigned int n_chan, unsigned int seglen);
-static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
-	unsigned int divisor2);
+static int check_channel_list(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      unsigned int *chanlist, unsigned int n_chan);
+static void setup_channel_list(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       unsigned int *chanlist, unsigned int n_chan,
+			       unsigned int seglen);
+static void start_pacer(struct comedi_device *dev, int mode,
+			unsigned int divisor1, unsigned int divisor2);
 static int pci1710_reset(struct comedi_device *dev);
 static int pci1710_reset(struct comedi_device *dev);
-static int pci171x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pci171x_ai_cancel(struct comedi_device *dev,
+			     struct comedi_subdevice *s);
 
 
 static const unsigned int muxonechan[] = { 0x0000, 0x0101, 0x0202, 0x0303, 0x0404, 0x0505, 0x0606, 0x0707,	/*  used for gain list programming */
 static const unsigned int muxonechan[] = { 0x0000, 0x0101, 0x0202, 0x0303, 0x0404, 0x0505, 0x0606, 0x0707,	/*  used for gain list programming */
 	0x0808, 0x0909, 0x0a0a, 0x0b0b, 0x0c0c, 0x0d0d, 0x0e0e, 0x0f0f,
 	0x0808, 0x0909, 0x0a0a, 0x0b0b, 0x0c0c, 0x0d0d, 0x0e0e, 0x0f0f,
@@ -324,8 +331,9 @@ static const unsigned int muxonechan[] = { 0x0000, 0x0101, 0x0202, 0x0303, 0x040
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci171x_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci171x_insn_read_ai(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, timeout;
 	int n, timeout;
 #ifdef PCI171x_PARANOIDCHECK
 #ifdef PCI171x_PARANOIDCHECK
@@ -364,10 +372,12 @@ static int pci171x_insn_read_ai(struct comedi_device *dev, struct comedi_subdevi
 		outb(0, dev->iobase + PCI171x_CLRFIFO);
 		outb(0, dev->iobase + PCI171x_CLRFIFO);
 		outb(0, dev->iobase + PCI171x_CLRINT);
 		outb(0, dev->iobase + PCI171x_CLRINT);
 		data[n] = 0;
 		data[n] = 0;
-		DPRINTK("adv_pci1710 EDBG: END: pci171x_insn_read_ai(...) n=%d\n", n);
+		DPRINTK
+		    ("adv_pci1710 EDBG: END: pci171x_insn_read_ai(...) n=%d\n",
+		     n);
 		return -ETIME;
 		return -ETIME;
 
 
-	      conv_finish:
+conv_finish:
 #ifdef PCI171x_PARANOIDCHECK
 #ifdef PCI171x_PARANOIDCHECK
 		idata = inw(dev->iobase + PCI171x_AD_DATA);
 		idata = inw(dev->iobase + PCI171x_AD_DATA);
 		if (this_board->cardtype != TYPE_PCI1713)
 		if (this_board->cardtype != TYPE_PCI1713)
@@ -392,8 +402,9 @@ static int pci171x_insn_read_ai(struct comedi_device *dev, struct comedi_subdevi
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci171x_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci171x_insn_write_ao(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, chan, range, ofs;
 	int n, chan, range, ofs;
 
 
@@ -423,8 +434,9 @@ static int pci171x_insn_write_ao(struct comedi_device *dev, struct comedi_subdev
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci171x_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci171x_insn_read_ao(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, chan;
 	int n, chan;
 
 
@@ -438,8 +450,9 @@ static int pci171x_insn_read_ao(struct comedi_device *dev, struct comedi_subdevi
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci171x_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci171x_insn_bits_di(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	data[1] = inw(dev->iobase + PCI171x_DI);
 	data[1] = inw(dev->iobase + PCI171x_DI);
 
 
@@ -449,8 +462,9 @@ static int pci171x_insn_bits_di(struct comedi_device *dev, struct comedi_subdevi
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci171x_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci171x_insn_bits_do(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (data[0]) {
 	if (data[0]) {
 		s->state &= ~data[0];
 		s->state &= ~data[0];
@@ -465,8 +479,10 @@ static int pci171x_insn_bits_do(struct comedi_device *dev, struct comedi_subdevi
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci171x_insn_counter_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci171x_insn_counter_read(struct comedi_device *dev,
+				     struct comedi_subdevice *s,
+				     struct comedi_insn *insn,
+				     unsigned int *data)
 {
 {
 	unsigned int msb, lsb, ccntrl;
 	unsigned int msb, lsb, ccntrl;
 	int i;
 	int i;
@@ -487,8 +503,10 @@ static int pci171x_insn_counter_read(struct comedi_device *dev, struct comedi_su
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci171x_insn_counter_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci171x_insn_counter_write(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data)
 {
 {
 	uint msb, lsb, ccntrl, status;
 	uint msb, lsb, ccntrl, status;
 
 
@@ -515,7 +533,9 @@ static int pci171x_insn_counter_write(struct comedi_device *dev, struct comedi_s
 ==============================================================================
 ==============================================================================
 */
 */
 static int pci171x_insn_counter_config(struct comedi_device *dev,
 static int pci171x_insn_counter_config(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+				       struct comedi_subdevice *s,
+				       struct comedi_insn *insn,
+				       unsigned int *data)
 {
 {
 #ifdef unused
 #ifdef unused
 	/* This doesn't work like a normal Comedi counter config */
 	/* This doesn't work like a normal Comedi counter config */
@@ -550,8 +570,9 @@ static int pci171x_insn_counter_config(struct comedi_device *dev,
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci1720_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci1720_insn_write_ao(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, rangereg, chan;
 	int n, rangereg, chan;
 
 
@@ -596,8 +617,8 @@ static void interrupt_pci1710_every_sample(void *d)
 	}
 	}
 	if (m & Status_FF) {
 	if (m & Status_FF) {
 		printk
 		printk
-			("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n",
-			dev->minor, m);
+		    ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n",
+		     dev->minor, m);
 		pci171x_ai_cancel(dev, s);
 		pci171x_ai_cancel(dev, s);
 		s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		comedi_event(dev, s);
 		comedi_event(dev, s);
@@ -613,16 +634,17 @@ static void interrupt_pci1710_every_sample(void *d)
 		DPRINTK("%04x:", sampl);
 		DPRINTK("%04x:", sampl);
 		if (this_board->cardtype != TYPE_PCI1713)
 		if (this_board->cardtype != TYPE_PCI1713)
 			if ((sampl & 0xf000) !=
 			if ((sampl & 0xf000) !=
-				devpriv->act_chanlist[s->async->cur_chan]) {
+			    devpriv->act_chanlist[s->async->cur_chan]) {
 				printk
 				printk
-					("comedi: A/D data dropout: received data from channel %d, expected %d!\n",
-					(sampl & 0xf000) >> 12,
-					(devpriv->act_chanlist[s->async->
-							cur_chan] & 0xf000) >>
-					12);
+				    ("comedi: A/D data dropout: received data from channel %d, expected %d!\n",
+				     (sampl & 0xf000) >> 12,
+				     (devpriv->
+				      act_chanlist[s->
+						   async->cur_chan] & 0xf000) >>
+				     12);
 				pci171x_ai_cancel(dev, s);
 				pci171x_ai_cancel(dev, s);
 				s->async->events |=
 				s->async->events |=
-					COMEDI_CB_EOA | COMEDI_CB_ERROR;
+				    COMEDI_CB_EOA | COMEDI_CB_ERROR;
 				comedi_event(dev, s);
 				comedi_event(dev, s);
 				return;
 				return;
 			}
 			}
@@ -631,7 +653,7 @@ static void interrupt_pci1710_every_sample(void *d)
 		comedi_buf_put(s->async, sampl & 0x0fff);
 		comedi_buf_put(s->async, sampl & 0x0fff);
 #else
 #else
 		comedi_buf_put(s->async,
 		comedi_buf_put(s->async,
-			inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff);
+			       inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff);
 #endif
 #endif
 		++s->async->cur_chan;
 		++s->async->cur_chan;
 
 
@@ -641,7 +663,10 @@ static void interrupt_pci1710_every_sample(void *d)
 
 
 		if (s->async->cur_chan == 0) {	/*  one scan done */
 		if (s->async->cur_chan == 0) {	/*  one scan done */
 			devpriv->ai_act_scan++;
 			devpriv->ai_act_scan++;
-			DPRINTK("adv_pci1710 EDBG: EOS1 bic %d bip %d buc %d bup %d\n", s->async->buf_int_count, s->async->buf_int_ptr, s->async->buf_user_count, s->async->buf_user_ptr);
+			DPRINTK
+			    ("adv_pci1710 EDBG: EOS1 bic %d bip %d buc %d bup %d\n",
+			     s->async->buf_int_count, s->async->buf_int_ptr,
+			     s->async->buf_user_count, s->async->buf_user_ptr);
 			DPRINTK("adv_pci1710 EDBG: EOS2\n");
 			DPRINTK("adv_pci1710 EDBG: EOS2\n");
 			if ((!devpriv->neverending_ai) && (devpriv->ai_act_scan >= devpriv->ai_scans)) {	/*  all data sampled */
 			if ((!devpriv->neverending_ai) && (devpriv->ai_act_scan >= devpriv->ai_scans)) {	/*  all data sampled */
 				pci171x_ai_cancel(dev, s);
 				pci171x_ai_cancel(dev, s);
@@ -661,8 +686,8 @@ static void interrupt_pci1710_every_sample(void *d)
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int move_block_from_fifo(struct comedi_device *dev, struct comedi_subdevice *s,
-	int n, int turn)
+static int move_block_from_fifo(struct comedi_device *dev,
+				struct comedi_subdevice *s, int n, int turn)
 {
 {
 	int i, j;
 	int i, j;
 #ifdef PCI171x_PARANOIDCHECK
 #ifdef PCI171x_PARANOIDCHECK
@@ -677,22 +702,21 @@ static int move_block_from_fifo(struct comedi_device *dev, struct comedi_subdevi
 		if (this_board->cardtype != TYPE_PCI1713)
 		if (this_board->cardtype != TYPE_PCI1713)
 			if ((sampl & 0xf000) != devpriv->act_chanlist[j]) {
 			if ((sampl & 0xf000) != devpriv->act_chanlist[j]) {
 				printk
 				printk
-					("comedi%d: A/D  FIFO data dropout: received data from channel %d, expected %d! (%d/%d/%d/%d/%d/%4x)\n",
-					dev->minor, (sampl & 0xf000) >> 12,
-					(devpriv->
-						act_chanlist[j] & 0xf000) >> 12,
-					i, j, devpriv->ai_act_scan, n, turn,
-					sampl);
+				    ("comedi%d: A/D  FIFO data dropout: received data from channel %d, expected %d! (%d/%d/%d/%d/%d/%4x)\n",
+				     dev->minor, (sampl & 0xf000) >> 12,
+				     (devpriv->act_chanlist[j] & 0xf000) >> 12,
+				     i, j, devpriv->ai_act_scan, n, turn,
+				     sampl);
 				pci171x_ai_cancel(dev, s);
 				pci171x_ai_cancel(dev, s);
 				s->async->events |=
 				s->async->events |=
-					COMEDI_CB_EOA | COMEDI_CB_ERROR;
+				    COMEDI_CB_EOA | COMEDI_CB_ERROR;
 				comedi_event(dev, s);
 				comedi_event(dev, s);
 				return 1;
 				return 1;
 			}
 			}
 		comedi_buf_put(s->async, sampl & 0x0fff);
 		comedi_buf_put(s->async, sampl & 0x0fff);
 #else
 #else
 		comedi_buf_put(s->async,
 		comedi_buf_put(s->async,
-			inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff);
+			       inw(dev->iobase + PCI171x_AD_DATA) & 0x0fff);
 #endif
 #endif
 		j++;
 		j++;
 		if (j >= devpriv->ai_n_chan) {
 		if (j >= devpriv->ai_n_chan) {
@@ -717,7 +741,7 @@ static void interrupt_pci1710_half_fifo(void *d)
 	m = inw(dev->iobase + PCI171x_STATUS);
 	m = inw(dev->iobase + PCI171x_STATUS);
 	if (!(m & Status_FH)) {
 	if (!(m & Status_FH)) {
 		printk("comedi%d: A/D FIFO not half full! (%4x)\n",
 		printk("comedi%d: A/D FIFO not half full! (%4x)\n",
-			dev->minor, m);
+		       dev->minor, m);
 		pci171x_ai_cancel(dev, s);
 		pci171x_ai_cancel(dev, s);
 		s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		comedi_event(dev, s);
 		comedi_event(dev, s);
@@ -725,8 +749,8 @@ static void interrupt_pci1710_half_fifo(void *d)
 	}
 	}
 	if (m & Status_FF) {
 	if (m & Status_FF) {
 		printk
 		printk
-			("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n",
-			dev->minor, m);
+		    ("comedi%d: A/D FIFO Full status (Fatal Error!) (%4x)\n",
+		     dev->minor, m);
 		pci171x_ai_cancel(dev, s);
 		pci171x_ai_cancel(dev, s);
 		s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		comedi_event(dev, s);
 		comedi_event(dev, s);
@@ -804,7 +828,7 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d)
 ==============================================================================
 ==============================================================================
 */
 */
 static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
 static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
-	struct comedi_subdevice *s)
+				     struct comedi_subdevice *s)
 {
 {
 	unsigned int divisor1, divisor2;
 	unsigned int divisor1, divisor2;
 	unsigned int seglen;
 	unsigned int seglen;
@@ -814,11 +838,11 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
 	start_pacer(dev, -1, 0, 0);	/*  stop pacer */
 	start_pacer(dev, -1, 0, 0);	/*  stop pacer */
 
 
 	seglen = check_channel_list(dev, s, devpriv->ai_chanlist,
 	seglen = check_channel_list(dev, s, devpriv->ai_chanlist,
-		devpriv->ai_n_chan);
+				    devpriv->ai_n_chan);
 	if (seglen < 1)
 	if (seglen < 1)
 		return -EINVAL;
 		return -EINVAL;
 	setup_channel_list(dev, s, devpriv->ai_chanlist,
 	setup_channel_list(dev, s, devpriv->ai_chanlist,
-		devpriv->ai_n_chan, seglen);
+			   devpriv->ai_n_chan, seglen);
 
 
 	outb(0, dev->iobase + PCI171x_CLRFIFO);
 	outb(0, dev->iobase + PCI171x_CLRFIFO);
 	outb(0, dev->iobase + PCI171x_CLRINT);
 	outb(0, dev->iobase + PCI171x_CLRINT);
@@ -840,7 +864,7 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
 
 
 	if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1)) {
 	if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1)) {
 		devpriv->neverending_ai = 1;
 		devpriv->neverending_ai = 1;
-	}			/* well, user want neverending */
+	} /* well, user want neverending */
 	else {
 	else {
 		devpriv->neverending_ai = 0;
 		devpriv->neverending_ai = 0;
 	}
 	}
@@ -853,16 +877,19 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
 		if (mode == 2) {
 		if (mode == 2) {
 			devpriv->ai_et_CntrlReg = devpriv->CntrlReg;
 			devpriv->ai_et_CntrlReg = devpriv->CntrlReg;
 			devpriv->CntrlReg &=
 			devpriv->CntrlReg &=
-				~(Control_PACER | Control_ONEFH | Control_GATE);
+			    ~(Control_PACER | Control_ONEFH | Control_GATE);
 			devpriv->CntrlReg |= Control_EXT;
 			devpriv->CntrlReg |= Control_EXT;
 			devpriv->ai_et = 1;
 			devpriv->ai_et = 1;
 		} else {
 		} else {
 			devpriv->ai_et = 0;
 			devpriv->ai_et = 0;
 		}
 		}
 		i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
 		i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
-			&divisor2, &devpriv->ai_timer1,
-			devpriv->ai_flags & TRIG_ROUND_MASK);
-		DPRINTK("adv_pci1710 EDBG: OSC base=%u div1=%u div2=%u timer=%u\n", devpriv->i8254_osc_base, divisor1, divisor2, devpriv->ai_timer1);
+					  &divisor2, &devpriv->ai_timer1,
+					  devpriv->ai_flags & TRIG_ROUND_MASK);
+		DPRINTK
+		    ("adv_pci1710 EDBG: OSC base=%u div1=%u div2=%u timer=%u\n",
+		     devpriv->i8254_osc_base, divisor1, divisor2,
+		     devpriv->ai_timer1);
 		outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
 		outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
 		if (mode != 2) {
 		if (mode != 2) {
 			/*  start pacer */
 			/*  start pacer */
@@ -889,21 +916,22 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev,
 static void pci171x_cmdtest_out(int e, struct comedi_cmd *cmd)
 static void pci171x_cmdtest_out(int e, struct comedi_cmd *cmd)
 {
 {
 	printk("adv_pci1710 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
 	printk("adv_pci1710 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e,
-		cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
+	       cmd->start_src, cmd->scan_begin_src, cmd->convert_src);
 	printk("adv_pci1710 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
 	printk("adv_pci1710 e=%d startarg=%d scanarg=%d convarg=%d\n", e,
-		cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
+	       cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg);
 	printk("adv_pci1710 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
 	printk("adv_pci1710 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src,
-		cmd->scan_end_src);
+	       cmd->scan_end_src);
 	printk("adv_pci1710 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n",
 	printk("adv_pci1710 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n",
-		e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len);
+	       e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len);
 }
 }
 #endif
 #endif
 
 
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int pci171x_ai_cmdtest(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp, divisor1, divisor2;
 	int tmp, divisor1, divisor2;
@@ -943,7 +971,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 #ifdef PCI171X_EXTDEBUG
 #ifdef PCI171X_EXTDEBUG
 		pci171x_cmdtest_out(1, cmd);
 		pci171x_cmdtest_out(1, cmd);
 #endif
 #endif
-		DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=1\n", err);
+		DPRINTK
+		    ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=1\n",
+		     err);
 		return 1;
 		return 1;
 	}
 	}
 
 
@@ -974,7 +1004,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 #ifdef PCI171X_EXTDEBUG
 #ifdef PCI171X_EXTDEBUG
 		pci171x_cmdtest_out(2, cmd);
 		pci171x_cmdtest_out(2, cmd);
 #endif
 #endif
-		DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=2\n", err);
+		DPRINTK
+		    ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=2\n",
+		     err);
 		return 2;
 		return 2;
 	}
 	}
 
 
@@ -1030,7 +1062,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 #ifdef PCI171X_EXTDEBUG
 #ifdef PCI171X_EXTDEBUG
 		pci171x_cmdtest_out(3, cmd);
 		pci171x_cmdtest_out(3, cmd);
 #endif
 #endif
-		DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=3\n", err);
+		DPRINTK
+		    ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=3\n",
+		     err);
 		return 3;
 		return 3;
 	}
 	}
 
 
@@ -1039,8 +1073,8 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 	if (cmd->convert_src == TRIG_TIMER) {
 	if (cmd->convert_src == TRIG_TIMER) {
 		tmp = cmd->convert_arg;
 		tmp = cmd->convert_arg;
 		i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
 		i8253_cascade_ns_to_timer(devpriv->i8254_osc_base, &divisor1,
-			&divisor2, &cmd->convert_arg,
-			cmd->flags & TRIG_ROUND_MASK);
+					  &divisor2, &cmd->convert_arg,
+					  cmd->flags & TRIG_ROUND_MASK);
 		if (cmd->convert_arg < this_board->ai_ns_min)
 		if (cmd->convert_arg < this_board->ai_ns_min)
 			cmd->convert_arg = this_board->ai_ns_min;
 			cmd->convert_arg = this_board->ai_ns_min;
 		if (tmp != cmd->convert_arg)
 		if (tmp != cmd->convert_arg)
@@ -1048,7 +1082,9 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 	}
 	}
 
 
 	if (err) {
 	if (err) {
-		DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=4\n", err);
+		DPRINTK
+		    ("adv_pci1710 EDBG: BGN: pci171x_ai_cmdtest(...) err=%d ret=4\n",
+		     err);
 		return 4;
 		return 4;
 	}
 	}
 
 
@@ -1056,7 +1092,7 @@ static int pci171x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 
 
 	if (cmd->chanlist) {
 	if (cmd->chanlist) {
 		if (!check_channel_list(dev, s, cmd->chanlist,
 		if (!check_channel_list(dev, s, cmd->chanlist,
-				cmd->chanlist_len))
+					cmd->chanlist_len))
 			return 5;	/*  incorrect channels list */
 			return 5;	/*  incorrect channels list */
 	}
 	}
 
 
@@ -1090,7 +1126,8 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 		if (cmd->convert_src == TRIG_TIMER) {	/*  mode 1 and 2 */
 		if (cmd->convert_src == TRIG_TIMER) {	/*  mode 1 and 2 */
 			devpriv->ai_timer1 = cmd->convert_arg;
 			devpriv->ai_timer1 = cmd->convert_arg;
 			return pci171x_ai_docmd_and_mode(cmd->start_src ==
 			return pci171x_ai_docmd_and_mode(cmd->start_src ==
-				TRIG_EXT ? 2 : 1, dev, s);
+							 TRIG_EXT ? 2 : 1, dev,
+							 s);
 		}
 		}
 		if (cmd->convert_src == TRIG_EXT) {	/*  mode 3 */
 		if (cmd->convert_src == TRIG_EXT) {	/*  mode 3 */
 			return pci171x_ai_docmd_and_mode(3, dev, s);
 			return pci171x_ai_docmd_and_mode(3, dev, s);
@@ -1106,8 +1143,9 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
  If it's ok, then program scan/gain logic.
  If it's ok, then program scan/gain logic.
  This works for all cards.
  This works for all cards.
 */
 */
-static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int *chanlist, unsigned int n_chan)
+static int check_channel_list(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      unsigned int *chanlist, unsigned int n_chan)
 {
 {
 	unsigned int chansegment[32];
 	unsigned int chansegment[32];
 	unsigned int i, nowmustbechan, seglen, segpos;
 	unsigned int i, nowmustbechan, seglen, segpos;
@@ -1128,18 +1166,18 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
 			if (CR_CHAN(chanlist[i]) & 1)	/*  odd channel cann't by differencial */
 			if (CR_CHAN(chanlist[i]) & 1)	/*  odd channel cann't by differencial */
 				if (CR_AREF(chanlist[i]) == AREF_DIFF) {
 				if (CR_AREF(chanlist[i]) == AREF_DIFF) {
 					comedi_error(dev,
 					comedi_error(dev,
-						"Odd channel can't be differential input!\n");
+						     "Odd channel can't be differential input!\n");
 					return 0;
 					return 0;
 				}
 				}
 			nowmustbechan =
 			nowmustbechan =
-				(CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
+			    (CR_CHAN(chansegment[i - 1]) + 1) % s->n_chan;
 			if (CR_AREF(chansegment[i - 1]) == AREF_DIFF)
 			if (CR_AREF(chansegment[i - 1]) == AREF_DIFF)
 				nowmustbechan = (nowmustbechan + 1) % s->n_chan;
 				nowmustbechan = (nowmustbechan + 1) % s->n_chan;
 			if (nowmustbechan != CR_CHAN(chanlist[i])) {	/*  channel list isn't continous :-( */
 			if (nowmustbechan != CR_CHAN(chanlist[i])) {	/*  channel list isn't continous :-( */
 				printk
 				printk
-					("channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n",
-					i, CR_CHAN(chanlist[i]), nowmustbechan,
-					CR_CHAN(chanlist[0]));
+				    ("channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n",
+				     i, CR_CHAN(chanlist[i]), nowmustbechan,
+				     CR_CHAN(chanlist[0]));
 				return 0;
 				return 0;
 			}
 			}
 			chansegment[i] = chanlist[i];	/*  well, this is next correct channel in list */
 			chansegment[i] = chanlist[i];	/*  well, this is next correct channel in list */
@@ -1149,13 +1187,13 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
 			/* printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); */
 			/* printk("%d %d=%d %d\n",CR_CHAN(chansegment[i%seglen]),CR_RANGE(chansegment[i%seglen]),CR_CHAN(chanlist[i]),CR_RANGE(chanlist[i])); */
 			if (chanlist[i] != chansegment[i % seglen]) {
 			if (chanlist[i] != chansegment[i % seglen]) {
 				printk
 				printk
-					("bad channel, reference 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]));
+				    ("bad channel, reference 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 */
 				return 0;	/*  chan/gain list is strange */
 			}
 			}
 		}
 		}
@@ -1165,8 +1203,10 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
 	return seglen;
 	return seglen;
 }
 }
 
 
-static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int *chanlist, unsigned int n_chan, unsigned int seglen)
+static void setup_channel_list(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       unsigned int *chanlist, unsigned int n_chan,
+			       unsigned int seglen)
 {
 {
 	unsigned int i, range, chanprog;
 	unsigned int i, range, chanprog;
 
 
@@ -1185,14 +1225,14 @@ static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevic
 		outw(range, dev->iobase + PCI171x_RANGE);	/* select gain */
 		outw(range, dev->iobase + PCI171x_RANGE);	/* select gain */
 #ifdef PCI171x_PARANOIDCHECK
 #ifdef PCI171x_PARANOIDCHECK
 		devpriv->act_chanlist[i] =
 		devpriv->act_chanlist[i] =
-			(CR_CHAN(chanlist[i]) << 12) & 0xf000;
+		    (CR_CHAN(chanlist[i]) << 12) & 0xf000;
 #endif
 #endif
 		DPRINTK("GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range,
 		DPRINTK("GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range,
 			devpriv->act_chanlist[i]);
 			devpriv->act_chanlist[i]);
 	}
 	}
 
 
 	devpriv->ai_et_MuxVal =
 	devpriv->ai_et_MuxVal =
-		CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8);
+	    CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8);
 	outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX);	/* select channel interval to scan */
 	outw(devpriv->ai_et_MuxVal, dev->iobase + PCI171x_MUX);	/* select channel interval to scan */
 	DPRINTK("MUX: %4x L%4x.H%4x\n",
 	DPRINTK("MUX: %4x L%4x.H%4x\n",
 		CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8),
 		CR_CHAN(chanlist[0]) | (CR_CHAN(chanlist[seglen - 1]) << 8),
@@ -1202,8 +1242,8 @@ static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevic
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1,
-	unsigned int divisor2)
+static void start_pacer(struct comedi_device *dev, int mode,
+			unsigned int divisor1, unsigned int divisor2)
 {
 {
 	DPRINTK("adv_pci1710 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode,
 	DPRINTK("adv_pci1710 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode,
 		divisor1, divisor2);
 		divisor1, divisor2);
@@ -1222,7 +1262,8 @@ static void start_pacer(struct comedi_device *dev, int mode, unsigned int diviso
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci171x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int pci171x_ai_cancel(struct comedi_device *dev,
+			     struct comedi_subdevice *s)
 {
 {
 	DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cancel(...)\n");
 	DPRINTK("adv_pci1710 EDBG: BGN: pci171x_ai_cancel(...)\n");
 
 
@@ -1318,7 +1359,8 @@ static int pci1710_reset(struct comedi_device *dev)
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int pci1710_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int ret, subdev, n_subdevices;
 	int ret, subdev, n_subdevices;
@@ -1347,36 +1389,35 @@ static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	pcidev = NULL;
 	pcidev = NULL;
 	board_index = this_board - boardtypes;
 	board_index = this_board - boardtypes;
 	while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH,
 	while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH,
-		PCI_ANY_ID, pcidev))) {
-		if (strcmp (this_board->name, DRV_NAME) == 0)
-		{
-			for (i = 0; i < n_boardtypes; ++i)
-			{
-				if (pcidev->device == boardtypes[i].device_id)
-				{
+						PCI_ANY_ID, pcidev))) {
+		if (strcmp(this_board->name, DRV_NAME) == 0) {
+			for (i = 0; i < n_boardtypes; ++i) {
+				if (pcidev->device == boardtypes[i].device_id) {
 					board_index = i;
 					board_index = i;
 					break;
 					break;
 				}
 				}
 			}
 			}
-			if (i == n_boardtypes) continue;
-		}else
-		{
-			if (pcidev->device != boardtypes[board_index].device_id) continue;
+			if (i == n_boardtypes)
+				continue;
+		} else {
+			if (pcidev->device != boardtypes[board_index].device_id)
+				continue;
 		}
 		}
 
 
 		/* Found matching vendor/device. */
 		/* Found matching vendor/device. */
 		if (opt_bus || opt_slot) {
 		if (opt_bus || opt_slot) {
 			/* Check bus/slot. */
 			/* Check bus/slot. */
 			if (opt_bus != pcidev->bus->number
 			if (opt_bus != pcidev->bus->number
-				|| opt_slot != PCI_SLOT(pcidev->devfn))
+			    || opt_slot != PCI_SLOT(pcidev->devfn))
 				continue;	/* no match */
 				continue;	/* no match */
 		}
 		}
 		/*
 		/*
-		* Look for device that isn't in use.
-		* Enable PCI device and request regions.
-		*/
+		 * Look for device that isn't in use.
+		 * Enable PCI device and request regions.
+		 */
 		if (comedi_pci_enable(pcidev, DRV_NAME)) {
 		if (comedi_pci_enable(pcidev, DRV_NAME)) {
-			errstr = "failed to enable PCI device and request regions!";
+			errstr =
+			    "failed to enable PCI device and request regions!";
 			continue;
 			continue;
 		}
 		}
 		/*  fixup board_ptr in case we were using the dummy entry with the driver name */
 		/*  fixup board_ptr in case we were using the dummy entry with the driver name */
@@ -1387,7 +1428,7 @@ static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	if (!pcidev) {
 	if (!pcidev) {
 		if (opt_bus || opt_slot) {
 		if (opt_bus || opt_slot) {
 			printk(" - Card at b:s %d:%d %s\n",
 			printk(" - Card at b:s %d:%d %s\n",
-				opt_bus, opt_slot, errstr);
+			       opt_bus, opt_slot, errstr);
 		} else {
 		} else {
 			printk(" - Card %s\n", errstr);
 			printk(" - Card %s\n", errstr);
 		}
 		}
@@ -1401,7 +1442,7 @@ static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	iobase = pci_resource_start(pcidev, 2);
 	iobase = pci_resource_start(pcidev, 2);
 
 
 	printk(", b:s:f=%d:%d:%d, io=0x%4lx", pci_bus, pci_slot, pci_func,
 	printk(", b:s:f=%d:%d:%d, io=0x%4lx", pci_bus, pci_slot, pci_func,
-		iobase);
+	       iobase);
 
 
 	dev->iobase = iobase;
 	dev->iobase = iobase;
 
 
@@ -1434,8 +1475,8 @@ static int pci1710_attach(struct comedi_device *dev, struct comedi_devconfig *it
 					IRQF_SHARED, "Advantech PCI-1710",
 					IRQF_SHARED, "Advantech PCI-1710",
 					dev)) {
 					dev)) {
 				printk
 				printk
-					(", unable to allocate IRQ %d, DISABLING IT",
-					irq);
+				    (", unable to allocate IRQ %d, DISABLING IT",
+				     irq);
 				irq = 0;	/* Can't use IRQ */
 				irq = 0;	/* Can't use IRQ */
 			} else {
 			} else {
 				printk(", irq=%u", irq);
 				printk(", irq=%u", irq);

+ 40 - 33
drivers/staging/comedi/drivers/adv_pci1723.c

@@ -95,8 +95,8 @@ TODO:
 /* static unsigned short pci_list_builded=0;      =1 list of card is know */
 /* static unsigned short pci_list_builded=0;      =1 list of card is know */
 
 
 static const struct comedi_lrange range_pci1723 = { 1, {
 static const struct comedi_lrange range_pci1723 = { 1, {
-			BIP_RANGE(10)
-	}
+							BIP_RANGE(10)
+							}
 };
 };
 
 
 /*
 /*
@@ -116,23 +116,24 @@ struct pci1723_board {
 
 
 static const struct pci1723_board boardtypes[] = {
 static const struct pci1723_board boardtypes[] = {
 	{
 	{
-	.name = "pci1723",
-	.vendor_id = ADVANTECH_VENDOR,
-	.device_id = 0x1723,
-	.iorange = IORANGE_1723,
-	.cardtype = TYPE_PCI1723,
-	.n_aochan = 8,
-	.n_diochan = 16,
-	.ao_maxdata = 0xffff,
-	.rangelist_ao = &range_pci1723,
-		},
+	 .name = "pci1723",
+	 .vendor_id = ADVANTECH_VENDOR,
+	 .device_id = 0x1723,
+	 .iorange = IORANGE_1723,
+	 .cardtype = TYPE_PCI1723,
+	 .n_aochan = 8,
+	 .n_diochan = 16,
+	 .ao_maxdata = 0xffff,
+	 .rangelist_ao = &range_pci1723,
+	 },
 };
 };
 
 
 /* This is used by modprobe to translate PCI IDs to drivers.  Should
 /* This is used by modprobe to translate PCI IDs to drivers.  Should
  * only be used for PCI and ISA-PnP devices */
  * only be used for PCI and ISA-PnP devices */
 static DEFINE_PCI_DEVICE_TABLE(pci1723_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(pci1723_pci_table) = {
-	{PCI_VENDOR_ID_ADVANTECH, 0x1723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_ADVANTECH, 0x1723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, pci1723_pci_table);
 MODULE_DEVICE_TABLE(pci, pci1723_pci_table);
@@ -143,7 +144,8 @@ MODULE_DEVICE_TABLE(pci, pci1723_pci_table);
  * the board, and also about the kernel module that contains
  * the board, and also about the kernel module that contains
  * the device code.
  * the device code.
  */
  */
-static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci1723_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int pci1723_detach(struct comedi_device *dev);
 static int pci1723_detach(struct comedi_device *dev);
 
 
 #define n_boardtypes (sizeof(boardtypes)/sizeof(struct pci1723_board))
 #define n_boardtypes (sizeof(boardtypes)/sizeof(struct pci1723_board))
@@ -189,7 +191,7 @@ static int pci1723_reset(struct comedi_device *dev)
 		/*  set all ranges to +/- 10V */
 		/*  set all ranges to +/- 10V */
 		devpriv->da_range[i] = 0;
 		devpriv->da_range[i] = 0;
 		outw(((devpriv->da_range[i] << 4) | i),
 		outw(((devpriv->da_range[i] << 4) | i),
-			PCI1723_RANGE_CALIBRATION_MODE);
+		     PCI1723_RANGE_CALIBRATION_MODE);
 	}
 	}
 
 
 	outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE);	/*  update ranges */
 	outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE);	/*  update ranges */
@@ -202,8 +204,9 @@ static int pci1723_reset(struct comedi_device *dev)
 	return 0;
 	return 0;
 }
 }
 
 
-static int pci1723_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci1723_insn_read_ao(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, chan;
 	int n, chan;
 
 
@@ -218,8 +221,9 @@ static int pci1723_insn_read_ao(struct comedi_device *dev, struct comedi_subdevi
 /*
 /*
   analog data output;
   analog data output;
 */
 */
-static int pci1723_ao_write_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci1723_ao_write_winsn(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, chan;
 	int n, chan;
 	chan = CR_CHAN(insn->chanspec);
 	chan = CR_CHAN(insn->chanspec);
@@ -238,8 +242,9 @@ static int pci1723_ao_write_winsn(struct comedi_device *dev, struct comedi_subde
 /*
 /*
   digital i/o config/query
   digital i/o config/query
 */
 */
-static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci1723_dio_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int mask;
 	unsigned int mask;
 	unsigned int bits;
 	unsigned int bits;
@@ -278,8 +283,9 @@ static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subd
 /*
 /*
   digital i/o bits read/write
   digital i/o bits read/write
 */
 */
-static int pci1723_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci1723_dio_insn_bits(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (data[0]) {
 	if (data[0]) {
 		s->state &= ~data[0];
 		s->state &= ~data[0];
@@ -294,7 +300,8 @@ static int pci1723_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
  * Attach is called by the Comedi core to configure the driver
  * Attach is called by the Comedi core to configure the driver
  * for a pci1723 board.
  * for a pci1723 board.
  */
  */
-static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int pci1723_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int ret, subdev, n_subdevices;
 	int ret, subdev, n_subdevices;
@@ -304,8 +311,7 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	int opt_bus, opt_slot;
 	int opt_bus, opt_slot;
 	const char *errstr;
 	const char *errstr;
 
 
-	printk("comedi%d: adv_pci1723: board=%s", dev->minor,
-		this_board->name);
+	printk("comedi%d: adv_pci1723: board=%s", dev->minor, this_board->name);
 
 
 	opt_bus = it->options[0];
 	opt_bus = it->options[0];
 	opt_slot = it->options[1];
 	opt_slot = it->options[1];
@@ -321,12 +327,12 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	pcidev = NULL;
 	pcidev = NULL;
 	while (NULL != (pcidev =
 	while (NULL != (pcidev =
 			pci_get_device(PCI_VENDOR_ID_ADVANTECH,
 			pci_get_device(PCI_VENDOR_ID_ADVANTECH,
-				this_board->device_id, pcidev))) {
+				       this_board->device_id, pcidev))) {
 		/* Found matching vendor/device. */
 		/* Found matching vendor/device. */
 		if (opt_bus || opt_slot) {
 		if (opt_bus || opt_slot) {
 			/* Check bus/slot. */
 			/* Check bus/slot. */
 			if (opt_bus != pcidev->bus->number
 			if (opt_bus != pcidev->bus->number
-				|| opt_slot != PCI_SLOT(pcidev->devfn))
+			    || opt_slot != PCI_SLOT(pcidev->devfn))
 				continue;	/* no match */
 				continue;	/* no match */
 		}
 		}
 		/*
 		/*
@@ -334,7 +340,8 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		 * Enable PCI device and request regions.
 		 * Enable PCI device and request regions.
 		 */
 		 */
 		if (comedi_pci_enable(pcidev, "adv_pci1723")) {
 		if (comedi_pci_enable(pcidev, "adv_pci1723")) {
-			errstr = "failed to enable PCI device and request regions!";
+			errstr =
+			    "failed to enable PCI device and request regions!";
 			continue;
 			continue;
 		}
 		}
 		break;
 		break;
@@ -343,7 +350,7 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	if (!pcidev) {
 	if (!pcidev) {
 		if (opt_bus || opt_slot) {
 		if (opt_bus || opt_slot) {
 			printk(" - Card at b:s %d:%d %s\n",
 			printk(" - Card at b:s %d:%d %s\n",
-				opt_bus, opt_slot, errstr);
+			       opt_bus, opt_slot, errstr);
 		} else {
 		} else {
 			printk(" - Card %s\n", errstr);
 			printk(" - Card %s\n", errstr);
 		}
 		}
@@ -356,7 +363,7 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	iobase = pci_resource_start(pcidev, 2);
 	iobase = pci_resource_start(pcidev, 2);
 
 
 	printk(", b:s:f=%d:%d:%d, io=0x%4x", pci_bus, pci_slot, pci_func,
 	printk(", b:s:f=%d:%d:%d, io=0x%4x", pci_bus, pci_slot, pci_func,
-		iobase);
+	       iobase);
 
 
 	dev->iobase = iobase;
 	dev->iobase = iobase;
 
 
@@ -416,7 +423,7 @@ static int pci1723_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		s = dev->subdevices + subdev;
 		s = dev->subdevices + subdev;
 		s->type = COMEDI_SUBD_DIO;
 		s->type = COMEDI_SUBD_DIO;
 		s->subdev_flags =
 		s->subdev_flags =
-			SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
+		    SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
 		s->n_chan = this_board->n_diochan;
 		s->n_chan = this_board->n_diochan;
 		s->maxdata = 1;
 		s->maxdata = 1;
 		s->len_chanlist = this_board->n_diochan;
 		s->len_chanlist = this_board->n_diochan;

+ 160 - 146
drivers/staging/comedi/drivers/adv_pci_dio.c

@@ -84,13 +84,13 @@ enum hw_io_access {
 #define PCI173x_BOARDID	   4	/* R:   Board I/D switch for 1730/3/4 */
 #define PCI173x_BOARDID	   4	/* R:   Board I/D switch for 1730/3/4 */
 
 
 /*  Advantech PCI-1736UP */
 /*  Advantech PCI-1736UP */
-#define PCI1736_IDI        0    /* R:   Isolated digital input  0-15 */
-#define PCI1736_IDO        0    /* W:   Isolated digital output 0-15 */
-#define PCI1736_3_INT_EN        0x08    /* R/W: enable/disable interrupts */
-#define PCI1736_3_INT_RF        0x0c    /* R/W: set falling/raising edge for interrupts */
-#define PCI1736_3_INT_CLR       0x10    /* R/W: clear interrupts */
-#define PCI1736_BOARDID    4            /* R:   Board I/D switch for 1736UP */
-#define PCI1736_MAINREG    0            /* Normal register (2) doesn't work */
+#define PCI1736_IDI        0	/* R:   Isolated digital input  0-15 */
+#define PCI1736_IDO        0	/* W:   Isolated digital output 0-15 */
+#define PCI1736_3_INT_EN        0x08	/* R/W: enable/disable interrupts */
+#define PCI1736_3_INT_RF        0x0c	/* R/W: set falling/raising edge for interrupts */
+#define PCI1736_3_INT_CLR       0x10	/* R/W: clear interrupts */
+#define PCI1736_BOARDID    4	/* R:   Board I/D switch for 1736UP */
+#define PCI1736_MAINREG    0	/* Normal register (2) doesn't work */
 
 
 /*  Advantech PCI-1750 */
 /*  Advantech PCI-1750 */
 #define PCI1750_IDI	   0	/* R:   Isolated digital input  0-15 */
 #define PCI1750_IDI	   0	/* R:   Isolated digital input  0-15 */
@@ -183,7 +183,8 @@ enum hw_io_access {
 
 
 #define OMBCMD_RETRY	0x03	/* 3 times try request before error */
 #define OMBCMD_RETRY	0x03	/* 3 times try request before error */
 
 
-static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci_dio_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int pci_dio_detach(struct comedi_device *dev);
 static int pci_dio_detach(struct comedi_device *dev);
 
 
 struct diosubd_data {
 struct diosubd_data {
@@ -207,117 +208,118 @@ struct dio_boardtype {
 };
 };
 
 
 static DEFINE_PCI_DEVICE_TABLE(pci_dio_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(pci_dio_pci_table) = {
-	{PCI_VENDOR_ID_ADVANTECH, 0x1730, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1733, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1734, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1752, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1753, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1754, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1756, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1760, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_ADVANTECH, 0x1762, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_ADVANTECH, 0x1730, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1733, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1734, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1750, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1751, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1752, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1753, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1754, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1756, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1760, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_ADVANTECH, 0x1762, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, pci_dio_pci_table);
 MODULE_DEVICE_TABLE(pci, pci_dio_pci_table);
 
 
 static const struct dio_boardtype boardtypes[] = {
 static const struct dio_boardtype boardtypes[] = {
 	{"pci1730", PCI_VENDOR_ID_ADVANTECH, 0x1730, PCIDIO_MAINREG,
 	{"pci1730", PCI_VENDOR_ID_ADVANTECH, 0x1730, PCIDIO_MAINREG,
-			TYPE_PCI1730,
-			{{16, PCI1730_DI, 2, 0}, {16, PCI1730_IDI, 2, 0}},
-			{{16, PCI1730_DO, 2, 0}, {16, PCI1730_IDO, 2, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{4, PCI173x_BOARDID, 1, SDF_INTERNAL},
-			IO_8b,
-		},
+	 TYPE_PCI1730,
+	 {{16, PCI1730_DI, 2, 0}, {16, PCI1730_IDI, 2, 0}},
+	 {{16, PCI1730_DO, 2, 0}, {16, PCI1730_IDO, 2, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {4, PCI173x_BOARDID, 1, SDF_INTERNAL},
+	 IO_8b,
+	 },
 	{"pci1733", PCI_VENDOR_ID_ADVANTECH, 0x1733, PCIDIO_MAINREG,
 	{"pci1733", PCI_VENDOR_ID_ADVANTECH, 0x1733, PCIDIO_MAINREG,
-			TYPE_PCI1733,
-			{{0, 0, 0, 0}, {32, PCI1733_IDI, 4, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{4, PCI173x_BOARDID, 1, SDF_INTERNAL},
-		IO_8b},
+	 TYPE_PCI1733,
+	 {{0, 0, 0, 0}, {32, PCI1733_IDI, 4, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {4, PCI173x_BOARDID, 1, SDF_INTERNAL},
+	 IO_8b},
 	{"pci1734", PCI_VENDOR_ID_ADVANTECH, 0x1734, PCIDIO_MAINREG,
 	{"pci1734", PCI_VENDOR_ID_ADVANTECH, 0x1734, PCIDIO_MAINREG,
-			TYPE_PCI1734,
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{0, 0, 0, 0}, {32, PCI1734_IDO, 4, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{4, PCI173x_BOARDID, 1, SDF_INTERNAL},
-		IO_8b},
+	 TYPE_PCI1734,
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{0, 0, 0, 0}, {32, PCI1734_IDO, 4, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {4, PCI173x_BOARDID, 1, SDF_INTERNAL},
+	 IO_8b},
 	{"pci1736", PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI1736_MAINREG,
 	{"pci1736", PCI_VENDOR_ID_ADVANTECH, 0x1736, PCI1736_MAINREG,
-			TYPE_PCI1736,
-			{{0, 0, 0, 0}, {16, PCI1736_IDI, 2, 0}},
-			{{0, 0, 0, 0}, {16, PCI1736_IDO, 2, 0}},
-			{{ 0, 0, 0, 0}, { 0, 0, 0, 0}},
-			{ 4, PCI1736_BOARDID, 1, SDF_INTERNAL},
-			IO_8b,
-        },
+	 TYPE_PCI1736,
+	 {{0, 0, 0, 0}, {16, PCI1736_IDI, 2, 0}},
+	 {{0, 0, 0, 0}, {16, PCI1736_IDO, 2, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {4, PCI1736_BOARDID, 1, SDF_INTERNAL},
+	 IO_8b,
+	 },
 	{"pci1750", PCI_VENDOR_ID_ADVANTECH, 0x1750, PCIDIO_MAINREG,
 	{"pci1750", PCI_VENDOR_ID_ADVANTECH, 0x1750, PCIDIO_MAINREG,
-			TYPE_PCI1750,
-			{{0, 0, 0, 0}, {16, PCI1750_IDI, 2, 0}},
-			{{0, 0, 0, 0}, {16, PCI1750_IDO, 2, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{0, 0, 0, 0},
-		IO_8b},
+	 TYPE_PCI1750,
+	 {{0, 0, 0, 0}, {16, PCI1750_IDI, 2, 0}},
+	 {{0, 0, 0, 0}, {16, PCI1750_IDO, 2, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {0, 0, 0, 0},
+	 IO_8b},
 	{"pci1751", PCI_VENDOR_ID_ADVANTECH, 0x1751, PCIDIO_MAINREG,
 	{"pci1751", PCI_VENDOR_ID_ADVANTECH, 0x1751, PCIDIO_MAINREG,
-			TYPE_PCI1751,
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{48, PCI1751_DIO, 2, 0}, {0, 0, 0, 0}},
-			{0, 0, 0, 0},
-		IO_8b},
+	 TYPE_PCI1751,
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{48, PCI1751_DIO, 2, 0}, {0, 0, 0, 0}},
+	 {0, 0, 0, 0},
+	 IO_8b},
 	{"pci1752", PCI_VENDOR_ID_ADVANTECH, 0x1752, PCIDIO_MAINREG,
 	{"pci1752", PCI_VENDOR_ID_ADVANTECH, 0x1752, PCIDIO_MAINREG,
-			TYPE_PCI1752,
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{32, PCI1752_IDO, 2, 0}, {32, PCI1752_IDO2, 2, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{4, PCI175x_BOARDID, 1, SDF_INTERNAL},
-		IO_16b},
+	 TYPE_PCI1752,
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{32, PCI1752_IDO, 2, 0}, {32, PCI1752_IDO2, 2, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {4, PCI175x_BOARDID, 1, SDF_INTERNAL},
+	 IO_16b},
 	{"pci1753", PCI_VENDOR_ID_ADVANTECH, 0x1753, PCIDIO_MAINREG,
 	{"pci1753", PCI_VENDOR_ID_ADVANTECH, 0x1753, PCIDIO_MAINREG,
-			TYPE_PCI1753,
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{96, PCI1753_DIO, 4, 0}, {0, 0, 0, 0}},
-			{0, 0, 0, 0},
-		IO_8b},
+	 TYPE_PCI1753,
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{96, PCI1753_DIO, 4, 0}, {0, 0, 0, 0}},
+	 {0, 0, 0, 0},
+	 IO_8b},
 	{"pci1753e", PCI_VENDOR_ID_ADVANTECH, 0x1753, PCIDIO_MAINREG,
 	{"pci1753e", PCI_VENDOR_ID_ADVANTECH, 0x1753, PCIDIO_MAINREG,
-			TYPE_PCI1753E,
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{96, PCI1753_DIO, 4, 0}, {96, PCI1753E_DIO, 4, 0}},
-			{0, 0, 0, 0},
-		IO_8b},
+	 TYPE_PCI1753E,
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{96, PCI1753_DIO, 4, 0}, {96, PCI1753E_DIO, 4, 0}},
+	 {0, 0, 0, 0},
+	 IO_8b},
 	{"pci1754", PCI_VENDOR_ID_ADVANTECH, 0x1754, PCIDIO_MAINREG,
 	{"pci1754", PCI_VENDOR_ID_ADVANTECH, 0x1754, PCIDIO_MAINREG,
-			TYPE_PCI1754,
-			{{32, PCI1754_IDI, 2, 0}, {32, PCI1754_IDI2, 2, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{4, PCI175x_BOARDID, 1, SDF_INTERNAL},
-		IO_16b},
+	 TYPE_PCI1754,
+	 {{32, PCI1754_IDI, 2, 0}, {32, PCI1754_IDI2, 2, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {4, PCI175x_BOARDID, 1, SDF_INTERNAL},
+	 IO_16b},
 	{"pci1756", PCI_VENDOR_ID_ADVANTECH, 0x1756, PCIDIO_MAINREG,
 	{"pci1756", PCI_VENDOR_ID_ADVANTECH, 0x1756, PCIDIO_MAINREG,
-			TYPE_PCI1756,
-			{{0, 0, 0, 0}, {32, PCI1756_IDI, 2, 0}},
-			{{0, 0, 0, 0}, {32, PCI1756_IDO, 2, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{4, PCI175x_BOARDID, 1, SDF_INTERNAL},
-		IO_16b},
+	 TYPE_PCI1756,
+	 {{0, 0, 0, 0}, {32, PCI1756_IDI, 2, 0}},
+	 {{0, 0, 0, 0}, {32, PCI1756_IDO, 2, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {4, PCI175x_BOARDID, 1, SDF_INTERNAL},
+	 IO_16b},
 	{"pci1760", PCI_VENDOR_ID_ADVANTECH, 0x1760, 0,
 	{"pci1760", PCI_VENDOR_ID_ADVANTECH, 0x1760, 0,
-			TYPE_PCI1760,
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},	/*  This card have own setup work */
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{0, 0, 0, 0},
-		IO_8b},
+	 TYPE_PCI1760,
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},	/*  This card have own setup work */
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {0, 0, 0, 0},
+	 IO_8b},
 	{"pci1762", PCI_VENDOR_ID_ADVANTECH, 0x1762, PCIDIO_MAINREG,
 	{"pci1762", PCI_VENDOR_ID_ADVANTECH, 0x1762, PCIDIO_MAINREG,
-			TYPE_PCI1762,
-			{{0, 0, 0, 0}, {16, PCI1762_IDI, 1, 0}},
-			{{0, 0, 0, 0}, {16, PCI1762_RO, 1, 0}},
-			{{0, 0, 0, 0}, {0, 0, 0, 0}},
-			{4, PCI1762_BOARDID, 1, SDF_INTERNAL},
-		IO_16b}
+	 TYPE_PCI1762,
+	 {{0, 0, 0, 0}, {16, PCI1762_IDI, 1, 0}},
+	 {{0, 0, 0, 0}, {16, PCI1762_RO, 1, 0}},
+	 {{0, 0, 0, 0}, {0, 0, 0, 0}},
+	 {4, PCI1762_BOARDID, 1, SDF_INTERNAL},
+	 IO_16b}
 };
 };
 
 
 #define n_boardtypes (sizeof(boardtypes)/sizeof(struct dio_boardtype))
 #define n_boardtypes (sizeof(boardtypes)/sizeof(struct dio_boardtype))
@@ -357,8 +359,9 @@ static struct pci_dio_private *pci_priv = NULL;	/* list of allocated cards */
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci_dio_insn_bits_di_b(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci_dio_insn_bits_di_b(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	const struct diosubd_data *d = (const struct diosubd_data *)s->private;
 	const struct diosubd_data *d = (const struct diosubd_data *)s->private;
 	int i;
 	int i;
@@ -374,8 +377,9 @@ static int pci_dio_insn_bits_di_b(struct comedi_device *dev, struct comedi_subde
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci_dio_insn_bits_di_w(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci_dio_insn_bits_di_w(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	const struct diosubd_data *d = (const struct diosubd_data *)s->private;
 	const struct diosubd_data *d = (const struct diosubd_data *)s->private;
 	int i;
 	int i;
@@ -390,8 +394,9 @@ static int pci_dio_insn_bits_di_w(struct comedi_device *dev, struct comedi_subde
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci_dio_insn_bits_do_b(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci_dio_insn_bits_do_b(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	const struct diosubd_data *d = (const struct diosubd_data *)s->private;
 	const struct diosubd_data *d = (const struct diosubd_data *)s->private;
 	int i;
 	int i;
@@ -401,7 +406,7 @@ static int pci_dio_insn_bits_do_b(struct comedi_device *dev, struct comedi_subde
 		s->state |= (data[0] & data[1]);
 		s->state |= (data[0] & data[1]);
 		for (i = 0; i < d->regs; i++)
 		for (i = 0; i < d->regs; i++)
 			outb((s->state >> (8 * i)) & 0xff,
 			outb((s->state >> (8 * i)) & 0xff,
-				dev->iobase + d->addr + i);
+			     dev->iobase + d->addr + i);
 	}
 	}
 	data[1] = s->state;
 	data[1] = s->state;
 
 
@@ -411,8 +416,9 @@ static int pci_dio_insn_bits_do_b(struct comedi_device *dev, struct comedi_subde
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci_dio_insn_bits_do_w(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci_dio_insn_bits_do_w(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	const struct diosubd_data *d = (const struct diosubd_data *)s->private;
 	const struct diosubd_data *d = (const struct diosubd_data *)s->private;
 	int i;
 	int i;
@@ -422,7 +428,7 @@ static int pci_dio_insn_bits_do_w(struct comedi_device *dev, struct comedi_subde
 		s->state |= (data[0] & data[1]);
 		s->state |= (data[0] & data[1]);
 		for (i = 0; i < d->regs; i++)
 		for (i = 0; i < d->regs; i++)
 			outw((s->state >> (16 * i)) & 0xffff,
 			outw((s->state >> (16 * i)) & 0xffff,
-				dev->iobase + d->addr + 2 * i);
+			     dev->iobase + d->addr + 2 * i);
 	}
 	}
 	data[1] = s->state;
 	data[1] = s->state;
 
 
@@ -433,7 +439,8 @@ static int pci_dio_insn_bits_do_w(struct comedi_device *dev, struct comedi_subde
 ==============================================================================
 ==============================================================================
 */
 */
 static int pci1760_unchecked_mbxrequest(struct comedi_device *dev,
 static int pci1760_unchecked_mbxrequest(struct comedi_device *dev,
-	unsigned char *omb, unsigned char *imb, int repeats)
+					unsigned char *omb, unsigned char *imb,
+					int repeats)
 {
 {
 	int cnt, tout, ok = 0;
 	int cnt, tout, ok = 0;
 
 
@@ -472,11 +479,11 @@ static int pci1760_clear_imb2(struct comedi_device *dev)
 }
 }
 
 
 static int pci1760_mbxrequest(struct comedi_device *dev,
 static int pci1760_mbxrequest(struct comedi_device *dev,
-	unsigned char *omb, unsigned char *imb)
+			      unsigned char *omb, unsigned char *imb)
 {
 {
 	if (omb[2] == CMD_ClearIMB2) {
 	if (omb[2] == CMD_ClearIMB2) {
 		comedi_error(dev,
 		comedi_error(dev,
-			"bug! this function should not be used for CMD_ClearIMB2 command");
+			     "bug! this function should not be used for CMD_ClearIMB2 command");
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 	if (inb(dev->iobase + IMB2) == omb[2]) {
 	if (inb(dev->iobase + IMB2) == omb[2]) {
@@ -491,8 +498,9 @@ static int pci1760_mbxrequest(struct comedi_device *dev,
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci1760_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci1760_insn_bits_di(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	data[1] = inb(dev->iobase + IMB3);
 	data[1] = inb(dev->iobase + IMB3);
 
 
@@ -502,8 +510,9 @@ static int pci1760_insn_bits_di(struct comedi_device *dev, struct comedi_subdevi
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci1760_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci1760_insn_bits_do(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int ret;
 	int ret;
 	unsigned char omb[4] = {
 	unsigned char omb[4] = {
@@ -530,8 +539,9 @@ static int pci1760_insn_bits_do(struct comedi_device *dev, struct comedi_subdevi
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci1760_insn_cnt_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci1760_insn_cnt_read(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int ret, n;
 	int ret, n;
 	unsigned char omb[4] = {
 	unsigned char omb[4] = {
@@ -555,8 +565,9 @@ static int pci1760_insn_cnt_read(struct comedi_device *dev, struct comedi_subdev
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci1760_insn_cnt_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci1760_insn_cnt_write(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int ret;
 	int ret;
 	unsigned char chan = CR_CHAN(insn->chanspec) & 0x07;
 	unsigned char chan = CR_CHAN(insn->chanspec) & 0x07;
@@ -570,7 +581,7 @@ static int pci1760_insn_cnt_write(struct comedi_device *dev, struct comedi_subde
 	unsigned char imb[4];
 	unsigned char imb[4];
 
 
 	if (devpriv->CntResValue[chan] != (data[0] & 0xffff)) {	/*  Set reset value if different */
 	if (devpriv->CntResValue[chan] != (data[0] & 0xffff)) {	/*  Set reset value if different */
-		ret =  pci1760_mbxrequest(dev, omb, imb);
+		ret = pci1760_mbxrequest(dev, omb, imb);
 		if (!ret)
 		if (!ret)
 			return ret;
 			return ret;
 		devpriv->CntResValue[chan] = data[0] & 0xffff;
 		devpriv->CntResValue[chan] = data[0] & 0xffff;
@@ -697,11 +708,11 @@ static int pci_dio_reset(struct comedi_device *dev)
 		break;
 		break;
 
 
 	case TYPE_PCI1736:
 	case TYPE_PCI1736:
-		outb(0, dev->iobase+PCI1736_IDO);
-		outb(0, dev->iobase+PCI1736_IDO+1);
-		outb(0, dev->iobase+PCI1736_3_INT_EN);  /*  disable interrupts */
-		outb(0x0f, dev->iobase+PCI1736_3_INT_CLR);/*  clear interrupts */
-		outb(0, dev->iobase+PCI1736_3_INT_RF);  /*  set rising edge trigger */
+		outb(0, dev->iobase + PCI1736_IDO);
+		outb(0, dev->iobase + PCI1736_IDO + 1);
+		outb(0, dev->iobase + PCI1736_3_INT_EN);	/*  disable interrupts */
+		outb(0x0f, dev->iobase + PCI1736_3_INT_CLR);	/*  clear interrupts */
+		outb(0, dev->iobase + PCI1736_3_INT_RF);	/*  set rising edge trigger */
 		break;
 		break;
 
 
 	case TYPE_PCI1750:
 	case TYPE_PCI1750:
@@ -756,7 +767,8 @@ static int pci_dio_reset(struct comedi_device *dev)
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci1760_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int pci1760_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int subdev = 0;
 	int subdev = 0;
@@ -809,7 +821,7 @@ static int pci1760_attach(struct comedi_device *dev, struct comedi_devconfig *it
 ==============================================================================
 ==============================================================================
 */
 */
 static int pci_dio_add_di(struct comedi_device *dev, struct comedi_subdevice *s,
 static int pci_dio_add_di(struct comedi_device *dev, struct comedi_subdevice *s,
-	const struct diosubd_data *d, int subdev)
+			  const struct diosubd_data *d, int subdev)
 {
 {
 	s->type = COMEDI_SUBD_DI;
 	s->type = COMEDI_SUBD_DI;
 	s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON | d->specflags;
 	s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON | d->specflags;
@@ -836,7 +848,7 @@ static int pci_dio_add_di(struct comedi_device *dev, struct comedi_subdevice *s,
 ==============================================================================
 ==============================================================================
 */
 */
 static int pci_dio_add_do(struct comedi_device *dev, struct comedi_subdevice *s,
 static int pci_dio_add_do(struct comedi_device *dev, struct comedi_subdevice *s,
-	const struct diosubd_data *d, int subdev)
+			  const struct diosubd_data *d, int subdev)
 {
 {
 	s->type = COMEDI_SUBD_DO;
 	s->type = COMEDI_SUBD_DO;
 	s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
 	s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
@@ -863,8 +875,9 @@ static int pci_dio_add_do(struct comedi_device *dev, struct comedi_subdevice *s,
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int CheckAndAllocCard(struct comedi_device *dev, struct comedi_devconfig *it,
-	struct pci_dev *pcidev)
+static int CheckAndAllocCard(struct comedi_device *dev,
+			     struct comedi_devconfig *it,
+			     struct pci_dev *pcidev)
 {
 {
 	struct pci_dio_private *pr, *prev;
 	struct pci_dio_private *pr, *prev;
 
 
@@ -889,7 +902,8 @@ static int CheckAndAllocCard(struct comedi_device *dev, struct comedi_devconfig
 /*
 /*
 ==============================================================================
 ==============================================================================
 */
 */
-static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int pci_dio_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int ret, subdev, n_subdevices, i, j;
 	int ret, subdev, n_subdevices, i, j;
@@ -905,8 +919,8 @@ static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	}
 	}
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 		/*  loop through cards supported by this driver */
 		/*  loop through cards supported by this driver */
 		for (i = 0; i < n_boardtypes; ++i) {
 		for (i = 0; i < n_boardtypes; ++i) {
 			if (boardtypes[i].vendor_id != pcidev->vendor)
 			if (boardtypes[i].vendor_id != pcidev->vendor)
@@ -917,13 +931,13 @@ static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it
 			if (it->options[0] || it->options[1]) {
 			if (it->options[0] || it->options[1]) {
 				/*  are we on the wrong bus/slot? */
 				/*  are we on the wrong bus/slot? */
 				if (pcidev->bus->number != it->options[0] ||
 				if (pcidev->bus->number != it->options[0] ||
-					PCI_SLOT(pcidev->devfn) !=
-					it->options[1]) {
+				    PCI_SLOT(pcidev->devfn) != it->options[1]) {
 					continue;
 					continue;
 				}
 				}
 			}
 			}
 			ret = CheckAndAllocCard(dev, it, pcidev);
 			ret = CheckAndAllocCard(dev, it, pcidev);
-			if (ret != 1) continue;
+			if (ret != 1)
+				continue;
 			dev->board_ptr = boardtypes + i;
 			dev->board_ptr = boardtypes + i;
 			break;
 			break;
 		}
 		}
@@ -932,20 +946,19 @@ static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	}
 	}
 
 
 	if (!dev->board_ptr) {
 	if (!dev->board_ptr) {
-		printk
-			(", Error: Requested type of the card was not found!\n");
+		printk(", Error: Requested type of the card was not found!\n");
 		return -EIO;
 		return -EIO;
 	}
 	}
 
 
 	if (comedi_pci_enable(pcidev, driver_pci_dio.driver_name)) {
 	if (comedi_pci_enable(pcidev, driver_pci_dio.driver_name)) {
 		printk
 		printk
-			(", Error: Can't enable PCI device and request regions!\n");
+		    (", Error: Can't enable PCI device and request regions!\n");
 		return -EIO;
 		return -EIO;
 	}
 	}
 	iobase = pci_resource_start(pcidev, this_board->main_pci_region);
 	iobase = pci_resource_start(pcidev, this_board->main_pci_region);
 	printk(", b:s:f=%d:%d:%d, io=0x%4lx",
 	printk(", b:s:f=%d:%d:%d, io=0x%4lx",
-		pcidev->bus->number, PCI_SLOT(pcidev->devfn),
-		PCI_FUNC(pcidev->devfn), iobase);
+	       pcidev->bus->number, PCI_SLOT(pcidev->devfn),
+	       PCI_FUNC(pcidev->devfn), iobase);
 
 
 	dev->iobase = iobase;
 	dev->iobase = iobase;
 	dev->board_name = this_board->name;
 	dev->board_name = this_board->name;
@@ -994,8 +1007,9 @@ static int pci_dio_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		for (j = 0; j < this_board->sdio[i].regs; j++) {
 		for (j = 0; j < this_board->sdio[i].regs; j++) {
 			s = dev->subdevices + subdev;
 			s = dev->subdevices + subdev;
 			subdev_8255_init(dev, s, NULL,
 			subdev_8255_init(dev, s, NULL,
-				dev->iobase + this_board->sdio[i].addr +
-				SIZE_8255 * j);
+					 dev->iobase +
+					 this_board->sdio[i].addr +
+					 SIZE_8255 * j);
 			subdev++;
 			subdev++;
 		}
 		}
 
 

+ 20 - 16
drivers/staging/comedi/drivers/aio_aio12_8.c

@@ -77,7 +77,7 @@ struct aio12_8_boardtype {
 
 
 static const struct aio12_8_boardtype board_types[] = {
 static const struct aio12_8_boardtype board_types[] = {
 	{
 	{
-	.name = "aio_aio12_8"},
+	 .name = "aio_aio12_8"},
 };
 };
 
 
 #define	thisboard	((const struct aio12_8_boardtype  *) dev->board_ptr)
 #define	thisboard	((const struct aio12_8_boardtype  *) dev->board_ptr)
@@ -88,13 +88,14 @@ struct aio12_8_private {
 
 
 #define devpriv	((struct aio12_8_private *) dev->private)
 #define devpriv	((struct aio12_8_private *) dev->private)
 
 
-static int aio_aio12_8_ai_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int aio_aio12_8_ai_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n;
 	int n;
 	unsigned char control =
 	unsigned char control =
-		ADC_MODE_NORMAL |
-		(CR_RANGE(insn->chanspec) << 3) | CR_CHAN(insn->chanspec);
+	    ADC_MODE_NORMAL |
+	    (CR_RANGE(insn->chanspec) << 3) | CR_CHAN(insn->chanspec);
 
 
 	/* read status to clear EOC latch */
 	/* read status to clear EOC latch */
 	inb(dev->iobase + AIO12_8_STATUS);
 	inb(dev->iobase + AIO12_8_STATUS);
@@ -107,7 +108,7 @@ static int aio_aio12_8_ai_read(struct comedi_device *dev, struct comedi_subdevic
 
 
 		/*  Wait for conversion to complete */
 		/*  Wait for conversion to complete */
 		while (timeout &&
 		while (timeout &&
-			!(inb(dev->iobase + AIO12_8_STATUS) & STATUS_ADC_EOC)) {
+		       !(inb(dev->iobase + AIO12_8_STATUS) & STATUS_ADC_EOC)) {
 			timeout--;
 			timeout--;
 			printk("timeout %d\n", timeout);
 			printk("timeout %d\n", timeout);
 			udelay(1);
 			udelay(1);
@@ -122,8 +123,9 @@ static int aio_aio12_8_ai_read(struct comedi_device *dev, struct comedi_subdevic
 	return n;
 	return n;
 }
 }
 
 
-static int aio_aio12_8_ao_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int aio_aio12_8_ao_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int val = devpriv->ao_readback[CR_CHAN(insn->chanspec)];
 	int val = devpriv->ao_readback[CR_CHAN(insn->chanspec)];
@@ -133,8 +135,9 @@ static int aio_aio12_8_ao_read(struct comedi_device *dev, struct comedi_subdevic
 	return insn->n;
 	return insn->n;
 }
 }
 
 
-static int aio_aio12_8_ao_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int aio_aio12_8_ao_write(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -154,14 +157,15 @@ static int aio_aio12_8_ao_write(struct comedi_device *dev, struct comedi_subdevi
 static const struct comedi_lrange range_aio_aio12_8 = {
 static const struct comedi_lrange range_aio_aio12_8 = {
 	4,
 	4,
 	{
 	{
-			UNI_RANGE(5),
-			BIP_RANGE(5),
-			UNI_RANGE(10),
-			BIP_RANGE(10),
-		}
+	 UNI_RANGE(5),
+	 BIP_RANGE(5),
+	 UNI_RANGE(10),
+	 BIP_RANGE(10),
+	 }
 };
 };
 
 
-static int aio_aio12_8_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int aio_aio12_8_attach(struct comedi_device *dev,
+			      struct comedi_devconfig *it)
 {
 {
 	int iobase;
 	int iobase;
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;

+ 20 - 10
drivers/staging/comedi/drivers/aio_iiro_16.c

@@ -52,9 +52,9 @@ struct aio_iiro_16_board {
 
 
 static const struct aio_iiro_16_board aio_iiro_16_boards[] = {
 static const struct aio_iiro_16_board aio_iiro_16_boards[] = {
 	{
 	{
-	.name = "aio_iiro_16",
-	.di = 16,
-	.do_ = 16},
+	 .name = "aio_iiro_16",
+	 .di = 16,
+	 .do_ = 16},
 };
 };
 
 
 #define	thisboard	((const struct aio_iiro_16_board *) dev->board_ptr)
 #define	thisboard	((const struct aio_iiro_16_board *) dev->board_ptr)
@@ -67,7 +67,8 @@ struct aio_iiro_16_private {
 
 
 #define	devpriv	((struct aio_iiro_16_private *) dev->private)
 #define	devpriv	((struct aio_iiro_16_private *) dev->private)
 
 
-static int aio_iiro_16_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int aio_iiro_16_attach(struct comedi_device *dev,
+			      struct comedi_devconfig *it);
 
 
 static int aio_iiro_16_detach(struct comedi_device *dev);
 static int aio_iiro_16_detach(struct comedi_device *dev);
 
 
@@ -82,12 +83,17 @@ static struct comedi_driver driver_aio_iiro_16 = {
 };
 };
 
 
 static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
 static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+					  struct comedi_subdevice *s,
+					  struct comedi_insn *insn,
+					  unsigned int *data);
 
 
 static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
 static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+					   struct comedi_subdevice *s,
+					   struct comedi_insn *insn,
+					   unsigned int *data);
 
 
-static int aio_iiro_16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int aio_iiro_16_attach(struct comedi_device *dev,
+			      struct comedi_devconfig *it)
 {
 {
 	int iobase;
 	int iobase;
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
@@ -143,7 +149,9 @@ static int aio_iiro_16_detach(struct comedi_device *dev)
 }
 }
 
 
 static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
 static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+					   struct comedi_subdevice *s,
+					   struct comedi_insn *insn,
+					   unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -153,7 +161,7 @@ static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
 		s->state |= data[0] & data[1];
 		s->state |= data[0] & data[1];
 		outb(s->state & 0xff, dev->iobase + AIO_IIRO_16_RELAY_0_7);
 		outb(s->state & 0xff, dev->iobase + AIO_IIRO_16_RELAY_0_7);
 		outb((s->state >> 8) & 0xff,
 		outb((s->state >> 8) & 0xff,
-			dev->iobase + AIO_IIRO_16_RELAY_8_15);
+		     dev->iobase + AIO_IIRO_16_RELAY_8_15);
 	}
 	}
 
 
 	data[1] = s->state;
 	data[1] = s->state;
@@ -162,7 +170,9 @@ static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
 }
 }
 
 
 static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
 static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+					  struct comedi_subdevice *s,
+					  struct comedi_insn *insn,
+					  unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;

+ 166 - 148
drivers/staging/comedi/drivers/amplc_dio200.c

@@ -290,60 +290,60 @@ struct dio200_board {
 
 
 static const struct dio200_board dio200_boards[] = {
 static const struct dio200_board dio200_boards[] = {
 	{
 	{
-	.name = "pc212e",
-	.bustype = isa_bustype,
-	.model = pc212e_model,
-	.layout = pc212_layout,
-		},
+	 .name = "pc212e",
+	 .bustype = isa_bustype,
+	 .model = pc212e_model,
+	 .layout = pc212_layout,
+	 },
 	{
 	{
-	.name = "pc214e",
-	.bustype = isa_bustype,
-	.model = pc214e_model,
-	.layout = pc214_layout,
-		},
+	 .name = "pc214e",
+	 .bustype = isa_bustype,
+	 .model = pc214e_model,
+	 .layout = pc214_layout,
+	 },
 	{
 	{
-	.name = "pc215e",
-	.bustype = isa_bustype,
-	.model = pc215e_model,
-	.layout = pc215_layout,
-		},
+	 .name = "pc215e",
+	 .bustype = isa_bustype,
+	 .model = pc215e_model,
+	 .layout = pc215_layout,
+	 },
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 	{
 	{
-	.name = "pci215",
-	.devid = PCI_DEVICE_ID_AMPLICON_PCI215,
-	.bustype = pci_bustype,
-	.model = pci215_model,
-	.layout = pc215_layout,
-		},
+	 .name = "pci215",
+	 .devid = PCI_DEVICE_ID_AMPLICON_PCI215,
+	 .bustype = pci_bustype,
+	 .model = pci215_model,
+	 .layout = pc215_layout,
+	 },
 #endif
 #endif
 	{
 	{
-	.name = "pc218e",
-	.bustype = isa_bustype,
-	.model = pc218e_model,
-	.layout = pc218_layout,
-		},
+	 .name = "pc218e",
+	 .bustype = isa_bustype,
+	 .model = pc218e_model,
+	 .layout = pc218_layout,
+	 },
 	{
 	{
-	.name = "pc272e",
-	.bustype = isa_bustype,
-	.model = pc272e_model,
-	.layout = pc272_layout,
-		},
+	 .name = "pc272e",
+	 .bustype = isa_bustype,
+	 .model = pc272e_model,
+	 .layout = pc272_layout,
+	 },
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 	{
 	{
-	.name = "pci272",
-	.devid = PCI_DEVICE_ID_AMPLICON_PCI272,
-	.bustype = pci_bustype,
-	.model = pci272_model,
-	.layout = pc272_layout,
-		},
+	 .name = "pci272",
+	 .devid = PCI_DEVICE_ID_AMPLICON_PCI272,
+	 .bustype = pci_bustype,
+	 .model = pci272_model,
+	 .layout = pc272_layout,
+	 },
 #endif
 #endif
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 	{
 	{
-	.name = DIO200_DRIVER_NAME,
-	.devid = PCI_DEVICE_ID_INVALID,
-	.bustype = pci_bustype,
-	.model = anypci_model,	/* wildcard */
-		},
+	 .name = DIO200_DRIVER_NAME,
+	 .devid = PCI_DEVICE_ID_INVALID,
+	 .bustype = pci_bustype,
+	 .model = anypci_model,	/* wildcard */
+	 },
 #endif
 #endif
 };
 };
 
 
@@ -367,51 +367,51 @@ struct dio200_layout_struct {
 
 
 static const struct dio200_layout_struct dio200_layouts[] = {
 static const struct dio200_layout_struct dio200_layouts[] = {
 	[pc212_layout] = {
 	[pc212_layout] = {
-	.n_subdevs = 6,
-	.sdtype = {sd_8255, sd_8254, sd_8254, sd_8254,
-					sd_8254,
-				sd_intr},
-	.sdinfo = {0x00, 0x08, 0x0C, 0x10, 0x14,
-				0x3F},
-	.has_int_sce = 1,
-	.has_clk_gat_sce = 1,
-		},
+			  .n_subdevs = 6,
+			  .sdtype = {sd_8255, sd_8254, sd_8254, sd_8254,
+				     sd_8254,
+				     sd_intr},
+			  .sdinfo = {0x00, 0x08, 0x0C, 0x10, 0x14,
+				     0x3F},
+			  .has_int_sce = 1,
+			  .has_clk_gat_sce = 1,
+			  },
 	[pc214_layout] = {
 	[pc214_layout] = {
-	.n_subdevs = 4,
-	.sdtype = {sd_8255, sd_8255, sd_8254,
-				sd_intr},
-	.sdinfo = {0x00, 0x08, 0x10, 0x01},
-	.has_int_sce = 0,
-	.has_clk_gat_sce = 0,
-		},
+			  .n_subdevs = 4,
+			  .sdtype = {sd_8255, sd_8255, sd_8254,
+				     sd_intr},
+			  .sdinfo = {0x00, 0x08, 0x10, 0x01},
+			  .has_int_sce = 0,
+			  .has_clk_gat_sce = 0,
+			  },
 	[pc215_layout] = {
 	[pc215_layout] = {
-	.n_subdevs = 5,
-	.sdtype = {sd_8255, sd_8255, sd_8254,
-					sd_8254,
-				sd_intr},
-	.sdinfo = {0x00, 0x08, 0x10, 0x14, 0x3F},
-	.has_int_sce = 1,
-	.has_clk_gat_sce = 1,
-		},
+			  .n_subdevs = 5,
+			  .sdtype = {sd_8255, sd_8255, sd_8254,
+				     sd_8254,
+				     sd_intr},
+			  .sdinfo = {0x00, 0x08, 0x10, 0x14, 0x3F},
+			  .has_int_sce = 1,
+			  .has_clk_gat_sce = 1,
+			  },
 	[pc218_layout] = {
 	[pc218_layout] = {
-	.n_subdevs = 7,
-	.sdtype = {sd_8254, sd_8254, sd_8255, sd_8254,
-					sd_8254,
-				sd_intr},
-	.sdinfo = {0x00, 0x04, 0x08, 0x0C, 0x10,
-					0x14,
-				0x3F},
-	.has_int_sce = 1,
-	.has_clk_gat_sce = 1,
-		},
+			  .n_subdevs = 7,
+			  .sdtype = {sd_8254, sd_8254, sd_8255, sd_8254,
+				     sd_8254,
+				     sd_intr},
+			  .sdinfo = {0x00, 0x04, 0x08, 0x0C, 0x10,
+				     0x14,
+				     0x3F},
+			  .has_int_sce = 1,
+			  .has_clk_gat_sce = 1,
+			  },
 	[pc272_layout] = {
 	[pc272_layout] = {
-	.n_subdevs = 4,
-	.sdtype = {sd_8255, sd_8255, sd_8255,
-				sd_intr},
-	.sdinfo = {0x00, 0x08, 0x10, 0x3F},
-	.has_int_sce = 1,
-	.has_clk_gat_sce = 0,
-		},
+			  .n_subdevs = 4,
+			  .sdtype = {sd_8255, sd_8255, sd_8255,
+				     sd_intr},
+			  .sdinfo = {0x00, 0x08, 0x10, 0x3F},
+			  .has_int_sce = 1,
+			  .has_clk_gat_sce = 0,
+			  },
 };
 };
 
 
 /*
 /*
@@ -420,11 +420,12 @@ static const struct dio200_layout_struct dio200_layouts[] = {
 
 
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 static DEFINE_PCI_DEVICE_TABLE(dio200_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(dio200_pci_table) = {
-	{PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI215,
-		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI272,
-		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI215,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI272,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, dio200_pci_table);
 MODULE_DEVICE_TABLE(pci, dio200_pci_table);
@@ -475,7 +476,8 @@ struct dio200_subdev_intr {
  * the board, and also about the kernel module that contains
  * the board, and also about the kernel module that contains
  * the device code.
  * the device code.
  */
  */
-static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dio200_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int dio200_detach(struct comedi_device *dev);
 static int dio200_detach(struct comedi_device *dev);
 static struct comedi_driver driver_amplc_dio200 = {
 static struct comedi_driver driver_amplc_dio200 = {
 	.driver_name = DIO200_DRIVER_NAME,
 	.driver_name = DIO200_DRIVER_NAME,
@@ -500,7 +502,7 @@ COMEDI_INITCLEANUP(driver_amplc_dio200);
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 static int
 static int
 dio200_find_pci(struct comedi_device *dev, int bus, int slot,
 dio200_find_pci(struct comedi_device *dev, int bus, int slot,
-	struct pci_dev **pci_dev_p)
+		struct pci_dev **pci_dev_p)
 {
 {
 	struct pci_dev *pci_dev = NULL;
 	struct pci_dev *pci_dev = NULL;
 
 
@@ -508,13 +510,13 @@ dio200_find_pci(struct comedi_device *dev, int bus, int slot,
 
 
 	/* Look for matching PCI device. */
 	/* Look for matching PCI device. */
 	for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
 	for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
-		pci_dev != NULL;
-		pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
-			PCI_ANY_ID, pci_dev)) {
+	     pci_dev != NULL;
+	     pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
+				      PCI_ANY_ID, pci_dev)) {
 		/* If bus/slot specified, check them. */
 		/* If bus/slot specified, check them. */
 		if (bus || slot) {
 		if (bus || slot) {
 			if (bus != pci_dev->bus->number
 			if (bus != pci_dev->bus->number
-				|| slot != PCI_SLOT(pci_dev->devfn))
+			    || slot != PCI_SLOT(pci_dev->devfn))
 				continue;
 				continue;
 		}
 		}
 		if (thisboard->model == anypci_model) {
 		if (thisboard->model == anypci_model) {
@@ -545,11 +547,11 @@ dio200_find_pci(struct comedi_device *dev, int bus, int slot,
 	/* No match found. */
 	/* No match found. */
 	if (bus || slot) {
 	if (bus || slot) {
 		printk(KERN_ERR
 		printk(KERN_ERR
-			"comedi%d: error! no %s found at pci %02x:%02x!\n",
-			dev->minor, thisboard->name, bus, slot);
+		       "comedi%d: error! no %s found at pci %02x:%02x!\n",
+		       dev->minor, thisboard->name, bus, slot);
 	} else {
 	} else {
 		printk(KERN_ERR "comedi%d: error! no %s found!\n",
 		printk(KERN_ERR "comedi%d: error! no %s found!\n",
-			dev->minor, thisboard->name);
+		       dev->minor, thisboard->name);
 	}
 	}
 	return -EIO;
 	return -EIO;
 }
 }
@@ -564,7 +566,7 @@ dio200_request_region(unsigned minor, unsigned long from, unsigned long extent)
 {
 {
 	if (!from || !request_region(from, extent, DIO200_DRIVER_NAME)) {
 	if (!from || !request_region(from, extent, DIO200_DRIVER_NAME)) {
 		printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
 		printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
-			minor, from, extent);
+		       minor, from, extent);
 		return -EIO;
 		return -EIO;
 	}
 	}
 	return 0;
 	return 0;
@@ -574,8 +576,9 @@ dio200_request_region(unsigned minor, unsigned long from, unsigned long extent)
  * 'insn_bits' function for an 'INTERRUPT' subdevice.
  * 'insn_bits' function for an 'INTERRUPT' subdevice.
  */
  */
 static int
 static int
-dio200_subdev_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+dio200_subdev_intr_insn_bits(struct comedi_device *dev,
+			     struct comedi_subdevice *s,
+			     struct comedi_insn *insn, unsigned int *data)
 {
 {
 	struct dio200_subdev_intr *subpriv = s->private;
 	struct dio200_subdev_intr *subpriv = s->private;
 
 
@@ -593,7 +596,8 @@ dio200_subdev_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice
 /*
 /*
  * Called to stop acquisition for an 'INTERRUPT' subdevice.
  * Called to stop acquisition for an 'INTERRUPT' subdevice.
  */
  */
-static void dio200_stop_intr(struct comedi_device *dev, struct comedi_subdevice *s)
+static void dio200_stop_intr(struct comedi_device *dev,
+			     struct comedi_subdevice *s)
 {
 {
 	struct dio200_subdev_intr *subpriv = s->private;
 	struct dio200_subdev_intr *subpriv = s->private;
 
 
@@ -607,7 +611,8 @@ static void dio200_stop_intr(struct comedi_device *dev, struct comedi_subdevice
 /*
 /*
  * Called to start acquisition for an 'INTERRUPT' subdevice.
  * Called to start acquisition for an 'INTERRUPT' subdevice.
  */
  */
-static int dio200_start_intr(struct comedi_device *dev, struct comedi_subdevice *s)
+static int dio200_start_intr(struct comedi_device *dev,
+			     struct comedi_subdevice *s)
 {
 {
 	unsigned int n;
 	unsigned int n;
 	unsigned isn_bits;
 	unsigned isn_bits;
@@ -644,7 +649,7 @@ static int dio200_start_intr(struct comedi_device *dev, struct comedi_subdevice
  */
  */
 static int
 static int
 dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
 dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int trignum)
+			  unsigned int trignum)
 {
 {
 	struct dio200_subdev_intr *subpriv;
 	struct dio200_subdev_intr *subpriv;
 	unsigned long flags;
 	unsigned long flags;
@@ -673,7 +678,8 @@ dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice *s,
  * This is called from the interrupt service routine to handle a read
  * This is called from the interrupt service routine to handle a read
  * scan on an 'INTERRUPT' subdevice.
  * scan on an 'INTERRUPT' subdevice.
  */
  */
-static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subdevice *s)
+static int dio200_handle_read_intr(struct comedi_device *dev,
+				   struct comedi_subdevice *s)
 {
 {
 	struct dio200_subdev_intr *subpriv = s->private;
 	struct dio200_subdev_intr *subpriv = s->private;
 	unsigned triggered;
 	unsigned triggered;
@@ -699,7 +705,7 @@ static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subd
 		 */
 		 */
 		cur_enabled = subpriv->enabled_isns;
 		cur_enabled = subpriv->enabled_isns;
 		while ((intstat = (inb(subpriv->iobase) & subpriv->valid_isns
 		while ((intstat = (inb(subpriv->iobase) & subpriv->valid_isns
-					& ~triggered)) != 0) {
+				   & ~triggered)) != 0) {
 			triggered |= intstat;
 			triggered |= intstat;
 			cur_enabled &= ~triggered;
 			cur_enabled &= ~triggered;
 			outb(cur_enabled, subpriv->iobase);
 			outb(cur_enabled, subpriv->iobase);
@@ -748,12 +754,12 @@ static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subd
 				/* Write the scan to the buffer. */
 				/* Write the scan to the buffer. */
 				if (comedi_buf_put(s->async, val)) {
 				if (comedi_buf_put(s->async, val)) {
 					s->async->events |= (COMEDI_CB_BLOCK |
 					s->async->events |= (COMEDI_CB_BLOCK |
-						COMEDI_CB_EOS);
+							     COMEDI_CB_EOS);
 				} else {
 				} else {
 					/* Error!  Stop acquisition.  */
 					/* Error!  Stop acquisition.  */
 					dio200_stop_intr(dev, s);
 					dio200_stop_intr(dev, s);
 					s->async->events |= COMEDI_CB_ERROR
 					s->async->events |= COMEDI_CB_ERROR
-						| COMEDI_CB_OVERFLOW;
+					    | COMEDI_CB_OVERFLOW;
 					comedi_error(dev, "buffer overflow");
 					comedi_error(dev, "buffer overflow");
 				}
 				}
 
 
@@ -764,9 +770,9 @@ static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subd
 						subpriv->stopcount--;
 						subpriv->stopcount--;
 						if (subpriv->stopcount == 0) {
 						if (subpriv->stopcount == 0) {
 							s->async->events |=
 							s->async->events |=
-								COMEDI_CB_EOA;
+							    COMEDI_CB_EOA;
 							dio200_stop_intr(dev,
 							dio200_stop_intr(dev,
-								s);
+									 s);
 						}
 						}
 					}
 					}
 				}
 				}
@@ -785,7 +791,8 @@ static int dio200_handle_read_intr(struct comedi_device *dev, struct comedi_subd
 /*
 /*
  * 'cancel' function for an 'INTERRUPT' subdevice.
  * 'cancel' function for an 'INTERRUPT' subdevice.
  */
  */
-static int dio200_subdev_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int dio200_subdev_intr_cancel(struct comedi_device *dev,
+				     struct comedi_subdevice *s)
 {
 {
 	struct dio200_subdev_intr *subpriv = s->private;
 	struct dio200_subdev_intr *subpriv = s->private;
 	unsigned long flags;
 	unsigned long flags;
@@ -803,8 +810,8 @@ static int dio200_subdev_intr_cancel(struct comedi_device *dev, struct comedi_su
  * 'do_cmdtest' function for an 'INTERRUPT' subdevice.
  * 'do_cmdtest' function for an 'INTERRUPT' subdevice.
  */
  */
 static int
 static int
-dio200_subdev_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+dio200_subdev_intr_cmdtest(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	unsigned int tmp;
 	unsigned int tmp;
@@ -909,7 +916,8 @@ dio200_subdev_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
 /*
 /*
  * 'do_cmd' function for an 'INTERRUPT' subdevice.
  * 'do_cmd' function for an 'INTERRUPT' subdevice.
  */
  */
-static int dio200_subdev_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int dio200_subdev_intr_cmd(struct comedi_device *dev,
+				  struct comedi_subdevice *s)
 {
 {
 	struct comedi_cmd *cmd = &s->async->cmd;
 	struct comedi_cmd *cmd = &s->async->cmd;
 	struct dio200_subdev_intr *subpriv = s->private;
 	struct dio200_subdev_intr *subpriv = s->private;
@@ -956,14 +964,15 @@ static int dio200_subdev_intr_cmd(struct comedi_device *dev, struct comedi_subde
  */
  */
 static int
 static int
 dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,
 dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned long iobase, unsigned valid_isns, int has_int_sce)
+			unsigned long iobase, unsigned valid_isns,
+			int has_int_sce)
 {
 {
 	struct dio200_subdev_intr *subpriv;
 	struct dio200_subdev_intr *subpriv;
 
 
 	subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
 	subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
 	if (!subpriv) {
 	if (!subpriv) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 	subpriv->iobase = iobase;
 	subpriv->iobase = iobase;
@@ -1000,7 +1009,8 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,
  * This function cleans up an 'INTERRUPT' subdevice.
  * This function cleans up an 'INTERRUPT' subdevice.
  */
  */
 static void
 static void
-dio200_subdev_intr_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
+dio200_subdev_intr_cleanup(struct comedi_device *dev,
+			   struct comedi_subdevice *s)
 {
 {
 	struct dio200_subdev_intr *subpriv = s->private;
 	struct dio200_subdev_intr *subpriv = s->private;
 
 
@@ -1023,7 +1033,8 @@ static irqreturn_t dio200_interrupt(int irq, void *d)
 
 
 	if (devpriv->intr_sd >= 0) {
 	if (devpriv->intr_sd >= 0) {
 		handled = dio200_handle_read_intr(dev,
 		handled = dio200_handle_read_intr(dev,
-			dev->subdevices + devpriv->intr_sd);
+						  dev->subdevices +
+						  devpriv->intr_sd);
 	} else {
 	} else {
 		handled = 0;
 		handled = 0;
 	}
 	}
@@ -1036,7 +1047,7 @@ static irqreturn_t dio200_interrupt(int irq, void *d)
  */
  */
 static int
 static int
 dio200_subdev_8254_read(struct comedi_device *dev, struct comedi_subdevice *s,
 dio200_subdev_8254_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			struct comedi_insn *insn, unsigned int *data)
 {
 {
 	struct dio200_subdev_8254 *subpriv = s->private;
 	struct dio200_subdev_8254 *subpriv = s->private;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -1051,7 +1062,7 @@ dio200_subdev_8254_read(struct comedi_device *dev, struct comedi_subdevice *s,
  */
  */
 static int
 static int
 dio200_subdev_8254_write(struct comedi_device *dev, struct comedi_subdevice *s,
 dio200_subdev_8254_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	struct dio200_subdev_8254 *subpriv = s->private;
 	struct dio200_subdev_8254 *subpriv = s->private;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -1065,8 +1076,8 @@ dio200_subdev_8254_write(struct comedi_device *dev, struct comedi_subdevice *s,
  * Set gate source for an '8254' counter subdevice channel.
  * Set gate source for an '8254' counter subdevice channel.
  */
  */
 static int
 static int
-dio200_set_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number,
-	unsigned int gate_src)
+dio200_set_gate_src(struct dio200_subdev_8254 *subpriv,
+		    unsigned int counter_number, unsigned int gate_src)
 {
 {
 	unsigned char byte;
 	unsigned char byte;
 
 
@@ -1088,7 +1099,8 @@ dio200_set_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_num
  * Get gate source for an '8254' counter subdevice channel.
  * Get gate source for an '8254' counter subdevice channel.
  */
  */
 static int
 static int
-dio200_get_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number)
+dio200_get_gate_src(struct dio200_subdev_8254 *subpriv,
+		    unsigned int counter_number)
 {
 {
 	if (!subpriv->has_clk_gat_sce)
 	if (!subpriv->has_clk_gat_sce)
 		return -1;
 		return -1;
@@ -1102,8 +1114,8 @@ dio200_get_gate_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_num
  * Set clock source for an '8254' counter subdevice channel.
  * Set clock source for an '8254' counter subdevice channel.
  */
  */
 static int
 static int
-dio200_set_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number,
-	unsigned int clock_src)
+dio200_set_clock_src(struct dio200_subdev_8254 *subpriv,
+		     unsigned int counter_number, unsigned int clock_src)
 {
 {
 	unsigned char byte;
 	unsigned char byte;
 
 
@@ -1125,8 +1137,8 @@ dio200_set_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_nu
  * Get clock source for an '8254' counter subdevice channel.
  * Get clock source for an '8254' counter subdevice channel.
  */
  */
 static int
 static int
-dio200_get_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_number,
-	unsigned int *period_ns)
+dio200_get_clock_src(struct dio200_subdev_8254 *subpriv,
+		     unsigned int counter_number, unsigned int *period_ns)
 {
 {
 	unsigned clock_src;
 	unsigned clock_src;
 
 
@@ -1145,7 +1157,7 @@ dio200_get_clock_src(struct dio200_subdev_8254 *subpriv, unsigned int counter_nu
  */
  */
 static int
 static int
 dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_subdevice *s,
 dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	struct dio200_subdev_8254 *subpriv = s->private;
 	struct dio200_subdev_8254 *subpriv = s->private;
 	int ret;
 	int ret;
@@ -1197,7 +1209,8 @@ dio200_subdev_8254_config(struct comedi_device *dev, struct comedi_subdevice *s,
  */
  */
 static int
 static int
 dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
 dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned long iobase, unsigned offset, int has_clk_gat_sce)
+			unsigned long iobase, unsigned offset,
+			int has_clk_gat_sce)
 {
 {
 	struct dio200_subdev_8254 *subpriv;
 	struct dio200_subdev_8254 *subpriv;
 	unsigned int chan;
 	unsigned int chan;
@@ -1205,7 +1218,7 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
 	subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
 	subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
 	if (!subpriv) {
 	if (!subpriv) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 
 
@@ -1224,16 +1237,16 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
 		/* Derive CLK_SCE and GAT_SCE register offsets from
 		/* Derive CLK_SCE and GAT_SCE register offsets from
 		 * 8254 offset. */
 		 * 8254 offset. */
 		subpriv->clk_sce_iobase =
 		subpriv->clk_sce_iobase =
-			DIO200_XCLK_SCE + (offset >> 3) + iobase;
+		    DIO200_XCLK_SCE + (offset >> 3) + iobase;
 		subpriv->gat_sce_iobase =
 		subpriv->gat_sce_iobase =
-			DIO200_XGAT_SCE + (offset >> 3) + iobase;
+		    DIO200_XGAT_SCE + (offset >> 3) + iobase;
 		subpriv->which = (offset >> 2) & 1;
 		subpriv->which = (offset >> 2) & 1;
 	}
 	}
 
 
 	/* Initialize channels. */
 	/* Initialize channels. */
 	for (chan = 0; chan < 3; chan++) {
 	for (chan = 0; chan < 3; chan++) {
 		i8254_set_mode(subpriv->iobase, 0, chan,
 		i8254_set_mode(subpriv->iobase, 0, chan,
-			I8254_MODE0 | I8254_BINARY);
+			       I8254_MODE0 | I8254_BINARY);
 		if (subpriv->has_clk_gat_sce) {
 		if (subpriv->has_clk_gat_sce) {
 			/* Gate source 0 is VCC (logic 1). */
 			/* Gate source 0 is VCC (logic 1). */
 			dio200_set_gate_src(subpriv, chan, 0);
 			dio200_set_gate_src(subpriv, chan, 0);
@@ -1249,7 +1262,8 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
  * This function cleans up an '8254' counter subdevice.
  * This function cleans up an '8254' counter subdevice.
  */
  */
 static void
 static void
-dio200_subdev_8254_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
+dio200_subdev_8254_cleanup(struct comedi_device *dev,
+			   struct comedi_subdevice *s)
 {
 {
 	struct dio200_subdev_intr *subpriv = s->private;
 	struct dio200_subdev_intr *subpriv = s->private;
 
 
@@ -1280,12 +1294,12 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	int ret;
 	int ret;
 
 
 	printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
 	printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
-		DIO200_DRIVER_NAME);
+	       DIO200_DRIVER_NAME);
 
 
 	ret = alloc_private(dev, sizeof(struct dio200_private));
 	ret = alloc_private(dev, sizeof(struct dio200_private));
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -1310,8 +1324,8 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 #endif
 #endif
 	default:
 	default:
 		printk(KERN_ERR
 		printk(KERN_ERR
-			"comedi%d: %s: BUG! cannot determine board type!\n",
-			dev->minor, DIO200_DRIVER_NAME);
+		       "comedi%d: %s: BUG! cannot determine board type!\n",
+		       dev->minor, DIO200_DRIVER_NAME);
 		return -EINVAL;
 		return -EINVAL;
 		break;
 		break;
 	}
 	}
@@ -1324,8 +1338,8 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME);
 		ret = comedi_pci_enable(pci_dev, DIO200_DRIVER_NAME);
 		if (ret < 0) {
 		if (ret < 0) {
 			printk(KERN_ERR
 			printk(KERN_ERR
-				"comedi%d: error! cannot enable PCI device and request regions!\n",
-				dev->minor);
+			       "comedi%d: error! cannot enable PCI device and request regions!\n",
+			       dev->minor);
 			return ret;
 			return ret;
 		}
 		}
 		iobase = pci_resource_start(pci_dev, 2);
 		iobase = pci_resource_start(pci_dev, 2);
@@ -1345,7 +1359,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	ret = alloc_subdevices(dev, layout->n_subdevs);
 	ret = alloc_subdevices(dev, layout->n_subdevs);
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -1355,7 +1369,8 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		case sd_8254:
 		case sd_8254:
 			/* counter subdevice (8254) */
 			/* counter subdevice (8254) */
 			ret = dio200_subdev_8254_init(dev, s, iobase,
 			ret = dio200_subdev_8254_init(dev, s, iobase,
-				layout->sdinfo[n], layout->has_clk_gat_sce);
+						      layout->sdinfo[n],
+						      layout->has_clk_gat_sce);
 			if (ret < 0) {
 			if (ret < 0) {
 				return ret;
 				return ret;
 			}
 			}
@@ -1363,7 +1378,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		case sd_8255:
 		case sd_8255:
 			/* digital i/o subdevice (8255) */
 			/* digital i/o subdevice (8255) */
 			ret = subdev_8255_init(dev, s, 0,
 			ret = subdev_8255_init(dev, s, 0,
-				iobase + layout->sdinfo[n]);
+					       iobase + layout->sdinfo[n]);
 			if (ret < 0) {
 			if (ret < 0) {
 				return ret;
 				return ret;
 			}
 			}
@@ -1372,8 +1387,11 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 			/* 'INTERRUPT' subdevice */
 			/* 'INTERRUPT' subdevice */
 			if (irq) {
 			if (irq) {
 				ret = dio200_subdev_intr_init(dev, s,
 				ret = dio200_subdev_intr_init(dev, s,
-					iobase + DIO200_INT_SCE,
-					layout->sdinfo[n], layout->has_int_sce);
+							      iobase +
+							      DIO200_INT_SCE,
+							      layout->sdinfo[n],
+							      layout->
+							      has_int_sce);
 				if (ret < 0) {
 				if (ret < 0) {
 					return ret;
 					return ret;
 				}
 				}
@@ -1403,8 +1421,8 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 			dev->irq = irq;
 			dev->irq = irq;
 		} else {
 		} else {
 			printk(KERN_WARNING
 			printk(KERN_WARNING
-				"comedi%d: warning! irq %u unavailable!\n",
-				dev->minor, irq);
+			       "comedi%d: warning! irq %u unavailable!\n",
+			       dev->minor, irq);
 		}
 		}
 	}
 	}
 
 
@@ -1441,7 +1459,7 @@ static int dio200_detach(struct comedi_device *dev)
 	unsigned n;
 	unsigned n;
 
 
 	printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
 	printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
-		DIO200_DRIVER_NAME);
+	       DIO200_DRIVER_NAME);
 
 
 	if (dev->irq) {
 	if (dev->irq) {
 		free_irq(dev->irq, dev);
 		free_irq(dev->irq, dev);
@@ -1482,7 +1500,7 @@ static int dio200_detach(struct comedi_device *dev)
 	}
 	}
 	if (dev->board_name) {
 	if (dev->board_name) {
 		printk(KERN_INFO "comedi%d: %s removed\n",
 		printk(KERN_INFO "comedi%d: %s removed\n",
-			dev->minor, dev->board_name);
+		       dev->minor, dev->board_name);
 	}
 	}
 
 
 	return 0;
 	return 0;

+ 63 - 55
drivers/staging/comedi/drivers/amplc_pc236.c

@@ -107,36 +107,37 @@ struct pc236_board {
 };
 };
 static const struct pc236_board pc236_boards[] = {
 static const struct pc236_board pc236_boards[] = {
 	{
 	{
-	.name = "pc36at",
-	.fancy_name = "PC36AT",
-	.bustype = isa_bustype,
-	.model = pc36at_model,
-		},
+	 .name = "pc36at",
+	 .fancy_name = "PC36AT",
+	 .bustype = isa_bustype,
+	 .model = pc36at_model,
+	 },
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 	{
 	{
-	.name = "pci236",
-	.fancy_name = "PCI236",
-	.devid = PCI_DEVICE_ID_AMPLICON_PCI236,
-	.bustype = pci_bustype,
-	.model = pci236_model,
-		},
+	 .name = "pci236",
+	 .fancy_name = "PCI236",
+	 .devid = PCI_DEVICE_ID_AMPLICON_PCI236,
+	 .bustype = pci_bustype,
+	 .model = pci236_model,
+	 },
 #endif
 #endif
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 	{
 	{
-	.name = PC236_DRIVER_NAME,
-	.fancy_name = PC236_DRIVER_NAME,
-	.devid = PCI_DEVICE_ID_INVALID,
-	.bustype = pci_bustype,
-	.model = anypci_model,	/* wildcard */
-		},
+	 .name = PC236_DRIVER_NAME,
+	 .fancy_name = PC236_DRIVER_NAME,
+	 .devid = PCI_DEVICE_ID_INVALID,
+	 .bustype = pci_bustype,
+	 .model = anypci_model,	/* wildcard */
+	 },
 #endif
 #endif
 };
 };
 
 
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 static DEFINE_PCI_DEVICE_TABLE(pc236_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(pc236_pci_table) = {
-	{PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI236, PCI_ANY_ID,
-		PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI236,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, pc236_pci_table);
 MODULE_DEVICE_TABLE(pci, pc236_pci_table);
@@ -186,16 +187,20 @@ COMEDI_INITCLEANUP(driver_amplc_pc236);
 #endif
 #endif
 
 
 static int pc236_request_region(unsigned minor, unsigned long from,
 static int pc236_request_region(unsigned minor, unsigned long from,
-	unsigned long extent);
+				unsigned long extent);
 static void pc236_intr_disable(struct comedi_device *dev);
 static void pc236_intr_disable(struct comedi_device *dev);
 static void pc236_intr_enable(struct comedi_device *dev);
 static void pc236_intr_enable(struct comedi_device *dev);
 static int pc236_intr_check(struct comedi_device *dev);
 static int pc236_intr_check(struct comedi_device *dev);
-static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int pc236_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd);
-static int pc236_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int pc236_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int pc236_intr_insn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data);
+static int pc236_intr_cmdtest(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_cmd *cmd);
+static int pc236_intr_cmd(struct comedi_device *dev,
+			  struct comedi_subdevice *s);
+static int pc236_intr_cancel(struct comedi_device *dev,
+			     struct comedi_subdevice *s);
 static irqreturn_t pc236_interrupt(int irq, void *d);
 static irqreturn_t pc236_interrupt(int irq, void *d);
 
 
 /*
 /*
@@ -205,7 +210,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d);
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 static int
 static int
 pc236_find_pci(struct comedi_device *dev, int bus, int slot,
 pc236_find_pci(struct comedi_device *dev, int bus, int slot,
-	struct pci_dev **pci_dev_p)
+	       struct pci_dev **pci_dev_p)
 {
 {
 	struct pci_dev *pci_dev = NULL;
 	struct pci_dev *pci_dev = NULL;
 
 
@@ -213,13 +218,13 @@ pc236_find_pci(struct comedi_device *dev, int bus, int slot,
 
 
 	/* Look for matching PCI device. */
 	/* Look for matching PCI device. */
 	for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
 	for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
-		pci_dev != NULL;
-		pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
-			PCI_ANY_ID, pci_dev)) {
+	     pci_dev != NULL;
+	     pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
+				      PCI_ANY_ID, pci_dev)) {
 		/* If bus/slot specified, check them. */
 		/* If bus/slot specified, check them. */
 		if (bus || slot) {
 		if (bus || slot) {
 			if (bus != pci_dev->bus->number
 			if (bus != pci_dev->bus->number
-				|| slot != PCI_SLOT(pci_dev->devfn))
+			    || slot != PCI_SLOT(pci_dev->devfn))
 				continue;
 				continue;
 		}
 		}
 		if (thisboard->model == anypci_model) {
 		if (thisboard->model == anypci_model) {
@@ -250,11 +255,11 @@ pc236_find_pci(struct comedi_device *dev, int bus, int slot,
 	/* No match found. */
 	/* No match found. */
 	if (bus || slot) {
 	if (bus || slot) {
 		printk(KERN_ERR
 		printk(KERN_ERR
-			"comedi%d: error! no %s found at pci %02x:%02x!\n",
-			dev->minor, thisboard->name, bus, slot);
+		       "comedi%d: error! no %s found at pci %02x:%02x!\n",
+		       dev->minor, thisboard->name, bus, slot);
 	} else {
 	} else {
 		printk(KERN_ERR "comedi%d: error! no %s found!\n",
 		printk(KERN_ERR "comedi%d: error! no %s found!\n",
-			dev->minor, thisboard->name);
+		       dev->minor, thisboard->name);
 	}
 	}
 	return -EIO;
 	return -EIO;
 }
 }
@@ -279,7 +284,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	int ret;
 	int ret;
 
 
 	printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
 	printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
-		PC236_DRIVER_NAME);
+	       PC236_DRIVER_NAME);
 /*
 /*
  * Allocate the private structure area.  alloc_private() is a
  * Allocate the private structure area.  alloc_private() is a
  * convenient macro defined in comedidev.h.
  * convenient macro defined in comedidev.h.
@@ -287,7 +292,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	ret = alloc_private(dev, sizeof(struct pc236_private));
 	ret = alloc_private(dev, sizeof(struct pc236_private));
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return ret;
 		return ret;
 	}
 	}
 	/* Process options. */
 	/* Process options. */
@@ -311,8 +316,8 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 #endif /* CONFIG_COMEDI_PCI */
 #endif /* CONFIG_COMEDI_PCI */
 	default:
 	default:
 		printk(KERN_ERR
 		printk(KERN_ERR
-			"comedi%d: %s: BUG! cannot determine board type!\n",
-			dev->minor, PC236_DRIVER_NAME);
+		       "comedi%d: %s: BUG! cannot determine board type!\n",
+		       dev->minor, PC236_DRIVER_NAME);
 		return -EINVAL;
 		return -EINVAL;
 		break;
 		break;
 	}
 	}
@@ -329,8 +334,8 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME);
 		ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME);
 		if (ret < 0) {
 		if (ret < 0) {
 			printk(KERN_ERR
 			printk(KERN_ERR
-				"comedi%d: error! cannot enable PCI device and request regions!\n",
-				dev->minor);
+			       "comedi%d: error! cannot enable PCI device and request regions!\n",
+			       dev->minor);
 			return ret;
 			return ret;
 		}
 		}
 		devpriv->lcr_iobase = pci_resource_start(pci_dev, 1);
 		devpriv->lcr_iobase = pci_resource_start(pci_dev, 1);
@@ -353,7 +358,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	ret = alloc_subdevices(dev, 2);
 	ret = alloc_subdevices(dev, 2);
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -362,7 +367,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	ret = subdev_8255_init(dev, s, NULL, iobase);
 	ret = subdev_8255_init(dev, s, NULL, iobase);
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return ret;
 		return ret;
 	}
 	}
 	s = dev->subdevices + 1;
 	s = dev->subdevices + 1;
@@ -416,7 +421,7 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 static int pc236_detach(struct comedi_device *dev)
 static int pc236_detach(struct comedi_device *dev)
 {
 {
 	printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
 	printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
-		PC236_DRIVER_NAME);
+	       PC236_DRIVER_NAME);
 	if (devpriv) {
 	if (devpriv) {
 		pc236_intr_disable(dev);
 		pc236_intr_disable(dev);
 	}
 	}
@@ -442,7 +447,7 @@ static int pc236_detach(struct comedi_device *dev)
 	}
 	}
 	if (dev->board_name) {
 	if (dev->board_name) {
 		printk(KERN_INFO "comedi%d: %s removed\n",
 		printk(KERN_INFO "comedi%d: %s removed\n",
-			dev->minor, dev->board_name);
+		       dev->minor, dev->board_name);
 	}
 	}
 	return 0;
 	return 0;
 }
 }
@@ -452,11 +457,11 @@ static int pc236_detach(struct comedi_device *dev)
  * if there is a conflict.
  * if there is a conflict.
  */
  */
 static int pc236_request_region(unsigned minor, unsigned long from,
 static int pc236_request_region(unsigned minor, unsigned long from,
-	unsigned long extent)
+				unsigned long extent)
 {
 {
 	if (!from || !request_region(from, extent, PC236_DRIVER_NAME)) {
 	if (!from || !request_region(from, extent, PC236_DRIVER_NAME)) {
 		printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
 		printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
-			minor, from, extent);
+		       minor, from, extent);
 		return -EIO;
 		return -EIO;
 	}
 	}
 	return 0;
 	return 0;
@@ -516,13 +521,13 @@ static int pc236_intr_check(struct comedi_device *dev)
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 		if (devpriv->lcr_iobase) {
 		if (devpriv->lcr_iobase) {
 			if ((inl(devpriv->lcr_iobase + PLX9052_INTCSR)
 			if ((inl(devpriv->lcr_iobase + PLX9052_INTCSR)
-					& PLX9052_INTCSR_LI1STAT_MASK)
-				== PLX9052_INTCSR_LI1STAT_INACTIVE) {
+			     & PLX9052_INTCSR_LI1STAT_MASK)
+			    == PLX9052_INTCSR_LI1STAT_INACTIVE) {
 				retval = 0;
 				retval = 0;
 			} else {
 			} else {
 				/* Clear interrupt and keep it enabled. */
 				/* Clear interrupt and keep it enabled. */
 				outl(PCI236_INTR_ENABLE,
 				outl(PCI236_INTR_ENABLE,
-					devpriv->lcr_iobase + PLX9052_INTCSR);
+				     devpriv->lcr_iobase + PLX9052_INTCSR);
 			}
 			}
 		}
 		}
 #endif
 #endif
@@ -536,8 +541,9 @@ static int pc236_intr_check(struct comedi_device *dev)
  * Input from subdevice 1.
  * Input from subdevice 1.
  * Copied from the comedi_parport driver.
  * Copied from the comedi_parport driver.
  */
  */
-static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pc236_intr_insn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	data[1] = 0;
 	data[1] = 0;
 	return 2;
 	return 2;
@@ -547,8 +553,9 @@ static int pc236_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s
  * Subdevice 1 command test.
  * Subdevice 1 command test.
  * Copied from the comedi_parport driver.
  * Copied from the comedi_parport driver.
  */
  */
-static int pc236_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int pc236_intr_cmdtest(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -635,7 +642,8 @@ static int pc236_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 /*
 /*
  * Subdevice 1 cancel command.
  * Subdevice 1 cancel command.
  */
  */
-static int pc236_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int pc236_intr_cancel(struct comedi_device *dev,
+			     struct comedi_subdevice *s)
 {
 {
 	pc236_intr_disable(dev);
 	pc236_intr_disable(dev);
 
 

+ 53 - 48
drivers/staging/comedi/drivers/amplc_pc263.c

@@ -74,36 +74,37 @@ struct pc263_board {
 };
 };
 static const struct pc263_board pc263_boards[] = {
 static const struct pc263_board pc263_boards[] = {
 	{
 	{
-	.name = "pc263",
-	.fancy_name = "PC263",
-	.bustype = isa_bustype,
-	.model = pc263_model,
-		},
+	 .name = "pc263",
+	 .fancy_name = "PC263",
+	 .bustype = isa_bustype,
+	 .model = pc263_model,
+	 },
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 	{
 	{
-	.name = "pci263",
-	.fancy_name = "PCI263",
-	.devid = PCI_DEVICE_ID_AMPLICON_PCI263,
-	.bustype = pci_bustype,
-	.model = pci263_model,
-		},
+	 .name = "pci263",
+	 .fancy_name = "PCI263",
+	 .devid = PCI_DEVICE_ID_AMPLICON_PCI263,
+	 .bustype = pci_bustype,
+	 .model = pci263_model,
+	 },
 #endif
 #endif
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 	{
 	{
-	.name = PC263_DRIVER_NAME,
-	.fancy_name = PC263_DRIVER_NAME,
-	.devid = PCI_DEVICE_ID_INVALID,
-	.bustype = pci_bustype,
-	.model = anypci_model,	/* wildcard */
-		},
+	 .name = PC263_DRIVER_NAME,
+	 .fancy_name = PC263_DRIVER_NAME,
+	 .devid = PCI_DEVICE_ID_INVALID,
+	 .bustype = pci_bustype,
+	 .model = anypci_model,	/* wildcard */
+	 },
 #endif
 #endif
 };
 };
 
 
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 static DEFINE_PCI_DEVICE_TABLE(pc263_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(pc263_pci_table) = {
-	{PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263, PCI_ANY_ID,
-		PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, pc263_pci_table);
 MODULE_DEVICE_TABLE(pci, pc263_pci_table);
@@ -145,11 +146,13 @@ static struct comedi_driver driver_amplc_pc263 = {
 };
 };
 
 
 static int pc263_request_region(unsigned minor, unsigned long from,
 static int pc263_request_region(unsigned minor, unsigned long from,
-	unsigned long extent);
-static int pc263_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int pc263_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+				unsigned long extent);
+static int pc263_dio_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
+static int pc263_dio_insn_config(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data);
 
 
 /*
 /*
  * This function looks for a PCI device matching the requested board name,
  * This function looks for a PCI device matching the requested board name,
@@ -158,7 +161,7 @@ static int pc263_dio_insn_config(struct comedi_device *dev, struct comedi_subdev
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 static int
 static int
 pc263_find_pci(struct comedi_device *dev, int bus, int slot,
 pc263_find_pci(struct comedi_device *dev, int bus, int slot,
-	struct pci_dev **pci_dev_p)
+	       struct pci_dev **pci_dev_p)
 {
 {
 	struct pci_dev *pci_dev = NULL;
 	struct pci_dev *pci_dev = NULL;
 
 
@@ -166,13 +169,13 @@ pc263_find_pci(struct comedi_device *dev, int bus, int slot,
 
 
 	/* Look for matching PCI device. */
 	/* Look for matching PCI device. */
 	for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
 	for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
-		pci_dev != NULL;
-		pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
-			PCI_ANY_ID, pci_dev)) {
+	     pci_dev != NULL;
+	     pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON,
+				      PCI_ANY_ID, pci_dev)) {
 		/* If bus/slot specified, check them. */
 		/* If bus/slot specified, check them. */
 		if (bus || slot) {
 		if (bus || slot) {
 			if (bus != pci_dev->bus->number
 			if (bus != pci_dev->bus->number
-				|| slot != PCI_SLOT(pci_dev->devfn))
+			    || slot != PCI_SLOT(pci_dev->devfn))
 				continue;
 				continue;
 		}
 		}
 		if (thisboard->model == anypci_model) {
 		if (thisboard->model == anypci_model) {
@@ -203,11 +206,11 @@ pc263_find_pci(struct comedi_device *dev, int bus, int slot,
 	/* No match found. */
 	/* No match found. */
 	if (bus || slot) {
 	if (bus || slot) {
 		printk(KERN_ERR
 		printk(KERN_ERR
-			"comedi%d: error! no %s found at pci %02x:%02x!\n",
-			dev->minor, thisboard->name, bus, slot);
+		       "comedi%d: error! no %s found at pci %02x:%02x!\n",
+		       dev->minor, thisboard->name, bus, slot);
 	} else {
 	} else {
 		printk(KERN_ERR "comedi%d: error! no %s found!\n",
 		printk(KERN_ERR "comedi%d: error! no %s found!\n",
-			dev->minor, thisboard->name);
+		       dev->minor, thisboard->name);
 	}
 	}
 	return -EIO;
 	return -EIO;
 }
 }
@@ -230,7 +233,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	int ret;
 	int ret;
 
 
 	printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
 	printk(KERN_DEBUG "comedi%d: %s: attach\n", dev->minor,
-		PC263_DRIVER_NAME);
+	       PC263_DRIVER_NAME);
 /*
 /*
  * Allocate the private structure area.  alloc_private() is a
  * Allocate the private structure area.  alloc_private() is a
  * convenient macro defined in comedidev.h.
  * convenient macro defined in comedidev.h.
@@ -239,7 +242,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	ret = alloc_private(dev, sizeof(struct pc263_private));
 	ret = alloc_private(dev, sizeof(struct pc263_private));
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return ret;
 		return ret;
 	}
 	}
 #endif
 #endif
@@ -261,8 +264,8 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 #endif /* CONFIG_COMEDI_PCI */
 #endif /* CONFIG_COMEDI_PCI */
 	default:
 	default:
 		printk(KERN_ERR
 		printk(KERN_ERR
-			"comedi%d: %s: BUG! cannot determine board type!\n",
-			dev->minor, PC263_DRIVER_NAME);
+		       "comedi%d: %s: BUG! cannot determine board type!\n",
+		       dev->minor, PC263_DRIVER_NAME);
 		return -EINVAL;
 		return -EINVAL;
 		break;
 		break;
 	}
 	}
@@ -278,8 +281,8 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME);
 		ret = comedi_pci_enable(pci_dev, PC263_DRIVER_NAME);
 		if (ret < 0) {
 		if (ret < 0) {
 			printk(KERN_ERR
 			printk(KERN_ERR
-				"comedi%d: error! cannot enable PCI device and request regions!\n",
-				dev->minor);
+			       "comedi%d: error! cannot enable PCI device and request regions!\n",
+			       dev->minor);
 			return ret;
 			return ret;
 		}
 		}
 		iobase = pci_resource_start(pci_dev, 2);
 		iobase = pci_resource_start(pci_dev, 2);
@@ -300,7 +303,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	ret = alloc_subdevices(dev, 1);
 	ret = alloc_subdevices(dev, 1);
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -344,7 +347,7 @@ static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 static int pc263_detach(struct comedi_device *dev)
 static int pc263_detach(struct comedi_device *dev)
 {
 {
 	printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
 	printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor,
-		PC263_DRIVER_NAME);
+	       PC263_DRIVER_NAME);
 
 
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 	if (devpriv)
 	if (devpriv)
@@ -366,7 +369,7 @@ static int pc263_detach(struct comedi_device *dev)
 	}
 	}
 	if (dev->board_name) {
 	if (dev->board_name) {
 		printk(KERN_INFO "comedi%d: %s removed\n",
 		printk(KERN_INFO "comedi%d: %s removed\n",
-			dev->minor, dev->board_name);
+		       dev->minor, dev->board_name);
 	}
 	}
 	return 0;
 	return 0;
 }
 }
@@ -376,11 +379,11 @@ static int pc263_detach(struct comedi_device *dev)
  * if there is a conflict.
  * if there is a conflict.
  */
  */
 static int pc263_request_region(unsigned minor, unsigned long from,
 static int pc263_request_region(unsigned minor, unsigned long from,
-	unsigned long extent)
+				unsigned long extent)
 {
 {
 	if (!from || !request_region(from, extent, PC263_DRIVER_NAME)) {
 	if (!from || !request_region(from, extent, PC263_DRIVER_NAME)) {
 		printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
 		printk(KERN_ERR "comedi%d: I/O port conflict (%#lx,%lu)!\n",
-			minor, from, extent);
+		       minor, from, extent);
 		return -EIO;
 		return -EIO;
 	}
 	}
 	return 0;
 	return 0;
@@ -391,8 +394,9 @@ static int pc263_request_region(unsigned minor, unsigned long from,
  * useful to applications if you implement the insn_bits interface.
  * useful to applications if you implement the insn_bits interface.
  * This allows packed reading/writing of the DIO channels.  The
  * This allows packed reading/writing of the DIO channels.  The
  * comedi core can convert between insn_bits and insn_read/write */
  * comedi core can convert between insn_bits and insn_read/write */
-static int pc263_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pc263_dio_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -416,8 +420,9 @@ static int pc263_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevic
 	return 2;
 	return 2;
 }
 }
 
 
-static int pc263_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pc263_dio_insn_config(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 1)
 	if (insn->n != 1)
 		return -EINVAL;
 		return -EINVAL;

+ 137 - 123
drivers/staging/comedi/drivers/amplc_pci224.c

@@ -283,15 +283,15 @@ Caveats:
 static const struct comedi_lrange range_pci224_internal = {
 static const struct comedi_lrange range_pci224_internal = {
 	8,
 	8,
 	{
 	{
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-			BIP_RANGE(2.5),
-			BIP_RANGE(1.25),
-			UNI_RANGE(10),
-			UNI_RANGE(5),
-			UNI_RANGE(2.5),
-			UNI_RANGE(1.25),
-		}
+	 BIP_RANGE(10),
+	 BIP_RANGE(5),
+	 BIP_RANGE(2.5),
+	 BIP_RANGE(1.25),
+	 UNI_RANGE(10),
+	 UNI_RANGE(5),
+	 UNI_RANGE(2.5),
+	 UNI_RANGE(1.25),
+	 }
 };
 };
 
 
 static const unsigned short hwrange_pci224_internal[8] = {
 static const unsigned short hwrange_pci224_internal[8] = {
@@ -309,9 +309,9 @@ static const unsigned short hwrange_pci224_internal[8] = {
 static const struct comedi_lrange range_pci224_external = {
 static const struct comedi_lrange range_pci224_external = {
 	2,
 	2,
 	{
 	{
-			RANGE_ext(-1, 1),	/* bipolar [-Vref,+Vref] */
-			RANGE_ext(0, 1),	/* unipolar [0,+Vref] */
-		}
+	 RANGE_ext(-1, 1),	/* bipolar [-Vref,+Vref] */
+	 RANGE_ext(0, 1),	/* unipolar [0,+Vref] */
+	 }
 };
 };
 
 
 static const unsigned short hwrange_pci224_external[2] = {
 static const unsigned short hwrange_pci224_external[2] = {
@@ -324,8 +324,8 @@ static const unsigned short hwrange_pci224_external[2] = {
 static const struct comedi_lrange range_pci234_ext2 = {
 static const struct comedi_lrange range_pci234_ext2 = {
 	1,
 	1,
 	{
 	{
-			RANGE_ext(-2, 2),
-		}
+	 RANGE_ext(-2, 2),
+	 }
 };
 };
 
 
 /* The hardware selectable Vref external range for PCI234
 /* The hardware selectable Vref external range for PCI234
@@ -333,8 +333,8 @@ static const struct comedi_lrange range_pci234_ext2 = {
 static const struct comedi_lrange range_pci234_ext = {
 static const struct comedi_lrange range_pci234_ext = {
 	1,
 	1,
 	{
 	{
-			RANGE_ext(-1, 1),
-		}
+	 RANGE_ext(-1, 1),
+	 }
 };
 };
 
 
 /* This serves for all the PCI234 ranges. */
 /* This serves for all the PCI234 ranges. */
@@ -358,24 +358,24 @@ struct pci224_board {
 
 
 static const struct pci224_board pci224_boards[] = {
 static const struct pci224_board pci224_boards[] = {
 	{
 	{
-	.name = "pci224",
-	.devid = PCI_DEVICE_ID_AMPLICON_PCI224,
-	.model = pci224_model,
-	.ao_chans = 16,
-	.ao_bits = 12,
-		},
+	 .name = "pci224",
+	 .devid = PCI_DEVICE_ID_AMPLICON_PCI224,
+	 .model = pci224_model,
+	 .ao_chans = 16,
+	 .ao_bits = 12,
+	 },
 	{
 	{
-	.name = "pci234",
-	.devid = PCI_DEVICE_ID_AMPLICON_PCI234,
-	.model = pci234_model,
-	.ao_chans = 4,
-	.ao_bits = 16,
-		},
+	 .name = "pci234",
+	 .devid = PCI_DEVICE_ID_AMPLICON_PCI234,
+	 .model = pci234_model,
+	 .ao_chans = 4,
+	 .ao_bits = 16,
+	 },
 	{
 	{
-	.name = DRIVER_NAME,
-	.devid = PCI_DEVICE_ID_INVALID,
-	.model = any_model,	/* wildcard */
-		},
+	 .name = DRIVER_NAME,
+	 .devid = PCI_DEVICE_ID_INVALID,
+	 .model = any_model,	/* wildcard */
+	 },
 };
 };
 
 
 /*
 /*
@@ -383,11 +383,12 @@ static const struct pci224_board pci224_boards[] = {
  */
  */
 
 
 static DEFINE_PCI_DEVICE_TABLE(pci224_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(pci224_pci_table) = {
-	{PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI224,
-		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI234,
-		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI224,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI234,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, pci224_pci_table);
 MODULE_DEVICE_TABLE(pci, pci224_pci_table);
@@ -428,7 +429,8 @@ struct pci224_private {
  * the board, and also about the kernel module that contains
  * the board, and also about the kernel module that contains
  * the device code.
  * the device code.
  */
  */
-static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci224_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int pci224_detach(struct comedi_device *dev);
 static int pci224_detach(struct comedi_device *dev);
 static struct comedi_driver driver_amplc_pci224 = {
 static struct comedi_driver driver_amplc_pci224 = {
 	.driver_name = DRIVER_NAME,
 	.driver_name = DRIVER_NAME,
@@ -446,7 +448,8 @@ COMEDI_PCI_INITCLEANUP(driver_amplc_pci224, pci224_pci_table);
  * Called from the 'insn_write' function to perform a single write.
  * Called from the 'insn_write' function to perform a single write.
  */
  */
 static void
 static void
-pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int data)
+pci224_ao_set_data(struct comedi_device *dev, int chan, int range,
+		   unsigned int data)
 {
 {
 	unsigned short mangled;
 	unsigned short mangled;
 
 
@@ -456,9 +459,10 @@ pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int
 	outw(1 << chan, dev->iobase + PCI224_DACCEN);
 	outw(1 << chan, dev->iobase + PCI224_DACCEN);
 	/* Set range and reset FIFO. */
 	/* Set range and reset FIFO. */
 	devpriv->daccon = COMBINE(devpriv->daccon, devpriv->hwrange[range],
 	devpriv->daccon = COMBINE(devpriv->daccon, devpriv->hwrange[range],
-		(PCI224_DACCON_POLAR_MASK | PCI224_DACCON_VREF_MASK));
+				  (PCI224_DACCON_POLAR_MASK |
+				   PCI224_DACCON_VREF_MASK));
 	outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
 	outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
-		dev->iobase + PCI224_DACCON);
+	     dev->iobase + PCI224_DACCON);
 	/*
 	/*
 	 * Mangle the data.  The hardware expects:
 	 * Mangle the data.  The hardware expects:
 	 * - bipolar: 16-bit 2's complement
 	 * - bipolar: 16-bit 2's complement
@@ -466,7 +470,7 @@ pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int
 	 */
 	 */
 	mangled = (unsigned short)data << (16 - thisboard->ao_bits);
 	mangled = (unsigned short)data << (16 - thisboard->ao_bits);
 	if ((devpriv->daccon & PCI224_DACCON_POLAR_MASK) ==
 	if ((devpriv->daccon & PCI224_DACCON_POLAR_MASK) ==
-		PCI224_DACCON_POLAR_BI) {
+	    PCI224_DACCON_POLAR_BI) {
 		mangled ^= 0x8000;
 		mangled ^= 0x8000;
 	}
 	}
 	/* Write mangled data to the FIFO. */
 	/* Write mangled data to the FIFO. */
@@ -480,7 +484,7 @@ pci224_ao_set_data(struct comedi_device *dev, int chan, int range, unsigned int
  */
  */
 static int
 static int
 pci224_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
 pci224_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)
 {
 {
 	int i;
 	int i;
 	int chan, range;
 	int chan, range;
@@ -507,7 +511,7 @@ pci224_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
  */
  */
 static int
 static int
 pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
 pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+		    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan;
 	int chan;
@@ -526,7 +530,7 @@ pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
  */
  */
 static void
 static void
 pci224_cascade_ns_to_timer(int osc_base, unsigned int *d1, unsigned int *d2,
 pci224_cascade_ns_to_timer(int osc_base, unsigned int *d1, unsigned int *d2,
-	unsigned int *nanosec, int round_mode)
+			   unsigned int *nanosec, int round_mode)
 {
 {
 	i8253_cascade_ns_to_timer(osc_base, d1, d2, nanosec, round_mode);
 	i8253_cascade_ns_to_timer(osc_base, d1, d2, nanosec, round_mode);
 }
 }
@@ -534,7 +538,8 @@ pci224_cascade_ns_to_timer(int osc_base, unsigned int *d1, unsigned int *d2,
 /*
 /*
  * Kills a command running on the AO subdevice.
  * Kills a command running on the AO subdevice.
  */
  */
-static void pci224_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s)
+static void pci224_ao_stop(struct comedi_device *dev,
+			   struct comedi_subdevice *s)
 {
 {
 	unsigned long flags;
 	unsigned long flags;
 
 
@@ -565,16 +570,19 @@ static void pci224_ao_stop(struct comedi_device *dev, struct comedi_subdevice *s
 	/* Reconfigure DAC for insn_write usage. */
 	/* Reconfigure DAC for insn_write usage. */
 	outw(0, dev->iobase + PCI224_DACCEN);	/* Disable channels. */
 	outw(0, dev->iobase + PCI224_DACCEN);	/* Disable channels. */
 	devpriv->daccon = COMBINE(devpriv->daccon,
 	devpriv->daccon = COMBINE(devpriv->daccon,
-		PCI224_DACCON_TRIG_SW | PCI224_DACCON_FIFOINTR_EMPTY,
-		PCI224_DACCON_TRIG_MASK | PCI224_DACCON_FIFOINTR_MASK);
+				  PCI224_DACCON_TRIG_SW |
+				  PCI224_DACCON_FIFOINTR_EMPTY,
+				  PCI224_DACCON_TRIG_MASK |
+				  PCI224_DACCON_FIFOINTR_MASK);
 	outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
 	outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
-		dev->iobase + PCI224_DACCON);
+	     dev->iobase + PCI224_DACCON);
 }
 }
 
 
 /*
 /*
  * Handles start of acquisition for the AO subdevice.
  * Handles start of acquisition for the AO subdevice.
  */
  */
-static void pci224_ao_start(struct comedi_device *dev, struct comedi_subdevice *s)
+static void pci224_ao_start(struct comedi_device *dev,
+			    struct comedi_subdevice *s)
 {
 {
 	struct comedi_cmd *cmd = &s->async->cmd;
 	struct comedi_cmd *cmd = &s->async->cmd;
 	unsigned long flags;
 	unsigned long flags;
@@ -601,7 +609,8 @@ static void pci224_ao_start(struct comedi_device *dev, struct comedi_subdevice *
 /*
 /*
  * Handles interrupts from the DAC FIFO.
  * Handles interrupts from the DAC FIFO.
  */
  */
-static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subdevice *s)
+static void pci224_ao_handle_fifo(struct comedi_device *dev,
+				  struct comedi_subdevice *s)
 {
 {
 	struct comedi_cmd *cmd = &s->async->cmd;
 	struct comedi_cmd *cmd = &s->async->cmd;
 	unsigned int num_scans;
 	unsigned int num_scans;
@@ -630,8 +639,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
 	switch (dacstat & PCI224_DACCON_FIFOFL_MASK) {
 	switch (dacstat & PCI224_DACCON_FIFOFL_MASK) {
 	case PCI224_DACCON_FIFOFL_EMPTY:
 	case PCI224_DACCON_FIFOFL_EMPTY:
 		room = PCI224_FIFO_ROOM_EMPTY;
 		room = PCI224_FIFO_ROOM_EMPTY;
-		if (!devpriv->ao_stop_continuous
-			&& devpriv->ao_stop_count == 0) {
+		if (!devpriv->ao_stop_continuous && devpriv->ao_stop_count == 0) {
 			/* FIFO empty at end of counted acquisition. */
 			/* FIFO empty at end of counted acquisition. */
 			pci224_ao_stop(dev, s);
 			pci224_ao_stop(dev, s);
 			s->async->events |= COMEDI_CB_EOA;
 			s->async->events |= COMEDI_CB_EOA;
@@ -656,7 +664,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
 			pci224_ao_stop(dev, s);
 			pci224_ao_stop(dev, s);
 			s->async->events |= COMEDI_CB_OVERFLOW;
 			s->async->events |= COMEDI_CB_OVERFLOW;
 			printk(KERN_ERR "comedi%d: "
 			printk(KERN_ERR "comedi%d: "
-				"AO buffer underrun\n", dev->minor);
+			       "AO buffer underrun\n", dev->minor);
 		}
 		}
 	}
 	}
 	/* Determine how many new scans can be put in the FIFO. */
 	/* Determine how many new scans can be put in the FIFO. */
@@ -670,11 +678,10 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
 	/* Process scans. */
 	/* Process scans. */
 	for (n = 0; n < num_scans; n++) {
 	for (n = 0; n < num_scans; n++) {
 		cfc_read_array_from_buffer(s, &devpriv->ao_scan_vals[0],
 		cfc_read_array_from_buffer(s, &devpriv->ao_scan_vals[0],
-			bytes_per_scan);
+					   bytes_per_scan);
 		for (i = 0; i < cmd->chanlist_len; i++) {
 		for (i = 0; i < cmd->chanlist_len; i++) {
-			outw(devpriv->ao_scan_vals[devpriv->
-					ao_scan_order[i]],
-				dev->iobase + PCI224_DACDATA);
+			outw(devpriv->ao_scan_vals[devpriv->ao_scan_order[i]],
+			     dev->iobase + PCI224_DACDATA);
 		}
 		}
 	}
 	}
 	if (!devpriv->ao_stop_continuous) {
 	if (!devpriv->ao_stop_continuous) {
@@ -685,14 +692,13 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
 			 * until FIFO is empty.
 			 * until FIFO is empty.
 			 */
 			 */
 			devpriv->daccon = COMBINE(devpriv->daccon,
 			devpriv->daccon = COMBINE(devpriv->daccon,
-				PCI224_DACCON_FIFOINTR_EMPTY,
-				PCI224_DACCON_FIFOINTR_MASK);
-			outw(devpriv->daccon,
-				dev->iobase + PCI224_DACCON);
+						  PCI224_DACCON_FIFOINTR_EMPTY,
+						  PCI224_DACCON_FIFOINTR_MASK);
+			outw(devpriv->daccon, dev->iobase + PCI224_DACCON);
 		}
 		}
 	}
 	}
 	if ((devpriv->daccon & PCI224_DACCON_TRIG_MASK) ==
 	if ((devpriv->daccon & PCI224_DACCON_TRIG_MASK) ==
-		PCI224_DACCON_TRIG_NONE) {
+	    PCI224_DACCON_TRIG_NONE) {
 		unsigned short trig;
 		unsigned short trig;
 
 
 		/*
 		/*
@@ -718,7 +724,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
 			}
 			}
 		}
 		}
 		devpriv->daccon = COMBINE(devpriv->daccon, trig,
 		devpriv->daccon = COMBINE(devpriv->daccon, trig,
-			PCI224_DACCON_TRIG_MASK);
+					  PCI224_DACCON_TRIG_MASK);
 		outw(devpriv->daccon, dev->iobase + PCI224_DACCON);
 		outw(devpriv->daccon, dev->iobase + PCI224_DACCON);
 	}
 	}
 	if (s->async->events) {
 	if (s->async->events) {
@@ -731,7 +737,7 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, struct comedi_subde
  */
  */
 static int
 static int
 pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
 pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int trignum)
+			unsigned int trignum)
 {
 {
 	if (trignum != 0)
 	if (trignum != 0)
 		return -EINVAL;
 		return -EINVAL;
@@ -750,7 +756,8 @@ pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
  * 'do_cmdtest' function for AO subdevice.
  * 'do_cmdtest' function for AO subdevice.
  */
  */
 static int
 static int
-pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd)
+pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+		  struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	unsigned int tmp;
 	unsigned int tmp;
@@ -828,13 +835,13 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct
 		/* Force to external trigger 0. */
 		/* Force to external trigger 0. */
 		if ((cmd->start_arg & ~CR_FLAGS_MASK) != 0) {
 		if ((cmd->start_arg & ~CR_FLAGS_MASK) != 0) {
 			cmd->start_arg = COMBINE(cmd->start_arg, 0,
 			cmd->start_arg = COMBINE(cmd->start_arg, 0,
-				~CR_FLAGS_MASK);
+						 ~CR_FLAGS_MASK);
 			err++;
 			err++;
 		}
 		}
 		/* The only flag allowed is CR_EDGE, which is ignored. */
 		/* The only flag allowed is CR_EDGE, which is ignored. */
 		if ((cmd->start_arg & CR_FLAGS_MASK & ~CR_EDGE) != 0) {
 		if ((cmd->start_arg & CR_FLAGS_MASK & ~CR_EDGE) != 0) {
 			cmd->start_arg = COMBINE(cmd->start_arg, 0,
 			cmd->start_arg = COMBINE(cmd->start_arg, 0,
-				CR_FLAGS_MASK & ~CR_EDGE);
+						 CR_FLAGS_MASK & ~CR_EDGE);
 			err++;
 			err++;
 		}
 		}
 		break;
 		break;
@@ -859,14 +866,16 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct
 		/* Force to external trigger 0. */
 		/* Force to external trigger 0. */
 		if ((cmd->scan_begin_arg & ~CR_FLAGS_MASK) != 0) {
 		if ((cmd->scan_begin_arg & ~CR_FLAGS_MASK) != 0) {
 			cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0,
 			cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0,
-				~CR_FLAGS_MASK);
+						      ~CR_FLAGS_MASK);
 			err++;
 			err++;
 		}
 		}
 		/* Only allow flags CR_EDGE and CR_INVERT.  Ignore CR_EDGE. */
 		/* Only allow flags CR_EDGE and CR_INVERT.  Ignore CR_EDGE. */
 		if ((cmd->scan_begin_arg & CR_FLAGS_MASK &
 		if ((cmd->scan_begin_arg & CR_FLAGS_MASK &
-				~(CR_EDGE | CR_INVERT)) != 0) {
+		     ~(CR_EDGE | CR_INVERT)) != 0) {
 			cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0,
 			cmd->scan_begin_arg = COMBINE(cmd->scan_begin_arg, 0,
-				CR_FLAGS_MASK & ~(CR_EDGE | CR_INVERT));
+						      CR_FLAGS_MASK & ~(CR_EDGE
+									|
+									CR_INVERT));
 			err++;
 			err++;
 		}
 		}
 		break;
 		break;
@@ -892,13 +901,13 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct
 		/* Force to external trigger 0. */
 		/* Force to external trigger 0. */
 		if ((cmd->stop_arg & ~CR_FLAGS_MASK) != 0) {
 		if ((cmd->stop_arg & ~CR_FLAGS_MASK) != 0) {
 			cmd->stop_arg = COMBINE(cmd->stop_arg, 0,
 			cmd->stop_arg = COMBINE(cmd->stop_arg, 0,
-				~CR_FLAGS_MASK);
+						~CR_FLAGS_MASK);
 			err++;
 			err++;
 		}
 		}
 		/* The only flag allowed is CR_EDGE, which is ignored. */
 		/* The only flag allowed is CR_EDGE, which is ignored. */
 		if ((cmd->stop_arg & CR_FLAGS_MASK & ~CR_EDGE) != 0) {
 		if ((cmd->stop_arg & CR_FLAGS_MASK & ~CR_EDGE) != 0) {
 			cmd->stop_arg = COMBINE(cmd->stop_arg, 0,
 			cmd->stop_arg = COMBINE(cmd->stop_arg, 0,
-				CR_FLAGS_MASK & ~CR_EDGE);
+						CR_FLAGS_MASK & ~CR_EDGE);
 		}
 		}
 		break;
 		break;
 	case TRIG_NONE:
 	case TRIG_NONE:
@@ -935,14 +944,14 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct
 		/* Be careful to avoid overflow! */
 		/* Be careful to avoid overflow! */
 		div2 = cmd->scan_begin_arg / TIMEBASE_10MHZ;
 		div2 = cmd->scan_begin_arg / TIMEBASE_10MHZ;
 		div2 += (round + cmd->scan_begin_arg % TIMEBASE_10MHZ) /
 		div2 += (round + cmd->scan_begin_arg % TIMEBASE_10MHZ) /
-			TIMEBASE_10MHZ;
+		    TIMEBASE_10MHZ;
 		if (div2 <= 0x10000) {
 		if (div2 <= 0x10000) {
 			/* A single timer will suffice. */
 			/* A single timer will suffice. */
 			if (div2 < 2)
 			if (div2 < 2)
 				div2 = 2;
 				div2 = 2;
 			cmd->scan_begin_arg = div2 * TIMEBASE_10MHZ;
 			cmd->scan_begin_arg = div2 * TIMEBASE_10MHZ;
 			if (cmd->scan_begin_arg < div2 ||
 			if (cmd->scan_begin_arg < div2 ||
-				cmd->scan_begin_arg < TIMEBASE_10MHZ) {
+			    cmd->scan_begin_arg < TIMEBASE_10MHZ) {
 				/* Overflow! */
 				/* Overflow! */
 				cmd->scan_begin_arg = MAX_SCAN_PERIOD;
 				cmd->scan_begin_arg = MAX_SCAN_PERIOD;
 			}
 			}
@@ -951,7 +960,8 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct
 			div1 = devpriv->cached_div1;
 			div1 = devpriv->cached_div1;
 			div2 = devpriv->cached_div2;
 			div2 = devpriv->cached_div2;
 			pci224_cascade_ns_to_timer(TIMEBASE_10MHZ, &div1, &div2,
 			pci224_cascade_ns_to_timer(TIMEBASE_10MHZ, &div1, &div2,
-				&cmd->scan_begin_arg, round_mode);
+						   &cmd->scan_begin_arg,
+						   round_mode);
 			devpriv->cached_div1 = div1;
 			devpriv->cached_div1 = div1;
 			devpriv->cached_div2 = div2;
 			devpriv->cached_div2 = div2;
 		}
 		}
@@ -1061,12 +1071,15 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	 * N.B. DAC FIFO interrupts are currently disabled.
 	 * N.B. DAC FIFO interrupts are currently disabled.
 	 */
 	 */
 	devpriv->daccon = COMBINE(devpriv->daccon,
 	devpriv->daccon = COMBINE(devpriv->daccon,
-		(devpriv->hwrange[range] | PCI224_DACCON_TRIG_NONE |
-			PCI224_DACCON_FIFOINTR_NHALF),
-		(PCI224_DACCON_POLAR_MASK | PCI224_DACCON_VREF_MASK |
-			PCI224_DACCON_TRIG_MASK | PCI224_DACCON_FIFOINTR_MASK));
+				  (devpriv->
+				   hwrange[range] | PCI224_DACCON_TRIG_NONE |
+				   PCI224_DACCON_FIFOINTR_NHALF),
+				  (PCI224_DACCON_POLAR_MASK |
+				   PCI224_DACCON_VREF_MASK |
+				   PCI224_DACCON_TRIG_MASK |
+				   PCI224_DACCON_FIFOINTR_MASK));
 	outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
 	outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
-		dev->iobase + PCI224_DACCON);
+	     dev->iobase + PCI224_DACCON);
 
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		unsigned int div1, div2, round;
 		unsigned int div1, div2, round;
@@ -1089,7 +1102,7 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 		/* Be careful to avoid overflow! */
 		/* Be careful to avoid overflow! */
 		div2 = cmd->scan_begin_arg / TIMEBASE_10MHZ;
 		div2 = cmd->scan_begin_arg / TIMEBASE_10MHZ;
 		div2 += (round + cmd->scan_begin_arg % TIMEBASE_10MHZ) /
 		div2 += (round + cmd->scan_begin_arg % TIMEBASE_10MHZ) /
-			TIMEBASE_10MHZ;
+		    TIMEBASE_10MHZ;
 		if (div2 <= 0x10000) {
 		if (div2 <= 0x10000) {
 			/* A single timer will suffice. */
 			/* A single timer will suffice. */
 			if (div2 < 2)
 			if (div2 < 2)
@@ -1101,7 +1114,7 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 			div1 = devpriv->cached_div1;
 			div1 = devpriv->cached_div1;
 			div2 = devpriv->cached_div2;
 			div2 = devpriv->cached_div2;
 			pci224_cascade_ns_to_timer(TIMEBASE_10MHZ, &div1, &div2,
 			pci224_cascade_ns_to_timer(TIMEBASE_10MHZ, &div1, &div2,
-				&ns, round_mode);
+						   &ns, round_mode);
 		}
 		}
 
 
 		/*
 		/*
@@ -1110,25 +1123,25 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 		 */
 		 */
 		/* Make sure Z2-0 is gated on.  */
 		/* Make sure Z2-0 is gated on.  */
 		outb(GAT_CONFIG(0, GAT_VCC),
 		outb(GAT_CONFIG(0, GAT_VCC),
-			devpriv->iobase1 + PCI224_ZGAT_SCE);
+		     devpriv->iobase1 + PCI224_ZGAT_SCE);
 		if (div1 == 1) {
 		if (div1 == 1) {
 			/* Not cascading.  Z2-0 needs 10 MHz clock. */
 			/* Not cascading.  Z2-0 needs 10 MHz clock. */
 			outb(CLK_CONFIG(0, CLK_10MHZ),
 			outb(CLK_CONFIG(0, CLK_10MHZ),
-				devpriv->iobase1 + PCI224_ZCLK_SCE);
+			     devpriv->iobase1 + PCI224_ZCLK_SCE);
 		} else {
 		} else {
 			/* Cascading with Z2-2. */
 			/* Cascading with Z2-2. */
 			/* Make sure Z2-2 is gated on.  */
 			/* Make sure Z2-2 is gated on.  */
 			outb(GAT_CONFIG(2, GAT_VCC),
 			outb(GAT_CONFIG(2, GAT_VCC),
-				devpriv->iobase1 + PCI224_ZGAT_SCE);
+			     devpriv->iobase1 + PCI224_ZGAT_SCE);
 			/* Z2-2 needs 10 MHz clock. */
 			/* Z2-2 needs 10 MHz clock. */
 			outb(CLK_CONFIG(2, CLK_10MHZ),
 			outb(CLK_CONFIG(2, CLK_10MHZ),
-				devpriv->iobase1 + PCI224_ZCLK_SCE);
+			     devpriv->iobase1 + PCI224_ZCLK_SCE);
 			/* Load Z2-2 mode (2) and counter (div1). */
 			/* Load Z2-2 mode (2) and counter (div1). */
 			i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0,
 			i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0,
-				2, div1, 2);
+				   2, div1, 2);
 			/* Z2-0 is clocked from Z2-2's output. */
 			/* Z2-0 is clocked from Z2-2's output. */
 			outb(CLK_CONFIG(0, CLK_OUTNM1),
 			outb(CLK_CONFIG(0, CLK_OUTNM1),
-				devpriv->iobase1 + PCI224_ZCLK_SCE);
+			     devpriv->iobase1 + PCI224_ZCLK_SCE);
 		}
 		}
 		/* Load Z2-0 mode (2) and counter (div2). */
 		/* Load Z2-0 mode (2) and counter (div2). */
 		i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, 0, div2, 2);
 		i8254_load(devpriv->iobase1 + PCI224_Z2_CT0, 0, 0, div2, 2);
@@ -1174,7 +1187,8 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 /*
 /*
  * 'cancel' function for AO subdevice.
  * 'cancel' function for AO subdevice.
  */
  */
-static int pci224_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int pci224_ao_cancel(struct comedi_device *dev,
+			    struct comedi_subdevice *s)
 {
 {
 	pci224_ao_stop(dev, s);
 	pci224_ao_stop(dev, s);
 	return 0;
 	return 0;
@@ -1184,8 +1198,8 @@ static int pci224_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *
  * 'munge' data for AO command.
  * 'munge' data for AO command.
  */
  */
 static void
 static void
-pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *data,
-	unsigned int num_bytes, unsigned int chan_index)
+pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s,
+		void *data, unsigned int num_bytes, unsigned int chan_index)
 {
 {
 	struct comedi_async *async = s->async;
 	struct comedi_async *async = s->async;
 	short *array = data;
 	short *array = data;
@@ -1198,7 +1212,7 @@ pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, void *dat
 	shift = 16 - thisboard->ao_bits;
 	shift = 16 - thisboard->ao_bits;
 	/* Channels will be all bipolar or all unipolar. */
 	/* Channels will be all bipolar or all unipolar. */
 	if ((devpriv->hwrange[CR_RANGE(async->cmd.chanlist[0])] &
 	if ((devpriv->hwrange[CR_RANGE(async->cmd.chanlist[0])] &
-			PCI224_DACCON_POLAR_MASK) == PCI224_DACCON_POLAR_UNI) {
+	     PCI224_DACCON_POLAR_MASK) == PCI224_DACCON_POLAR_UNI) {
 		/* Unipolar */
 		/* Unipolar */
 		offset = 0;
 		offset = 0;
 	} else {
 	} else {
@@ -1253,7 +1267,7 @@ static irqreturn_t pci224_interrupt(int irq, void *d)
 		spin_lock_irqsave(&devpriv->ao_spinlock, flags);
 		spin_lock_irqsave(&devpriv->ao_spinlock, flags);
 		if (curenab != devpriv->intsce) {
 		if (curenab != devpriv->intsce) {
 			outb(devpriv->intsce,
 			outb(devpriv->intsce,
-				devpriv->iobase1 + PCI224_INT_SCE);
+			     devpriv->iobase1 + PCI224_INT_SCE);
 		}
 		}
 		devpriv->intr_running = 0;
 		devpriv->intr_running = 0;
 		spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
 		spin_unlock_irqrestore(&devpriv->ao_spinlock, flags);
@@ -1267,7 +1281,7 @@ static irqreturn_t pci224_interrupt(int irq, void *d)
  */
  */
 static int
 static int
 pci224_find_pci(struct comedi_device *dev, int bus, int slot,
 pci224_find_pci(struct comedi_device *dev, int bus, int slot,
-	struct pci_dev **pci_dev_p)
+		struct pci_dev **pci_dev_p)
 {
 {
 	struct pci_dev *pci_dev = NULL;
 	struct pci_dev *pci_dev = NULL;
 
 
@@ -1275,13 +1289,13 @@ pci224_find_pci(struct comedi_device *dev, int bus, int slot,
 
 
 	/* Look for matching PCI device. */
 	/* Look for matching PCI device. */
 	for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
 	for (pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID, NULL);
-		pci_dev != NULL;
-		pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID,
-			pci_dev)) {
+	     pci_dev != NULL;
+	     pci_dev = pci_get_device(PCI_VENDOR_ID_AMPLICON, PCI_ANY_ID,
+				      pci_dev)) {
 		/* If bus/slot specified, check them. */
 		/* If bus/slot specified, check them. */
 		if (bus || slot) {
 		if (bus || slot) {
 			if (bus != pci_dev->bus->number
 			if (bus != pci_dev->bus->number
-				|| slot != PCI_SLOT(pci_dev->devfn))
+			    || slot != PCI_SLOT(pci_dev->devfn))
 				continue;
 				continue;
 		}
 		}
 		if (thisboard->model == any_model) {
 		if (thisboard->model == any_model) {
@@ -1310,11 +1324,11 @@ pci224_find_pci(struct comedi_device *dev, int bus, int slot,
 	/* No match found. */
 	/* No match found. */
 	if (bus || slot) {
 	if (bus || slot) {
 		printk(KERN_ERR "comedi%d: error! "
 		printk(KERN_ERR "comedi%d: error! "
-			"no %s found at pci %02x:%02x!\n",
-			dev->minor, thisboard->name, bus, slot);
+		       "no %s found at pci %02x:%02x!\n",
+		       dev->minor, thisboard->name, bus, slot);
 	} else {
 	} else {
 		printk(KERN_ERR "comedi%d: error! no %s found!\n",
 		printk(KERN_ERR "comedi%d: error! no %s found!\n",
-			dev->minor, thisboard->name);
+		       dev->minor, thisboard->name);
 	}
 	}
 	return -EIO;
 	return -EIO;
 }
 }
@@ -1341,7 +1355,7 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	ret = alloc_private(dev, sizeof(struct pci224_private));
 	ret = alloc_private(dev, sizeof(struct pci224_private));
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -1353,8 +1367,8 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	ret = comedi_pci_enable(pci_dev, DRIVER_NAME);
 	ret = comedi_pci_enable(pci_dev, DRIVER_NAME);
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR
 		printk(KERN_ERR
-			"comedi%d: error! cannot enable PCI device "
-			"and request regions!\n", dev->minor);
+		       "comedi%d: error! cannot enable PCI device "
+		       "and request regions!\n", dev->minor);
 		return ret;
 		return ret;
 	}
 	}
 	spin_lock_init(&devpriv->ao_spinlock);
 	spin_lock_init(&devpriv->ao_spinlock);
@@ -1365,21 +1379,21 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 
 	/* Allocate readback buffer for AO channels. */
 	/* Allocate readback buffer for AO channels. */
 	devpriv->ao_readback = kmalloc(sizeof(devpriv->ao_readback[0]) *
 	devpriv->ao_readback = kmalloc(sizeof(devpriv->ao_readback[0]) *
-		thisboard->ao_chans, GFP_KERNEL);
+				       thisboard->ao_chans, GFP_KERNEL);
 	if (!devpriv->ao_readback) {
 	if (!devpriv->ao_readback) {
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 
 
 	/* Allocate buffer to hold values for AO channel scan. */
 	/* Allocate buffer to hold values for AO channel scan. */
 	devpriv->ao_scan_vals = kmalloc(sizeof(devpriv->ao_scan_vals[0]) *
 	devpriv->ao_scan_vals = kmalloc(sizeof(devpriv->ao_scan_vals[0]) *
-		thisboard->ao_chans, GFP_KERNEL);
+					thisboard->ao_chans, GFP_KERNEL);
 	if (!devpriv->ao_scan_vals) {
 	if (!devpriv->ao_scan_vals) {
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 
 
 	/* Allocate buffer to hold AO channel scan order. */
 	/* Allocate buffer to hold AO channel scan order. */
 	devpriv->ao_scan_order = kmalloc(sizeof(devpriv->ao_scan_order[0]) *
 	devpriv->ao_scan_order = kmalloc(sizeof(devpriv->ao_scan_order[0]) *
-		thisboard->ao_chans, GFP_KERNEL);
+					 thisboard->ao_chans, GFP_KERNEL);
 	if (!devpriv->ao_scan_order) {
 	if (!devpriv->ao_scan_order) {
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
@@ -1393,15 +1407,16 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	outw(0, dev->iobase + PCI224_DACCEN);
 	outw(0, dev->iobase + PCI224_DACCEN);
 	outw(0, dev->iobase + PCI224_FIFOSIZ);
 	outw(0, dev->iobase + PCI224_FIFOSIZ);
 	devpriv->daccon = (PCI224_DACCON_TRIG_SW | PCI224_DACCON_POLAR_BI |
 	devpriv->daccon = (PCI224_DACCON_TRIG_SW | PCI224_DACCON_POLAR_BI |
-		PCI224_DACCON_FIFOENAB | PCI224_DACCON_FIFOINTR_EMPTY);
+			   PCI224_DACCON_FIFOENAB |
+			   PCI224_DACCON_FIFOINTR_EMPTY);
 	outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
 	outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
-		dev->iobase + PCI224_DACCON);
+	     dev->iobase + PCI224_DACCON);
 
 
 	/* Allocate subdevices.  There is only one!  */
 	/* Allocate subdevices.  There is only one!  */
 	ret = alloc_subdevices(dev, 1);
 	ret = alloc_subdevices(dev, 1);
 	if (ret < 0) {
 	if (ret < 0) {
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
 		printk(KERN_ERR "comedi%d: error! out of memory!\n",
-			dev->minor);
+		       dev->minor);
 		return ret;
 		return ret;
 	}
 	}
 
 
@@ -1427,22 +1442,22 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		const struct comedi_lrange **range_table_list;
 		const struct comedi_lrange **range_table_list;
 
 
 		s->range_table_list = range_table_list =
 		s->range_table_list = range_table_list =
-			kmalloc(sizeof(struct comedi_lrange *) * s->n_chan,
-			GFP_KERNEL);
+		    kmalloc(sizeof(struct comedi_lrange *) * s->n_chan,
+			    GFP_KERNEL);
 		if (!s->range_table_list) {
 		if (!s->range_table_list) {
 			return -ENOMEM;
 			return -ENOMEM;
 		}
 		}
 		for (n = 2; n < 3 + s->n_chan; n++) {
 		for (n = 2; n < 3 + s->n_chan; n++) {
 			if (it->options[n] < 0 || it->options[n] > 1) {
 			if (it->options[n] < 0 || it->options[n] > 1) {
 				printk(KERN_WARNING "comedi%d: %s: warning! "
 				printk(KERN_WARNING "comedi%d: %s: warning! "
-					"bad options[%u]=%d\n",
-					dev->minor, DRIVER_NAME, n,
-					it->options[n]);
+				       "bad options[%u]=%d\n",
+				       dev->minor, DRIVER_NAME, n,
+				       it->options[n]);
 			}
 			}
 		}
 		}
 		for (n = 0; n < s->n_chan; n++) {
 		for (n = 0; n < s->n_chan; n++) {
 			if (n < COMEDI_NDEVCONFOPTS - 3 &&
 			if (n < COMEDI_NDEVCONFOPTS - 3 &&
-				it->options[3 + n] == 1) {
+			    it->options[3 + n] == 1) {
 				if (it->options[2] == 1) {
 				if (it->options[2] == 1) {
 					range_table_list[n] = &range_pci234_ext;
 					range_table_list[n] = &range_pci234_ext;
 				} else {
 				} else {
@@ -1451,7 +1466,7 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 			} else {
 			} else {
 				if (it->options[2] == 1) {
 				if (it->options[2] == 1) {
 					range_table_list[n] =
 					range_table_list[n] =
-						&range_pci234_ext2;
+					    &range_pci234_ext2;
 				} else {
 				} else {
 					range_table_list[n] = &range_bipolar10;
 					range_table_list[n] = &range_bipolar10;
 				}
 				}
@@ -1466,9 +1481,8 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		} else {
 		} else {
 			if (it->options[2] != 0) {
 			if (it->options[2] != 0) {
 				printk(KERN_WARNING "comedi%d: %s: warning! "
 				printk(KERN_WARNING "comedi%d: %s: warning! "
-					"bad options[2]=%d\n",
-					dev->minor, DRIVER_NAME,
-					it->options[2]);
+				       "bad options[2]=%d\n",
+				       dev->minor, DRIVER_NAME, it->options[2]);
 			}
 			}
 			s->range_table = &range_pci224_internal;
 			s->range_table = &range_pci224_internal;
 			devpriv->hwrange = hwrange_pci224_internal;
 			devpriv->hwrange = hwrange_pci224_internal;
@@ -1482,7 +1496,7 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 				  DRIVER_NAME, dev);
 				  DRIVER_NAME, dev);
 		if (ret < 0) {
 		if (ret < 0) {
 			printk(KERN_ERR "comedi%d: error! "
 			printk(KERN_ERR "comedi%d: error! "
-				"unable to allocate irq %u\n", dev->minor, irq);
+			       "unable to allocate irq %u\n", dev->minor, irq);
 			return ret;
 			return ret;
 		} else {
 		} else {
 			dev->irq = irq;
 			dev->irq = irq;
@@ -1545,7 +1559,7 @@ static int pci224_detach(struct comedi_device *dev)
 	}
 	}
 	if (dev->board_name) {
 	if (dev->board_name) {
 		printk(KERN_INFO "comedi%d: %s removed\n",
 		printk(KERN_INFO "comedi%d: %s removed\n",
-			dev->minor, dev->board_name);
+		       dev->minor, dev->board_name);
 	}
 	}
 
 
 	return 0;
 	return 0;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 224 - 200
drivers/staging/comedi/drivers/amplc_pci230.c


+ 24 - 18
drivers/staging/comedi/drivers/c6xdigio.c

@@ -97,7 +97,8 @@ union encvaluetype {
 
 
 #define C6XDIGIO_TIME_OUT 20
 #define C6XDIGIO_TIME_OUT 20
 
 
-static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int c6xdigio_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it);
 static int c6xdigio_detach(struct comedi_device *dev);
 static int c6xdigio_detach(struct comedi_device *dev);
 struct comedi_driver driver_c6xdigio = {
 struct comedi_driver driver_c6xdigio = {
 	.driver_name = "c6xdigio",
 	.driver_name = "c6xdigio",
@@ -114,28 +115,28 @@ static void C6X_pwmInit(unsigned long baseAddr)
 
 
 	WriteByteToHwPort(baseAddr, 0x70);
 	WriteByteToHwPort(baseAddr, 0x70);
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0)
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0)
-		&& (timeout < C6XDIGIO_TIME_OUT)) {
+	       && (timeout < C6XDIGIO_TIME_OUT)) {
 		timeout++;
 		timeout++;
 	}
 	}
 
 
 	WriteByteToHwPort(baseAddr, 0x74);
 	WriteByteToHwPort(baseAddr, 0x74);
 	timeout = 0;
 	timeout = 0;
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
-		&& (timeout < C6XDIGIO_TIME_OUT)) {
+	       && (timeout < C6XDIGIO_TIME_OUT)) {
 		timeout++;
 		timeout++;
 	}
 	}
 
 
 	WriteByteToHwPort(baseAddr, 0x70);
 	WriteByteToHwPort(baseAddr, 0x70);
 	timeout = 0;
 	timeout = 0;
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x0)
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x0)
-		&& (timeout < C6XDIGIO_TIME_OUT)) {
+	       && (timeout < C6XDIGIO_TIME_OUT)) {
 		timeout++;
 		timeout++;
 	}
 	}
 
 
 	WriteByteToHwPort(baseAddr, 0x0);
 	WriteByteToHwPort(baseAddr, 0x0);
 	timeout = 0;
 	timeout = 0;
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
-		&& (timeout < C6XDIGIO_TIME_OUT)) {
+	       && (timeout < C6XDIGIO_TIME_OUT)) {
 		timeout++;
 		timeout++;
 	}
 	}
 
 
@@ -315,38 +316,41 @@ static void C6X_encResetAll(unsigned long baseAddr)
 
 
 	WriteByteToHwPort(baseAddr, 0x68);
 	WriteByteToHwPort(baseAddr, 0x68);
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0)
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0)
-		&& (timeout < C6XDIGIO_TIME_OUT)) {
+	       && (timeout < C6XDIGIO_TIME_OUT)) {
 		timeout++;
 		timeout++;
 	}
 	}
 	WriteByteToHwPort(baseAddr, 0x6C);
 	WriteByteToHwPort(baseAddr, 0x6C);
 	timeout = 0;
 	timeout = 0;
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
-		&& (timeout < C6XDIGIO_TIME_OUT)) {
+	       && (timeout < C6XDIGIO_TIME_OUT)) {
 		timeout++;
 		timeout++;
 	}
 	}
 	WriteByteToHwPort(baseAddr, 0x68);
 	WriteByteToHwPort(baseAddr, 0x68);
 	timeout = 0;
 	timeout = 0;
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x0)
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x0)
-		&& (timeout < C6XDIGIO_TIME_OUT)) {
+	       && (timeout < C6XDIGIO_TIME_OUT)) {
 		timeout++;
 		timeout++;
 	}
 	}
 	WriteByteToHwPort(baseAddr, 0x0);
 	WriteByteToHwPort(baseAddr, 0x0);
 	timeout = 0;
 	timeout = 0;
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
 	while (((ReadByteFromHwPort(baseAddr + 1) & 0x80) == 0x80)
-		&& (timeout < C6XDIGIO_TIME_OUT)) {
+	       && (timeout < C6XDIGIO_TIME_OUT)) {
 		timeout++;
 		timeout++;
 	}
 	}
 }
 }
 
 
 static int c6xdigio_pwmo_insn_read(struct comedi_device *dev,
 static int c6xdigio_pwmo_insn_read(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	printk("c6xdigio_pwmo_insn_read %x\n", insn->n);
 	printk("c6xdigio_pwmo_insn_read %x\n", insn->n);
 	return insn->n;
 	return insn->n;
 }
 }
 
 
 static int c6xdigio_pwmo_insn_write(struct comedi_device *dev,
 static int c6xdigio_pwmo_insn_write(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+				    struct comedi_subdevice *s,
+				    struct comedi_insn *insn,
+				    unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -375,12 +379,13 @@ static int c6xdigio_pwmo_insn_write(struct comedi_device *dev,
 /* { */
 /* { */
 /* int i; */
 /* int i; */
 /* int chan = CR_CHAN(insn->chanspec); */
 /* int chan = CR_CHAN(insn->chanspec); */
-/*  *//* C6X_encResetAll( dev->iobase ); */
-/*  *//* return insn->n; */
+      /*  *//* C6X_encResetAll( dev->iobase ); */
+      /*  *//* return insn->n; */
 /* } */
 /* } */
 
 
 static int c6xdigio_ei_insn_read(struct comedi_device *dev,
 static int c6xdigio_ei_insn_read(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	/*   printk("c6xdigio_ei__insn_read %x\n", insn->n); */
 	/*   printk("c6xdigio_ei__insn_read %x\n", insn->n); */
 	int n;
 	int n;
@@ -415,9 +420,9 @@ static void board_init(struct comedi_device *dev)
 
 
 static const struct pnp_device_id c6xdigio_pnp_tbl[] = {
 static const struct pnp_device_id c6xdigio_pnp_tbl[] = {
 	/* Standard LPT Printer Port */
 	/* Standard LPT Printer Port */
-	{.id = "PNP0400", .driver_data = 0},
+	{.id = "PNP0400",.driver_data = 0},
 	/* ECP Printer Port */
 	/* ECP Printer Port */
-	{.id = "PNP0401", .driver_data = 0},
+	{.id = "PNP0401",.driver_data = 0},
 	{}
 	{}
 };
 };
 
 
@@ -426,7 +431,8 @@ static struct pnp_driver c6xdigio_pnp_driver = {
 	.id_table = c6xdigio_pnp_tbl,
 	.id_table = c6xdigio_pnp_tbl,
 };
 };
 
 
-static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int c6xdigio_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it)
 {
 {
 	int result = 0;
 	int result = 0;
 	unsigned long iobase;
 	unsigned long iobase;
@@ -478,7 +484,7 @@ static int c6xdigio_attach(struct comedi_device *dev, struct comedi_devconfig *i
 	s->range_table = &range_unknown;
 	s->range_table = &range_unknown;
 
 
 	/*           s = dev->subdevices + 2; */
 	/*           s = dev->subdevices + 2; */
-	      /* pwm output subdevice */
+	/* pwm output subdevice */
 	/*       s->type = COMEDI_SUBD_COUNTER;  // Not sure what to put here */
 	/*       s->type = COMEDI_SUBD_COUNTER;  // Not sure what to put here */
 	/*       s->subdev_flags = SDF_WRITEABLE; */
 	/*       s->subdev_flags = SDF_WRITEABLE; */
 	/*       s->n_chan = 1; */
 	/*       s->n_chan = 1; */

+ 96 - 72
drivers/staging/comedi/drivers/cb_das16_cs.c

@@ -62,23 +62,23 @@ struct das16cs_board {
 };
 };
 static const struct das16cs_board das16cs_boards[] = {
 static const struct das16cs_board das16cs_boards[] = {
 	{
 	{
-	.device_id = 0x0000,/* unknown */
-	.name = "PC-CARD DAS16/16",
-	.n_ao_chans = 0,
-		},
+	 .device_id = 0x0000,	/* unknown */
+	 .name = "PC-CARD DAS16/16",
+	 .n_ao_chans = 0,
+	 },
 	{
 	{
-	.device_id = 0x0039,
-	.name = "PC-CARD DAS16/16-AO",
-	.n_ao_chans = 2,
-		},
+	 .device_id = 0x0039,
+	 .name = "PC-CARD DAS16/16-AO",
+	 .n_ao_chans = 2,
+	 },
 	{
 	{
-	.device_id = 0x4009,
-	.name = "PCM-DAS16s/16",
-	.n_ao_chans = 0,
-		},
+	 .device_id = 0x4009,
+	 .name = "PCM-DAS16s/16",
+	 .n_ao_chans = 0,
+	 },
 };
 };
 
 
-#define n_boards (sizeof(das16cs_boards)/sizeof(das16cs_boards[0]))
+#define n_boards ARRAY_SIZE(das16cs_boards)
 #define thisboard ((const struct das16cs_board *)dev->board_ptr)
 #define thisboard ((const struct das16cs_board *)dev->board_ptr)
 
 
 struct das16cs_private {
 struct das16cs_private {
@@ -90,7 +90,8 @@ struct das16cs_private {
 };
 };
 #define devpriv ((struct das16cs_private *)dev->private)
 #define devpriv ((struct das16cs_private *)dev->private)
 
 
-static int das16cs_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das16cs_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int das16cs_detach(struct comedi_device *dev);
 static int das16cs_detach(struct comedi_device *dev);
 static struct comedi_driver driver_das16cs = {
 static struct comedi_driver driver_das16cs = {
 	.driver_name = "cb_das16_cs",
 	.driver_name = "cb_das16_cs",
@@ -102,31 +103,43 @@ static struct comedi_driver driver_das16cs = {
 static struct pcmcia_device *cur_dev = NULL;
 static struct pcmcia_device *cur_dev = NULL;
 
 
 static const struct comedi_lrange das16cs_ai_range = { 4, {
 static const struct comedi_lrange das16cs_ai_range = { 4, {
-			RANGE(-10, 10),
-			RANGE(-5, 5),
-			RANGE(-2.5, 2.5),
-			RANGE(-1.25, 1.25),
-	}
+							   RANGE(-10, 10),
+							   RANGE(-5, 5),
+							   RANGE(-2.5, 2.5),
+							   RANGE(-1.25, 1.25),
+							   }
 };
 };
 
 
 static irqreturn_t das16cs_interrupt(int irq, void *d);
 static irqreturn_t das16cs_interrupt(int irq, void *d);
-static int das16cs_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das16cs_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd);
-static int das16cs_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das16cs_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das16cs_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das16cs_timer_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das16cs_timer_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int das16cs_ai_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int das16cs_ai_cmd(struct comedi_device *dev,
+			  struct comedi_subdevice *s);
+static int das16cs_ai_cmdtest(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_cmd *cmd);
+static int das16cs_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int das16cs_ao_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int das16cs_dio_insn_bits(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data);
+static int das16cs_dio_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn,
+				   unsigned int *data);
+static int das16cs_timer_insn_read(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn,
+				   unsigned int *data);
+static int das16cs_timer_insn_config(struct comedi_device *dev,
+				     struct comedi_subdevice *s,
+				     struct comedi_insn *insn,
+				     unsigned int *data);
 
 
 static int get_prodid(struct comedi_device *dev, struct pcmcia_device *link)
 static int get_prodid(struct comedi_device *dev, struct pcmcia_device *link)
 {
 {
@@ -140,15 +153,15 @@ static int get_prodid(struct comedi_device *dev, struct pcmcia_device *link)
 	tuple.DesiredTuple = CISTPL_MANFID;
 	tuple.DesiredTuple = CISTPL_MANFID;
 	tuple.Attributes = TUPLE_RETURN_COMMON;
 	tuple.Attributes = TUPLE_RETURN_COMMON;
 	if ((pcmcia_get_first_tuple(link, &tuple) == 0) &&
 	if ((pcmcia_get_first_tuple(link, &tuple) == 0) &&
-		(pcmcia_get_tuple_data(link, &tuple) == 0)) {
+	    (pcmcia_get_tuple_data(link, &tuple) == 0)) {
 		prodid = le16_to_cpu(buf[1]);
 		prodid = le16_to_cpu(buf[1]);
 	}
 	}
 
 
 	return prodid;
 	return prodid;
 }
 }
 
 
-static const struct das16cs_board *das16cs_probe(struct comedi_device * dev,
-	struct pcmcia_device *link)
+static const struct das16cs_board *das16cs_probe(struct comedi_device *dev,
+						 struct pcmcia_device *link)
 {
 {
 	int id;
 	int id;
 	int i;
 	int i;
@@ -166,7 +179,8 @@ static const struct das16cs_board *das16cs_probe(struct comedi_device * dev,
 	return NULL;
 	return NULL;
 }
 }
 
 
-static int das16cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int das16cs_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct pcmcia_device *link;
 	struct pcmcia_device *link;
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
@@ -287,8 +301,9 @@ static irqreturn_t das16cs_interrupt(int irq, void *d)
  * "instructions" read/write data in "one-shot" or "software-triggered"
  * "instructions" read/write data in "one-shot" or "software-triggered"
  * mode.
  * mode.
  */
  */
-static int das16cs_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das16cs_ai_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int to;
 	int to;
@@ -334,8 +349,9 @@ static int das16cs_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	return -EINVAL;
 	return -EINVAL;
 }
 }
 
 
-static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int das16cs_ai_cmdtest(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -381,7 +397,7 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 
 
 	/* note that mutual compatiblity is not an issue here */
 	/* note that mutual compatiblity is not an issue here */
 	if (cmd->scan_begin_src != TRIG_TIMER &&
 	if (cmd->scan_begin_src != TRIG_TIMER &&
-		cmd->scan_begin_src != TRIG_EXT)
+	    cmd->scan_begin_src != TRIG_EXT)
 		err++;
 		err++;
 	if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
 	if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
 		err++;
 		err++;
@@ -463,7 +479,8 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 
 
 		tmp = cmd->scan_begin_arg;
 		tmp = cmd->scan_begin_arg;
 		i8253_cascade_ns_to_timer(100, &div1, &div2,
 		i8253_cascade_ns_to_timer(100, &div1, &div2,
-			&cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK);
+					  &cmd->scan_begin_arg,
+					  cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->scan_begin_arg)
 		if (tmp != cmd->scan_begin_arg)
 			err++;
 			err++;
 	}
 	}
@@ -472,14 +489,15 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 
 
 		tmp = cmd->convert_arg;
 		tmp = cmd->convert_arg;
 		i8253_cascade_ns_to_timer(100, &div1, &div2,
 		i8253_cascade_ns_to_timer(100, &div1, &div2,
-			&cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK);
+					  &cmd->scan_begin_arg,
+					  cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->convert_arg)
 		if (tmp != cmd->convert_arg)
 			err++;
 			err++;
 		if (cmd->scan_begin_src == TRIG_TIMER &&
 		if (cmd->scan_begin_src == TRIG_TIMER &&
-			cmd->scan_begin_arg <
-			cmd->convert_arg * cmd->scan_end_arg) {
+		    cmd->scan_begin_arg <
+		    cmd->convert_arg * cmd->scan_end_arg) {
 			cmd->scan_begin_arg =
 			cmd->scan_begin_arg =
-				cmd->convert_arg * cmd->scan_end_arg;
+			    cmd->convert_arg * cmd->scan_end_arg;
 			err++;
 			err++;
 		}
 		}
 	}
 	}
@@ -490,8 +508,9 @@ static int das16cs_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 	return 0;
 	return 0;
 }
 }
 
 
-static int das16cs_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das16cs_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -536,8 +555,9 @@ static int das16cs_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *
 
 
 /* AO subdevices should have a read insn as well as a write insn.
 /* AO subdevices should have a read insn as well as a write insn.
  * Usually this means copying a value stored in devpriv. */
  * Usually this means copying a value stored in devpriv. */
-static int das16cs_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das16cs_ao_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -553,8 +573,9 @@ static int das16cs_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *
  * useful to applications if you implement the insn_bits interface.
  * useful to applications if you implement the insn_bits interface.
  * This allows packed reading/writing of the DIO channels.  The
  * This allows packed reading/writing of the DIO channels.  The
  * comedi core can convert between insn_bits and insn_read/write */
  * comedi core can convert between insn_bits and insn_read/write */
-static int das16cs_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das16cs_dio_insn_bits(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -573,8 +594,9 @@ static int das16cs_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
 	return 2;
 	return 2;
 }
 }
 
 
-static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das16cs_dio_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
 	int bits;
 	int bits;
@@ -593,8 +615,7 @@ static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subd
 		break;
 		break;
 	case INSN_CONFIG_DIO_QUERY:
 	case INSN_CONFIG_DIO_QUERY:
 		data[1] =
 		data[1] =
-			(s->
-			io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+		    (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
 		return insn->n;
 		return insn->n;
 		break;
 		break;
 	default:
 	default:
@@ -611,14 +632,17 @@ static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subd
 	return insn->n;
 	return insn->n;
 }
 }
 
 
-static int das16cs_timer_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das16cs_timer_insn_read(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	return -EINVAL;
 	return -EINVAL;
 }
 }
 
 
-static int das16cs_timer_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das16cs_timer_insn_config(struct comedi_device *dev,
+				     struct comedi_subdevice *s,
+				     struct comedi_insn *insn,
+				     unsigned int *data)
 {
 {
 	return -EINVAL;
 	return -EINVAL;
 }
 }
@@ -650,7 +674,7 @@ static int pc_debug = PCMCIA_DEBUG;
 module_param(pc_debug, int, 0644);
 module_param(pc_debug, int, 0644);
 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
 static char *version =
 static char *version =
-	"cb_das16_cs.c pcmcia code (David Schleef), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)";
+    "cb_das16_cs.c pcmcia code (David Schleef), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)";
 #else
 #else
 #define DEBUG(n, args...)
 #define DEBUG(n, args...)
 #endif
 #endif
@@ -739,7 +763,7 @@ static void das16cs_pcmcia_detach(struct pcmcia_device *link)
 	DEBUG(0, "das16cs_pcmcia_detach(0x%p)\n", link);
 	DEBUG(0, "das16cs_pcmcia_detach(0x%p)\n", link);
 
 
 	if (link->dev_node) {
 	if (link->dev_node) {
-		((struct local_info_t *) link->priv)->stop = 1;
+		((struct local_info_t *)link->priv)->stop = 1;
 		das16cs_pcmcia_release(link);
 		das16cs_pcmcia_release(link);
 	}
 	}
 	/* This points to the parent struct local_info_t struct */
 	/* This points to the parent struct local_info_t struct */
@@ -853,7 +877,7 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
 		/* If we got this far, we're cool! */
 		/* If we got this far, we're cool! */
 		break;
 		break;
 
 
-	      next_entry:
+next_entry:
 		last_fn = GetNextTuple;
 		last_fn = GetNextTuple;
 
 
 		last_ret = pcmcia_get_next_tuple(link, &tuple);
 		last_ret = pcmcia_get_next_tuple(link, &tuple);
@@ -893,20 +917,20 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
 
 
 	/* Finally, report what we've done */
 	/* Finally, report what we've done */
 	printk(KERN_INFO "%s: index 0x%02x",
 	printk(KERN_INFO "%s: index 0x%02x",
-		dev->node.dev_name, link->conf.ConfigIndex);
+	       dev->node.dev_name, link->conf.ConfigIndex);
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
 		printk(", irq %u", link->irq.AssignedIRQ);
 		printk(", irq %u", link->irq.AssignedIRQ);
 	if (link->io.NumPorts1)
 	if (link->io.NumPorts1)
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
-			link->io.BasePort1 + link->io.NumPorts1 - 1);
+		       link->io.BasePort1 + link->io.NumPorts1 - 1);
 	if (link->io.NumPorts2)
 	if (link->io.NumPorts2)
 		printk(" & 0x%04x-0x%04x", link->io.BasePort2,
 		printk(" & 0x%04x-0x%04x", link->io.BasePort2,
-			link->io.BasePort2 + link->io.NumPorts2 - 1);
+		       link->io.BasePort2 + link->io.NumPorts2 - 1);
 	printk("\n");
 	printk("\n");
 
 
 	return;
 	return;
 
 
-      cs_failed:
+cs_failed:
 	cs_error(link, last_fn, last_ret);
 	cs_error(link, last_fn, last_ret);
 	das16cs_pcmcia_release(link);
 	das16cs_pcmcia_release(link);
 }				/* das16cs_pcmcia_config */
 }				/* das16cs_pcmcia_config */
@@ -953,7 +977,7 @@ struct pcmcia_driver das16cs_driver = {
 	.id_table = das16cs_id_table,
 	.id_table = das16cs_id_table,
 	.owner = THIS_MODULE,
 	.owner = THIS_MODULE,
 	.drv = {
 	.drv = {
-			.name = dev_info,
+		.name = dev_info,
 		},
 		},
 };
 };
 
 

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 319 - 269
drivers/staging/comedi/drivers/cb_pcidas.c


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 502 - 471
drivers/staging/comedi/drivers/cb_pcidas64.c


+ 115 - 103
drivers/staging/comedi/drivers/cb_pcidda.c

@@ -115,13 +115,13 @@ Please report success/failure with other different cards to
 static const struct comedi_lrange cb_pcidda_ranges = {
 static const struct comedi_lrange cb_pcidda_ranges = {
 	6,
 	6,
 	{
 	{
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-			BIP_RANGE(2.5),
-			UNI_RANGE(10),
-			UNI_RANGE(5),
-			UNI_RANGE(2.5),
-		}
+	 BIP_RANGE(10),
+	 BIP_RANGE(5),
+	 BIP_RANGE(2.5),
+	 UNI_RANGE(10),
+	 UNI_RANGE(5),
+	 UNI_RANGE(2.5),
+	 }
 };
 };
 
 
 /*
 /*
@@ -147,63 +147,64 @@ struct cb_pcidda_board {
 
 
 static const struct cb_pcidda_board cb_pcidda_boards[] = {
 static const struct cb_pcidda_board cb_pcidda_boards[] = {
 	{
 	{
-	.name = "pci-dda02/12",
-	.status = 1,
-	.device_id = 0x20,
-	.ao_chans = 2,
-	.ao_bits = 12,
-	.ranges = &cb_pcidda_ranges,
-		},
+	 .name = "pci-dda02/12",
+	 .status = 1,
+	 .device_id = 0x20,
+	 .ao_chans = 2,
+	 .ao_bits = 12,
+	 .ranges = &cb_pcidda_ranges,
+	 },
 	{
 	{
-	.name = "pci-dda04/12",
-	.status = 1,
-	.device_id = 0x21,
-	.ao_chans = 4,
-	.ao_bits = 12,
-	.ranges = &cb_pcidda_ranges,
-		},
+	 .name = "pci-dda04/12",
+	 .status = 1,
+	 .device_id = 0x21,
+	 .ao_chans = 4,
+	 .ao_bits = 12,
+	 .ranges = &cb_pcidda_ranges,
+	 },
 	{
 	{
-	.name = "pci-dda08/12",
-	.status = 0,
-	.device_id = 0x22,
-	.ao_chans = 8,
-	.ao_bits = 12,
-	.ranges = &cb_pcidda_ranges,
-		},
+	 .name = "pci-dda08/12",
+	 .status = 0,
+	 .device_id = 0x22,
+	 .ao_chans = 8,
+	 .ao_bits = 12,
+	 .ranges = &cb_pcidda_ranges,
+	 },
 	{
 	{
-	.name = "pci-dda02/16",
-	.status = 2,
-	.device_id = 0x23,
-	.ao_chans = 2,
-	.ao_bits = 16,
-	.ranges = &cb_pcidda_ranges,
-		},
+	 .name = "pci-dda02/16",
+	 .status = 2,
+	 .device_id = 0x23,
+	 .ao_chans = 2,
+	 .ao_bits = 16,
+	 .ranges = &cb_pcidda_ranges,
+	 },
 	{
 	{
-	.name = "pci-dda04/16",
-	.status = 2,
-	.device_id = 0x24,
-	.ao_chans = 4,
-	.ao_bits = 16,
-	.ranges = &cb_pcidda_ranges,
-		},
+	 .name = "pci-dda04/16",
+	 .status = 2,
+	 .device_id = 0x24,
+	 .ao_chans = 4,
+	 .ao_bits = 16,
+	 .ranges = &cb_pcidda_ranges,
+	 },
 	{
 	{
-	.name = "pci-dda08/16",
-	.status = 0,
-	.device_id = 0x25,
-	.ao_chans = 8,
-	.ao_bits = 16,
-	.ranges = &cb_pcidda_ranges,
-		},
+	 .name = "pci-dda08/16",
+	 .status = 0,
+	 .device_id = 0x25,
+	 .ao_chans = 8,
+	 .ao_bits = 16,
+	 .ranges = &cb_pcidda_ranges,
+	 },
 };
 };
 
 
 static DEFINE_PCI_DEVICE_TABLE(cb_pcidda_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(cb_pcidda_pci_table) = {
-	{PCI_VENDOR_ID_CB, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_CB, 0x0021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_CB, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_CB, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_CB, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_CB, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_CB, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_CB, 0x0021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_CB, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_CB, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_CB, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_CB, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, cb_pcidda_pci_table);
 MODULE_DEVICE_TABLE(pci, cb_pcidda_pci_table);
@@ -239,11 +240,13 @@ struct cb_pcidda_private {
  */
  */
 #define devpriv ((struct cb_pcidda_private *)dev->private)
 #define devpriv ((struct cb_pcidda_private *)dev->private)
 
 
-static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int cb_pcidda_attach(struct comedi_device *dev,
+			    struct comedi_devconfig *it);
 static int cb_pcidda_detach(struct comedi_device *dev);
 static int cb_pcidda_detach(struct comedi_device *dev);
 /* static int cb_pcidda_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); */
 /* static int cb_pcidda_ai_rinsn(struct comedi_device *dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data); */
-static int cb_pcidda_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int cb_pcidda_ao_winsn(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data);
 
 
 /* static int cb_pcidda_ai_cmd(struct comedi_device *dev, struct *comedi_subdevice *s);*/
 /* static int cb_pcidda_ai_cmd(struct comedi_device *dev, struct *comedi_subdevice *s);*/
 /* static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd); */
 /* static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd); */
@@ -251,11 +254,11 @@ static int cb_pcidda_ao_winsn(struct comedi_device *dev, struct comedi_subdevice
 
 
 static unsigned int cb_pcidda_serial_in(struct comedi_device *dev);
 static unsigned int cb_pcidda_serial_in(struct comedi_device *dev);
 static void cb_pcidda_serial_out(struct comedi_device *dev, unsigned int value,
 static void cb_pcidda_serial_out(struct comedi_device *dev, unsigned int value,
-	unsigned int num_bits);
+				 unsigned int num_bits);
 static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
 static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
-	unsigned int address);
+					  unsigned int address);
 static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
 static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
-	unsigned int range);
+				unsigned int range);
 
 
 /*
 /*
  * The struct comedi_driver structure tells the Comedi core module
  * The struct comedi_driver structure tells the Comedi core module
@@ -274,7 +277,8 @@ static struct comedi_driver driver_cb_pcidda = {
  * Attach is called by the Comedi core to configure the driver
  * Attach is called by the Comedi core to configure the driver
  * for a particular board.
  * for a particular board.
  */
  */
-static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int cb_pcidda_attach(struct comedi_device *dev,
+			    struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	struct pci_dev *pcidev;
 	struct pci_dev *pcidev;
@@ -294,29 +298,29 @@ static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *
 	printk("\n");
 	printk("\n");
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 		if (pcidev->vendor == PCI_VENDOR_ID_CB) {
 		if (pcidev->vendor == PCI_VENDOR_ID_CB) {
 			if (it->options[0] || it->options[1]) {
 			if (it->options[0] || it->options[1]) {
 				if (pcidev->bus->number != it->options[0] ||
 				if (pcidev->bus->number != it->options[0] ||
-					PCI_SLOT(pcidev->devfn) !=
-					it->options[1]) {
+				    PCI_SLOT(pcidev->devfn) != it->options[1]) {
 					continue;
 					continue;
 				}
 				}
 			}
 			}
 			for (index = 0; index < N_BOARDS; index++) {
 			for (index = 0; index < N_BOARDS; index++) {
 				if (cb_pcidda_boards[index].device_id ==
 				if (cb_pcidda_boards[index].device_id ==
-					pcidev->device) {
+				    pcidev->device) {
 					goto found;
 					goto found;
 				}
 				}
 			}
 			}
 		}
 		}
 	}
 	}
 	if (!pcidev) {
 	if (!pcidev) {
-		printk("Not a ComputerBoards/MeasurementComputing card on requested position\n");
+		printk
+		    ("Not a ComputerBoards/MeasurementComputing card on requested position\n");
 		return -EIO;
 		return -EIO;
 	}
 	}
-      found:
+found:
 	devpriv->pci_dev = pcidev;
 	devpriv->pci_dev = pcidev;
 	dev->board_ptr = cb_pcidda_boards + index;
 	dev->board_ptr = cb_pcidda_boards + index;
 	/*  "thisboard" macro can be used from here. */
 	/*  "thisboard" macro can be used from here. */
@@ -326,7 +330,8 @@ static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *
 	 * Enable PCI device and request regions.
 	 * Enable PCI device and request regions.
 	 */
 	 */
 	if (comedi_pci_enable(pcidev, thisboard->name)) {
 	if (comedi_pci_enable(pcidev, thisboard->name)) {
-		printk("cb_pcidda: failed to enable PCI device and request regions\n");
+		printk
+		    ("cb_pcidda: failed to enable PCI device and request regions\n");
 		return -EIO;
 		return -EIO;
 	}
 	}
 
 
@@ -334,14 +339,17 @@ static int cb_pcidda_attach(struct comedi_device *dev, struct comedi_devconfig *
  * Allocate the I/O ports.
  * Allocate the I/O ports.
  */
  */
 	devpriv->digitalio =
 	devpriv->digitalio =
-		pci_resource_start(devpriv->pci_dev, DIGITALIO_BADRINDEX);
+	    pci_resource_start(devpriv->pci_dev, DIGITALIO_BADRINDEX);
 	devpriv->dac = pci_resource_start(devpriv->pci_dev, DAC_BADRINDEX);
 	devpriv->dac = pci_resource_start(devpriv->pci_dev, DAC_BADRINDEX);
 
 
 /*
 /*
  * Warn about the status of the driver.
  * Warn about the status of the driver.
  */
  */
 	if (thisboard->status == 2)
 	if (thisboard->status == 2)
-		printk("WARNING: DRIVER FOR THIS BOARD NOT CHECKED WITH MANUAL. " "WORKS ASSUMING FULL COMPATIBILITY WITH PCI-DDA08/12. " "PLEASE REPORT USAGE TO <ivanmr@altavista.com>.\n");
+		printk
+		    ("WARNING: DRIVER FOR THIS BOARD NOT CHECKED WITH MANUAL. "
+		     "WORKS ASSUMING FULL COMPATIBILITY WITH PCI-DDA08/12. "
+		     "PLEASE REPORT USAGE TO <ivanmr@altavista.com>.\n");
 
 
 /*
 /*
  * Initialize dev->board_name.
  * Initialize dev->board_name.
@@ -423,7 +431,8 @@ static int cb_pcidda_detach(struct comedi_device *dev)
  * I will program this later... ;-)
  * I will program this later... ;-)
  */
  */
 #if 0
 #if 0
-static int cb_pcidda_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int cb_pcidda_ai_cmd(struct comedi_device *dev,
+			    struct comedi_subdevice *s)
 {
 {
 	printk("cb_pcidda_ai_cmd\n");
 	printk("cb_pcidda_ai_cmd\n");
 	printk("subdev: %d\n", cmd->subdev);
 	printk("subdev: %d\n", cmd->subdev);
@@ -442,8 +451,9 @@ static int cb_pcidda_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *
 #endif
 #endif
 
 
 #if 0
 #if 0
-static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int cb_pcidda_ai_cmdtest(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -489,7 +499,7 @@ static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevi
 
 
 	/* note that mutual compatiblity is not an issue here */
 	/* note that mutual compatiblity is not an issue here */
 	if (cmd->scan_begin_src != TRIG_TIMER
 	if (cmd->scan_begin_src != TRIG_TIMER
-		&& cmd->scan_begin_src != TRIG_EXT)
+	    && cmd->scan_begin_src != TRIG_EXT)
 		err++;
 		err++;
 	if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
 	if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
 		err++;
 		err++;
@@ -569,21 +579,21 @@ static int cb_pcidda_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevi
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		tmp = cmd->scan_begin_arg;
 		tmp = cmd->scan_begin_arg;
 		cb_pcidda_ns_to_timer(&cmd->scan_begin_arg,
 		cb_pcidda_ns_to_timer(&cmd->scan_begin_arg,
-			cmd->flags & TRIG_ROUND_MASK);
+				      cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->scan_begin_arg)
 		if (tmp != cmd->scan_begin_arg)
 			err++;
 			err++;
 	}
 	}
 	if (cmd->convert_src == TRIG_TIMER) {
 	if (cmd->convert_src == TRIG_TIMER) {
 		tmp = cmd->convert_arg;
 		tmp = cmd->convert_arg;
 		cb_pcidda_ns_to_timer(&cmd->convert_arg,
 		cb_pcidda_ns_to_timer(&cmd->convert_arg,
-			cmd->flags & TRIG_ROUND_MASK);
+				      cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->convert_arg)
 		if (tmp != cmd->convert_arg)
 			err++;
 			err++;
 		if (cmd->scan_begin_src == TRIG_TIMER &&
 		if (cmd->scan_begin_src == TRIG_TIMER &&
-			cmd->scan_begin_arg <
-			cmd->convert_arg * cmd->scan_end_arg) {
+		    cmd->scan_begin_arg <
+		    cmd->convert_arg * cmd->scan_end_arg) {
 			cmd->scan_begin_arg =
 			cmd->scan_begin_arg =
-				cmd->convert_arg * cmd->scan_end_arg;
+			    cmd->convert_arg * cmd->scan_end_arg;
 			err++;
 			err++;
 		}
 		}
 	}
 	}
@@ -608,8 +618,9 @@ static int cb_pcidda_ns_to_timer(unsigned int *ns, int round)
 }
 }
 #endif
 #endif
 
 
-static int cb_pcidda_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int cb_pcidda_ao_winsn(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int command;
 	unsigned int command;
 	unsigned int channel, range;
 	unsigned int channel, range;
@@ -676,7 +687,7 @@ static unsigned int cb_pcidda_serial_in(struct comedi_device *dev)
 
 
 /* lowlevel write to eeprom/dac */
 /* lowlevel write to eeprom/dac */
 static void cb_pcidda_serial_out(struct comedi_device *dev, unsigned int value,
 static void cb_pcidda_serial_out(struct comedi_device *dev, unsigned int value,
-	unsigned int num_bits)
+				 unsigned int num_bits)
 {
 {
 	int i;
 	int i;
 
 
@@ -692,7 +703,7 @@ static void cb_pcidda_serial_out(struct comedi_device *dev, unsigned int value,
 
 
 /* reads a 16 bit value from board's eeprom */
 /* reads a 16 bit value from board's eeprom */
 static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
 static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
-	unsigned int address)
+					  unsigned int address)
 {
 {
 	unsigned int i;
 	unsigned int i;
 	unsigned int cal2_bits;
 	unsigned int cal2_bits;
@@ -725,8 +736,9 @@ static unsigned int cb_pcidda_read_eeprom(struct comedi_device *dev,
 }
 }
 
 
 /* writes to 8 bit calibration dacs */
 /* writes to 8 bit calibration dacs */
-static void cb_pcidda_write_caldac(struct comedi_device *dev, unsigned int caldac,
-	unsigned int channel, unsigned int value)
+static void cb_pcidda_write_caldac(struct comedi_device *dev,
+				   unsigned int caldac, unsigned int channel,
+				   unsigned int value)
 {
 {
 	unsigned int cal2_bits;
 	unsigned int cal2_bits;
 	unsigned int i;
 	unsigned int i;
@@ -787,14 +799,14 @@ static unsigned int fine_offset_channel(unsigned int ao_channel)
 
 
 /* returns eeprom address that provides offset for given ao channel and range */
 /* returns eeprom address that provides offset for given ao channel and range */
 static unsigned int offset_eeprom_address(unsigned int ao_channel,
 static unsigned int offset_eeprom_address(unsigned int ao_channel,
-	unsigned int range)
+					  unsigned int range)
 {
 {
 	return 0x7 + 2 * range + 12 * ao_channel;
 	return 0x7 + 2 * range + 12 * ao_channel;
 }
 }
 
 
 /* returns eeprom address that provides gain calibration for given ao channel and range */
 /* returns eeprom address that provides gain calibration for given ao channel and range */
 static unsigned int gain_eeprom_address(unsigned int ao_channel,
 static unsigned int gain_eeprom_address(unsigned int ao_channel,
-	unsigned int range)
+					unsigned int range)
 {
 {
 	return 0x8 + 2 * range + 12 * ao_channel;
 	return 0x8 + 2 * range + 12 * ao_channel;
 }
 }
@@ -813,7 +825,7 @@ static unsigned int eeprom_fine_byte(unsigned int word)
 
 
 /* set caldacs to eeprom values for given channel and range */
 /* set caldacs to eeprom values for given channel and range */
 static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
 static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
-	unsigned int range)
+				unsigned int range)
 {
 {
 	unsigned int coarse_offset, fine_offset, coarse_gain, fine_gain;
 	unsigned int coarse_offset, fine_offset, coarse_gain, fine_gain;
 
 
@@ -822,27 +834,27 @@ static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel,
 
 
 	/*  get values from eeprom data */
 	/*  get values from eeprom data */
 	coarse_offset =
 	coarse_offset =
-		eeprom_coarse_byte(devpriv->
-		eeprom_data[offset_eeprom_address(channel, range)]);
+	    eeprom_coarse_byte(devpriv->eeprom_data
+			       [offset_eeprom_address(channel, range)]);
 	fine_offset =
 	fine_offset =
-		eeprom_fine_byte(devpriv->
-		eeprom_data[offset_eeprom_address(channel, range)]);
+	    eeprom_fine_byte(devpriv->eeprom_data
+			     [offset_eeprom_address(channel, range)]);
 	coarse_gain =
 	coarse_gain =
-		eeprom_coarse_byte(devpriv->
-		eeprom_data[gain_eeprom_address(channel, range)]);
+	    eeprom_coarse_byte(devpriv->eeprom_data
+			       [gain_eeprom_address(channel, range)]);
 	fine_gain =
 	fine_gain =
-		eeprom_fine_byte(devpriv->
-		eeprom_data[gain_eeprom_address(channel, range)]);
+	    eeprom_fine_byte(devpriv->eeprom_data
+			     [gain_eeprom_address(channel, range)]);
 
 
 	/*  set caldacs */
 	/*  set caldacs */
 	cb_pcidda_write_caldac(dev, caldac_number(channel),
 	cb_pcidda_write_caldac(dev, caldac_number(channel),
-		coarse_offset_channel(channel), coarse_offset);
+			       coarse_offset_channel(channel), coarse_offset);
 	cb_pcidda_write_caldac(dev, caldac_number(channel),
 	cb_pcidda_write_caldac(dev, caldac_number(channel),
-		fine_offset_channel(channel), fine_offset);
+			       fine_offset_channel(channel), fine_offset);
 	cb_pcidda_write_caldac(dev, caldac_number(channel),
 	cb_pcidda_write_caldac(dev, caldac_number(channel),
-		coarse_gain_channel(channel), coarse_gain);
+			       coarse_gain_channel(channel), coarse_gain);
 	cb_pcidda_write_caldac(dev, caldac_number(channel),
 	cb_pcidda_write_caldac(dev, caldac_number(channel),
-		fine_gain_channel(channel), fine_gain);
+			       fine_gain_channel(channel), fine_gain);
 }
 }
 
 
 /*
 /*

+ 37 - 37
drivers/staging/comedi/drivers/cb_pcidio.c

@@ -63,23 +63,23 @@ struct pcidio_board {
 
 
 static const struct pcidio_board pcidio_boards[] = {
 static const struct pcidio_board pcidio_boards[] = {
 	{
 	{
-	.name = "pci-dio24",
-	.n_8255 = 1,
-	.pcicontroler_badrindex = 1,
-	.dioregs_badrindex = 2,
-		},
+	 .name = "pci-dio24",
+	 .n_8255 = 1,
+	 .pcicontroler_badrindex = 1,
+	 .dioregs_badrindex = 2,
+	 },
 	{
 	{
-	.name = "pci-dio24h",
-	.n_8255 = 1,
-	.pcicontroler_badrindex = 1,
-	.dioregs_badrindex = 2,
-		},
+	 .name = "pci-dio24h",
+	 .n_8255 = 1,
+	 .pcicontroler_badrindex = 1,
+	 .dioregs_badrindex = 2,
+	 },
 	{
 	{
-	.name = "pci-dio48h",
-	.n_8255 = 2,
-	.pcicontroler_badrindex = 0,
-	.dioregs_badrindex = 1,
-		},
+	 .name = "pci-dio48h",
+	 .n_8255 = 2,
+	 .pcicontroler_badrindex = 0,
+	 .dioregs_badrindex = 1,
+	 },
 };
 };
 
 
 /* This is used by modprobe to translate PCI IDs to drivers.  Should
 /* This is used by modprobe to translate PCI IDs to drivers.  Should
@@ -87,10 +87,11 @@ static const struct pcidio_board pcidio_boards[] = {
 /* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
 /* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
  * upstream. */
  * upstream. */
 static DEFINE_PCI_DEVICE_TABLE(pcidio_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(pcidio_pci_table) = {
-	{PCI_VENDOR_ID_CB, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_CB, 0x0014, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_CB, 0x000b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_CB, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_CB, 0x0014, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_CB, 0x000b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, pcidio_pci_table);
 MODULE_DEVICE_TABLE(pci, pcidio_pci_table);
@@ -127,7 +128,8 @@ struct pcidio_private {
  * the board, and also about the kernel module that contains
  * the board, and also about the kernel module that contains
  * the device code.
  * the device code.
  */
  */
-static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pcidio_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int pcidio_detach(struct comedi_device *dev);
 static int pcidio_detach(struct comedi_device *dev);
 static struct comedi_driver driver_cb_pcidio = {
 static struct comedi_driver driver_cb_pcidio = {
 	.driver_name = "cb_pcidio",
 	.driver_name = "cb_pcidio",
@@ -197,15 +199,13 @@ static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
  */
  */
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 		/*  is it not a computer boards card? */
 		/*  is it not a computer boards card? */
 		if (pcidev->vendor != PCI_VENDOR_ID_CB)
 		if (pcidev->vendor != PCI_VENDOR_ID_CB)
 			continue;
 			continue;
 		/*  loop through cards supported by this driver */
 		/*  loop through cards supported by this driver */
-		for (index = 0;
-			index < ARRAY_SIZE(pcidio_boards);
-			index++) {
+		for (index = 0; index < ARRAY_SIZE(pcidio_boards); index++) {
 			if (pcidio_pci_table[index].device != pcidev->device)
 			if (pcidio_pci_table[index].device != pcidev->device)
 				continue;
 				continue;
 
 
@@ -213,8 +213,7 @@ static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 			if (it->options[0] || it->options[1]) {
 			if (it->options[0] || it->options[1]) {
 				/*  are we on the wrong bus/slot? */
 				/*  are we on the wrong bus/slot? */
 				if (pcidev->bus->number != it->options[0] ||
 				if (pcidev->bus->number != it->options[0] ||
-					PCI_SLOT(pcidev->devfn) !=
-					it->options[1]) {
+				    PCI_SLOT(pcidev->devfn) != it->options[1]) {
 					continue;
 					continue;
 				}
 				}
 			}
 			}
@@ -224,10 +223,10 @@ static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	}
 	}
 
 
 	printk("No supported ComputerBoards/MeasurementComputing card found on "
 	printk("No supported ComputerBoards/MeasurementComputing card found on "
-		"requested position\n");
+	       "requested position\n");
 	return -EIO;
 	return -EIO;
 
 
-      found:
+found:
 
 
 /*
 /*
  * Initialize dev->board_name.  Note that we can use the "thisboard"
  * Initialize dev->board_name.  Note that we can use the "thisboard"
@@ -237,16 +236,17 @@ static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 
 	devpriv->pci_dev = pcidev;
 	devpriv->pci_dev = pcidev;
 	printk("Found %s on bus %i, slot %i\n", thisboard->name,
 	printk("Found %s on bus %i, slot %i\n", thisboard->name,
-		devpriv->pci_dev->bus->number,
-		PCI_SLOT(devpriv->pci_dev->devfn));
+	       devpriv->pci_dev->bus->number,
+	       PCI_SLOT(devpriv->pci_dev->devfn));
 	if (comedi_pci_enable(pcidev, thisboard->name)) {
 	if (comedi_pci_enable(pcidev, thisboard->name)) {
-		printk("cb_pcidio: failed to enable PCI device and request regions\n");
+		printk
+		    ("cb_pcidio: failed to enable PCI device and request regions\n");
 		return -EIO;
 		return -EIO;
 	}
 	}
 	devpriv->dio_reg_base
 	devpriv->dio_reg_base
-		=
-		pci_resource_start(devpriv->pci_dev,
-		pcidio_boards[index].dioregs_badrindex);
+	    =
+	    pci_resource_start(devpriv->pci_dev,
+			       pcidio_boards[index].dioregs_badrindex);
 
 
 /*
 /*
  * Allocate the subdevice structures.  alloc_subdevice() is a
  * Allocate the subdevice structures.  alloc_subdevice() is a
@@ -257,9 +257,9 @@ static int pcidio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 
 	for (i = 0; i < thisboard->n_8255; i++) {
 	for (i = 0; i < thisboard->n_8255; i++) {
 		subdev_8255_init(dev, dev->subdevices + i,
 		subdev_8255_init(dev, dev->subdevices + i,
-			NULL, devpriv->dio_reg_base + i * 4);
+				 NULL, devpriv->dio_reg_base + i * 4);
 		printk(" subdev %d: base = 0x%lx\n", i,
 		printk(" subdev %d: base = 0x%lx\n", i,
-			devpriv->dio_reg_base + i * 4);
+		       devpriv->dio_reg_base + i * 4);
 	}
 	}
 
 
 	printk("attached\n");
 	printk("attached\n");

+ 49 - 40
drivers/staging/comedi/drivers/cb_pcimdas.c

@@ -103,29 +103,31 @@ struct cb_pcimdas_board {
 
 
 static const struct cb_pcimdas_board cb_pcimdas_boards[] = {
 static const struct cb_pcimdas_board cb_pcimdas_boards[] = {
 	{
 	{
-	.name = "PCIM-DAS1602/16",
-	.device_id = 0x56,
-	.ai_se_chans = 16,
-	.ai_diff_chans = 8,
-	.ai_bits = 16,
-	.ai_speed = 10000,	/* ?? */
-	.ao_nchan = 2,
-	.ao_bits = 12,
-	.has_ao_fifo = 0,	/* ?? */
-	.ao_scan_speed = 10000,
-			/* ?? */
-	.fifo_size = 1024,
-	.dio_bits = 24,
-	.has_dio = 1,
+	 .name = "PCIM-DAS1602/16",
+	 .device_id = 0x56,
+	 .ai_se_chans = 16,
+	 .ai_diff_chans = 8,
+	 .ai_bits = 16,
+	 .ai_speed = 10000,	/* ?? */
+	 .ao_nchan = 2,
+	 .ao_bits = 12,
+	 .has_ao_fifo = 0,	/* ?? */
+	 .ao_scan_speed = 10000,
+	 /* ?? */
+	 .fifo_size = 1024,
+	 .dio_bits = 24,
+	 .has_dio = 1,
 /*	.ranges = &cb_pcimdas_ranges, */
 /*	.ranges = &cb_pcimdas_ranges, */
-		},
+	 },
 };
 };
 
 
 /* This is used by modprobe to translate PCI IDs to drivers.  Should
 /* This is used by modprobe to translate PCI IDs to drivers.  Should
  * only be used for PCI and ISA-PnP devices */
  * only be used for PCI and ISA-PnP devices */
 static DEFINE_PCI_DEVICE_TABLE(cb_pcimdas_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(cb_pcimdas_pci_table) = {
-	{PCI_VENDOR_ID_COMPUTERBOARDS, 0x0056, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_COMPUTERBOARDS, 0x0056, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table);
 MODULE_DEVICE_TABLE(pci, cb_pcimdas_pci_table);
@@ -176,7 +178,8 @@ struct cb_pcimdas_private {
  * the board, and also about the kernel module that contains
  * the board, and also about the kernel module that contains
  * the device code.
  * the device code.
  */
  */
-static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int cb_pcimdas_attach(struct comedi_device *dev,
+			     struct comedi_devconfig *it);
 static int cb_pcimdas_detach(struct comedi_device *dev);
 static int cb_pcimdas_detach(struct comedi_device *dev);
 static struct comedi_driver driver_cb_pcimdas = {
 static struct comedi_driver driver_cb_pcimdas = {
 	.driver_name = "cb_pcimdas",
 	.driver_name = "cb_pcimdas",
@@ -185,12 +188,15 @@ static struct comedi_driver driver_cb_pcimdas = {
 	.detach = cb_pcimdas_detach,
 	.detach = cb_pcimdas_detach,
 };
 };
 
 
-static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int cb_pcimdas_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int cb_pcimdas_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
+static int cb_pcimdas_ao_winsn(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
+static int cb_pcimdas_ao_rinsn(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
 
 
 /*
 /*
  * Attach is called by the Comedi core to configure the driver
  * Attach is called by the Comedi core to configure the driver
@@ -198,7 +204,8 @@ static int cb_pcimdas_ao_rinsn(struct comedi_device *dev, struct comedi_subdevic
  * in the driver structure, dev->board_ptr contains that
  * in the driver structure, dev->board_ptr contains that
  * address.
  * address.
  */
  */
-static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int cb_pcimdas_attach(struct comedi_device *dev,
+			     struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	struct pci_dev *pcidev;
 	struct pci_dev *pcidev;
@@ -219,22 +226,21 @@ static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig
 	printk("\n");
 	printk("\n");
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 		/*  is it not a computer boards card? */
 		/*  is it not a computer boards card? */
 		if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
 		if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
 			continue;
 			continue;
 		/*  loop through cards supported by this driver */
 		/*  loop through cards supported by this driver */
 		for (index = 0; index < N_BOARDS; index++) {
 		for (index = 0; index < N_BOARDS; index++) {
 			if (cb_pcimdas_boards[index].device_id !=
 			if (cb_pcimdas_boards[index].device_id !=
-				pcidev->device)
+			    pcidev->device)
 				continue;
 				continue;
 			/*  was a particular bus/slot requested? */
 			/*  was a particular bus/slot requested? */
 			if (it->options[0] || it->options[1]) {
 			if (it->options[0] || it->options[1]) {
 				/*  are we on the wrong bus/slot? */
 				/*  are we on the wrong bus/slot? */
 				if (pcidev->bus->number != it->options[0] ||
 				if (pcidev->bus->number != it->options[0] ||
-					PCI_SLOT(pcidev->devfn) !=
-					it->options[1]) {
+				    PCI_SLOT(pcidev->devfn) != it->options[1]) {
 					continue;
 					continue;
 				}
 				}
 			}
 			}
@@ -245,13 +251,13 @@ static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig
 	}
 	}
 
 
 	printk("No supported ComputerBoards/MeasurementComputing card found on "
 	printk("No supported ComputerBoards/MeasurementComputing card found on "
-		"requested position\n");
+	       "requested position\n");
 	return -EIO;
 	return -EIO;
 
 
-      found:
+found:
 
 
 	printk("Found %s on bus %i, slot %i\n", cb_pcimdas_boards[index].name,
 	printk("Found %s on bus %i, slot %i\n", cb_pcimdas_boards[index].name,
-		pcidev->bus->number, PCI_SLOT(pcidev->devfn));
+	       pcidev->bus->number, PCI_SLOT(pcidev->devfn));
 
 
 	/*  Warn about non-tested features */
 	/*  Warn about non-tested features */
 	switch (thisboard->device_id) {
 	switch (thisboard->device_id) {
@@ -259,7 +265,7 @@ static int cb_pcimdas_attach(struct comedi_device *dev, struct comedi_devconfig
 		break;
 		break;
 	default:
 	default:
 		printk("THIS CARD IS UNSUPPORTED.\n"
 		printk("THIS CARD IS UNSUPPORTED.\n"
-			"PLEASE REPORT USAGE TO <mocelet@sucs.org>\n");
+		       "PLEASE REPORT USAGE TO <mocelet@sucs.org>\n");
 	};
 	};
 
 
 	if (comedi_pci_enable(pcidev, "cb_pcimdas")) {
 	if (comedi_pci_enable(pcidev, "cb_pcimdas")) {
@@ -373,8 +379,9 @@ static int cb_pcimdas_detach(struct comedi_device *dev)
  * "instructions" read/write data in "one-shot" or "software-triggered"
  * "instructions" read/write data in "one-shot" or "software-triggered"
  * mode.
  * mode.
  */
  */
-static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int cb_pcimdas_ai_rinsn(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, i;
 	int n, i;
 	unsigned int d;
 	unsigned int d;
@@ -438,8 +445,9 @@ static int cb_pcimdas_ai_rinsn(struct comedi_device *dev, struct comedi_subdevic
 	return n;
 	return n;
 }
 }
 
 
-static int cb_pcimdas_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int cb_pcimdas_ao_winsn(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -466,8 +474,9 @@ static int cb_pcimdas_ao_winsn(struct comedi_device *dev, struct comedi_subdevic
 
 
 /* AO subdevices should have a read insn as well as a write insn.
 /* AO subdevices should have a read insn as well as a write insn.
  * Usually this means copying a value stored in devpriv. */
  * Usually this means copying a value stored in devpriv. */
-static int cb_pcimdas_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int cb_pcimdas_ao_rinsn(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);

+ 31 - 30
drivers/staging/comedi/drivers/cb_pcimdda.c

@@ -118,16 +118,16 @@ enum DIO_METHODS {
 
 
 static const struct board_struct boards[] = {
 static const struct board_struct boards[] = {
 	{
 	{
-	.name = "cb_pcimdda06-16",
-	.device_id = PCI_ID_PCIM_DDA06_16,
-	.ao_chans = 6,
-	.ao_bits = 16,
-	.dio_chans = 24,
-	.dio_method = DIO_8255,
-	.dio_offset = 12,
-	.regs_badrindex = 3,
-	.reg_sz = 16,
-		}
+	 .name = "cb_pcimdda06-16",
+	 .device_id = PCI_ID_PCIM_DDA06_16,
+	 .ao_chans = 6,
+	 .ao_bits = 16,
+	 .dio_chans = 24,
+	 .dio_method = DIO_8255,
+	 .dio_offset = 12,
+	 .regs_badrindex = 3,
+	 .reg_sz = 16,
+	 }
 };
 };
 
 
 /*
 /*
@@ -143,9 +143,10 @@ static const struct board_struct boards[] = {
 /* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
 /* Please add your PCI vendor ID to comedidev.h, and it will be forwarded
  * upstream. */
  * upstream. */
 static DEFINE_PCI_DEVICE_TABLE(pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(pci_table) = {
-	{PCI_VENDOR_ID_COMPUTERBOARDS, PCI_ID_PCIM_DDA06_16, PCI_ANY_ID,
-		PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_COMPUTERBOARDS, PCI_ID_PCIM_DDA06_16, PCI_ANY_ID,
+		    PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, pci_table);
 MODULE_DEVICE_TABLE(pci, pci_table);
@@ -190,15 +191,15 @@ static struct comedi_driver cb_pcimdda_driver = {
 
 
 MODULE_AUTHOR("Calin A. Culianu <calin@rtlab.org>");
 MODULE_AUTHOR("Calin A. Culianu <calin@rtlab.org>");
 MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA "
 MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA "
-	"series.  Currently only supports PCIM-DDA06-16 (which "
-	"also happens to be the only board in this series. :) ) ");
+		   "series.  Currently only supports PCIM-DDA06-16 (which "
+		   "also happens to be the only board in this series. :) ) ");
 MODULE_LICENSE("GPL");
 MODULE_LICENSE("GPL");
 COMEDI_PCI_INITCLEANUP_NOMODULE(cb_pcimdda_driver, pci_table);
 COMEDI_PCI_INITCLEANUP_NOMODULE(cb_pcimdda_driver, pci_table);
 
 
 static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+		    struct comedi_insn *insn, unsigned int *data);
 static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+		    struct comedi_insn *insn, unsigned int *data);
 
 
 /*---------------------------------------------------------------------------
 /*---------------------------------------------------------------------------
   HELPER FUNCTION DECLARATIONS
   HELPER FUNCTION DECLARATIONS
@@ -207,7 +208,7 @@ static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 /* returns a maxdata value for a given n_bits */
 /* returns a maxdata value for a given n_bits */
 static inline unsigned int figure_out_maxdata(int bits)
 static inline unsigned int figure_out_maxdata(int bits)
 {
 {
-	return ((unsigned int) 1 << bits) - 1;
+	return ((unsigned int)1 << bits) - 1;
 }
 }
 
 
 /*
 /*
@@ -344,7 +345,7 @@ static int detach(struct comedi_device *dev)
 
 
 		if (devpriv->attached_successfully && thisboard)
 		if (devpriv->attached_successfully && thisboard)
 			printk("comedi%d: %s: detached\n", dev->minor,
 			printk("comedi%d: %s: detached\n", dev->minor,
-				thisboard->name);
+			       thisboard->name);
 
 
 	}
 	}
 
 
@@ -352,7 +353,7 @@ static int detach(struct comedi_device *dev)
 }
 }
 
 
 static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+		    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -391,7 +392,7 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
    applications, I would imagine.
    applications, I would imagine.
 */
 */
 static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+		    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -431,8 +432,8 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
 	unsigned long registers;
 	unsigned long registers;
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 		/*  is it not a computer boards card? */
 		/*  is it not a computer boards card? */
 		if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
 		if (pcidev->vendor != PCI_VENDOR_ID_COMPUTERBOARDS)
 			continue;
 			continue;
@@ -444,8 +445,7 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
 			if (it->options[0] || it->options[1]) {
 			if (it->options[0] || it->options[1]) {
 				/*  are we on the wrong bus/slot? */
 				/*  are we on the wrong bus/slot? */
 				if (pcidev->bus->number != it->options[0] ||
 				if (pcidev->bus->number != it->options[0] ||
-					PCI_SLOT(pcidev->devfn) !=
-					it->options[1]) {
+				    PCI_SLOT(pcidev->devfn) != it->options[1]) {
 					continue;
 					continue;
 				}
 				}
 			}
 			}
@@ -454,20 +454,21 @@ static int probe(struct comedi_device *dev, const struct comedi_devconfig *it)
 			devpriv->pci_dev = pcidev;
 			devpriv->pci_dev = pcidev;
 			dev->board_ptr = boards + index;
 			dev->board_ptr = boards + index;
 			if (comedi_pci_enable(pcidev, thisboard->name)) {
 			if (comedi_pci_enable(pcidev, thisboard->name)) {
-				printk("cb_pcimdda: Failed to enable PCI device and request regions\n");
+				printk
+				    ("cb_pcimdda: Failed to enable PCI device and request regions\n");
 				return -EIO;
 				return -EIO;
 			}
 			}
 			registers =
 			registers =
-				pci_resource_start(devpriv->pci_dev,
-				REGS_BADRINDEX);
+			    pci_resource_start(devpriv->pci_dev,
+					       REGS_BADRINDEX);
 			devpriv->registers = registers;
 			devpriv->registers = registers;
 			devpriv->dio_registers
 			devpriv->dio_registers
-				= devpriv->registers + thisboard->dio_offset;
+			    = devpriv->registers + thisboard->dio_offset;
 			return 0;
 			return 0;
 		}
 		}
 	}
 	}
 
 
 	printk("cb_pcimdda: No supported ComputerBoards/MeasurementComputing "
 	printk("cb_pcimdda: No supported ComputerBoards/MeasurementComputing "
-		"card found at the requested position\n");
+	       "card found at the requested position\n");
 	return -ENODEV;
 	return -ENODEV;
 }
 }

+ 31 - 25
drivers/staging/comedi/drivers/comedi_bond.c

@@ -132,8 +132,8 @@ struct BondingBoard {
 
 
 static const struct BondingBoard bondingBoards[] = {
 static const struct BondingBoard bondingBoards[] = {
 	{
 	{
-		.name =	MODULE_NAME,
-	},
+	 .name = MODULE_NAME,
+	 },
 };
 };
 
 
 /*
 /*
@@ -176,7 +176,8 @@ struct Private {
  * the board, and also about the kernel module that contains
  * the board, and also about the kernel module that contains
  * the device code.
  * the device code.
  */
  */
-static int bonding_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int bonding_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int bonding_detach(struct comedi_device *dev);
 static int bonding_detach(struct comedi_device *dev);
 /** Build Private array of all devices.. */
 /** Build Private array of all devices.. */
 static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it);
 static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it);
@@ -186,10 +187,10 @@ static void doDevUnconfig(struct comedi_device *dev);
 static void *Realloc(const void *ptr, size_t len, size_t old_len);
 static void *Realloc(const void *ptr, size_t len, size_t old_len);
 
 
 static struct comedi_driver driver_bonding = {
 static struct comedi_driver driver_bonding = {
-      .driver_name =	MODULE_NAME,
-      .module =		THIS_MODULE,
-      .attach =		bonding_attach,
-      .detach =		bonding_detach,
+	.driver_name = MODULE_NAME,
+	.module = THIS_MODULE,
+	.attach = bonding_attach,
+	.detach = bonding_detach,
 	/* It is not necessary to implement the following members if you are
 	/* It is not necessary to implement the following members if you are
 	 * writing a driver for a ISA PnP or PCI card */
 	 * writing a driver for a ISA PnP or PCI card */
 	/* Most drivers will support multiple types of boards by
 	/* Most drivers will support multiple types of boards by
@@ -208,15 +209,18 @@ static struct comedi_driver driver_bonding = {
 	 * the type of board in software.  ISA PnP, PCI, and PCMCIA
 	 * the type of board in software.  ISA PnP, PCI, and PCMCIA
 	 * devices are such boards.
 	 * devices are such boards.
 	 */
 	 */
-      .board_name =	&bondingBoards[0].name,
-      .offset =		sizeof(struct BondingBoard),
-      .num_names =	ARRAY_SIZE(bondingBoards),
+	.board_name = &bondingBoards[0].name,
+	.offset = sizeof(struct BondingBoard),
+	.num_names = ARRAY_SIZE(bondingBoards),
 };
 };
 
 
-static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+static int bonding_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);
-static int bonding_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-				   struct comedi_insn *insn, unsigned int *data);
+static int bonding_dio_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn,
+				   unsigned int *data);
 
 
 /*
 /*
  * Attach is called by the Comedi core to configure the driver
  * Attach is called by the Comedi core to configure the driver
@@ -224,7 +228,8 @@ static int bonding_dio_insn_config(struct comedi_device *dev, struct comedi_subd
  * in the driver structure, dev->board_ptr contains that
  * in the driver structure, dev->board_ptr contains that
  * address.
  * address.
  */
  */
-static int bonding_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int bonding_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 
 
@@ -293,7 +298,8 @@ static int bonding_detach(struct comedi_device *dev)
  * useful to applications if you implement the insn_bits interface.
  * useful to applications if you implement the insn_bits interface.
  * This allows packed reading/writing of the DIO channels.  The
  * This allows packed reading/writing of the DIO channels.  The
  * comedi core can convert between insn_bits and insn_read/write */
  * comedi core can convert between insn_bits and insn_read/write */
-static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+static int bonding_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)
 {
 {
 #define LSAMPL_BITS (sizeof(unsigned int)*8)
 #define LSAMPL_BITS (sizeof(unsigned int)*8)
@@ -317,14 +323,14 @@ static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
 
 
 		/* Argh, we have >= LSAMPL_BITS chans.. take all bits */
 		/* Argh, we have >= LSAMPL_BITS chans.. take all bits */
 		if (bdev->nchans >= LSAMPL_BITS)
 		if (bdev->nchans >= LSAMPL_BITS)
-			subdevMask = (unsigned int) (-1);
+			subdevMask = (unsigned int)(-1);
 
 
 		writeMask = (data[0] >> num_done) & subdevMask;
 		writeMask = (data[0] >> num_done) & subdevMask;
 		dataBits = (data[1] >> num_done) & subdevMask;
 		dataBits = (data[1] >> num_done) & subdevMask;
 
 
 		/* Read/Write the new digital lines */
 		/* Read/Write the new digital lines */
 		if (comedi_dio_bitfield(bdev->dev, bdev->subdev, writeMask,
 		if (comedi_dio_bitfield(bdev->dev, bdev->subdev, writeMask,
-				&dataBits) != 2)
+					&dataBits) != 2)
 			return -EINVAL;
 			return -EINVAL;
 
 
 		/* Make room for the new bits in data[1], the return value */
 		/* Make room for the new bits in data[1], the return value */
@@ -340,7 +346,8 @@ static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
 	return insn->n;
 	return insn->n;
 }
 }
 
 
-static int bonding_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+static int bonding_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)
 {
 {
 	int chan = CR_CHAN(insn->chanspec), ret, io_bits = s->io_bits;
 	int chan = CR_CHAN(insn->chanspec), ret, io_bits = s->io_bits;
@@ -366,7 +373,7 @@ static int bonding_dio_insn_config(struct comedi_device *dev, struct comedi_subd
 		break;
 		break;
 	case INSN_CONFIG_DIO_QUERY:
 	case INSN_CONFIG_DIO_QUERY:
 		data[1] =
 		data[1] =
-			(io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+		    (io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
 		return insn->n;
 		return insn->n;
 		break;
 		break;
 	default:
 	default:
@@ -435,7 +442,7 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it)
 
 
 		/* Do DIO, as that's all we support now.. */
 		/* Do DIO, as that's all we support now.. */
 		while ((sdev = comedi_find_subdevice_by_type(d, COMEDI_SUBD_DIO,
 		while ((sdev = comedi_find_subdevice_by_type(d, COMEDI_SUBD_DIO,
-					sdev + 1)) > -1) {
+							     sdev + 1)) > -1) {
 			nchans = comedi_get_n_channels(d, sdev);
 			nchans = comedi_get_n_channels(d, sdev);
 			if (nchans <= 0) {
 			if (nchans <= 0) {
 				ERROR("comedi_get_n_channels() returned %d "
 				ERROR("comedi_get_n_channels() returned %d "
@@ -465,8 +472,8 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it)
 			/* ergh.. ugly.. we need to realloc :(  */
 			/* ergh.. ugly.. we need to realloc :(  */
 			tmp = devpriv->ndevs * sizeof(bdev);
 			tmp = devpriv->ndevs * sizeof(bdev);
 			devpriv->devs =
 			devpriv->devs =
-				Realloc(devpriv->devs,
-				++devpriv->ndevs * sizeof(bdev), tmp);
+			    Realloc(devpriv->devs,
+				    ++devpriv->ndevs * sizeof(bdev), tmp);
 			if (!devpriv->devs) {
 			if (!devpriv->devs) {
 				ERROR("Could not allocate memory. "
 				ERROR("Could not allocate memory. "
 				      "Out of memory?");
 				      "Out of memory?");
@@ -478,10 +485,9 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it)
 	/** Append dev:subdev to devpriv->name */
 	/** Append dev:subdev to devpriv->name */
 				char buf[20];
 				char buf[20];
 				int left =
 				int left =
-					MAX_BOARD_NAME - strlen(devpriv->name) -
-					1;
+				    MAX_BOARD_NAME - strlen(devpriv->name) - 1;
 				snprintf(buf, sizeof(buf), "%d:%d ", dev->minor,
 				snprintf(buf, sizeof(buf), "%d:%d ", dev->minor,
-					bdev->subdev);
+					 bdev->subdev);
 				buf[sizeof(buf) - 1] = 0;
 				buf[sizeof(buf) - 1] = 0;
 				strncat(devpriv->name, buf, left);
 				strncat(devpriv->name, buf, left);
 			}
 			}

+ 9 - 5
drivers/staging/comedi/drivers/comedi_fc.c

@@ -42,8 +42,8 @@ static void increment_scan_progress(struct comedi_subdevice *subd,
 }
 }
 
 
 /* Writes an array of data points to comedi's buffer */
 /* Writes an array of data points to comedi's buffer */
-unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *subd, void *data,
-				       unsigned int num_bytes)
+unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *subd,
+				       void *data, unsigned int num_bytes)
 {
 {
 	struct comedi_async *async = subd->async;
 	struct comedi_async *async = subd->async;
 	unsigned int retval;
 	unsigned int retval;
@@ -65,10 +65,11 @@ unsigned int cfc_write_array_to_buffer(struct comedi_subdevice *subd, void *data
 
 
 	return num_bytes;
 	return num_bytes;
 }
 }
+
 EXPORT_SYMBOL(cfc_write_array_to_buffer);
 EXPORT_SYMBOL(cfc_write_array_to_buffer);
 
 
-unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *subd, void *data,
-					unsigned int num_bytes)
+unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *subd,
+					void *data, unsigned int num_bytes)
 {
 {
 	struct comedi_async *async = subd->async;
 	struct comedi_async *async = subd->async;
 
 
@@ -83,9 +84,11 @@ unsigned int cfc_read_array_from_buffer(struct comedi_subdevice *subd, void *dat
 
 
 	return num_bytes;
 	return num_bytes;
 }
 }
+
 EXPORT_SYMBOL(cfc_read_array_from_buffer);
 EXPORT_SYMBOL(cfc_read_array_from_buffer);
 
 
-unsigned int cfc_handle_events(struct comedi_device *dev, struct comedi_subdevice *subd)
+unsigned int cfc_handle_events(struct comedi_device *dev,
+			       struct comedi_subdevice *subd)
 {
 {
 	unsigned int events = subd->async->events;
 	unsigned int events = subd->async->events;
 
 
@@ -99,6 +102,7 @@ unsigned int cfc_handle_events(struct comedi_device *dev, struct comedi_subdevic
 
 
 	return events;
 	return events;
 }
 }
+
 EXPORT_SYMBOL(cfc_handle_events);
 EXPORT_SYMBOL(cfc_handle_events);
 
 
 MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>");
 MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>");

+ 2 - 2
drivers/staging/comedi/drivers/comedi_fc.h

@@ -40,8 +40,8 @@ static inline unsigned int cfc_write_to_buffer(struct comedi_subdevice *subd,
 	return cfc_write_array_to_buffer(subd, &data, sizeof(data));
 	return cfc_write_array_to_buffer(subd, &data, sizeof(data));
 };
 };
 
 
-static inline unsigned int cfc_write_long_to_buffer(struct comedi_subdevice *subd,
-						    unsigned int data)
+static inline unsigned int cfc_write_long_to_buffer(struct comedi_subdevice
+						    *subd, unsigned int data)
 {
 {
 	return cfc_write_array_to_buffer(subd, &data, sizeof(data));
 	return cfc_write_array_to_buffer(subd, &data, sizeof(data));
 };
 };

+ 18 - 11
drivers/staging/comedi/drivers/comedi_parport.c

@@ -91,13 +91,14 @@ pin, which can be used to wake up tasks.
 #define PARPORT_B 1
 #define PARPORT_B 1
 #define PARPORT_C 2
 #define PARPORT_C 2
 
 
-static int parport_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int parport_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int parport_detach(struct comedi_device *dev);
 static int parport_detach(struct comedi_device *dev);
 static struct comedi_driver driver_parport = {
 static struct comedi_driver driver_parport = {
-      .driver_name =	"comedi_parport",
-      .module =		THIS_MODULE,
-      .attach =		parport_attach,
-      .detach =		parport_detach,
+	.driver_name = "comedi_parport",
+	.module = THIS_MODULE,
+	.attach = parport_attach,
+	.detach = parport_detach,
 };
 };
 
 
 COMEDI_INITCLEANUP(driver_parport);
 COMEDI_INITCLEANUP(driver_parport);
@@ -124,7 +125,8 @@ static int parport_insn_a(struct comedi_device *dev, struct comedi_subdevice *s,
 	return 2;
 	return 2;
 }
 }
 
 
-static int parport_insn_config_a(struct comedi_device *dev, struct comedi_subdevice *s,
+static int parport_insn_config_a(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
 				 struct comedi_insn *insn, unsigned int *data)
 				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (data[0]) {
 	if (data[0]) {
@@ -168,7 +170,8 @@ static int parport_insn_c(struct comedi_device *dev, struct comedi_subdevice *s,
 	return 2;
 	return 2;
 }
 }
 
 
-static int parport_intr_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+static int parport_intr_insn(struct comedi_device *dev,
+			     struct comedi_subdevice *s,
 			     struct comedi_insn *insn, unsigned int *data)
 			     struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n < 1)
 	if (insn->n < 1)
@@ -178,7 +181,8 @@ static int parport_intr_insn(struct comedi_device *dev, struct comedi_subdevice
 	return 2;
 	return 2;
 }
 }
 
 
-static int parport_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+static int parport_intr_cmdtest(struct comedi_device *dev,
+				struct comedi_subdevice *s,
 				struct comedi_cmd *cmd)
 				struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
@@ -253,7 +257,8 @@ static int parport_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevi
 	return 0;
 	return 0;
 }
 }
 
 
-static int parport_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int parport_intr_cmd(struct comedi_device *dev,
+			    struct comedi_subdevice *s)
 {
 {
 	devpriv->c_data |= 0x10;
 	devpriv->c_data |= 0x10;
 	outb(devpriv->c_data, dev->iobase + PARPORT_C);
 	outb(devpriv->c_data, dev->iobase + PARPORT_C);
@@ -263,7 +268,8 @@ static int parport_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *
 	return 0;
 	return 0;
 }
 }
 
 
-static int parport_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int parport_intr_cancel(struct comedi_device *dev,
+			       struct comedi_subdevice *s)
 {
 {
 	printk(KERN_DEBUG "parport_intr_cancel()\n");
 	printk(KERN_DEBUG "parport_intr_cancel()\n");
 
 
@@ -292,7 +298,8 @@ static irqreturn_t parport_interrupt(int irq, void *d)
 	return IRQ_HANDLED;
 	return IRQ_HANDLED;
 }
 }
 
 
-static int parport_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int parport_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	int ret;
 	int ret;
 	unsigned int irq;
 	unsigned int irq;

+ 83 - 60
drivers/staging/comedi/drivers/comedi_test.c

@@ -69,11 +69,11 @@ struct waveform_board {
 
 
 static const struct waveform_board waveform_boards[] = {
 static const struct waveform_board waveform_boards[] = {
 	{
 	{
-		.name =		"comedi_test",
-		.ai_chans =	N_CHANS,
-		.ai_bits =	16,
-		.have_dio =	0,
-	},
+	 .name = "comedi_test",
+	 .ai_chans = N_CHANS,
+	 .ai_bits = 16,
+	 .have_dio = 0,
+	 },
 };
 };
 
 
 #define thisboard ((const struct waveform_board *)dev->board_ptr)
 #define thisboard ((const struct waveform_board *)dev->board_ptr)
@@ -84,7 +84,7 @@ struct waveform_private {
 	struct timeval last;	/* time at which last timer interrupt occured */
 	struct timeval last;	/* time at which last timer interrupt occured */
 	unsigned int uvolt_amplitude;	/* waveform amplitude in microvolts */
 	unsigned int uvolt_amplitude;	/* waveform amplitude in microvolts */
 	unsigned long usec_period;	/* waveform period in microseconds */
 	unsigned long usec_period;	/* waveform period in microseconds */
-	unsigned long usec_current; /* current time (modulo waveform period) */
+	unsigned long usec_current;	/* current time (modulo waveform period) */
 	unsigned long usec_remainder;	/* usec since last scan; */
 	unsigned long usec_remainder;	/* usec since last scan; */
 	unsigned long ai_count;	/* number of conversions remaining */
 	unsigned long ai_count;	/* number of conversions remaining */
 	unsigned int scan_period;	/* scan period in usec */
 	unsigned int scan_period;	/* scan period in usec */
@@ -94,36 +94,42 @@ struct waveform_private {
 };
 };
 #define devpriv ((struct waveform_private *)dev->private)
 #define devpriv ((struct waveform_private *)dev->private)
 
 
-static int waveform_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int waveform_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it);
 static int waveform_detach(struct comedi_device *dev);
 static int waveform_detach(struct comedi_device *dev);
 static struct comedi_driver driver_waveform = {
 static struct comedi_driver driver_waveform = {
-      .driver_name =	"comedi_test",
-      .module =		THIS_MODULE,
-      .attach =		waveform_attach,
-      .detach =		waveform_detach,
-      .board_name =	&waveform_boards[0].name,
-      .offset =		sizeof(struct waveform_board),
-      .num_names =	ARRAY_SIZE(waveform_boards),
+	.driver_name = "comedi_test",
+	.module = THIS_MODULE,
+	.attach = waveform_attach,
+	.detach = waveform_detach,
+	.board_name = &waveform_boards[0].name,
+	.offset = sizeof(struct waveform_board),
+	.num_names = ARRAY_SIZE(waveform_boards),
 };
 };
 
 
 COMEDI_INITCLEANUP(driver_waveform);
 COMEDI_INITCLEANUP(driver_waveform);
 
 
-static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_ai_cmdtest(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
 			       struct comedi_cmd *cmd);
 			       struct comedi_cmd *cmd);
-static int waveform_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int waveform_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-static int waveform_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_ai_cmd(struct comedi_device *dev,
+			   struct comedi_subdevice *s);
+static int waveform_ai_cancel(struct comedi_device *dev,
+			      struct comedi_subdevice *s);
+static int waveform_ai_insn_read(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
 				 struct comedi_insn *insn, unsigned int *data);
 				 struct comedi_insn *insn, unsigned int *data);
-static int waveform_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_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);
 static short fake_sawtooth(struct comedi_device *dev, unsigned int range,
 static short fake_sawtooth(struct comedi_device *dev, unsigned int range,
-			     unsigned long current_time);
+			   unsigned long current_time);
 static short fake_squarewave(struct comedi_device *dev, unsigned int range,
 static short fake_squarewave(struct comedi_device *dev, unsigned int range,
-			       unsigned long current_time);
-static short fake_flatline(struct comedi_device *dev, unsigned int range,
 			     unsigned long current_time);
 			     unsigned long current_time);
+static short fake_flatline(struct comedi_device *dev, unsigned int range,
+			   unsigned long current_time);
 static short fake_waveform(struct comedi_device *dev, unsigned int channel,
 static short fake_waveform(struct comedi_device *dev, unsigned int channel,
-			     unsigned int range, unsigned long current_time);
+			   unsigned int range, unsigned long current_time);
 
 
 /* 1000 nanosec in a microsec */
 /* 1000 nanosec in a microsec */
 static const int nano_per_micro = 1000;
 static const int nano_per_micro = 1000;
@@ -132,9 +138,9 @@ static const int nano_per_micro = 1000;
 static const struct comedi_lrange waveform_ai_ranges = {
 static const struct comedi_lrange waveform_ai_ranges = {
 	2,
 	2,
 	{
 	{
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-		}
+	 BIP_RANGE(10),
+	 BIP_RANGE(5),
+	 }
 };
 };
 
 
 /*
 /*
@@ -144,7 +150,7 @@ static const struct comedi_lrange waveform_ai_ranges = {
 */
 */
 static void waveform_ai_interrupt(unsigned long arg)
 static void waveform_ai_interrupt(unsigned long arg)
 {
 {
-	struct comedi_device *dev = (struct comedi_device *) arg;
+	struct comedi_device *dev = (struct comedi_device *)arg;
 	struct comedi_async *async = dev->read_subdev->async;
 	struct comedi_async *async = dev->read_subdev->async;
 	struct comedi_cmd *cmd = &async->cmd;
 	struct comedi_cmd *cmd = &async->cmd;
 	unsigned int i, j;
 	unsigned int i, j;
@@ -156,27 +162,34 @@ static void waveform_ai_interrupt(unsigned long arg)
 	do_gettimeofday(&now);
 	do_gettimeofday(&now);
 
 
 	elapsed_time =
 	elapsed_time =
-		1000000 * (now.tv_sec - devpriv->last.tv_sec) + now.tv_usec -
-		devpriv->last.tv_usec;
+	    1000000 * (now.tv_sec - devpriv->last.tv_sec) + now.tv_usec -
+	    devpriv->last.tv_usec;
 	devpriv->last = now;
 	devpriv->last = now;
 	num_scans =
 	num_scans =
-		(devpriv->usec_remainder + elapsed_time) / devpriv->scan_period;
+	    (devpriv->usec_remainder + elapsed_time) / devpriv->scan_period;
 	devpriv->usec_remainder =
 	devpriv->usec_remainder =
-		(devpriv->usec_remainder + elapsed_time) % devpriv->scan_period;
+	    (devpriv->usec_remainder + elapsed_time) % devpriv->scan_period;
 	async->events = 0;
 	async->events = 0;
 
 
 	for (i = 0; i < num_scans; i++) {
 	for (i = 0; i < num_scans; i++) {
 		for (j = 0; j < cmd->chanlist_len; j++) {
 		for (j = 0; j < cmd->chanlist_len; j++) {
 			cfc_write_to_buffer(dev->read_subdev,
 			cfc_write_to_buffer(dev->read_subdev,
-				fake_waveform(dev, CR_CHAN(cmd->chanlist[j]),
-					CR_RANGE(cmd->chanlist[j]),
-					devpriv->usec_current +
-					i * devpriv->scan_period +
-					j * devpriv->convert_period));
+					    fake_waveform(dev,
+							  CR_CHAN(cmd->
+								  chanlist[j]),
+							  CR_RANGE(cmd->
+								   chanlist[j]),
+							  devpriv->
+							  usec_current +
+							  i *
+							  devpriv->scan_period +
+							  j *
+							  devpriv->
+							  convert_period));
 		}
 		}
 		devpriv->ai_count++;
 		devpriv->ai_count++;
 		if (cmd->stop_src == TRIG_COUNT
 		if (cmd->stop_src == TRIG_COUNT
-			&& devpriv->ai_count >= cmd->stop_arg) {
+		    && devpriv->ai_count >= cmd->stop_arg) {
 			async->events |= COMEDI_CB_EOA;
 			async->events |= COMEDI_CB_EOA;
 			break;
 			break;
 		}
 		}
@@ -193,7 +206,8 @@ static void waveform_ai_interrupt(unsigned long arg)
 	comedi_event(dev, dev->read_subdev);
 	comedi_event(dev, dev->read_subdev);
 }
 }
 
 
-static int waveform_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int waveform_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int amplitude = it->options[0];
 	int amplitude = it->options[0];
@@ -255,8 +269,8 @@ static int waveform_attach(struct comedi_device *dev, struct comedi_devconfig *i
 	devpriv->timer.data = (unsigned long)dev;
 	devpriv->timer.data = (unsigned long)dev;
 
 
 	printk(KERN_INFO "comedi%d: comedi_test: "
 	printk(KERN_INFO "comedi%d: comedi_test: "
-		"%i microvolt, %li microsecond waveform attached\n", dev->minor,
-		devpriv->uvolt_amplitude, devpriv->usec_period);
+	       "%i microvolt, %li microsecond waveform attached\n", dev->minor,
+	       devpriv->uvolt_amplitude, devpriv->usec_period);
 	return 1;
 	return 1;
 }
 }
 
 
@@ -270,7 +284,8 @@ static int waveform_detach(struct comedi_device *dev)
 	return 0;
 	return 0;
 }
 }
 
 
-static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_ai_cmdtest(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
 			       struct comedi_cmd *cmd)
 			       struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
@@ -336,10 +351,10 @@ static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevic
 			err++;
 			err++;
 		}
 		}
 		if (cmd->convert_src == TRIG_TIMER &&
 		if (cmd->convert_src == TRIG_TIMER &&
-			cmd->scan_begin_arg <
-			cmd->convert_arg * cmd->chanlist_len) {
+		    cmd->scan_begin_arg <
+		    cmd->convert_arg * cmd->chanlist_len) {
 			cmd->scan_begin_arg =
 			cmd->scan_begin_arg =
-				cmd->convert_arg * cmd->chanlist_len;
+			    cmd->convert_arg * cmd->chanlist_len;
 			err++;
 			err++;
 		}
 		}
 	}
 	}
@@ -377,8 +392,8 @@ static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevic
 		tmp = cmd->scan_begin_arg;
 		tmp = cmd->scan_begin_arg;
 		/* round to nearest microsec */
 		/* round to nearest microsec */
 		cmd->scan_begin_arg =
 		cmd->scan_begin_arg =
-			nano_per_micro * ((tmp +
-				(nano_per_micro / 2)) / nano_per_micro);
+		    nano_per_micro * ((tmp +
+				       (nano_per_micro / 2)) / nano_per_micro);
 		if (tmp != cmd->scan_begin_arg)
 		if (tmp != cmd->scan_begin_arg)
 			err++;
 			err++;
 	}
 	}
@@ -386,8 +401,8 @@ static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevic
 		tmp = cmd->convert_arg;
 		tmp = cmd->convert_arg;
 		/* round to nearest microsec */
 		/* round to nearest microsec */
 		cmd->convert_arg =
 		cmd->convert_arg =
-			nano_per_micro * ((tmp +
-				(nano_per_micro / 2)) / nano_per_micro);
+		    nano_per_micro * ((tmp +
+				       (nano_per_micro / 2)) / nano_per_micro);
 		if (tmp != cmd->convert_arg)
 		if (tmp != cmd->convert_arg)
 			err++;
 			err++;
 	}
 	}
@@ -398,13 +413,14 @@ static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevic
 	return 0;
 	return 0;
 }
 }
 
 
-static int waveform_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int waveform_ai_cmd(struct comedi_device *dev,
+			   struct comedi_subdevice *s)
 {
 {
 	struct comedi_cmd *cmd = &s->async->cmd;
 	struct comedi_cmd *cmd = &s->async->cmd;
 
 
 	if (cmd->flags & TRIG_RT) {
 	if (cmd->flags & TRIG_RT) {
 		comedi_error(dev,
 		comedi_error(dev,
-			"commands at RT priority not supported in this driver");
+			     "commands at RT priority not supported in this driver");
 		return -1;
 		return -1;
 	}
 	}
 
 
@@ -430,7 +446,8 @@ static int waveform_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s
 	return 0;
 	return 0;
 }
 }
 
 
-static int waveform_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int waveform_ai_cancel(struct comedi_device *dev,
+			      struct comedi_subdevice *s)
 {
 {
 	devpriv->timer_running = 0;
 	devpriv->timer_running = 0;
 	del_timer(&devpriv->timer);
 	del_timer(&devpriv->timer);
@@ -438,12 +455,13 @@ static int waveform_ai_cancel(struct comedi_device *dev, struct comedi_subdevice
 }
 }
 
 
 static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index,
 static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index,
-			     unsigned long current_time)
+			   unsigned long current_time)
 {
 {
 	struct comedi_subdevice *s = dev->read_subdev;
 	struct comedi_subdevice *s = dev->read_subdev;
 	unsigned int offset = s->maxdata / 2;
 	unsigned int offset = s->maxdata / 2;
 	u64 value;
 	u64 value;
-	const struct comedi_krange *krange = &s->range_table->range[range_index];
+	const struct comedi_krange *krange =
+	    &s->range_table->range[range_index];
 	u64 binary_amplitude;
 	u64 binary_amplitude;
 
 
 	binary_amplitude = s->maxdata;
 	binary_amplitude = s->maxdata;
@@ -458,13 +476,16 @@ static short fake_sawtooth(struct comedi_device *dev, unsigned int range_index,
 
 
 	return offset + value;
 	return offset + value;
 }
 }
-static short fake_squarewave(struct comedi_device *dev, unsigned int range_index,
-			       unsigned long current_time)
+
+static short fake_squarewave(struct comedi_device *dev,
+			     unsigned int range_index,
+			     unsigned long current_time)
 {
 {
 	struct comedi_subdevice *s = dev->read_subdev;
 	struct comedi_subdevice *s = dev->read_subdev;
 	unsigned int offset = s->maxdata / 2;
 	unsigned int offset = s->maxdata / 2;
 	u64 value;
 	u64 value;
-	const struct comedi_krange *krange = &s->range_table->range[range_index];
+	const struct comedi_krange *krange =
+	    &s->range_table->range[range_index];
 	current_time %= devpriv->usec_period;
 	current_time %= devpriv->usec_period;
 
 
 	value = s->maxdata;
 	value = s->maxdata;
@@ -478,14 +499,14 @@ static short fake_squarewave(struct comedi_device *dev, unsigned int range_index
 }
 }
 
 
 static short fake_flatline(struct comedi_device *dev, unsigned int range_index,
 static short fake_flatline(struct comedi_device *dev, unsigned int range_index,
-			     unsigned long current_time)
+			   unsigned long current_time)
 {
 {
 	return dev->read_subdev->maxdata / 2;
 	return dev->read_subdev->maxdata / 2;
 }
 }
 
 
 /* generates a different waveform depending on what channel is read */
 /* generates a different waveform depending on what channel is read */
 static short fake_waveform(struct comedi_device *dev, unsigned int channel,
 static short fake_waveform(struct comedi_device *dev, unsigned int channel,
-			     unsigned int range, unsigned long current_time)
+			   unsigned int range, unsigned long current_time)
 {
 {
 	enum {
 	enum {
 		SAWTOOTH_CHAN,
 		SAWTOOTH_CHAN,
@@ -505,7 +526,8 @@ static short fake_waveform(struct comedi_device *dev, unsigned int channel,
 	return fake_flatline(dev, range, current_time);
 	return fake_flatline(dev, range, current_time);
 }
 }
 
 
-static int waveform_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_ai_insn_read(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
 				 struct comedi_insn *insn, unsigned int *data)
 				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i, chan = CR_CHAN(insn->chanspec);
 	int i, chan = CR_CHAN(insn->chanspec);
@@ -516,7 +538,8 @@ static int waveform_ai_insn_read(struct comedi_device *dev, struct comedi_subdev
 	return insn->n;
 	return insn->n;
 }
 }
 
 
-static int waveform_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+static int waveform_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)
 {
 {
 	int i, chan = CR_CHAN(insn->chanspec);
 	int i, chan = CR_CHAN(insn->chanspec);

+ 27 - 21
drivers/staging/comedi/drivers/contec_pci_dio.c

@@ -57,9 +57,10 @@ static const struct contec_board contec_boards[] = {
 
 
 #define PCI_DEVICE_ID_PIO1616L 0x8172
 #define PCI_DEVICE_ID_PIO1616L 0x8172
 static DEFINE_PCI_DEVICE_TABLE(contec_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(contec_pci_table) = {
-	{PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L, PCI_ANY_ID, PCI_ANY_ID,
-		0, 0, PIO1616L},
-	{0}
+	{
+	PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L, PCI_ANY_ID,
+		    PCI_ANY_ID, 0, 0, PIO1616L}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, contec_pci_table);
 MODULE_DEVICE_TABLE(pci, contec_pci_table);
@@ -75,7 +76,8 @@ struct contec_private {
 
 
 #define devpriv ((struct contec_private *)dev->private)
 #define devpriv ((struct contec_private *)dev->private)
 
 
-static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int contec_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int contec_detach(struct comedi_device *dev);
 static int contec_detach(struct comedi_device *dev);
 static struct comedi_driver driver_contec = {
 static struct comedi_driver driver_contec = {
 	.driver_name = "contec_pci_dio",
 	.driver_name = "contec_pci_dio",
@@ -85,14 +87,16 @@ static struct comedi_driver driver_contec = {
 };
 };
 
 
 /* Classic digital IO */
 /* Classic digital IO */
-static int contec_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int contec_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int contec_di_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
+static int contec_do_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
 
 
 #if 0
 #if 0
 static int contec_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 static int contec_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd);
+			  struct comedi_cmd *cmd);
 
 
 static int contec_ns_to_timer(unsigned int *ns, int round);
 static int contec_ns_to_timer(unsigned int *ns, int round);
 #endif
 #endif
@@ -113,22 +117,22 @@ static int contec_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		return -ENOMEM;
 		return -ENOMEM;
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 
 
 		if (pcidev->vendor == PCI_VENDOR_ID_CONTEC &&
 		if (pcidev->vendor == PCI_VENDOR_ID_CONTEC &&
-			pcidev->device == PCI_DEVICE_ID_PIO1616L) {
+		    pcidev->device == PCI_DEVICE_ID_PIO1616L) {
 			if (it->options[0] || it->options[1]) {
 			if (it->options[0] || it->options[1]) {
 				/* Check bus and slot. */
 				/* Check bus and slot. */
 				if (it->options[0] != pcidev->bus->number ||
 				if (it->options[0] != pcidev->bus->number ||
-					it->options[1] !=
-					PCI_SLOT(pcidev->devfn)) {
+				    it->options[1] != PCI_SLOT(pcidev->devfn)) {
 					continue;
 					continue;
 				}
 				}
 			}
 			}
 			devpriv->pci_dev = pcidev;
 			devpriv->pci_dev = pcidev;
 			if (comedi_pci_enable(pcidev, "contec_pci_dio")) {
 			if (comedi_pci_enable(pcidev, "contec_pci_dio")) {
-				printk("error enabling PCI device and request regions!\n");
+				printk
+				    ("error enabling PCI device and request regions!\n");
 				return -EIO;
 				return -EIO;
 			}
 			}
 			dev->iobase = pci_resource_start(pcidev, 0);
 			dev->iobase = pci_resource_start(pcidev, 0);
@@ -180,7 +184,7 @@ static int contec_detach(struct comedi_device *dev)
 
 
 #if 0
 #if 0
 static int contec_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
 static int contec_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+			  struct comedi_cmd *cmd)
 {
 {
 	printk("contec_cmdtest called\n");
 	printk("contec_cmdtest called\n");
 	return 0;
 	return 0;
@@ -192,8 +196,9 @@ static int contec_ns_to_timer(unsigned int *ns, int round)
 }
 }
 #endif
 #endif
 
 
-static int contec_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int contec_do_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 
 
 	printk("contec_do_insn_bits called\n");
 	printk("contec_do_insn_bits called\n");
@@ -206,14 +211,15 @@ static int contec_do_insn_bits(struct comedi_device *dev, struct comedi_subdevic
 		s->state &= ~data[0];
 		s->state &= ~data[0];
 		s->state |= data[0] & data[1];
 		s->state |= data[0] & data[1];
 		printk("  out: %d on %lx\n", s->state,
 		printk("  out: %d on %lx\n", s->state,
-			dev->iobase + thisboard->out_offs);
+		       dev->iobase + thisboard->out_offs);
 		outw(s->state, dev->iobase + thisboard->out_offs);
 		outw(s->state, dev->iobase + thisboard->out_offs);
 	}
 	}
 	return 2;
 	return 2;
 }
 }
 
 
-static int contec_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int contec_di_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 
 
 	printk("contec_di_insn_bits called\n");
 	printk("contec_di_insn_bits called\n");

+ 65 - 54
drivers/staging/comedi/drivers/daqboard2000.c

@@ -107,13 +107,10 @@ Configuration options:
 		  |    	   +---------------- Unipolar
 		  |    	   +---------------- Unipolar
 		  +------------------------- Correction gain high
 		  +------------------------- Correction gain high
 
 
-
-
    999. The card seems to have an incredible amount of capabilities, but
    999. The card seems to have an incredible amount of capabilities, but
         trying to reverse engineer them from the Windows source is beyond my
         trying to reverse engineer them from the Windows source is beyond my
 	patience.
 	patience.
 
 
-
  */
  */
 
 
 #include "../comedidev.h"
 #include "../comedidev.h"
@@ -147,25 +144,32 @@ Configuration options:
 
 
 /* Available ranges */
 /* Available ranges */
 static const struct comedi_lrange range_daqboard2000_ai = { 13, {
 static const struct comedi_lrange range_daqboard2000_ai = { 13, {
-			RANGE(-10, 10),
-			RANGE(-5, 5),
-			RANGE(-2.5, 2.5),
-			RANGE(-1.25, 1.25),
-			RANGE(-0.625, 0.625),
-			RANGE(-0.3125, 0.3125),
-			RANGE(-0.156, 0.156),
-			RANGE(0, 10),
-			RANGE(0, 5),
-			RANGE(0, 2.5),
-			RANGE(0, 1.25),
-			RANGE(0, 0.625),
-			RANGE(0, 0.3125)
-	}
+								 RANGE(-10, 10),
+								 RANGE(-5, 5),
+								 RANGE(-2.5,
+								       2.5),
+								 RANGE(-1.25,
+								       1.25),
+								 RANGE(-0.625,
+								       0.625),
+								 RANGE(-0.3125,
+								       0.3125),
+								 RANGE(-0.156,
+								       0.156),
+								 RANGE(0, 10),
+								 RANGE(0, 5),
+								 RANGE(0, 2.5),
+								 RANGE(0, 1.25),
+								 RANGE(0,
+								       0.625),
+								 RANGE(0,
+								       0.3125)
+								 }
 };
 };
 
 
 static const struct comedi_lrange range_daqboard2000_ao = { 1, {
 static const struct comedi_lrange range_daqboard2000_ao = { 1, {
-			RANGE(-10, 10)
-	}
+								RANGE(-10, 10)
+								}
 };
 };
 
 
 struct daqboard2000_hw {
 struct daqboard2000_hw {
@@ -297,7 +301,8 @@ struct daqboard2000_hw {
 #define DAQBOARD2000_PosRefDacSelect             0x0100
 #define DAQBOARD2000_PosRefDacSelect             0x0100
 #define DAQBOARD2000_NegRefDacSelect             0x0000
 #define DAQBOARD2000_NegRefDacSelect             0x0000
 
 
-static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int daqboard2000_attach(struct comedi_device *dev,
+			       struct comedi_devconfig *it);
 static int daqboard2000_detach(struct comedi_device *dev);
 static int daqboard2000_detach(struct comedi_device *dev);
 
 
 static struct comedi_driver driver_daqboard2000 = {
 static struct comedi_driver driver_daqboard2000 = {
@@ -320,8 +325,9 @@ static const struct daq200_boardtype boardtypes[] = {
 #define this_board ((const struct daq200_boardtype *)dev->board_ptr)
 #define this_board ((const struct daq200_boardtype *)dev->board_ptr)
 
 
 static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(daqboard2000_pci_table) = {
-	{0x1616, 0x0409, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	0x1616, 0x0409, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, daqboard2000_pci_table);
 MODULE_DEVICE_TABLE(pci, daqboard2000_pci_table);
@@ -394,17 +400,18 @@ static void setup_sampling(struct comedi_device *dev, int chan, int gain)
 	writeAcqScanListEntry(dev, word3);
 	writeAcqScanListEntry(dev, word3);
 }
 }
 
 
-static int daqboard2000_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int daqboard2000_ai_insn_read(struct comedi_device *dev,
+				     struct comedi_subdevice *s,
+				     struct comedi_insn *insn,
+				     unsigned int *data)
 {
 {
 	int i;
 	int i;
 	struct daqboard2000_hw *fpga = devpriv->daq;
 	struct daqboard2000_hw *fpga = devpriv->daq;
 	int gain, chan, timeout;
 	int gain, chan, timeout;
 
 
 	fpga->acqControl =
 	fpga->acqControl =
-		DAQBOARD2000_AcqResetScanListFifo |
-		DAQBOARD2000_AcqResetResultsFifo |
-		DAQBOARD2000_AcqResetConfigPipe;
+	    DAQBOARD2000_AcqResetScanListFifo |
+	    DAQBOARD2000_AcqResetResultsFifo | DAQBOARD2000_AcqResetConfigPipe;
 
 
 	/* If pacer clock is not set to some high value (> 10 us), we
 	/* If pacer clock is not set to some high value (> 10 us), we
 	   risk multiple samples to be put into the result FIFO. */
 	   risk multiple samples to be put into the result FIFO. */
@@ -436,9 +443,8 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, struct comedi_su
 			/* udelay(2); */
 			/* udelay(2); */
 		}
 		}
 		for (timeout = 0; timeout < 20; timeout++) {
 		for (timeout = 0; timeout < 20; timeout++) {
-			if (fpga->
-				acqControl &
-				DAQBOARD2000_AcqResultsFIFOHasValidData) {
+			if (fpga->acqControl &
+			    DAQBOARD2000_AcqResultsFIFOHasValidData) {
 				break;
 				break;
 			}
 			}
 			/* udelay(2); */
 			/* udelay(2); */
@@ -451,8 +457,10 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, struct comedi_su
 	return i;
 	return i;
 }
 }
 
 
-static int daqboard2000_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int daqboard2000_ao_insn_read(struct comedi_device *dev,
+				     struct comedi_subdevice *s,
+				     struct comedi_insn *insn,
+				     unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -464,8 +472,10 @@ static int daqboard2000_ao_insn_read(struct comedi_device *dev, struct comedi_su
 	return i;
 	return i;
 }
 }
 
 
-static int daqboard2000_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int daqboard2000_ao_insn_write(struct comedi_device *dev,
+				      struct comedi_subdevice *s,
+				      struct comedi_insn *insn,
+				      unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -521,7 +531,7 @@ static void daqboard2000_pulseProgPin(struct comedi_device *dev)
 	writel(DAQBOARD2000_SECRProgPinHi, devpriv->plx + 0x6c);
 	writel(DAQBOARD2000_SECRProgPinHi, devpriv->plx + 0x6c);
 	udelay(10000);
 	udelay(10000);
 	writel(DAQBOARD2000_SECRProgPinLo, devpriv->plx + 0x6c);
 	writel(DAQBOARD2000_SECRProgPinLo, devpriv->plx + 0x6c);
-	udelay(10000);	/* Not in the original code, but I like symmetry... */
+	udelay(10000);		/* Not in the original code, but I like symmetry... */
 }
 }
 
 
 static int daqboard2000_pollCPLD(struct comedi_device *dev, int mask)
 static int daqboard2000_pollCPLD(struct comedi_device *dev, int mask)
@@ -550,14 +560,14 @@ static int daqboard2000_writeCPLD(struct comedi_device *dev, int data)
 	udelay(10);
 	udelay(10);
 	writew(data, devpriv->daq + 0x1000);
 	writew(data, devpriv->daq + 0x1000);
 	if ((readw(devpriv->daq + 0x1000) & DAQBOARD2000_CPLD_INIT) ==
 	if ((readw(devpriv->daq + 0x1000) & DAQBOARD2000_CPLD_INIT) ==
-		DAQBOARD2000_CPLD_INIT) {
+	    DAQBOARD2000_CPLD_INIT) {
 		result = 1;
 		result = 1;
 	}
 	}
 	return result;
 	return result;
 }
 }
 
 
 static int initialize_daqboard2000(struct comedi_device *dev,
 static int initialize_daqboard2000(struct comedi_device *dev,
-	unsigned char *cpld_array, int len)
+				   unsigned char *cpld_array, int len)
 {
 {
 	int result = -EIO;
 	int result = -EIO;
 	/* Read the serial EEPROM control register */
 	/* Read the serial EEPROM control register */
@@ -585,7 +595,7 @@ static int initialize_daqboard2000(struct comedi_device *dev,
 		if (daqboard2000_pollCPLD(dev, DAQBOARD2000_CPLD_INIT)) {
 		if (daqboard2000_pollCPLD(dev, DAQBOARD2000_CPLD_INIT)) {
 			for (i = 0; i < len; i++) {
 			for (i = 0; i < len; i++) {
 				if (cpld_array[i] == 0xff
 				if (cpld_array[i] == 0xff
-					&& cpld_array[i + 1] == 0x20) {
+				    && cpld_array[i + 1] == 0x20) {
 #ifdef DEBUG_EEPROM
 #ifdef DEBUG_EEPROM
 					printk("Preamble found at %d\n", i);
 					printk("Preamble found at %d\n", i);
 #endif
 #endif
@@ -594,8 +604,7 @@ static int initialize_daqboard2000(struct comedi_device *dev,
 			}
 			}
 			for (; i < len; i += 2) {
 			for (; i < len; i += 2) {
 				int data =
 				int data =
-					(cpld_array[i] << 8) + cpld_array[i +
-					1];
+				    (cpld_array[i] << 8) + cpld_array[i + 1];
 				if (!daqboard2000_writeCPLD(dev, data)) {
 				if (!daqboard2000_writeCPLD(dev, data)) {
 					break;
 					break;
 				}
 				}
@@ -702,7 +711,7 @@ rmmod daqboard2000 ; rmmod comedi; make install ; modprobe daqboard2000; /usr/sb
 */
 */
 
 
 static int daqboard2000_8255_cb(int dir, int port, int data,
 static int daqboard2000_8255_cb(int dir, int port, int data,
-	unsigned long ioaddr)
+				unsigned long ioaddr)
 {
 {
 	int result = 0;
 	int result = 0;
 	if (dir) {
 	if (dir) {
@@ -718,7 +727,8 @@ static int daqboard2000_8255_cb(int dir, int port, int data,
 	return result;
 	return result;
 }
 }
 
 
-static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int daqboard2000_attach(struct comedi_device *dev,
+			       struct comedi_devconfig *it)
 {
 {
 	int result = 0;
 	int result = 0;
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
@@ -737,21 +747,20 @@ static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfi
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 	for (card = pci_get_device(0x1616, 0x0409, NULL);
 	for (card = pci_get_device(0x1616, 0x0409, NULL);
-		card != NULL;
-		card = pci_get_device(0x1616, 0x0409, card)) {
+	     card != NULL; card = pci_get_device(0x1616, 0x0409, card)) {
 		if (bus || slot) {
 		if (bus || slot) {
 			/* requested particular bus/slot */
 			/* requested particular bus/slot */
 			if (card->bus->number != bus ||
 			if (card->bus->number != bus ||
-				PCI_SLOT(card->devfn) != slot) {
+			    PCI_SLOT(card->devfn) != slot) {
 				continue;
 				continue;
 			}
 			}
 		}
 		}
-		break;  /* found one */
+		break;		/* found one */
 	}
 	}
 	if (!card) {
 	if (!card) {
 		if (bus || slot)
 		if (bus || slot)
 			printk(" no daqboard2000 found at bus/slot: %d/%d\n",
 			printk(" no daqboard2000 found at bus/slot: %d/%d\n",
-				bus, slot);
+			       bus, slot);
 		else
 		else
 			printk(" no daqboard2000 found\n");
 			printk(" no daqboard2000 found\n");
 		return -EIO;
 		return -EIO;
@@ -759,8 +768,8 @@ static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfi
 		u32 id;
 		u32 id;
 		int i;
 		int i;
 		devpriv->pci_dev = card;
 		devpriv->pci_dev = card;
-		id = ((u32) card->subsystem_device << 16) | card->
-			subsystem_vendor;
+		id = ((u32) card->
+		      subsystem_device << 16) | card->subsystem_vendor;
 		for (i = 0; i < n_boardtypes; i++) {
 		for (i = 0; i < n_boardtypes; i++) {
 			if (boardtypes[i].id == id) {
 			if (boardtypes[i].id == id) {
 				printk(" %s", boardtypes[i].name);
 				printk(" %s", boardtypes[i].name);
@@ -768,7 +777,9 @@ static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfi
 			}
 			}
 		}
 		}
 		if (!dev->board_ptr) {
 		if (!dev->board_ptr) {
-			printk(" unknown subsystem id %08x (pretend it is an ids2)", id);
+			printk
+			    (" unknown subsystem id %08x (pretend it is an ids2)",
+			     id);
 			dev->board_ptr = boardtypes;
 			dev->board_ptr = boardtypes;
 		}
 		}
 	}
 	}
@@ -780,9 +791,9 @@ static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfi
 	}
 	}
 	devpriv->got_regions = 1;
 	devpriv->got_regions = 1;
 	devpriv->plx =
 	devpriv->plx =
-		ioremap(pci_resource_start(card, 0), DAQBOARD2000_PLX_SIZE);
+	    ioremap(pci_resource_start(card, 0), DAQBOARD2000_PLX_SIZE);
 	devpriv->daq =
 	devpriv->daq =
-		ioremap(pci_resource_start(card, 2), DAQBOARD2000_DAQ_SIZE);
+	    ioremap(pci_resource_start(card, 2), DAQBOARD2000_DAQ_SIZE);
 	if (!devpriv->plx || !devpriv->daq) {
 	if (!devpriv->plx || !devpriv->daq) {
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
@@ -844,10 +855,10 @@ static int daqboard2000_attach(struct comedi_device *dev, struct comedi_devconfi
 
 
 	s = dev->subdevices + 2;
 	s = dev->subdevices + 2;
 	result = subdev_8255_init(dev, s, daqboard2000_8255_cb,
 	result = subdev_8255_init(dev, s, daqboard2000_8255_cb,
-		(unsigned long)(dev->iobase + 0x40));
+				  (unsigned long)(dev->iobase + 0x40));
 
 
 	printk("\n");
 	printk("\n");
-      out:
+out:
 	return result;
 	return result;
 }
 }
 
 

+ 318 - 304
drivers/staging/comedi/drivers/das08.c

@@ -155,60 +155,66 @@ driver.
 /* gainlist same as _pgx_ below */
 /* gainlist same as _pgx_ below */
 
 
 static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+			  struct comedi_insn *insn, unsigned int *data);
 static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
 static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+			  struct comedi_insn *insn, unsigned int *data);
 static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
 static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das08jr_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das08jr_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das08jr_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das08ao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+			  struct comedi_insn *insn, unsigned int *data);
+static int das08jr_di_rbits(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int das08jr_do_wbits(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int das08jr_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int das08ao_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
 static void i8254_set_mode_low(unsigned int base, int channel,
 static void i8254_set_mode_low(unsigned int base, int channel,
-	unsigned int mode);
+			       unsigned int mode);
 
 
 static const struct comedi_lrange range_das08_pgl = { 9, {
 static const struct comedi_lrange range_das08_pgl = { 9, {
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-			BIP_RANGE(2.5),
-			BIP_RANGE(1.25),
-			BIP_RANGE(0.625),
-			UNI_RANGE(10),
-			UNI_RANGE(5),
-			UNI_RANGE(2.5),
-			UNI_RANGE(1.25)
-	}
+							  BIP_RANGE(10),
+							  BIP_RANGE(5),
+							  BIP_RANGE(2.5),
+							  BIP_RANGE(1.25),
+							  BIP_RANGE(0.625),
+							  UNI_RANGE(10),
+							  UNI_RANGE(5),
+							  UNI_RANGE(2.5),
+							  UNI_RANGE(1.25)
+							  }
 };
 };
+
 static const struct comedi_lrange range_das08_pgh = { 12, {
 static const struct comedi_lrange range_das08_pgh = { 12, {
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-			BIP_RANGE(1),
-			BIP_RANGE(0.5),
-			BIP_RANGE(0.1),
-			BIP_RANGE(0.05),
-			BIP_RANGE(0.01),
-			BIP_RANGE(0.005),
-			UNI_RANGE(10),
-			UNI_RANGE(1),
-			UNI_RANGE(0.1),
-			UNI_RANGE(0.01),
-	}
+							   BIP_RANGE(10),
+							   BIP_RANGE(5),
+							   BIP_RANGE(1),
+							   BIP_RANGE(0.5),
+							   BIP_RANGE(0.1),
+							   BIP_RANGE(0.05),
+							   BIP_RANGE(0.01),
+							   BIP_RANGE(0.005),
+							   UNI_RANGE(10),
+							   UNI_RANGE(1),
+							   UNI_RANGE(0.1),
+							   UNI_RANGE(0.01),
+							   }
 };
 };
+
 static const struct comedi_lrange range_das08_pgm = { 9, {
 static const struct comedi_lrange range_das08_pgm = { 9, {
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-			BIP_RANGE(0.5),
-			BIP_RANGE(0.05),
-			BIP_RANGE(0.01),
-			UNI_RANGE(10),
-			UNI_RANGE(1),
-			UNI_RANGE(0.1),
-			UNI_RANGE(0.01)
-	}
+							  BIP_RANGE(10),
+							  BIP_RANGE(5),
+							  BIP_RANGE(0.5),
+							  BIP_RANGE(0.05),
+							  BIP_RANGE(0.01),
+							  UNI_RANGE(10),
+							  UNI_RANGE(1),
+							  UNI_RANGE(0.1),
+							  UNI_RANGE(0.01)
+							  }
 };				/*
 };				/*
 				   cio-das08jr.pdf
 				   cio-das08jr.pdf
 
 
@@ -234,7 +240,7 @@ static const struct comedi_lrange *const das08_ai_lranges[] = {
 };
 };
 
 
 static const int das08_pgh_gainlist[] =
 static const int das08_pgh_gainlist[] =
-	{ 8, 0, 10, 2, 12, 4, 14, 6, 1, 3, 5, 7 };
+    { 8, 0, 10, 2, 12, 4, 14, 6, 1, 3, 5, 7 };
 static const int das08_pgl_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 };
 static const int das08_pgl_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 };
 static const int das08_pgm_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 };
 static const int das08_pgm_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 };
 
 
@@ -248,260 +254,261 @@ static const int *const das08_gainlists[] = {
 
 
 static const struct das08_board_struct das08_boards[] = {
 static const struct das08_board_struct das08_boards[] = {
 	{
 	{
-	.name = "isa-das08",	/*  cio-das08.pdf */
-	.bustype = isa,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_pg_none,
-	.ai_encoding = das08_encode12,
-	.ao = NULL,
-	.ao_nbits = 12,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 4,
-	.i8255_offset = 8,
-	.i8254_offset = 4,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "isa-das08",	/*  cio-das08.pdf */
+	 .bustype = isa,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_pg_none,
+	 .ai_encoding = das08_encode12,
+	 .ao = NULL,
+	 .ao_nbits = 12,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 4,
+	 .i8255_offset = 8,
+	 .i8254_offset = 4,
+	 .iosize = 16,		/*  unchecked */
+	 },
 	{
 	{
-	.name = "das08-pgm",	/*  cio-das08pgx.pdf */
-	.bustype = isa,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_pgm,
-	.ai_encoding = das08_encode12,
-	.ao = NULL,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 4,
-	.i8255_offset = 0,
-	.i8254_offset = 0x04,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "das08-pgm",	/*  cio-das08pgx.pdf */
+	 .bustype = isa,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_pgm,
+	 .ai_encoding = das08_encode12,
+	 .ao = NULL,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 4,
+	 .i8255_offset = 0,
+	 .i8254_offset = 0x04,
+	 .iosize = 16,		/*  unchecked */
+	 },
 	{
 	{
-	.name = "das08-pgh",	/*  cio-das08pgx.pdf */
-	.bustype = isa,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_pgh,
-	.ai_encoding = das08_encode12,
-	.ao = NULL,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 4,
-	.i8255_offset = 0,
-	.i8254_offset = 0x04,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "das08-pgh",	/*  cio-das08pgx.pdf */
+	 .bustype = isa,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_pgh,
+	 .ai_encoding = das08_encode12,
+	 .ao = NULL,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 4,
+	 .i8255_offset = 0,
+	 .i8254_offset = 0x04,
+	 .iosize = 16,		/*  unchecked */
+	 },
 	{
 	{
-	.name = "das08-pgl",	/*  cio-das08pgx.pdf */
-	.bustype = isa,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_pgl,
-	.ai_encoding = das08_encode12,
-	.ao = NULL,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 4,
-	.i8255_offset = 0,
-	.i8254_offset = 0x04,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "das08-pgl",	/*  cio-das08pgx.pdf */
+	 .bustype = isa,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_pgl,
+	 .ai_encoding = das08_encode12,
+	 .ao = NULL,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 4,
+	 .i8255_offset = 0,
+	 .i8254_offset = 0x04,
+	 .iosize = 16,		/*  unchecked */
+	 },
 	{
 	{
-	.name = "das08-aoh",	/*  cio-das08_aox.pdf */
-	.bustype = isa,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_pgh,
-	.ai_encoding = das08_encode12,
-	.ao = das08ao_ao_winsn,	/*  8 */
-	.ao_nbits = 12,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 4,
-	.i8255_offset = 0x0c,
-	.i8254_offset = 0x04,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "das08-aoh",	/*  cio-das08_aox.pdf */
+	 .bustype = isa,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_pgh,
+	 .ai_encoding = das08_encode12,
+	 .ao = das08ao_ao_winsn,	/*  8 */
+	 .ao_nbits = 12,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 4,
+	 .i8255_offset = 0x0c,
+	 .i8254_offset = 0x04,
+	 .iosize = 16,		/*  unchecked */
+	 },
 	{
 	{
-	.name = "das08-aol",	/*  cio-das08_aox.pdf */
-	.bustype = isa,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_pgl,
-	.ai_encoding = das08_encode12,
-	.ao = das08ao_ao_winsn,	/*  8 */
-	.ao_nbits = 12,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 4,
-	.i8255_offset = 0x0c,
-	.i8254_offset = 0x04,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "das08-aol",	/*  cio-das08_aox.pdf */
+	 .bustype = isa,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_pgl,
+	 .ai_encoding = das08_encode12,
+	 .ao = das08ao_ao_winsn,	/*  8 */
+	 .ao_nbits = 12,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 4,
+	 .i8255_offset = 0x0c,
+	 .i8254_offset = 0x04,
+	 .iosize = 16,		/*  unchecked */
+	 },
 	{
 	{
-	.name = "das08-aom",	/*  cio-das08_aox.pdf */
-	.bustype = isa,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_pgm,
-	.ai_encoding = das08_encode12,
-	.ao = das08ao_ao_winsn,	/*  8 */
-	.ao_nbits = 12,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 4,
-	.i8255_offset = 0x0c,
-	.i8254_offset = 0x04,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "das08-aom",	/*  cio-das08_aox.pdf */
+	 .bustype = isa,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_pgm,
+	 .ai_encoding = das08_encode12,
+	 .ao = das08ao_ao_winsn,	/*  8 */
+	 .ao_nbits = 12,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 4,
+	 .i8255_offset = 0x0c,
+	 .i8254_offset = 0x04,
+	 .iosize = 16,		/*  unchecked */
+	 },
 	{
 	{
-	.name = "das08/jr-ao",	/*  cio-das08-jr-ao.pdf */
-	.bustype = isa,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_pg_none,
-	.ai_encoding = das08_encode12,
-	.ao = das08jr_ao_winsn,
-	.ao_nbits = 12,
-	.di = das08jr_di_rbits,
-	.do_ = das08jr_do_wbits,
-	.do_nchan = 8,
-	.i8255_offset = 0,
-	.i8254_offset = 0,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "das08/jr-ao",	/*  cio-das08-jr-ao.pdf */
+	 .bustype = isa,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_pg_none,
+	 .ai_encoding = das08_encode12,
+	 .ao = das08jr_ao_winsn,
+	 .ao_nbits = 12,
+	 .di = das08jr_di_rbits,
+	 .do_ = das08jr_do_wbits,
+	 .do_nchan = 8,
+	 .i8255_offset = 0,
+	 .i8254_offset = 0,
+	 .iosize = 16,		/*  unchecked */
+	 },
 	{
 	{
-	.name = "das08jr-16-ao",	/*  cio-das08jr-16-ao.pdf */
-	.bustype = isa,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 16,
-	.ai_pg = das08_pg_none,
-	.ai_encoding = das08_encode12,
-	.ao = das08jr_ao_winsn,
-	.ao_nbits = 16,
-	.di = das08jr_di_rbits,
-	.do_ = das08jr_do_wbits,
-	.do_nchan = 8,
-	.i8255_offset = 0,
-	.i8254_offset = 0x04,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "das08jr-16-ao",	/*  cio-das08jr-16-ao.pdf */
+	 .bustype = isa,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 16,
+	 .ai_pg = das08_pg_none,
+	 .ai_encoding = das08_encode12,
+	 .ao = das08jr_ao_winsn,
+	 .ao_nbits = 16,
+	 .di = das08jr_di_rbits,
+	 .do_ = das08jr_do_wbits,
+	 .do_nchan = 8,
+	 .i8255_offset = 0,
+	 .i8254_offset = 0x04,
+	 .iosize = 16,		/*  unchecked */
+	 },
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 	{
 	{
-	.name = "das08",	/*  pci-das08 */
-	.id = PCI_DEVICE_ID_PCIDAS08,
-	.bustype = pci,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_bipolar5,
-	.ai_encoding = das08_encode12,
-	.ao = NULL,
-	.ao_nbits = 0,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 4,
-	.i8255_offset = 0,
-	.i8254_offset = 4,
-	.iosize = 8,
-		},
+	 .name = "das08",	/*  pci-das08 */
+	 .id = PCI_DEVICE_ID_PCIDAS08,
+	 .bustype = pci,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_bipolar5,
+	 .ai_encoding = das08_encode12,
+	 .ao = NULL,
+	 .ao_nbits = 0,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 4,
+	 .i8255_offset = 0,
+	 .i8254_offset = 4,
+	 .iosize = 8,
+	 },
 #endif
 #endif
 	{
 	{
-	.name = "pc104-das08",
-	.bustype = pc104,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_pg_none,
-	.ai_encoding = das08_encode12,
-	.ao = NULL,
-	.ao_nbits = 0,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 4,
-	.i8255_offset = 0,
-	.i8254_offset = 4,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "pc104-das08",
+	 .bustype = pc104,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_pg_none,
+	 .ai_encoding = das08_encode12,
+	 .ao = NULL,
+	 .ao_nbits = 0,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 4,
+	 .i8255_offset = 0,
+	 .i8254_offset = 4,
+	 .iosize = 16,		/*  unchecked */
+	 },
 #if 0
 #if 0
 	{
 	{
-	.name = "das08/f",
-		},
+	 .name = "das08/f",
+	 },
 	{
 	{
-	.name = "das08jr",
-		},
+	 .name = "das08jr",
+	 },
 #endif
 #endif
 	{
 	{
-	.name = "das08jr/16",
-	.bustype = isa,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 16,
-	.ai_pg = das08_pg_none,
-	.ai_encoding = das08_encode16,
-	.ao = NULL,
-	.ao_nbits = 0,
-	.di = das08jr_di_rbits,
-	.do_ = das08jr_do_wbits,
-	.do_nchan = 8,
-	.i8255_offset = 0,
-	.i8254_offset = 0,
-	.iosize = 16,	/*  unchecked */
-		},
+	 .name = "das08jr/16",
+	 .bustype = isa,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 16,
+	 .ai_pg = das08_pg_none,
+	 .ai_encoding = das08_encode16,
+	 .ao = NULL,
+	 .ao_nbits = 0,
+	 .di = das08jr_di_rbits,
+	 .do_ = das08jr_do_wbits,
+	 .do_nchan = 8,
+	 .i8255_offset = 0,
+	 .i8254_offset = 0,
+	 .iosize = 16,		/*  unchecked */
+	 },
 #if 0
 #if 0
 	{
 	{
-	.name = "das48-pga",	/*  cio-das48-pga.pdf */
-		},
+	 .name = "das48-pga",	/*  cio-das48-pga.pdf */
+	 },
 	{
 	{
-	.name = "das08-pga-g2",	/*  a KM board */
-		},
+	 .name = "das08-pga-g2",	/*  a KM board */
+	 },
 #endif
 #endif
 };
 };
 
 
 #ifdef CONFIG_COMEDI_PCMCIA
 #ifdef CONFIG_COMEDI_PCMCIA
 struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = {
 struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = {
 	{
 	{
-	.name = "pcm-das08",
-	.id = 0x0,	/*  XXX */
-	.bustype = pcmcia,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_bipolar5,
-	.ai_encoding = das08_pcm_encode12,
-	.ao = NULL,
-	.ao_nbits = 0,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 3,
-	.i8255_offset = 0,
-	.i8254_offset = 0,
-	.iosize = 16,
-		},
+	 .name = "pcm-das08",
+	 .id = 0x0,		/*  XXX */
+	 .bustype = pcmcia,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_bipolar5,
+	 .ai_encoding = das08_pcm_encode12,
+	 .ao = NULL,
+	 .ao_nbits = 0,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 3,
+	 .i8255_offset = 0,
+	 .i8254_offset = 0,
+	 .iosize = 16,
+	 },
 	/*  duplicate so driver name can be used also */
 	/*  duplicate so driver name can be used also */
 	{
 	{
-	.name = "das08_cs",
-	.id = 0x0,	/*  XXX */
-	.bustype = pcmcia,
-	.ai = das08_ai_rinsn,
-	.ai_nbits = 12,
-	.ai_pg = das08_bipolar5,
-	.ai_encoding = das08_pcm_encode12,
-	.ao = NULL,
-	.ao_nbits = 0,
-	.di = das08_di_rbits,
-	.do_ = das08_do_wbits,
-	.do_nchan = 3,
-	.i8255_offset = 0,
-	.i8254_offset = 0,
-	.iosize = 16,
-		},
+	 .name = "das08_cs",
+	 .id = 0x0,		/*  XXX */
+	 .bustype = pcmcia,
+	 .ai = das08_ai_rinsn,
+	 .ai_nbits = 12,
+	 .ai_pg = das08_bipolar5,
+	 .ai_encoding = das08_pcm_encode12,
+	 .ao = NULL,
+	 .ao_nbits = 0,
+	 .di = das08_di_rbits,
+	 .do_ = das08_do_wbits,
+	 .do_nchan = 3,
+	 .i8255_offset = 0,
+	 .i8254_offset = 0,
+	 .iosize = 16,
+	 },
 };
 };
 #endif
 #endif
 
 
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(das08_pci_table) = {
-	{PCI_VENDOR_ID_COMPUTERBOARDS, PCI_DEVICE_ID_PCIDAS08, PCI_ANY_ID,
-		PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_COMPUTERBOARDS, PCI_DEVICE_ID_PCIDAS08,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, das08_pci_table);
 MODULE_DEVICE_TABLE(pci, das08_pci_table);
@@ -513,7 +520,7 @@ MODULE_DEVICE_TABLE(pci, das08_pci_table);
 #define TIMEOUT 100000
 #define TIMEOUT 100000
 
 
 static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i, n;
 	int i, n;
 	int chan;
 	int chan;
@@ -538,7 +545,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 		/* set gain/range */
 		/* set gain/range */
 		range = CR_RANGE(insn->chanspec);
 		range = CR_RANGE(insn->chanspec);
 		outb(devpriv->pg_gainlist[range],
 		outb(devpriv->pg_gainlist[range],
-			dev->iobase + DAS08AO_GAIN_CONTROL);
+		     dev->iobase + DAS08AO_GAIN_CONTROL);
 	}
 	}
 
 
 	for (n = 0; n < insn->n; n++) {
 	for (n = 0; n < insn->n; n++) {
@@ -580,7 +587,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 }
 }
 
 
 static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
 static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	data[0] = 0;
 	data[0] = 0;
 	data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS));
 	data[1] = DAS08_IP(inb(dev->iobase + DAS08_STATUS));
@@ -589,7 +596,7 @@ static int das08_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
 }
 }
 
 
 static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
 static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int wbits;
 	int wbits;
 
 
@@ -611,8 +618,9 @@ static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
 	return 2;
 	return 2;
 }
 }
 
 
-static int das08jr_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das08jr_di_rbits(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	data[0] = 0;
 	data[0] = 0;
 	data[1] = inb(dev->iobase + DAS08JR_DIO);
 	data[1] = inb(dev->iobase + DAS08JR_DIO);
@@ -620,8 +628,9 @@ static int das08jr_di_rbits(struct comedi_device *dev, struct comedi_subdevice *
 	return 2;
 	return 2;
 }
 }
 
 
-static int das08jr_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das08jr_do_wbits(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	/*  null bits we are going to set */
 	/*  null bits we are going to set */
 	devpriv->do_bits &= ~data[0];
 	devpriv->do_bits &= ~data[0];
@@ -634,8 +643,9 @@ static int das08jr_do_wbits(struct comedi_device *dev, struct comedi_subdevice *
 	return 2;
 	return 2;
 }
 }
 
 
-static int das08jr_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das08jr_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n;
 	int n;
 	int lsb, msb;
 	int lsb, msb;
@@ -668,8 +678,9 @@ static int das08jr_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *
  * a different method to force an update.
  * a different method to force an update.
  *
  *
  */
  */
-static int das08ao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das08ao_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n;
 	int n;
 	int lsb, msb;
 	int lsb, msb;
@@ -716,7 +727,7 @@ static unsigned int i8254_read_channel_low(unsigned int base, int chan)
 }
 }
 
 
 static void i8254_write_channel_low(unsigned int base, int chan,
 static void i8254_write_channel_low(unsigned int base, int chan,
-	unsigned int value)
+				    unsigned int value)
 {
 {
 	unsigned int msb, lsb;
 	unsigned int msb, lsb;
 
 
@@ -740,7 +751,7 @@ static unsigned int i8254_read_channel(struct i8254_struct *st, int channel)
 }
 }
 
 
 static void i8254_write_channel(struct i8254_struct *st, int channel,
 static void i8254_write_channel(struct i8254_struct *st, int channel,
-	unsigned int value)
+				unsigned int value)
 {
 {
 	int chan = st->logic2phys[channel];
 	int chan = st->logic2phys[channel];
 
 
@@ -755,13 +766,13 @@ static void i8254_initialize(struct i8254_struct *st)
 }
 }
 
 
 static void i8254_set_mode_low(unsigned int base, int channel,
 static void i8254_set_mode_low(unsigned int base, int channel,
-	unsigned int mode)
+			       unsigned int mode)
 {
 {
 	outb((channel << 6) | 0x30 | (mode & 0x0F), base + I8254_CTRL);
 	outb((channel << 6) | 0x30 | (mode & 0x0F), base + I8254_CTRL);
 }
 }
 
 
 static void i8254_set_mode(struct i8254_struct *st, int channel,
 static void i8254_set_mode(struct i8254_struct *st, int channel,
-	unsigned int mode)
+			   unsigned int mode)
 {
 {
 	int chan = st->logic2phys[channel];
 	int chan = st->logic2phys[channel];
 
 
@@ -782,8 +793,9 @@ static unsigned int i8254_read_status(struct i8254_struct *st, int channel)
 	return i8254_read_status_low(st->iobase, chan);
 	return i8254_read_status_low(st->iobase, chan);
 }
 }
 
 
-static int das08_counter_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das08_counter_read(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int chan = insn->chanspec;
 	int chan = insn->chanspec;
 
 
@@ -794,8 +806,9 @@ static int das08_counter_read(struct comedi_device *dev, struct comedi_subdevice
 	return 1;
 	return 1;
 }
 }
 
 
-static int das08_counter_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das08_counter_write(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int chan = insn->chanspec;
 	int chan = insn->chanspec;
 
 
@@ -805,8 +818,9 @@ static int das08_counter_write(struct comedi_device *dev, struct comedi_subdevic
 	return 1;
 	return 1;
 }
 }
 
 
-static int das08_counter_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das08_counter_config(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int chan = insn->chanspec;
 	int chan = insn->chanspec;
 
 
@@ -835,8 +849,7 @@ static struct comedi_driver driver_das08 = {
 	.attach = das08_attach,
 	.attach = das08_attach,
 	.detach = das08_common_detach,
 	.detach = das08_common_detach,
 	.board_name = &das08_boards[0].name,
 	.board_name = &das08_boards[0].name,
-	.num_names = sizeof(das08_boards) /
-		sizeof(struct das08_board_struct),
+	.num_names = sizeof(das08_boards) / sizeof(struct das08_board_struct),
 	.offset = sizeof(struct das08_board_struct),
 	.offset = sizeof(struct das08_board_struct),
 };
 };
 
 
@@ -921,7 +934,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
 	/* 8255 */
 	/* 8255 */
 	if (thisboard->i8255_offset != 0) {
 	if (thisboard->i8255_offset != 0) {
 		subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase +
 		subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase +
-				thisboard->i8255_offset));
+							       thisboard->
+							       i8255_offset));
 	} else {
 	} else {
 		s->type = COMEDI_SUBD_UNUSED;
 		s->type = COMEDI_SUBD_UNUSED;
 	}
 	}
@@ -943,8 +957,8 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
 		devpriv->i8254.logic2phys[2] = 2;
 		devpriv->i8254.logic2phys[2] = 2;
 		devpriv->i8254.iobase = iobase + thisboard->i8254_offset;
 		devpriv->i8254.iobase = iobase + thisboard->i8254_offset;
 		devpriv->i8254.mode[0] =
 		devpriv->i8254.mode[0] =
-			devpriv->i8254.mode[1] =
-			devpriv->i8254.mode[2] = I8254_MODE0 | I8254_BINARY;
+		    devpriv->i8254.mode[1] =
+		    devpriv->i8254.mode[2] = I8254_MODE0 | I8254_BINARY;
 		i8254_initialize(&devpriv->i8254);
 		i8254_initialize(&devpriv->i8254);
 	} else {
 	} else {
 		s->type = COMEDI_SUBD_UNUSED;
 		s->type = COMEDI_SUBD_UNUSED;
@@ -972,19 +986,19 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 		if (it->options[0] || it->options[1]) {
 		if (it->options[0] || it->options[1]) {
 			printk("bus %i slot %i ",
 			printk("bus %i slot %i ",
-				it->options[0], it->options[1]);
+			       it->options[0], it->options[1]);
 		}
 		}
 		printk("\n");
 		printk("\n");
 		/*  find card */
 		/*  find card */
 		for (pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 		for (pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-			pdev != NULL;
-			pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) {
+		     pdev != NULL;
+		     pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) {
 			if (pdev->vendor == PCI_VENDOR_ID_COMPUTERBOARDS
 			if (pdev->vendor == PCI_VENDOR_ID_COMPUTERBOARDS
-				&& pdev->device == PCI_DEVICE_ID_PCIDAS08) {
+			    && pdev->device == PCI_DEVICE_ID_PCIDAS08) {
 				if (it->options[0] || it->options[1]) {
 				if (it->options[0] || it->options[1]) {
 					if (pdev->bus->number == it->options[0]
 					if (pdev->bus->number == it->options[0]
-						&& PCI_SLOT(pdev->devfn) ==
-						it->options[1]) {
+					    && PCI_SLOT(pdev->devfn) ==
+					    it->options[1]) {
 						break;
 						break;
 					}
 					}
 				} else {
 				} else {
@@ -999,7 +1013,8 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		devpriv->pdev = pdev;
 		devpriv->pdev = pdev;
 		/*  enable PCI device and reserve I/O spaces */
 		/*  enable PCI device and reserve I/O spaces */
 		if (comedi_pci_enable(pdev, DRV_NAME)) {
 		if (comedi_pci_enable(pdev, DRV_NAME)) {
-			printk(" Error enabling PCI device and requesting regions\n");
+			printk
+			    (" Error enabling PCI device and requesting regions\n");
 			return -EIO;
 			return -EIO;
 		}
 		}
 		/*  read base addresses */
 		/*  read base addresses */
@@ -1018,10 +1033,10 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		/* Enable local interrupt 1 and pci interrupt */
 		/* Enable local interrupt 1 and pci interrupt */
 		outw(INTR1_ENABLE | PCI_INTR_ENABLE, pci_iobase + INTCSR);
 		outw(INTR1_ENABLE | PCI_INTR_ENABLE, pci_iobase + INTCSR);
 #endif
 #endif
-#else	/* CONFIG_COMEDI_PCI */
+#else /* CONFIG_COMEDI_PCI */
 		printk("this driver has not been built with PCI support.\n");
 		printk("this driver has not been built with PCI support.\n");
 		return -EINVAL;
 		return -EINVAL;
-#endif	/* CONFIG_COMEDI_PCI */
+#endif /* CONFIG_COMEDI_PCI */
 	} else {
 	} else {
 		iobase = it->options[0];
 		iobase = it->options[0];
 	}
 	}
@@ -1042,7 +1057,6 @@ int das08_common_detach(struct comedi_device *dev)
 		if (dev->iobase)
 		if (dev->iobase)
 			release_region(dev->iobase, thisboard->iosize);
 			release_region(dev->iobase, thisboard->iosize);
 	}
 	}
-
 #ifdef CONFIG_COMEDI_PCI
 #ifdef CONFIG_COMEDI_PCI
 	if (devpriv) {
 	if (devpriv) {
 		if (devpriv->pdev) {
 		if (devpriv->pdev) {

+ 2 - 1
drivers/staging/comedi/drivers/das08.h

@@ -28,7 +28,8 @@ enum das08_bustype { isa, pci, pcmcia, pc104 };
 /* different ways ai data is encoded in first two registers */
 /* different ways ai data is encoded in first two registers */
 enum das08_ai_encoding { das08_encode12, das08_encode16, das08_pcm_encode12 };
 enum das08_ai_encoding { das08_encode12, das08_encode16, das08_pcm_encode12 };
 enum das08_lrange { das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl,
 enum das08_lrange { das08_pg_none, das08_bipolar5, das08_pgh, das08_pgl,
-		das08_pgm };
+	das08_pgm
+};
 
 
 struct das08_board_struct {
 struct das08_board_struct {
 	const char *name;
 	const char *name;

+ 13 - 12
drivers/staging/comedi/drivers/das08_cs.c

@@ -56,7 +56,8 @@ static struct pcmcia_device *cur_dev = NULL;
 
 
 #define thisboard ((const struct das08_board_struct *)dev->board_ptr)
 #define thisboard ((const struct das08_board_struct *)dev->board_ptr)
 
 
-static int das08_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das08_cs_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it);
 
 
 static struct comedi_driver driver_das08_cs = {
 static struct comedi_driver driver_das08_cs = {
 	.driver_name = "das08_cs",
 	.driver_name = "das08_cs",
@@ -64,12 +65,12 @@ static struct comedi_driver driver_das08_cs = {
 	.attach = das08_cs_attach,
 	.attach = das08_cs_attach,
 	.detach = das08_common_detach,
 	.detach = das08_common_detach,
 	.board_name = &das08_cs_boards[0].name,
 	.board_name = &das08_cs_boards[0].name,
-	.num_names = sizeof(das08_cs_boards) /
-		sizeof(struct das08_board_struct),
+	.num_names = ARRAY_SIZE(das08_cs_boards),
 	.offset = sizeof(struct das08_board_struct),
 	.offset = sizeof(struct das08_board_struct),
 };
 };
 
 
-static int das08_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int das08_cs_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it)
 {
 {
 	int ret;
 	int ret;
 	unsigned long iobase;
 	unsigned long iobase;
@@ -122,7 +123,7 @@ static int pc_debug = PCMCIA_DEBUG;
 module_param(pc_debug, int, 0644);
 module_param(pc_debug, int, 0644);
 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
 #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
 static const char *version =
 static const char *version =
-	"das08.c pcmcia code (Frank Hess), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)";
+    "das08.c pcmcia code (Frank Hess), modified from dummy_cs.c 1.31 2001/08/24 12:13:13 (David Hinds)";
 #else
 #else
 #define DEBUG(n, args...)
 #define DEBUG(n, args...)
 #endif
 #endif
@@ -226,7 +227,7 @@ static void das08_pcmcia_detach(struct pcmcia_device *link)
 	DEBUG(0, "das08_pcmcia_detach(0x%p)\n", link);
 	DEBUG(0, "das08_pcmcia_detach(0x%p)\n", link);
 
 
 	if (link->dev_node) {
 	if (link->dev_node) {
-		((struct local_info_t *) link->priv)->stop = 1;
+		((struct local_info_t *)link->priv)->stop = 1;
 		das08_pcmcia_release(link);
 		das08_pcmcia_release(link);
 	}
 	}
 
 
@@ -356,7 +357,7 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
 		/* If we got this far, we're cool! */
 		/* If we got this far, we're cool! */
 		break;
 		break;
 
 
-	      next_entry:
+next_entry:
 		last_fn = GetNextTuple;
 		last_fn = GetNextTuple;
 
 
 		last_ret = pcmcia_get_next_tuple(link, &tuple);
 		last_ret = pcmcia_get_next_tuple(link, &tuple);
@@ -391,20 +392,20 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
 
 
 	/* Finally, report what we've done */
 	/* Finally, report what we've done */
 	printk(KERN_INFO "%s: index 0x%02x",
 	printk(KERN_INFO "%s: index 0x%02x",
-		dev->node.dev_name, link->conf.ConfigIndex);
+	       dev->node.dev_name, link->conf.ConfigIndex);
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
 		printk(", irq %u", link->irq.AssignedIRQ);
 		printk(", irq %u", link->irq.AssignedIRQ);
 	if (link->io.NumPorts1)
 	if (link->io.NumPorts1)
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
-			link->io.BasePort1 + link->io.NumPorts1 - 1);
+		       link->io.BasePort1 + link->io.NumPorts1 - 1);
 	if (link->io.NumPorts2)
 	if (link->io.NumPorts2)
 		printk(" & 0x%04x-0x%04x", link->io.BasePort2,
 		printk(" & 0x%04x-0x%04x", link->io.BasePort2,
-			link->io.BasePort2 + link->io.NumPorts2 - 1);
+		       link->io.BasePort2 + link->io.NumPorts2 - 1);
 	printk("\n");
 	printk("\n");
 
 
 	return;
 	return;
 
 
-      cs_failed:
+cs_failed:
 	cs_error(link, last_fn, last_ret);
 	cs_error(link, last_fn, last_ret);
 	das08_pcmcia_release(link);
 	das08_pcmcia_release(link);
 
 
@@ -470,7 +471,7 @@ struct pcmcia_driver das08_cs_driver = {
 	.id_table = das08_cs_id_table,
 	.id_table = das08_cs_id_table,
 	.owner = THIS_MODULE,
 	.owner = THIS_MODULE,
 	.drv = {
 	.drv = {
-			.name = dev_info,
+		.name = dev_info,
 		},
 		},
 };
 };
 
 

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 389 - 373
drivers/staging/comedi/drivers/das16.c


+ 73 - 59
drivers/staging/comedi/drivers/das16m1.c

@@ -120,36 +120,41 @@ irq can be omitted, although the cmd interface will not work without it.
 
 
 static const struct comedi_lrange range_das16m1 = { 9,
 static const struct comedi_lrange range_das16m1 = { 9,
 	{
 	{
-			BIP_RANGE(5),
-			BIP_RANGE(2.5),
-			BIP_RANGE(1.25),
-			BIP_RANGE(0.625),
-			UNI_RANGE(10),
-			UNI_RANGE(5),
-			UNI_RANGE(2.5),
-			UNI_RANGE(1.25),
-			BIP_RANGE(10),
-		}
+	 BIP_RANGE(5),
+	 BIP_RANGE(2.5),
+	 BIP_RANGE(1.25),
+	 BIP_RANGE(0.625),
+	 UNI_RANGE(10),
+	 UNI_RANGE(5),
+	 UNI_RANGE(2.5),
+	 UNI_RANGE(1.25),
+	 BIP_RANGE(10),
+	 }
 };
 };
 
 
-static int das16m1_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das16m1_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-
-static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd);
-static int das16m1_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s);
-static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int das16m1_do_wbits(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int das16m1_di_rbits(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int das16m1_ai_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+
+static int das16m1_cmd_test(struct comedi_device *dev,
+			    struct comedi_subdevice *s, struct comedi_cmd *cmd);
+static int das16m1_cmd_exec(struct comedi_device *dev,
+			    struct comedi_subdevice *s);
+static int das16m1_cancel(struct comedi_device *dev,
+			  struct comedi_subdevice *s);
 
 
 static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s);
 static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s);
 static irqreturn_t das16m1_interrupt(int irq, void *d);
 static irqreturn_t das16m1_interrupt(int irq, void *d);
 static void das16m1_handler(struct comedi_device *dev, unsigned int status);
 static void das16m1_handler(struct comedi_device *dev, unsigned int status);
 
 
-static unsigned int das16m1_set_pacer(struct comedi_device *dev, unsigned int ns,
-	int round_flag);
+static unsigned int das16m1_set_pacer(struct comedi_device *dev,
+				      unsigned int ns, int round_flag);
 
 
 static int das16m1_irq_bits(unsigned int irq);
 static int das16m1_irq_bits(unsigned int irq);
 
 
@@ -160,12 +165,13 @@ struct das16m1_board {
 
 
 static const struct das16m1_board das16m1_boards[] = {
 static const struct das16m1_board das16m1_boards[] = {
 	{
 	{
-	.name = "cio-das16/m1",	/*  CIO-DAS16_M1.pdf */
-	.ai_speed = 1000,	/*  1MHz max speed */
-		},
+	 .name = "cio-das16/m1",	/*  CIO-DAS16_M1.pdf */
+	 .ai_speed = 1000,	/*  1MHz max speed */
+	 },
 };
 };
 
 
-static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das16m1_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int das16m1_detach(struct comedi_device *dev);
 static int das16m1_detach(struct comedi_device *dev);
 static struct comedi_driver driver_das16m1 = {
 static struct comedi_driver driver_das16m1 = {
 	.driver_name = "das16m1",
 	.driver_name = "das16m1",
@@ -199,8 +205,8 @@ static inline short munge_sample(short data)
 	return (data >> 4) & 0xfff;
 	return (data >> 4) & 0xfff;
 }
 }
 
 
-static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int das16m1_cmd_test(struct comedi_device *dev,
+			    struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
 {
 	unsigned int err = 0, tmp, i;
 	unsigned int err = 0, tmp, i;
 
 
@@ -289,8 +295,10 @@ static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *
 		tmp = cmd->convert_arg;
 		tmp = cmd->convert_arg;
 		/* calculate counter values that give desired timing */
 		/* calculate counter values that give desired timing */
 		i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL,
 		i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL,
-			&(devpriv->divisor1), &(devpriv->divisor2),
-			&(cmd->convert_arg), cmd->flags & TRIG_ROUND_MASK);
+					       &(devpriv->divisor1),
+					       &(devpriv->divisor2),
+					       &(cmd->convert_arg),
+					       cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->convert_arg)
 		if (tmp != cmd->convert_arg)
 			err++;
 			err++;
 	}
 	}
@@ -304,13 +312,13 @@ static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *
 			/*  even/odd channels must go into even/odd queue addresses */
 			/*  even/odd channels must go into even/odd queue addresses */
 			if ((i % 2) != (CR_CHAN(cmd->chanlist[i]) % 2)) {
 			if ((i % 2) != (CR_CHAN(cmd->chanlist[i]) % 2)) {
 				comedi_error(dev, "bad chanlist:\n"
 				comedi_error(dev, "bad chanlist:\n"
-					" even/odd channels must go have even/odd chanlist indices");
+					     " even/odd channels must go have even/odd chanlist indices");
 				err++;
 				err++;
 			}
 			}
 		}
 		}
 		if ((cmd->chanlist_len % 2) != 0) {
 		if ((cmd->chanlist_len % 2) != 0) {
 			comedi_error(dev,
 			comedi_error(dev,
-				"chanlist must be of even length or length 1");
+				     "chanlist must be of even length or length 1");
 			err++;
 			err++;
 		}
 		}
 	}
 	}
@@ -321,7 +329,8 @@ static int das16m1_cmd_test(struct comedi_device *dev, struct comedi_subdevice *
 	return 0;
 	return 0;
 }
 }
 
 
-static int das16m1_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
+static int das16m1_cmd_exec(struct comedi_device *dev,
+			    struct comedi_subdevice *s)
 {
 {
 	struct comedi_async *async = s->async;
 	struct comedi_async *async = s->async;
 	struct comedi_cmd *cmd = &async->cmd;
 	struct comedi_cmd *cmd = &async->cmd;
@@ -345,20 +354,20 @@ static int das16m1_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *
 	/* remember current reading of counter so we know when counter has
 	/* remember current reading of counter so we know when counter has
 	 * actually been loaded */
 	 * actually been loaded */
 	devpriv->initial_hw_count =
 	devpriv->initial_hw_count =
-		i8254_read(dev->iobase + DAS16M1_8254_FIRST, 0, 1);
+	    i8254_read(dev->iobase + DAS16M1_8254_FIRST, 0, 1);
 	/* setup channel/gain queue */
 	/* setup channel/gain queue */
 	for (i = 0; i < cmd->chanlist_len; i++) {
 	for (i = 0; i < cmd->chanlist_len; i++) {
 		outb(i, dev->iobase + DAS16M1_QUEUE_ADDR);
 		outb(i, dev->iobase + DAS16M1_QUEUE_ADDR);
-		byte = Q_CHAN(CR_CHAN(cmd->
-				chanlist[i])) | Q_RANGE(CR_RANGE(cmd->
-				chanlist[i]));
+		byte =
+		    Q_CHAN(CR_CHAN(cmd->chanlist[i])) |
+		    Q_RANGE(CR_RANGE(cmd->chanlist[i]));
 		outb(byte, dev->iobase + DAS16M1_QUEUE_DATA);
 		outb(byte, dev->iobase + DAS16M1_QUEUE_DATA);
 	}
 	}
 
 
 	/* set counter mode and counts */
 	/* set counter mode and counts */
 	cmd->convert_arg =
 	cmd->convert_arg =
-		das16m1_set_pacer(dev, cmd->convert_arg,
-		cmd->flags & TRIG_ROUND_MASK);
+	    das16m1_set_pacer(dev, cmd->convert_arg,
+			      cmd->flags & TRIG_ROUND_MASK);
 
 
 	/*  set control & status register */
 	/*  set control & status register */
 	byte = 0;
 	byte = 0;
@@ -392,8 +401,9 @@ static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 	return 0;
 	return 0;
 }
 }
 
 
-static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das16m1_ai_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i, n;
 	int i, n;
 	int byte;
 	int byte;
@@ -405,8 +415,8 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *
 
 
 	/* setup channel/gain queue */
 	/* setup channel/gain queue */
 	outb(0, dev->iobase + DAS16M1_QUEUE_ADDR);
 	outb(0, dev->iobase + DAS16M1_QUEUE_ADDR);
-	byte = Q_CHAN(CR_CHAN(insn->chanspec)) | Q_RANGE(CR_RANGE(insn->
-			chanspec));
+	byte =
+	    Q_CHAN(CR_CHAN(insn->chanspec)) | Q_RANGE(CR_RANGE(insn->chanspec));
 	outb(byte, dev->iobase + DAS16M1_QUEUE_DATA);
 	outb(byte, dev->iobase + DAS16M1_QUEUE_DATA);
 
 
 	for (n = 0; n < insn->n; n++) {
 	for (n = 0; n < insn->n; n++) {
@@ -429,8 +439,9 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *
 	return n;
 	return n;
 }
 }
 
 
-static int das16m1_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das16m1_di_rbits(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int bits;
 	unsigned int bits;
 
 
@@ -441,8 +452,9 @@ static int das16m1_di_rbits(struct comedi_device *dev, struct comedi_subdevice *
 	return 2;
 	return 2;
 }
 }
 
 
-static int das16m1_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das16m1_do_wbits(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int wbits;
 	unsigned int wbits;
 
 
@@ -552,7 +564,7 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status)
 	insw(dev->iobase, devpriv->ai_buffer, num_samples);
 	insw(dev->iobase, devpriv->ai_buffer, num_samples);
 	munge_sample_array(devpriv->ai_buffer, num_samples);
 	munge_sample_array(devpriv->ai_buffer, num_samples);
 	cfc_write_array_to_buffer(s, devpriv->ai_buffer,
 	cfc_write_array_to_buffer(s, devpriv->ai_buffer,
-		num_samples * sizeof(short));
+				  num_samples * sizeof(short));
 	devpriv->adc_count += num_samples;
 	devpriv->adc_count += num_samples;
 
 
 	if (cmd->stop_src == TRIG_COUNT) {
 	if (cmd->stop_src == TRIG_COUNT) {
@@ -577,17 +589,18 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status)
 /* This function takes a time in nanoseconds and sets the     *
 /* This function takes a time in nanoseconds and sets the     *
  * 2 pacer clocks to the closest frequency possible. It also  *
  * 2 pacer clocks to the closest frequency possible. It also  *
  * returns the actual sampling period.                        */
  * returns the actual sampling period.                        */
-static unsigned int das16m1_set_pacer(struct comedi_device *dev, unsigned int ns,
-	int rounding_flags)
+static unsigned int das16m1_set_pacer(struct comedi_device *dev,
+				      unsigned int ns, int rounding_flags)
 {
 {
 	i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL, &(devpriv->divisor1),
 	i8253_cascade_ns_to_timer_2div(DAS16M1_XTAL, &(devpriv->divisor1),
-		&(devpriv->divisor2), &ns, rounding_flags & TRIG_ROUND_MASK);
+				       &(devpriv->divisor2), &ns,
+				       rounding_flags & TRIG_ROUND_MASK);
 
 
 	/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
 	/* Write the values of ctr1 and ctr2 into counters 1 and 2 */
 	i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 1, devpriv->divisor1,
 	i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 1, devpriv->divisor1,
-		2);
+		   2);
 	i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 2, devpriv->divisor2,
 	i8254_load(dev->iobase + DAS16M1_8254_SECOND, 0, 2, devpriv->divisor2,
-		2);
+		   2);
 
 
 	return ns;
 	return ns;
 }
 }
@@ -634,7 +647,8 @@ static int das16m1_irq_bits(unsigned int irq)
  *   1  IRQ
  *   1  IRQ
  */
  */
 
 
-static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int das16m1_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int ret;
 	int ret;
@@ -652,14 +666,14 @@ static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	dev->board_name = thisboard->name;
 	dev->board_name = thisboard->name;
 
 
 	printk(" io 0x%lx-0x%lx 0x%lx-0x%lx",
 	printk(" io 0x%lx-0x%lx 0x%lx-0x%lx",
-		iobase, iobase + DAS16M1_SIZE,
-		iobase + DAS16M1_82C55, iobase + DAS16M1_82C55 + DAS16M1_SIZE2);
+	       iobase, iobase + DAS16M1_SIZE,
+	       iobase + DAS16M1_82C55, iobase + DAS16M1_82C55 + DAS16M1_SIZE2);
 	if (!request_region(iobase, DAS16M1_SIZE, driver_das16m1.driver_name)) {
 	if (!request_region(iobase, DAS16M1_SIZE, driver_das16m1.driver_name)) {
 		printk(" I/O port conflict\n");
 		printk(" I/O port conflict\n");
 		return -EIO;
 		return -EIO;
 	}
 	}
 	if (!request_region(iobase + DAS16M1_82C55, DAS16M1_SIZE2,
 	if (!request_region(iobase + DAS16M1_82C55, DAS16M1_SIZE2,
-			driver_das16m1.driver_name)) {
+			    driver_das16m1.driver_name)) {
 		release_region(iobase, DAS16M1_SIZE);
 		release_region(iobase, DAS16M1_SIZE);
 		printk(" I/O port conflict\n");
 		printk(" I/O port conflict\n");
 		return -EIO;
 		return -EIO;
@@ -682,7 +696,7 @@ static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		printk(", no irq\n");
 		printk(", no irq\n");
 	} else {
 	} else {
 		printk(", invalid irq\n"
 		printk(", invalid irq\n"
-			" valid irqs are 2, 3, 5, 7, 10, 11, 12, or 15\n");
+		       " valid irqs are 2, 3, 5, 7, 10, 11, 12, or 15\n");
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 
 

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 337 - 298
drivers/staging/comedi/drivers/das1800.c


+ 14 - 9
drivers/staging/comedi/drivers/das6402.c

@@ -99,7 +99,8 @@ This driver has suffered bitrot.
 #define	C2 0x80
 #define	C2 0x80
 #define	RWLH 0x30
 #define	RWLH 0x30
 
 
-static int das6402_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das6402_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int das6402_detach(struct comedi_device *dev);
 static int das6402_detach(struct comedi_device *dev);
 static struct comedi_driver driver_das6402 = {
 static struct comedi_driver driver_das6402 = {
 	.driver_name = "das6402",
 	.driver_name = "das6402",
@@ -117,7 +118,8 @@ struct das6402_private {
 };
 };
 #define devpriv ((struct das6402_private *)dev->private)
 #define devpriv ((struct das6402_private *)dev->private)
 
 
-static void das6402_ai_fifo_dregs(struct comedi_device *dev, struct comedi_subdevice *s);
+static void das6402_ai_fifo_dregs(struct comedi_device *dev,
+				  struct comedi_subdevice *s);
 
 
 static void das6402_setcounter(struct comedi_device *dev)
 static void das6402_setcounter(struct comedi_device *dev)
 {
 {
@@ -163,7 +165,7 @@ static irqreturn_t intr_handler(int irq, void *d)
 	}
 	}
 #ifdef DEBUG
 #ifdef DEBUG
 	printk("das6402: interrupt! das6402_irqcount=%i\n",
 	printk("das6402: interrupt! das6402_irqcount=%i\n",
-		devpriv->das6402_irqcount);
+	       devpriv->das6402_irqcount);
 	printk("das6402: iobase+2=%i\n", inw_p(dev->iobase + 2));
 	printk("das6402: iobase+2=%i\n", inw_p(dev->iobase + 2));
 #endif
 #endif
 
 
@@ -174,7 +176,7 @@ static irqreturn_t intr_handler(int irq, void *d)
 		outb(0x07, dev->iobase + 8);	/* clears all flip-flops */
 		outb(0x07, dev->iobase + 8);	/* clears all flip-flops */
 #ifdef DEBUG
 #ifdef DEBUG
 		printk("das6402: Got %i samples\n\n",
 		printk("das6402: Got %i samples\n\n",
-			devpriv->das6402_wordsread - diff);
+		       devpriv->das6402_wordsread - diff);
 #endif
 #endif
 		s->async->events |= COMEDI_CB_EOA;
 		s->async->events |= COMEDI_CB_EOA;
 		comedi_event(dev, s);
 		comedi_event(dev, s);
@@ -196,7 +198,8 @@ static void das6402_ai_fifo_read(struct comedi_device *dev, short *data, int n)
 }
 }
 #endif
 #endif
 
 
-static void das6402_ai_fifo_dregs(struct comedi_device *dev, struct comedi_subdevice *s)
+static void das6402_ai_fifo_dregs(struct comedi_device *dev,
+				  struct comedi_subdevice *s)
 {
 {
 	while (1) {
 	while (1) {
 		if (!(inb(dev->iobase + 8) & 0x01))
 		if (!(inb(dev->iobase + 8) & 0x01))
@@ -205,7 +208,8 @@ static void das6402_ai_fifo_dregs(struct comedi_device *dev, struct comedi_subde
 	}
 	}
 }
 }
 
 
-static int das6402_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int das6402_ai_cancel(struct comedi_device *dev,
+			     struct comedi_subdevice *s)
 {
 {
 	/*
 	/*
 	 *  This function should reset the board from whatever condition it
 	 *  This function should reset the board from whatever condition it
@@ -227,8 +231,8 @@ static int das6402_ai_cancel(struct comedi_device *dev, struct comedi_subdevice
 }
 }
 
 
 #ifdef unused
 #ifdef unused
-static int das6402_ai_mode2(struct comedi_device *dev, struct comedi_subdevice *s,
-	comedi_trig *it)
+static int das6402_ai_mode2(struct comedi_device *dev,
+			    struct comedi_subdevice *s, comedi_trig * it)
 {
 {
 	devpriv->das6402_ignoreirq = 1;
 	devpriv->das6402_ignoreirq = 1;
 
 
@@ -300,7 +304,8 @@ static int das6402_detach(struct comedi_device *dev)
 	return 0;
 	return 0;
 }
 }
 
 
-static int das6402_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int das6402_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	unsigned int irq;
 	unsigned int irq;
 	unsigned long iobase;
 	unsigned long iobase;

+ 119 - 105
drivers/staging/comedi/drivers/das800.c

@@ -118,114 +118,114 @@ struct das800_board {
 static const struct comedi_lrange range_das800_ai = {
 static const struct comedi_lrange range_das800_ai = {
 	1,
 	1,
 	{
 	{
-			RANGE(-5, 5),
-		}
+	 RANGE(-5, 5),
+	 }
 };
 };
 
 
 static const struct comedi_lrange range_das801_ai = {
 static const struct comedi_lrange range_das801_ai = {
 	9,
 	9,
 	{
 	{
-			RANGE(-5, 5),
-			RANGE(-10, 10),
-			RANGE(0, 10),
-			RANGE(-0.5, 0.5),
-			RANGE(0, 1),
-			RANGE(-0.05, 0.05),
-			RANGE(0, 0.1),
-			RANGE(-0.01, 0.01),
-			RANGE(0, 0.02),
-		}
+	 RANGE(-5, 5),
+	 RANGE(-10, 10),
+	 RANGE(0, 10),
+	 RANGE(-0.5, 0.5),
+	 RANGE(0, 1),
+	 RANGE(-0.05, 0.05),
+	 RANGE(0, 0.1),
+	 RANGE(-0.01, 0.01),
+	 RANGE(0, 0.02),
+	 }
 };
 };
 
 
 static const struct comedi_lrange range_cio_das801_ai = {
 static const struct comedi_lrange range_cio_das801_ai = {
 	9,
 	9,
 	{
 	{
-			RANGE(-5, 5),
-			RANGE(-10, 10),
-			RANGE(0, 10),
-			RANGE(-0.5, 0.5),
-			RANGE(0, 1),
-			RANGE(-0.05, 0.05),
-			RANGE(0, 0.1),
-			RANGE(-0.005, 0.005),
-			RANGE(0, 0.01),
-		}
+	 RANGE(-5, 5),
+	 RANGE(-10, 10),
+	 RANGE(0, 10),
+	 RANGE(-0.5, 0.5),
+	 RANGE(0, 1),
+	 RANGE(-0.05, 0.05),
+	 RANGE(0, 0.1),
+	 RANGE(-0.005, 0.005),
+	 RANGE(0, 0.01),
+	 }
 };
 };
 
 
 static const struct comedi_lrange range_das802_ai = {
 static const struct comedi_lrange range_das802_ai = {
 	9,
 	9,
 	{
 	{
-			RANGE(-5, 5),
-			RANGE(-10, 10),
-			RANGE(0, 10),
-			RANGE(-2.5, 2.5),
-			RANGE(0, 5),
-			RANGE(-1.25, 1.25),
-			RANGE(0, 2.5),
-			RANGE(-0.625, 0.625),
-			RANGE(0, 1.25),
-		}
+	 RANGE(-5, 5),
+	 RANGE(-10, 10),
+	 RANGE(0, 10),
+	 RANGE(-2.5, 2.5),
+	 RANGE(0, 5),
+	 RANGE(-1.25, 1.25),
+	 RANGE(0, 2.5),
+	 RANGE(-0.625, 0.625),
+	 RANGE(0, 1.25),
+	 }
 };
 };
 
 
 static const struct comedi_lrange range_das80216_ai = {
 static const struct comedi_lrange range_das80216_ai = {
 	8,
 	8,
 	{
 	{
-			RANGE(-10, 10),
-			RANGE(0, 10),
-			RANGE(-5, 5),
-			RANGE(0, 5),
-			RANGE(-2.5, 2.5),
-			RANGE(0, 2.5),
-			RANGE(-1.25, 1.25),
-			RANGE(0, 1.25),
-		}
+	 RANGE(-10, 10),
+	 RANGE(0, 10),
+	 RANGE(-5, 5),
+	 RANGE(0, 5),
+	 RANGE(-2.5, 2.5),
+	 RANGE(0, 2.5),
+	 RANGE(-1.25, 1.25),
+	 RANGE(0, 1.25),
+	 }
 };
 };
 
 
 enum { das800, ciodas800, das801, ciodas801, das802, ciodas802, ciodas80216 };
 enum { das800, ciodas800, das801, ciodas801, das802, ciodas802, ciodas80216 };
 
 
 static const struct das800_board das800_boards[] = {
 static const struct das800_board das800_boards[] = {
 	{
 	{
-	.name = "das-800",
-	.ai_speed = 25000,
-	.ai_range = &range_das800_ai,
-	.resolution = 12,
-		},
+	 .name = "das-800",
+	 .ai_speed = 25000,
+	 .ai_range = &range_das800_ai,
+	 .resolution = 12,
+	 },
 	{
 	{
-	.name = "cio-das800",
-	.ai_speed = 20000,
-	.ai_range = &range_das800_ai,
-	.resolution = 12,
-		},
+	 .name = "cio-das800",
+	 .ai_speed = 20000,
+	 .ai_range = &range_das800_ai,
+	 .resolution = 12,
+	 },
 	{
 	{
-	.name = "das-801",
-	.ai_speed = 25000,
-	.ai_range = &range_das801_ai,
-	.resolution = 12,
-		},
+	 .name = "das-801",
+	 .ai_speed = 25000,
+	 .ai_range = &range_das801_ai,
+	 .resolution = 12,
+	 },
 	{
 	{
-	.name = "cio-das801",
-	.ai_speed = 20000,
-	.ai_range = &range_cio_das801_ai,
-	.resolution = 12,
-		},
+	 .name = "cio-das801",
+	 .ai_speed = 20000,
+	 .ai_range = &range_cio_das801_ai,
+	 .resolution = 12,
+	 },
 	{
 	{
-	.name = "das-802",
-	.ai_speed = 25000,
-	.ai_range = &range_das802_ai,
-	.resolution = 12,
-		},
+	 .name = "das-802",
+	 .ai_speed = 25000,
+	 .ai_range = &range_das802_ai,
+	 .resolution = 12,
+	 },
 	{
 	{
-	.name = "cio-das802",
-	.ai_speed = 20000,
-	.ai_range = &range_das802_ai,
-	.resolution = 12,
-		},
+	 .name = "cio-das802",
+	 .ai_speed = 20000,
+	 .ai_range = &range_das802_ai,
+	 .resolution = 12,
+	 },
 	{
 	{
-	.name = "cio-das802/16",
-	.ai_speed = 10000,
-	.ai_range = &range_das80216_ai,
-	.resolution = 16,
-		},
+	 .name = "cio-das802/16",
+	 .ai_speed = 10000,
+	 .ai_range = &range_das80216_ai,
+	 .resolution = 16,
+	 },
 };
 };
 
 
 /*
 /*
@@ -243,7 +243,8 @@ struct das800_private {
 
 
 #define devpriv ((struct das800_private *)dev->private)
 #define devpriv ((struct das800_private *)dev->private)
 
 
-static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int das800_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int das800_detach(struct comedi_device *dev);
 static int das800_detach(struct comedi_device *dev);
 static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
 static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
 
 
@@ -260,15 +261,20 @@ static struct comedi_driver driver_das800 = {
 static irqreturn_t das800_interrupt(int irq, void *d);
 static irqreturn_t das800_interrupt(int irq, void *d);
 static void enable_das800(struct comedi_device *dev);
 static void enable_das800(struct comedi_device *dev);
 static void disable_das800(struct comedi_device *dev);
 static void disable_das800(struct comedi_device *dev);
-static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd);
-static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int das800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int das800_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int das800_ai_do_cmdtest(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_cmd *cmd);
+static int das800_ai_do_cmd(struct comedi_device *dev,
+			    struct comedi_subdevice *s);
+static int das800_ai_rinsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data);
+static int das800_di_rbits(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data);
+static int das800_do_wbits(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data);
 static int das800_probe(struct comedi_device *dev);
 static int das800_probe(struct comedi_device *dev);
 static int das800_set_frequency(struct comedi_device *dev);
 static int das800_set_frequency(struct comedi_device *dev);
 
 
@@ -330,7 +336,7 @@ static int das800_probe(struct comedi_device *dev)
 		break;
 		break;
 	default:
 	default:
 		printk(" Board model: probe returned 0x%x (unknown)\n",
 		printk(" Board model: probe returned 0x%x (unknown)\n",
-			id_bits);
+		       id_bits);
 		return board;
 		return board;
 		break;
 		break;
 	}
 	}
@@ -429,7 +435,7 @@ static irqreturn_t das800_interrupt(int irq, void *d)
 		 * We already have spinlock, so indirect addressing is safe */
 		 * We already have spinlock, so indirect addressing is safe */
 		outb(CONTROL1, dev->iobase + DAS800_GAIN);	/* select dev->iobase + 2 to be control register 1 */
 		outb(CONTROL1, dev->iobase + DAS800_GAIN);	/* select dev->iobase + 2 to be control register 1 */
 		outb(CONTROL1_INTE | devpriv->do_bits,
 		outb(CONTROL1_INTE | devpriv->do_bits,
-			dev->iobase + DAS800_CONTROL1);
+		     dev->iobase + DAS800_CONTROL1);
 		spin_unlock_irqrestore(&dev->spinlock, irq_flags);
 		spin_unlock_irqrestore(&dev->spinlock, irq_flags);
 		/* otherwise, stop taking data */
 		/* otherwise, stop taking data */
 	} else {
 	} else {
@@ -585,8 +591,9 @@ static void disable_das800(struct comedi_device *dev)
 	spin_unlock_irqrestore(&dev->spinlock, irq_flags);
 	spin_unlock_irqrestore(&dev->spinlock, irq_flags);
 }
 }
 
 
-static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int das800_ai_do_cmdtest(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -676,8 +683,9 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevi
 		tmp = cmd->convert_arg;
 		tmp = cmd->convert_arg;
 		/* calculate counter values that give desired timing */
 		/* calculate counter values that give desired timing */
 		i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
 		i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
-			&(devpriv->divisor2), &(cmd->convert_arg),
-			cmd->flags & TRIG_ROUND_MASK);
+					       &(devpriv->divisor2),
+					       &(cmd->convert_arg),
+					       cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->convert_arg)
 		if (tmp != cmd->convert_arg)
 			err++;
 			err++;
 	}
 	}
@@ -691,14 +699,14 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevi
 		startChan = CR_CHAN(cmd->chanlist[0]);
 		startChan = CR_CHAN(cmd->chanlist[0]);
 		for (i = 1; i < cmd->chanlist_len; i++) {
 		for (i = 1; i < cmd->chanlist_len; i++) {
 			if (CR_CHAN(cmd->chanlist[i]) !=
 			if (CR_CHAN(cmd->chanlist[i]) !=
-				(startChan + i) % N_CHAN_AI) {
+			    (startChan + i) % N_CHAN_AI) {
 				comedi_error(dev,
 				comedi_error(dev,
-					"entries in chanlist must be consecutive channels, counting upwards\n");
+					     "entries in chanlist must be consecutive channels, counting upwards\n");
 				err++;
 				err++;
 			}
 			}
 			if (CR_RANGE(cmd->chanlist[i]) != gain) {
 			if (CR_RANGE(cmd->chanlist[i]) != gain) {
 				comedi_error(dev,
 				comedi_error(dev,
-					"entries in chanlist must all have the same gain\n");
+					     "entries in chanlist must all have the same gain\n");
 				err++;
 				err++;
 			}
 			}
 		}
 		}
@@ -710,7 +718,8 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_subdevi
 	return 0;
 	return 0;
 }
 }
 
 
-static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int das800_ai_do_cmd(struct comedi_device *dev,
+			    struct comedi_subdevice *s)
 {
 {
 	int startChan, endChan, scan, gain;
 	int startChan, endChan, scan, gain;
 	int conv_bits;
 	int conv_bits;
@@ -719,7 +728,7 @@ static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *
 
 
 	if (!dev->irq) {
 	if (!dev->irq) {
 		comedi_error(dev,
 		comedi_error(dev,
-			"no irq assigned for das-800, cannot do hardware conversions");
+			     "no irq assigned for das-800, cannot do hardware conversions");
 		return -1;
 		return -1;
 	}
 	}
 
 
@@ -767,8 +776,10 @@ static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *
 		conv_bits |= CASC | ITE;
 		conv_bits |= CASC | ITE;
 		/* set conversion frequency */
 		/* set conversion frequency */
 		i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
 		i8253_cascade_ns_to_timer_2div(TIMER_BASE, &(devpriv->divisor1),
-			&(devpriv->divisor2), &(async->cmd.convert_arg),
-			async->cmd.flags & TRIG_ROUND_MASK);
+					       &(devpriv->divisor2),
+					       &(async->cmd.convert_arg),
+					       async->cmd.
+					       flags & TRIG_ROUND_MASK);
 		if (das800_set_frequency(dev) < 0) {
 		if (das800_set_frequency(dev) < 0) {
 			comedi_error(dev, "Error setting up counters");
 			comedi_error(dev, "Error setting up counters");
 			return -1;
 			return -1;
@@ -789,8 +800,9 @@ static int das800_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *
 	return 0;
 	return 0;
 }
 }
 
 
-static int das800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das800_ai_rinsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	int i, n;
 	int i, n;
 	int chan;
 	int chan;
@@ -843,8 +855,9 @@ static int das800_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
 	return n;
 	return n;
 }
 }
 
 
-static int das800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das800_di_rbits(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	unsigned int bits;
 	unsigned int bits;
 
 
@@ -856,8 +869,9 @@ static int das800_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s
 	return 2;
 	return 2;
 }
 }
 
 
-static int das800_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int das800_do_wbits(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	int wbits;
 	int wbits;
 	unsigned long irq_flags;
 	unsigned long irq_flags;

+ 81 - 63
drivers/staging/comedi/drivers/dmm32at.c

@@ -168,11 +168,11 @@ Configuration Options:
 static const struct comedi_lrange dmm32at_airanges = {
 static const struct comedi_lrange dmm32at_airanges = {
 	4,
 	4,
 	{
 	{
-			UNI_RANGE(10),
-			UNI_RANGE(5),
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-		}
+	 UNI_RANGE(10),
+	 UNI_RANGE(5),
+	 BIP_RANGE(10),
+	 BIP_RANGE(5),
+	 }
 };
 };
 
 
 /* register values for above ranges */
 /* register values for above ranges */
@@ -189,11 +189,11 @@ static const unsigned char dmm32at_rangebits[] = {
 static const struct comedi_lrange dmm32at_aoranges = {
 static const struct comedi_lrange dmm32at_aoranges = {
 	4,
 	4,
 	{
 	{
-			UNI_RANGE(10),
-			UNI_RANGE(5),
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-		}
+	 UNI_RANGE(10),
+	 UNI_RANGE(5),
+	 BIP_RANGE(10),
+	 BIP_RANGE(5),
+	 }
 };
 };
 
 
 /*
 /*
@@ -214,16 +214,16 @@ struct dmm32at_board {
 };
 };
 static const struct dmm32at_board dmm32at_boards[] = {
 static const struct dmm32at_board dmm32at_boards[] = {
 	{
 	{
-	.name = "dmm32at",
-	.ai_chans = 32,
-	.ai_bits = 16,
-	.ai_ranges = &dmm32at_airanges,
-	.ao_chans = 4,
-	.ao_bits = 12,
-	.ao_ranges = &dmm32at_aoranges,
-	.have_dio = 1,
-	.dio_chans = 24,
-		},
+	 .name = "dmm32at",
+	 .ai_chans = 32,
+	 .ai_bits = 16,
+	 .ai_ranges = &dmm32at_airanges,
+	 .ao_chans = 4,
+	 .ao_bits = 12,
+	 .ao_ranges = &dmm32at_aoranges,
+	 .have_dio = 1,
+	 .dio_chans = 24,
+	 },
 };
 };
 
 
 /*
 /*
@@ -259,7 +259,8 @@ struct dmm32at_private {
  * the board, and also about the kernel module that contains
  * the board, and also about the kernel module that contains
  * the device code.
  * the device code.
  */
  */
-static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dmm32at_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int dmm32at_detach(struct comedi_device *dev);
 static int dmm32at_detach(struct comedi_device *dev);
 static struct comedi_driver driver_dmm32at = {
 static struct comedi_driver driver_dmm32at = {
 	.driver_name = "dmm32at",
 	.driver_name = "dmm32at",
@@ -290,20 +291,29 @@ static struct comedi_driver driver_dmm32at = {
 };
 };
 
 
 /* prototypes for driver functions below */
 /* prototypes for driver functions below */
-static int dmm32at_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dmm32at_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dmm32at_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dmm32at_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dmm32at_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd);
-static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int dmm32at_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int dmm32at_ai_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int dmm32at_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int dmm32at_ao_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int dmm32at_dio_insn_bits(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data);
+static int dmm32at_dio_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn,
+				   unsigned int *data);
+static int dmm32at_ai_cmdtest(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_cmd *cmd);
+static int dmm32at_ai_cmd(struct comedi_device *dev,
+			  struct comedi_subdevice *s);
+static int dmm32at_ai_cancel(struct comedi_device *dev,
+			     struct comedi_subdevice *s);
 static int dmm32at_ns_to_timer(unsigned int *ns, int round);
 static int dmm32at_ns_to_timer(unsigned int *ns, int round);
 static irqreturn_t dmm32at_isr(int irq, void *d);
 static irqreturn_t dmm32at_isr(int irq, void *d);
 void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec);
 void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec);
@@ -314,7 +324,8 @@ void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec);
  * in the driver structure, dev->board_ptr contains that
  * in the driver structure, dev->board_ptr contains that
  * address.
  * address.
  */
  */
-static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int dmm32at_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	int ret;
 	int ret;
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
@@ -369,12 +380,12 @@ static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	airback = dmm_inb(dev, DMM32AT_AIRBACK);
 	airback = dmm_inb(dev, DMM32AT_AIRBACK);
 
 
 	printk("dmm32at: lo=0x%02x hi=0x%02x fifostat=0x%02x\n",
 	printk("dmm32at: lo=0x%02x hi=0x%02x fifostat=0x%02x\n",
-		ailo, aihi, fifostat);
+	       ailo, aihi, fifostat);
 	printk("dmm32at: aistat=0x%02x intstat=0x%02x airback=0x%02x\n",
 	printk("dmm32at: aistat=0x%02x intstat=0x%02x airback=0x%02x\n",
-		aistat, intstat, airback);
+	       aistat, intstat, airback);
 
 
 	if ((ailo != 0x00) || (aihi != 0x1f) || (fifostat != 0x80) ||
 	if ((ailo != 0x00) || (aihi != 0x1f) || (fifostat != 0x80) ||
-		(aistat != 0x60 || (intstat != 0x00) || airback != 0x0c)) {
+	    (aistat != 0x60 || (intstat != 0x00) || airback != 0x0c)) {
 		printk("dmmat32: board detection failed\n");
 		printk("dmmat32: board detection failed\n");
 		return -EIO;
 		return -EIO;
 	}
 	}
@@ -450,7 +461,7 @@ static int dmm32at_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_DIOACC);
 		dmm_outb(dev, DMM32AT_CNTRL, DMM32AT_DIOACC);
 		/* set the DIO's to the defualt input setting */
 		/* set the DIO's to the defualt input setting */
 		devpriv->dio_config = DMM32AT_DIRA | DMM32AT_DIRB |
 		devpriv->dio_config = DMM32AT_DIRA | DMM32AT_DIRB |
-			DMM32AT_DIRCL | DMM32AT_DIRCH | DMM32AT_DIENABLE;
+		    DMM32AT_DIRCL | DMM32AT_DIRCH | DMM32AT_DIENABLE;
 		dmm_outb(dev, DMM32AT_DIOCONF, devpriv->dio_config);
 		dmm_outb(dev, DMM32AT_DIOCONF, devpriv->dio_config);
 
 
 		/* set up the subdevice */
 		/* set up the subdevice */
@@ -497,8 +508,9 @@ static int dmm32at_detach(struct comedi_device *dev)
  * mode.
  * mode.
  */
  */
 
 
-static int dmm32at_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dmm32at_ai_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, i;
 	int n, i;
 	unsigned int d;
 	unsigned int d;
@@ -568,8 +580,9 @@ static int dmm32at_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *
 	return n;
 	return n;
 }
 }
 
 
-static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int dmm32at_ai_cmdtest(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -618,7 +631,7 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 
 
 	/* note that mutual compatiblity is not an issue here */
 	/* note that mutual compatiblity is not an issue here */
 	if (cmd->scan_begin_src != TRIG_TIMER &&
 	if (cmd->scan_begin_src != TRIG_TIMER &&
-		cmd->scan_begin_src != TRIG_EXT)
+	    cmd->scan_begin_src != TRIG_EXT)
 		err++;
 		err++;
 	if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
 	if (cmd->convert_src != TRIG_TIMER && cmd->convert_src != TRIG_EXT)
 		err++;
 		err++;
@@ -703,21 +716,21 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		tmp = cmd->scan_begin_arg;
 		tmp = cmd->scan_begin_arg;
 		dmm32at_ns_to_timer(&cmd->scan_begin_arg,
 		dmm32at_ns_to_timer(&cmd->scan_begin_arg,
-			cmd->flags & TRIG_ROUND_MASK);
+				    cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->scan_begin_arg)
 		if (tmp != cmd->scan_begin_arg)
 			err++;
 			err++;
 	}
 	}
 	if (cmd->convert_src == TRIG_TIMER) {
 	if (cmd->convert_src == TRIG_TIMER) {
 		tmp = cmd->convert_arg;
 		tmp = cmd->convert_arg;
 		dmm32at_ns_to_timer(&cmd->convert_arg,
 		dmm32at_ns_to_timer(&cmd->convert_arg,
-			cmd->flags & TRIG_ROUND_MASK);
+				    cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->convert_arg)
 		if (tmp != cmd->convert_arg)
 			err++;
 			err++;
 		if (cmd->scan_begin_src == TRIG_TIMER &&
 		if (cmd->scan_begin_src == TRIG_TIMER &&
-			cmd->scan_begin_arg <
-			cmd->convert_arg * cmd->scan_end_arg) {
+		    cmd->scan_begin_arg <
+		    cmd->convert_arg * cmd->scan_end_arg) {
 			cmd->scan_begin_arg =
 			cmd->scan_begin_arg =
-				cmd->convert_arg * cmd->scan_end_arg;
+			    cmd->convert_arg * cmd->scan_end_arg;
 			err++;
 			err++;
 		}
 		}
 	}
 	}
@@ -733,14 +746,14 @@ static int dmm32at_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 		start_chan = CR_CHAN(cmd->chanlist[0]);
 		start_chan = CR_CHAN(cmd->chanlist[0]);
 		for (i = 1; i < cmd->chanlist_len; i++) {
 		for (i = 1; i < cmd->chanlist_len; i++) {
 			if (CR_CHAN(cmd->chanlist[i]) !=
 			if (CR_CHAN(cmd->chanlist[i]) !=
-				(start_chan + i) % s->n_chan) {
+			    (start_chan + i) % s->n_chan) {
 				comedi_error(dev,
 				comedi_error(dev,
-					"entries in chanlist must be consecutive channels, counting upwards\n");
+					     "entries in chanlist must be consecutive channels, counting upwards\n");
 				err++;
 				err++;
 			}
 			}
 			if (CR_RANGE(cmd->chanlist[i]) != gain) {
 			if (CR_RANGE(cmd->chanlist[i]) != gain) {
 				comedi_error(dev,
 				comedi_error(dev,
-					"entries in chanlist must all have the same gain\n");
+					     "entries in chanlist must all have the same gain\n");
 				err++;
 				err++;
 			}
 			}
 		}
 		}
@@ -822,7 +835,8 @@ static int dmm32at_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
 
 }
 }
 
 
-static int dmm32at_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int dmm32at_ai_cancel(struct comedi_device *dev,
+			     struct comedi_subdevice *s)
 {
 {
 	devpriv->ai_scans_left = 1;
 	devpriv->ai_scans_left = 1;
 	return 0;
 	return 0;
@@ -893,8 +907,9 @@ static int dmm32at_ns_to_timer(unsigned int *ns, int round)
 	return *ns;
 	return *ns;
 }
 }
 
 
-static int dmm32at_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dmm32at_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -936,8 +951,9 @@ static int dmm32at_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *
 
 
 /* AO subdevices should have a read insn as well as a write insn.
 /* AO subdevices should have a read insn as well as a write insn.
  * Usually this means copying a value stored in devpriv. */
  * Usually this means copying a value stored in devpriv. */
-static int dmm32at_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dmm32at_ao_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -953,8 +969,9 @@ static int dmm32at_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *
  * useful to applications if you implement the insn_bits interface.
  * useful to applications if you implement the insn_bits interface.
  * This allows packed reading/writing of the DIO channels.  The
  * This allows packed reading/writing of the DIO channels.  The
  * comedi core can convert between insn_bits and insn_read/write */
  * comedi core can convert between insn_bits and insn_read/write */
-static int dmm32at_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dmm32at_dio_insn_bits(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned char diobits;
 	unsigned char diobits;
 
 
@@ -975,7 +992,7 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
 
 
 	/* if either part of dio is set for output */
 	/* if either part of dio is set for output */
 	if (((devpriv->dio_config & DMM32AT_DIRCL) == 0) ||
 	if (((devpriv->dio_config & DMM32AT_DIRCL) == 0) ||
-		((devpriv->dio_config & DMM32AT_DIRCH) == 0)) {
+	    ((devpriv->dio_config & DMM32AT_DIRCH) == 0)) {
 		diobits = (s->state & 0x00ff0000) >> 16;
 		diobits = (s->state & 0x00ff0000) >> 16;
 		dmm_outb(dev, DMM32AT_DIOC, diobits);
 		dmm_outb(dev, DMM32AT_DIOC, diobits);
 	}
 	}
@@ -1006,8 +1023,9 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
 	return 2;
 	return 2;
 }
 }
 
 
-static int dmm32at_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dmm32at_dio_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned char chanbit;
 	unsigned char chanbit;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);

+ 137 - 105
drivers/staging/comedi/drivers/dt2801.c

@@ -88,7 +88,8 @@ Configuration options:
 #define DT2801_STATUS		1
 #define DT2801_STATUS		1
 #define DT2801_CMD		1
 #define DT2801_CMD		1
 
 
-static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt2801_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int dt2801_detach(struct comedi_device *dev);
 static int dt2801_detach(struct comedi_device *dev);
 static struct comedi_driver driver_dt2801 = {
 static struct comedi_driver driver_dt2801 = {
 	.driver_name = "dt2801",
 	.driver_name = "dt2801",
@@ -102,37 +103,57 @@ COMEDI_INITCLEANUP(driver_dt2801);
 #if 0
 #if 0
 /* ignore 'defined but not used' warning */
 /* ignore 'defined but not used' warning */
 static const struct comedi_lrange range_dt2801_ai_pgh_bipolar = { 4, {
 static const struct comedi_lrange range_dt2801_ai_pgh_bipolar = { 4, {
-			RANGE(-10, 10),
-			RANGE(-5, 5),
-			RANGE(-2.5, 2.5),
-			RANGE(-1.25, 1.25),
-	}
+								      RANGE(-10,
+									    10),
+								      RANGE(-5,
+									    5),
+								      RANGE
+								      (-2.5,
+								       2.5),
+								      RANGE
+								      (-1.25,
+								       1.25),
+								      }
 };
 };
 #endif
 #endif
 static const struct comedi_lrange range_dt2801_ai_pgl_bipolar = { 4, {
 static const struct comedi_lrange range_dt2801_ai_pgl_bipolar = { 4, {
-			RANGE(-10, 10),
-			RANGE(-1, 1),
-			RANGE(-0.1, 0.1),
-			RANGE(-0.02, 0.02),
-	}
+								      RANGE(-10,
+									    10),
+								      RANGE(-1,
+									    1),
+								      RANGE
+								      (-0.1,
+								       0.1),
+								      RANGE
+								      (-0.02,
+								       0.02),
+								      }
 };
 };
 
 
 #if 0
 #if 0
 /* ignore 'defined but not used' warning */
 /* ignore 'defined but not used' warning */
 static const struct comedi_lrange range_dt2801_ai_pgh_unipolar = { 4, {
 static const struct comedi_lrange range_dt2801_ai_pgh_unipolar = { 4, {
-			RANGE(0, 10),
-			RANGE(0, 5),
-			RANGE(0, 2.5),
-			RANGE(0, 1.25),
-	}
+								       RANGE(0,
+									     10),
+								       RANGE(0,
+									     5),
+								       RANGE(0,
+									     2.5),
+								       RANGE(0,
+									     1.25),
+								       }
 };
 };
 #endif
 #endif
 static const struct comedi_lrange range_dt2801_ai_pgl_unipolar = { 4, {
 static const struct comedi_lrange range_dt2801_ai_pgl_unipolar = { 4, {
-			RANGE(0, 10),
-			RANGE(0, 1),
-			RANGE(0, 0.1),
-			RANGE(0, 0.02),
-	}
+								       RANGE(0,
+									     10),
+								       RANGE(0,
+									     1),
+								       RANGE(0,
+									     0.1),
+								       RANGE(0,
+									     0.02),
+								       }
 };
 };
 
 
 struct dt2801_board {
 struct dt2801_board {
@@ -146,75 +167,74 @@ struct dt2801_board {
 	int dabits;
 	int dabits;
 };
 };
 
 
-
 /* Typeid's for the different boards of the DT2801-series
 /* Typeid's for the different boards of the DT2801-series
    (taken from the test-software, that comes with the board)
    (taken from the test-software, that comes with the board)
    */
    */
 static const struct dt2801_board boardtypes[] = {
 static const struct dt2801_board boardtypes[] = {
 	{
 	{
-	.name = "dt2801",
-	.boardcode = 0x09,
-	.ad_diff = 2,
-	.ad_chan = 16,
-	.adbits = 12,
-	.adrangetype = 0,
-	.dabits = 12},
+	 .name = "dt2801",
+	 .boardcode = 0x09,
+	 .ad_diff = 2,
+	 .ad_chan = 16,
+	 .adbits = 12,
+	 .adrangetype = 0,
+	 .dabits = 12},
 	{
 	{
-	.name = "dt2801-a",
-	.boardcode = 0x52,
-	.ad_diff = 2,
-	.ad_chan = 16,
-	.adbits = 12,
-	.adrangetype = 0,
-	.dabits = 12},
+	 .name = "dt2801-a",
+	 .boardcode = 0x52,
+	 .ad_diff = 2,
+	 .ad_chan = 16,
+	 .adbits = 12,
+	 .adrangetype = 0,
+	 .dabits = 12},
 	{
 	{
-	.name = "dt2801/5716a",
-	.boardcode = 0x82,
-	.ad_diff = 1,
-	.ad_chan = 16,
-	.adbits = 16,
-	.adrangetype = 1,
-	.dabits = 12},
+	 .name = "dt2801/5716a",
+	 .boardcode = 0x82,
+	 .ad_diff = 1,
+	 .ad_chan = 16,
+	 .adbits = 16,
+	 .adrangetype = 1,
+	 .dabits = 12},
 	{
 	{
-	.name = "dt2805",
-	.boardcode = 0x12,
-	.ad_diff = 1,
-	.ad_chan = 16,
-	.adbits = 12,
-	.adrangetype = 0,
-	.dabits = 12},
+	 .name = "dt2805",
+	 .boardcode = 0x12,
+	 .ad_diff = 1,
+	 .ad_chan = 16,
+	 .adbits = 12,
+	 .adrangetype = 0,
+	 .dabits = 12},
 	{
 	{
-	.name = "dt2805/5716a",
-	.boardcode = 0x92,
-	.ad_diff = 1,
-	.ad_chan = 16,
-	.adbits = 16,
-	.adrangetype = 1,
-	.dabits = 12},
+	 .name = "dt2805/5716a",
+	 .boardcode = 0x92,
+	 .ad_diff = 1,
+	 .ad_chan = 16,
+	 .adbits = 16,
+	 .adrangetype = 1,
+	 .dabits = 12},
 	{
 	{
-	.name = "dt2808",
-	.boardcode = 0x20,
-	.ad_diff = 0,
-	.ad_chan = 16,
-	.adbits = 12,
-	.adrangetype = 2,
-	.dabits = 8},
+	 .name = "dt2808",
+	 .boardcode = 0x20,
+	 .ad_diff = 0,
+	 .ad_chan = 16,
+	 .adbits = 12,
+	 .adrangetype = 2,
+	 .dabits = 8},
 	{
 	{
-	.name = "dt2818",
-	.boardcode = 0xa2,
-	.ad_diff = 0,
-	.ad_chan = 4,
-	.adbits = 12,
-	.adrangetype = 0,
-	.dabits = 12},
+	 .name = "dt2818",
+	 .boardcode = 0xa2,
+	 .ad_diff = 0,
+	 .ad_chan = 4,
+	 .adbits = 12,
+	 .adrangetype = 0,
+	 .dabits = 12},
 	{
 	{
-	.name = "dt2809",
-	.boardcode = 0xb0,
-	.ad_diff = 0,
-	.ad_chan = 8,
-	.adbits = 12,
-	.adrangetype = 1,
-	.dabits = 12},
+	 .name = "dt2809",
+	 .boardcode = 0xb0,
+	 .ad_diff = 0,
+	 .ad_chan = 8,
+	 .adbits = 12,
+	 .adrangetype = 1,
+	 .dabits = 12},
 };
 };
 
 
 #define boardtype (*(const struct dt2801_board *)dev->board_ptr)
 #define boardtype (*(const struct dt2801_board *)dev->board_ptr)
@@ -227,16 +247,21 @@ struct dt2801_private {
 
 
 #define devpriv ((struct dt2801_private *)dev->private)
 #define devpriv ((struct dt2801_private *)dev->private)
 
 
-static int dt2801_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dt2801_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dt2801_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dt2801_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dt2801_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int dt2801_ai_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
+static int dt2801_ao_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
+static int dt2801_ao_insn_write(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data);
+static int dt2801_dio_insn_bits(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data);
+static int dt2801_dio_insn_config(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data);
 
 
 /* These are the low-level routines:
 /* These are the low-level routines:
    writecommand: write a command to the board
    writecommand: write a command to the board
@@ -299,7 +324,8 @@ static int dt2801_writedata(struct comedi_device *dev, unsigned int data)
 		}
 		}
 #if 0
 #if 0
 		if (stat & DT_S_READY) {
 		if (stat & DT_S_READY) {
-			printk("dt2801: ready flag set (bad!) in dt2801_writedata()\n");
+			printk
+			    ("dt2801: ready flag set (bad!) in dt2801_writedata()\n");
 			return -EIO;
 			return -EIO;
 		}
 		}
 #endif
 #endif
@@ -353,7 +379,8 @@ static int dt2801_writecmd(struct comedi_device *dev, int command)
 
 
 	stat = inb_p(dev->iobase + DT2801_STATUS);
 	stat = inb_p(dev->iobase + DT2801_STATUS);
 	if (stat & DT_S_COMPOSITE_ERROR) {
 	if (stat & DT_S_COMPOSITE_ERROR) {
-		printk("dt2801: composite-error in dt2801_writecmd(), ignoring\n");
+		printk
+		    ("dt2801: composite-error in dt2801_writecmd(), ignoring\n");
 	}
 	}
 	if (!(stat & DT_S_READY)) {
 	if (!(stat & DT_S_READY)) {
 		printk("dt2801: !ready in dt2801_writecmd(), ignoring\n");
 		printk("dt2801: !ready in dt2801_writecmd(), ignoring\n");
@@ -463,8 +490,8 @@ static const struct comedi_lrange *ai_range_lkup(int type, int opt)
 	switch (type) {
 	switch (type) {
 	case 0:
 	case 0:
 		return (opt) ?
 		return (opt) ?
-			&range_dt2801_ai_pgl_unipolar :
-			&range_dt2801_ai_pgl_bipolar;
+		    &range_dt2801_ai_pgl_unipolar :
+		    &range_dt2801_ai_pgl_bipolar;
 	case 1:
 	case 1:
 		return (opt) ? &range_unipolar10 : &range_bipolar10;
 		return (opt) ? &range_unipolar10 : &range_bipolar10;
 	case 2:
 	case 2:
@@ -510,10 +537,10 @@ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 			goto havetype;
 			goto havetype;
 	}
 	}
 	printk("dt2801: unrecognized board code=0x%02x, contact author\n",
 	printk("dt2801: unrecognized board code=0x%02x, contact author\n",
-		board_code);
+	       board_code);
 	type = 0;
 	type = 0;
 
 
-      havetype:
+havetype:
 	dev->board_ptr = boardtypes + type;
 	dev->board_ptr = boardtypes + type;
 	printk("dt2801: %s at port 0x%lx", boardtype.name, iobase);
 	printk("dt2801: %s at port 0x%lx", boardtype.name, iobase);
 
 
@@ -579,7 +606,7 @@ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	s->insn_config = dt2801_dio_insn_config;
 	s->insn_config = dt2801_dio_insn_config;
 
 
 	ret = 0;
 	ret = 0;
-      out:
+out:
 	printk("\n");
 	printk("\n");
 
 
 	return ret;
 	return ret;
@@ -611,8 +638,9 @@ static int dt2801_error(struct comedi_device *dev, int stat)
 	return -EIO;
 	return -EIO;
 }
 }
 
 
-static int dt2801_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2801_ai_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int d;
 	int d;
 	int stat;
 	int stat;
@@ -633,16 +661,18 @@ static int dt2801_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
 	return i;
 	return i;
 }
 }
 
 
-static int dt2801_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2801_ao_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	data[0] = devpriv->ao_readback[CR_CHAN(insn->chanspec)];
 	data[0] = devpriv->ao_readback[CR_CHAN(insn->chanspec)];
 
 
 	return 1;
 	return 1;
 }
 }
 
 
-static int dt2801_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2801_ao_insn_write(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	dt2801_writecmd(dev, DT_C_WRITE_DAIM);
 	dt2801_writecmd(dev, DT_C_WRITE_DAIM);
 	dt2801_writedata(dev, CR_CHAN(insn->chanspec));
 	dt2801_writedata(dev, CR_CHAN(insn->chanspec));
@@ -653,8 +683,9 @@ static int dt2801_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
 	return 1;
 	return 1;
 }
 }
 
 
-static int dt2801_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2801_dio_insn_bits(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int which = 0;
 	int which = 0;
 
 
@@ -677,8 +708,9 @@ static int dt2801_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
 	return 2;
 	return 2;
 }
 }
 
 
-static int dt2801_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2801_dio_insn_config(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int which = 0;
 	int which = 0;
 
 

+ 117 - 61
drivers/staging/comedi/drivers/dt2811.c

@@ -53,46 +53,95 @@ Configuration options:
 static const char *driver_name = "dt2811";
 static const char *driver_name = "dt2811";
 
 
 static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, {
 static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, {
-			RANGE(0, 5),
-			RANGE(0, 2.5),
-			RANGE(0, 1.25),
-			RANGE(0, 0.625)
-	}
+									 RANGE
+									 (0, 5),
+									 RANGE
+									 (0,
+									  2.5),
+									 RANGE
+									 (0,
+									  1.25),
+									 RANGE
+									 (0,
+									  0.625)
+									 }
 };
 };
+
 static const struct comedi_lrange range_dt2811_pgh_ai_2_5_bipolar = { 4, {
 static const struct comedi_lrange range_dt2811_pgh_ai_2_5_bipolar = { 4, {
-			RANGE(-2.5, 2.5),
-			RANGE(-1.25, 1.25),
-			RANGE(-0.625, 0.625),
-			RANGE(-0.3125, 0.3125)
-	}
+									  RANGE
+									  (-2.5,
+									   2.5),
+									  RANGE
+									  (-1.25,
+									   1.25),
+									  RANGE
+									  (-0.625,
+									   0.625),
+									  RANGE
+									  (-0.3125,
+									   0.3125)
+									  }
 };
 };
+
 static const struct comedi_lrange range_dt2811_pgh_ai_5_bipolar = { 4, {
 static const struct comedi_lrange range_dt2811_pgh_ai_5_bipolar = { 4, {
-			RANGE(-5, 5),
-			RANGE(-2.5, 2.5),
-			RANGE(-1.25, 1.25),
-			RANGE(-0.625, 0.625)
-	}
+									RANGE
+									(-5, 5),
+									RANGE
+									(-2.5,
+									 2.5),
+									RANGE
+									(-1.25,
+									 1.25),
+									RANGE
+									(-0.625,
+									 0.625)
+									}
 };
 };
+
 static const struct comedi_lrange range_dt2811_pgl_ai_5_unipolar = { 4, {
 static const struct comedi_lrange range_dt2811_pgl_ai_5_unipolar = { 4, {
-			RANGE(0, 5),
-			RANGE(0, 0.5),
-			RANGE(0, 0.05),
-			RANGE(0, 0.01)
-	}
+									 RANGE
+									 (0, 5),
+									 RANGE
+									 (0,
+									  0.5),
+									 RANGE
+									 (0,
+									  0.05),
+									 RANGE
+									 (0,
+									  0.01)
+									 }
 };
 };
+
 static const struct comedi_lrange range_dt2811_pgl_ai_2_5_bipolar = { 4, {
 static const struct comedi_lrange range_dt2811_pgl_ai_2_5_bipolar = { 4, {
-			RANGE(-2.5, 2.5),
-			RANGE(-0.25, 0.25),
-			RANGE(-0.025, 0.025),
-			RANGE(-0.005, 0.005)
-	}
+									  RANGE
+									  (-2.5,
+									   2.5),
+									  RANGE
+									  (-0.25,
+									   0.25),
+									  RANGE
+									  (-0.025,
+									   0.025),
+									  RANGE
+									  (-0.005,
+									   0.005)
+									  }
 };
 };
+
 static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { 4, {
 static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { 4, {
-			RANGE(-5, 5),
-			RANGE(-0.5, 0.5),
-			RANGE(-0.05, 0.05),
-			RANGE(-0.01, 0.01)
-	}
+									RANGE
+									(-5, 5),
+									RANGE
+									(-0.5,
+									 0.5),
+									RANGE
+									(-0.05,
+									 0.05),
+									RANGE
+									(-0.01,
+									 0.01)
+									}
 };
 };
 
 
 /*
 /*
@@ -202,20 +251,21 @@ struct dt2811_board {
 
 
 static const struct dt2811_board boardtypes[] = {
 static const struct dt2811_board boardtypes[] = {
 	{"dt2811-pgh",
 	{"dt2811-pgh",
-			&range_dt2811_pgh_ai_5_bipolar,
-			&range_dt2811_pgh_ai_2_5_bipolar,
-			&range_dt2811_pgh_ai_5_unipolar,
-		},
+	 &range_dt2811_pgh_ai_5_bipolar,
+	 &range_dt2811_pgh_ai_2_5_bipolar,
+	 &range_dt2811_pgh_ai_5_unipolar,
+	 },
 	{"dt2811-pgl",
 	{"dt2811-pgl",
-			&range_dt2811_pgl_ai_5_bipolar,
-			&range_dt2811_pgl_ai_2_5_bipolar,
-			&range_dt2811_pgl_ai_5_unipolar,
-		},
+	 &range_dt2811_pgl_ai_5_bipolar,
+	 &range_dt2811_pgl_ai_2_5_bipolar,
+	 &range_dt2811_pgl_ai_5_unipolar,
+	 },
 };
 };
 
 
 #define this_board ((const struct dt2811_board *)dev->board_ptr)
 #define this_board ((const struct dt2811_board *)dev->board_ptr)
 
 
-static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt2811_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int dt2811_detach(struct comedi_device *dev);
 static int dt2811_detach(struct comedi_device *dev);
 static struct comedi_driver driver_dt2811 = {
 static struct comedi_driver driver_dt2811 = {
 	.driver_name = "dt2811",
 	.driver_name = "dt2811",
@@ -230,15 +280,18 @@ static struct comedi_driver driver_dt2811 = {
 COMEDI_INITCLEANUP(driver_dt2811);
 COMEDI_INITCLEANUP(driver_dt2811);
 
 
 static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+			  struct comedi_insn *insn, unsigned int *data);
 static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dt2811_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dt2811_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int dt2811_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+			  struct comedi_insn *insn, unsigned int *data);
+static int dt2811_ao_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
+static int dt2811_di_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
+static int dt2811_do_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
 
 
 enum { card_2811_pgh, card_2811_pgl };
 enum { card_2811_pgh, card_2811_pgl };
 
 
@@ -349,7 +402,7 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		irqs = probe_irq_on();
 		irqs = probe_irq_on();
 
 
 		outb(DT2811_CLRERROR | DT2811_INTENB,
 		outb(DT2811_CLRERROR | DT2811_INTENB,
-			dev->iobase + DT2811_ADCSR);
+		     dev->iobase + DT2811_ADCSR);
 		outb(0, dev->iobase + DT2811_ADGCR);
 		outb(0, dev->iobase + DT2811_ADGCR);
 
 
 		udelay(100);
 		udelay(100);
@@ -368,7 +421,7 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 			i = inb(dev->iobase + DT2811_ADDATHI);
 			i = inb(dev->iobase + DT2811_ADDATHI);
 			printk("(irq = %d)\n", irq);
 			printk("(irq = %d)\n", irq);
 			ret = request_irq(irq, dt2811_interrupt, 0,
 			ret = request_irq(irq, dt2811_interrupt, 0,
-				driver_name, dev);
+					  driver_name, dev);
 			if (ret < 0)
 			if (ret < 0)
 				return -EIO;
 				return -EIO;
 			dev->irq = irq;
 			dev->irq = irq;
@@ -500,7 +553,7 @@ static int dt2811_detach(struct comedi_device *dev)
 }
 }
 
 
 static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
 	int timeout = DT2811_TIMEOUT;
 	int timeout = DT2811_TIMEOUT;
@@ -510,7 +563,7 @@ static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 		outb(chan, dev->iobase + DT2811_ADGCR);
 		outb(chan, dev->iobase + DT2811_ADGCR);
 
 
 		while (timeout
 		while (timeout
-			&& inb(dev->iobase + DT2811_ADCSR) & DT2811_ADBUSY)
+		       && inb(dev->iobase + DT2811_ADCSR) & DT2811_ADBUSY)
 			timeout--;
 			timeout--;
 		if (!timeout)
 		if (!timeout)
 			return -ETIME;
 			return -ETIME;
@@ -526,7 +579,7 @@ static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 #if 0
 #if 0
 /* Wow.  This is code from the Comedi stone age.  But it hasn't been
 /* Wow.  This is code from the Comedi stone age.  But it hasn't been
  * replaced, so I'll let it stay. */
  * replaced, so I'll let it stay. */
-int dt2811_adtrig(kdev_t minor, comedi_adtrig *adtrig)
+int dt2811_adtrig(kdev_t minor, comedi_adtrig * adtrig)
 {
 {
 	struct comedi_device *dev = comedi_devices + minor;
 	struct comedi_device *dev = comedi_devices + minor;
 
 
@@ -537,7 +590,7 @@ int dt2811_adtrig(kdev_t minor, comedi_adtrig *adtrig)
 	case COMEDI_MDEMAND:
 	case COMEDI_MDEMAND:
 		dev->ntrig = adtrig->n - 1;
 		dev->ntrig = adtrig->n - 1;
 		/*printk("dt2811: AD soft trigger\n"); */
 		/*printk("dt2811: AD soft trigger\n"); */
-		/*outb(DT2811_CLRERROR|DT2811_INTENB,dev->iobase+DT2811_ADCSR); */ /* not neccessary */
+		/*outb(DT2811_CLRERROR|DT2811_INTENB,dev->iobase+DT2811_ADCSR); *//* not neccessary */
 		outb(dev->curadchan, dev->iobase + DT2811_ADGCR);
 		outb(dev->curadchan, dev->iobase + DT2811_ADGCR);
 		do_gettimeofday(&trigtime);
 		do_gettimeofday(&trigtime);
 		break;
 		break;
@@ -551,7 +604,7 @@ int dt2811_adtrig(kdev_t minor, comedi_adtrig *adtrig)
 #endif
 #endif
 
 
 static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan;
 	int chan;
@@ -561,15 +614,16 @@ static int dt2811_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 	for (i = 0; i < insn->n; i++) {
 	for (i = 0; i < insn->n; i++) {
 		outb(data[i] & 0xff, dev->iobase + DT2811_DADAT0LO + 2 * chan);
 		outb(data[i] & 0xff, dev->iobase + DT2811_DADAT0LO + 2 * chan);
 		outb((data[i] >> 8) & 0xff,
 		outb((data[i] >> 8) & 0xff,
-			dev->iobase + DT2811_DADAT0HI + 2 * chan);
+		     dev->iobase + DT2811_DADAT0HI + 2 * chan);
 		devpriv->ao_readback[chan] = data[i];
 		devpriv->ao_readback[chan] = data[i];
 	}
 	}
 
 
 	return i;
 	return i;
 }
 }
 
 
-static int dt2811_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2811_ao_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan;
 	int chan;
@@ -583,8 +637,9 @@ static int dt2811_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
 	return i;
 	return i;
 }
 }
 
 
-static int dt2811_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2811_di_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -594,8 +649,9 @@ static int dt2811_di_insn_bits(struct comedi_device *dev, struct comedi_subdevic
 	return 2;
 	return 2;
 }
 }
 
 
-static int dt2811_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2811_do_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;

+ 9 - 7
drivers/staging/comedi/drivers/dt2814.c

@@ -60,7 +60,8 @@ addition, the clock does not seem to be very accurate.
 #define DT2814_ENB 0x10
 #define DT2814_ENB 0x10
 #define DT2814_CHANMASK 0x0f
 #define DT2814_CHANMASK 0x0f
 
 
-static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt2814_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int dt2814_detach(struct comedi_device *dev);
 static int dt2814_detach(struct comedi_device *dev);
 static struct comedi_driver driver_dt2814 = {
 static struct comedi_driver driver_dt2814 = {
 	.driver_name = "dt2814",
 	.driver_name = "dt2814",
@@ -84,8 +85,9 @@ struct dt2814_private {
 #define DT2814_TIMEOUT 10
 #define DT2814_TIMEOUT 10
 #define DT2814_MAX_SPEED 100000	/* Arbitrary 10 khz limit */
 #define DT2814_MAX_SPEED 100000	/* Arbitrary 10 khz limit */
 
 
-static int dt2814_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2814_ai_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, i, hi, lo;
 	int n, i, hi, lo;
 	int chan;
 	int chan;
@@ -135,8 +137,8 @@ static int dt2814_ns_to_timer(unsigned int *ns, unsigned int flags)
 	return i;
 	return i;
 }
 }
 
 
-static int dt2814_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int dt2814_ai_cmdtest(struct comedi_device *dev,
+			     struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -234,8 +236,8 @@ static int dt2814_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	int trigvar;
 	int trigvar;
 
 
 	trigvar =
 	trigvar =
-		dt2814_ns_to_timer(&cmd->scan_begin_arg,
-		cmd->flags & TRIG_ROUND_MASK);
+	    dt2814_ns_to_timer(&cmd->scan_begin_arg,
+			       cmd->flags & TRIG_ROUND_MASK);
 
 
 	chan = CR_CHAN(cmd->chanlist[0]);
 	chan = CR_CHAN(cmd->chanlist[0]);
 
 

+ 21 - 17
drivers/staging/comedi/drivers/dt2815.c

@@ -62,12 +62,15 @@ Configuration options:
 #include <linux/delay.h>
 #include <linux/delay.h>
 
 
 static const struct comedi_lrange range_dt2815_ao_32_current = { 1, {
 static const struct comedi_lrange range_dt2815_ao_32_current = { 1, {
-			RANGE_mA(0, 32)
-	}
+								     RANGE_mA(0,
+									      32)
+								     }
 };
 };
+
 static const struct comedi_lrange range_dt2815_ao_20_current = { 1, {
 static const struct comedi_lrange range_dt2815_ao_20_current = { 1, {
-			RANGE_mA(4, 20)
-	}
+								     RANGE_mA(4,
+									      20)
+								     }
 };
 };
 
 
 #define DT2815_SIZE 2
 #define DT2815_SIZE 2
@@ -75,7 +78,8 @@ static const struct comedi_lrange range_dt2815_ao_20_current = { 1, {
 #define DT2815_DATA 0
 #define DT2815_DATA 0
 #define DT2815_STATUS 1
 #define DT2815_STATUS 1
 
 
-static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt2815_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int dt2815_detach(struct comedi_device *dev);
 static int dt2815_detach(struct comedi_device *dev);
 static struct comedi_driver driver_dt2815 = {
 static struct comedi_driver driver_dt2815 = {
 	.driver_name = "dt2815",
 	.driver_name = "dt2815",
@@ -94,7 +98,6 @@ struct dt2815_private {
 	unsigned int ao_readback[8];
 	unsigned int ao_readback[8];
 };
 };
 
 
-
 #define devpriv ((struct dt2815_private *)dev->private)
 #define devpriv ((struct dt2815_private *)dev->private)
 
 
 static int dt2815_wait_for_status(struct comedi_device *dev, int status)
 static int dt2815_wait_for_status(struct comedi_device *dev, int status)
@@ -108,8 +111,9 @@ static int dt2815_wait_for_status(struct comedi_device *dev, int status)
 	return status;
 	return status;
 }
 }
 
 
-static int dt2815_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2815_ao_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -122,7 +126,7 @@ static int dt2815_ao_insn_read(struct comedi_device *dev, struct comedi_subdevic
 }
 }
 
 
 static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -136,8 +140,8 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 		status = dt2815_wait_for_status(dev, 0x00);
 		status = dt2815_wait_for_status(dev, 0x00);
 		if (status != 0) {
 		if (status != 0) {
 			printk
 			printk
-				("dt2815: failed to write low byte on %d reason %x\n",
-				chan, status);
+			    ("dt2815: failed to write low byte on %d reason %x\n",
+			     chan, status);
 			return -EBUSY;
 			return -EBUSY;
 		}
 		}
 
 
@@ -146,8 +150,8 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 		status = dt2815_wait_for_status(dev, 0x10);
 		status = dt2815_wait_for_status(dev, 0x10);
 		if (status != 0x10) {
 		if (status != 0x10) {
 			printk
 			printk
-				("dt2815: failed to write high byte on %d reason %x\n",
-				chan, status);
+			    ("dt2815: failed to write high byte on %d reason %x\n",
+			     chan, status);
 			return -EBUSY;
 			return -EBUSY;
 		}
 		}
 		devpriv->ao_readback[chan] = data[i];
 		devpriv->ao_readback[chan] = data[i];
@@ -212,12 +216,12 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	s->range_table_list = devpriv->range_type_list;
 	s->range_table_list = devpriv->range_type_list;
 
 
 	current_range_type = (it->options[3])
 	current_range_type = (it->options[3])
-		? &range_dt2815_ao_20_current : &range_dt2815_ao_32_current;
+	    ? &range_dt2815_ao_20_current : &range_dt2815_ao_32_current;
 	voltage_range_type = (it->options[2])
 	voltage_range_type = (it->options[2])
-		? &range_bipolar5 : &range_unipolar5;
+	    ? &range_bipolar5 : &range_unipolar5;
 	for (i = 0; i < 8; i++) {
 	for (i = 0; i < 8; i++) {
 		devpriv->range_type_list[i] = (it->options[5 + i])
 		devpriv->range_type_list[i] = (it->options[5 + i])
-			? current_range_type : voltage_range_type;
+		    ? current_range_type : voltage_range_type;
 	}
 	}
 
 
 	/* Init the 2815 */
 	/* Init the 2815 */
@@ -236,7 +240,7 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 			break;
 			break;
 		} else if (status != 0x00) {
 		} else if (status != 0x00) {
 			printk("dt2815: unexpected status 0x%x (@t=%d)\n",
 			printk("dt2815: unexpected status 0x%x (@t=%d)\n",
-				status, i);
+			       status, i);
 			if (status & 0x60) {
 			if (status & 0x60) {
 				outb(0x00, dev->iobase + DT2815_STATUS);
 				outb(0x00, dev->iobase + DT2815_STATUS);
 			}
 			}

+ 11 - 8
drivers/staging/comedi/drivers/dt2817.c

@@ -47,7 +47,8 @@ Configuration options:
 #define DT2817_CR 0
 #define DT2817_CR 0
 #define DT2817_DATA 1
 #define DT2817_DATA 1
 
 
-static int dt2817_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt2817_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int dt2817_detach(struct comedi_device *dev);
 static int dt2817_detach(struct comedi_device *dev);
 static struct comedi_driver driver_dt2817 = {
 static struct comedi_driver driver_dt2817 = {
 	.driver_name = "dt2817",
 	.driver_name = "dt2817",
@@ -58,8 +59,9 @@ static struct comedi_driver driver_dt2817 = {
 
 
 COMEDI_INITCLEANUP(driver_dt2817);
 COMEDI_INITCLEANUP(driver_dt2817);
 
 
-static int dt2817_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2817_dio_insn_config(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int mask;
 	int mask;
 	int chan;
 	int chan;
@@ -96,8 +98,9 @@ static int dt2817_dio_insn_config(struct comedi_device *dev, struct comedi_subde
 	return 1;
 	return 1;
 }
 }
 
 
-static int dt2817_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt2817_dio_insn_bits(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int changed;
 	unsigned int changed;
 
 
@@ -115,13 +118,13 @@ static int dt2817_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
 			outb(s->state & 0xff, dev->iobase + DT2817_DATA + 0);
 			outb(s->state & 0xff, dev->iobase + DT2817_DATA + 0);
 		if (changed & 0x0000ff00)
 		if (changed & 0x0000ff00)
 			outb((s->state >> 8) & 0xff,
 			outb((s->state >> 8) & 0xff,
-				dev->iobase + DT2817_DATA + 1);
+			     dev->iobase + DT2817_DATA + 1);
 		if (changed & 0x00ff0000)
 		if (changed & 0x00ff0000)
 			outb((s->state >> 16) & 0xff,
 			outb((s->state >> 16) & 0xff,
-				dev->iobase + DT2817_DATA + 2);
+			     dev->iobase + DT2817_DATA + 2);
 		if (changed & 0xff000000)
 		if (changed & 0xff000000)
 			outb((s->state >> 24) & 0xff,
 			outb((s->state >> 24) & 0xff,
-				dev->iobase + DT2817_DATA + 3);
+			     dev->iobase + DT2817_DATA + 3);
 	}
 	}
 	data[1] = inb(dev->iobase + DT2817_DATA + 0);
 	data[1] = inb(dev->iobase + DT2817_DATA + 0);
 	data[1] |= (inb(dev->iobase + DT2817_DATA + 1) << 8);
 	data[1] |= (inb(dev->iobase + DT2817_DATA + 1) << 8);

+ 152 - 112
drivers/staging/comedi/drivers/dt282x.c

@@ -155,46 +155,78 @@ Notes:
 #define DT2821_BDINIT	0x0001	/* (W)   initialize board         */
 #define DT2821_BDINIT	0x0001	/* (W)   initialize board         */
 
 
 static const struct comedi_lrange range_dt282x_ai_lo_bipolar = { 4, {
 static const struct comedi_lrange range_dt282x_ai_lo_bipolar = { 4, {
-			RANGE(-10, 10),
-			RANGE(-5, 5),
-			RANGE(-2.5, 2.5),
-			RANGE(-1.25, 1.25)
-	}
+								     RANGE(-10,
+									   10),
+								     RANGE(-5,
+									   5),
+								     RANGE(-2.5,
+									   2.5),
+								     RANGE
+								     (-1.25,
+								      1.25)
+								     }
 };
 };
+
 static const struct comedi_lrange range_dt282x_ai_lo_unipolar = { 4, {
 static const struct comedi_lrange range_dt282x_ai_lo_unipolar = { 4, {
-			RANGE(0, 10),
-			RANGE(0, 5),
-			RANGE(0, 2.5),
-			RANGE(0, 1.25)
-	}
+								      RANGE(0,
+									    10),
+								      RANGE(0,
+									    5),
+								      RANGE(0,
+									    2.5),
+								      RANGE(0,
+									    1.25)
+								      }
 };
 };
+
 static const struct comedi_lrange range_dt282x_ai_5_bipolar = { 4, {
 static const struct comedi_lrange range_dt282x_ai_5_bipolar = { 4, {
-			RANGE(-5, 5),
-			RANGE(-2.5, 2.5),
-			RANGE(-1.25, 1.25),
-			RANGE(-0.625, 0.625),
-	}
+								    RANGE(-5,
+									  5),
+								    RANGE(-2.5,
+									  2.5),
+								    RANGE(-1.25,
+									  1.25),
+								    RANGE
+								    (-0.625,
+								     0.625),
+								    }
 };
 };
+
 static const struct comedi_lrange range_dt282x_ai_5_unipolar = { 4, {
 static const struct comedi_lrange range_dt282x_ai_5_unipolar = { 4, {
-			RANGE(0, 5),
-			RANGE(0, 2.5),
-			RANGE(0, 1.25),
-			RANGE(0, 0.625),
-	}
+								     RANGE(0,
+									   5),
+								     RANGE(0,
+									   2.5),
+								     RANGE(0,
+									   1.25),
+								     RANGE(0,
+									   0.625),
+								     }
 };
 };
+
 static const struct comedi_lrange range_dt282x_ai_hi_bipolar = { 4, {
 static const struct comedi_lrange range_dt282x_ai_hi_bipolar = { 4, {
-			RANGE(-10, 10),
-			RANGE(-1, 1),
-			RANGE(-0.1, 0.1),
-			RANGE(-0.02, 0.02)
-	}
+								     RANGE(-10,
+									   10),
+								     RANGE(-1,
+									   1),
+								     RANGE(-0.1,
+									   0.1),
+								     RANGE
+								     (-0.02,
+								      0.02)
+								     }
 };
 };
+
 static const struct comedi_lrange range_dt282x_ai_hi_unipolar = { 4, {
 static const struct comedi_lrange range_dt282x_ai_hi_unipolar = { 4, {
-			RANGE(0, 10),
-			RANGE(0, 1),
-			RANGE(0, 0.1),
-			RANGE(0, 0.02)
-	}
+								      RANGE(0,
+									    10),
+								      RANGE(0,
+									    1),
+								      RANGE(0,
+									    0.1),
+								      RANGE(0,
+									    0.02)
+								      }
 };
 };
 
 
 struct dt282x_board {
 struct dt282x_board {
@@ -217,7 +249,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 0,
 	 .ispgl = 0,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt2821-f",
 	{.name = "dt2821-f",
 	 .adbits = 12,
 	 .adbits = 12,
 	 .adchan_se = 16,
 	 .adchan_se = 16,
@@ -226,7 +258,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 0,
 	 .ispgl = 0,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt2821-g",
 	{.name = "dt2821-g",
 	 .adbits = 12,
 	 .adbits = 12,
 	 .adchan_se = 16,
 	 .adchan_se = 16,
@@ -235,7 +267,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 0,
 	 .ispgl = 0,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt2823",
 	{.name = "dt2823",
 	 .adbits = 16,
 	 .adbits = 16,
 	 .adchan_se = 0,
 	 .adchan_se = 0,
@@ -244,16 +276,16 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 0,
 	 .ispgl = 0,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 16,
 	 .dabits = 16,
-	},
+	 },
 	{.name = "dt2824-pgh",
 	{.name = "dt2824-pgh",
-	  .adbits = 12,
-	  .adchan_se = 16,
-	  .adchan_di = 8,
-	  .ai_speed = 20000,
-	  .ispgl = 0,
-	  .dachan = 0,
-	  .dabits = 0,
-	},
+	 .adbits = 12,
+	 .adchan_se = 16,
+	 .adchan_di = 8,
+	 .ai_speed = 20000,
+	 .ispgl = 0,
+	 .dachan = 0,
+	 .dabits = 0,
+	 },
 	{.name = "dt2824-pgl",
 	{.name = "dt2824-pgl",
 	 .adbits = 12,
 	 .adbits = 12,
 	 .adchan_se = 16,
 	 .adchan_se = 16,
@@ -262,7 +294,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 1,
 	 .ispgl = 1,
 	 .dachan = 0,
 	 .dachan = 0,
 	 .dabits = 0,
 	 .dabits = 0,
-	},
+	 },
 	{.name = "dt2825",
 	{.name = "dt2825",
 	 .adbits = 12,
 	 .adbits = 12,
 	 .adchan_se = 16,
 	 .adchan_se = 16,
@@ -271,7 +303,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 1,
 	 .ispgl = 1,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt2827",
 	{.name = "dt2827",
 	 .adbits = 16,
 	 .adbits = 16,
 	 .adchan_se = 0,
 	 .adchan_se = 0,
@@ -280,7 +312,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 0,
 	 .ispgl = 0,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt2828",
 	{.name = "dt2828",
 	 .adbits = 12,
 	 .adbits = 12,
 	 .adchan_se = 4,
 	 .adchan_se = 4,
@@ -289,7 +321,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 0,
 	 .ispgl = 0,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt2829",
 	{.name = "dt2829",
 	 .adbits = 16,
 	 .adbits = 16,
 	 .adchan_se = 8,
 	 .adchan_se = 8,
@@ -298,7 +330,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 0,
 	 .ispgl = 0,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 16,
 	 .dabits = 16,
-	},
+	 },
 	{.name = "dt21-ez",
 	{.name = "dt21-ez",
 	 .adbits = 12,
 	 .adbits = 12,
 	 .adchan_se = 16,
 	 .adchan_se = 16,
@@ -307,7 +339,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 0,
 	 .ispgl = 0,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt23-ez",
 	{.name = "dt23-ez",
 	 .adbits = 16,
 	 .adbits = 16,
 	 .adchan_se = 16,
 	 .adchan_se = 16,
@@ -316,7 +348,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 0,
 	 .ispgl = 0,
 	 .dachan = 0,
 	 .dachan = 0,
 	 .dabits = 0,
 	 .dabits = 0,
-	},
+	 },
 	{.name = "dt24-ez",
 	{.name = "dt24-ez",
 	 .adbits = 12,
 	 .adbits = 12,
 	 .adchan_se = 16,
 	 .adchan_se = 16,
@@ -325,7 +357,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 0,
 	 .ispgl = 0,
 	 .dachan = 0,
 	 .dachan = 0,
 	 .dabits = 0,
 	 .dabits = 0,
-	},
+	 },
 	{.name = "dt24-ez-pgl",
 	{.name = "dt24-ez-pgl",
 	 .adbits = 12,
 	 .adbits = 12,
 	 .adchan_se = 16,
 	 .adchan_se = 16,
@@ -334,7 +366,7 @@ static const struct dt282x_board boardtypes[] = {
 	 .ispgl = 1,
 	 .ispgl = 1,
 	 .dachan = 0,
 	 .dachan = 0,
 	 .dabits = 0,
 	 .dabits = 0,
-	},
+	 },
 };
 };
 
 
 #define n_boardtypes sizeof(boardtypes)/sizeof(struct dt282x_board)
 #define n_boardtypes sizeof(boardtypes)/sizeof(struct dt282x_board)
@@ -394,7 +426,8 @@ struct dt282x_private {
 		if (_i){b}				\
 		if (_i){b}				\
 	}while (0)
 	}while (0)
 
 
-static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt282x_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int dt282x_detach(struct comedi_device *dev);
 static int dt282x_detach(struct comedi_device *dev);
 static struct comedi_driver driver_dt282x = {
 static struct comedi_driver driver_dt282x = {
 	.driver_name = "dt282x",
 	.driver_name = "dt282x",
@@ -411,15 +444,17 @@ COMEDI_INITCLEANUP(driver_dt282x);
 static void free_resources(struct comedi_device *dev);
 static void free_resources(struct comedi_device *dev);
 static int prep_ai_dma(struct comedi_device *dev, int chan, int size);
 static int prep_ai_dma(struct comedi_device *dev, int chan, int size);
 static int prep_ao_dma(struct comedi_device *dev, int chan, int size);
 static int prep_ao_dma(struct comedi_device *dev, int chan, int size);
-static int dt282x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-static int dt282x_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+static int dt282x_ai_cancel(struct comedi_device *dev,
+			    struct comedi_subdevice *s);
+static int dt282x_ao_cancel(struct comedi_device *dev,
+			    struct comedi_subdevice *s);
 static int dt282x_ns_to_timer(int *nanosec, int round_mode);
 static int dt282x_ns_to_timer(int *nanosec, int round_mode);
 static void dt282x_disable_dma(struct comedi_device *dev);
 static void dt282x_disable_dma(struct comedi_device *dev);
 
 
 static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2);
 static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2);
 
 
 static void dt282x_munge(struct comedi_device *dev, short *buf,
 static void dt282x_munge(struct comedi_device *dev, short *buf,
-	unsigned int nbytes)
+			 unsigned int nbytes)
 {
 {
 	unsigned int i;
 	unsigned int i;
 	unsigned short mask = (1 << boardtype.adbits) - 1;
 	unsigned short mask = (1 << boardtype.adbits) - 1;
@@ -628,7 +663,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
 		int ret;
 		int ret;
 		short data;
 		short data;
 
 
-		data = (short) inw(dev->iobase + DT2821_ADDAT);
+		data = (short)inw(dev->iobase + DT2821_ADDAT);
 		data &= (1 << boardtype.adbits) - 1;
 		data &= (1 << boardtype.adbits) - 1;
 		if (devpriv->ad_2scomp) {
 		if (devpriv->ad_2scomp) {
 			data ^= 1 << (boardtype.adbits - 1);
 			data ^= 1 << (boardtype.adbits - 1);
@@ -654,7 +689,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
 }
 }
 
 
 static void dt282x_load_changain(struct comedi_device *dev, int n,
 static void dt282x_load_changain(struct comedi_device *dev, int n,
-	unsigned int *chanlist)
+				 unsigned int *chanlist)
 {
 {
 	unsigned int i;
 	unsigned int i;
 	unsigned int chan, range;
 	unsigned int chan, range;
@@ -674,8 +709,9 @@ static void dt282x_load_changain(struct comedi_device *dev, int n,
  *      - preload multiplexer
  *      - preload multiplexer
  *      - trigger conversion and wait for it to finish
  *      - trigger conversion and wait for it to finish
  */
  */
-static int dt282x_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt282x_ai_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 
 
@@ -686,18 +722,15 @@ static int dt282x_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
 	dt282x_load_changain(dev, 1, &insn->chanspec);
 	dt282x_load_changain(dev, 1, &insn->chanspec);
 
 
 	update_supcsr(DT2821_PRLD);
 	update_supcsr(DT2821_PRLD);
-	wait_for(!mux_busy(), comedi_error(dev, "timeout\n");
-		return -ETIME;
-		);
+	wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);
 
 
 	for (i = 0; i < insn->n; i++) {
 	for (i = 0; i < insn->n; i++) {
 		update_supcsr(DT2821_STRIG);
 		update_supcsr(DT2821_STRIG);
 		wait_for(ad_done(), comedi_error(dev, "timeout\n");
 		wait_for(ad_done(), comedi_error(dev, "timeout\n");
-			return -ETIME;
-			);
+			 return -ETIME;);
 
 
 		data[i] =
 		data[i] =
-			inw(dev->iobase +
+		    inw(dev->iobase +
 			DT2821_ADDAT) & ((1 << boardtype.adbits) - 1);
 			DT2821_ADDAT) & ((1 << boardtype.adbits) - 1);
 		if (devpriv->ad_2scomp)
 		if (devpriv->ad_2scomp)
 			data[i] ^= (1 << (boardtype.adbits - 1));
 			data[i] ^= (1 << (boardtype.adbits - 1));
@@ -706,8 +739,8 @@ static int dt282x_ai_insn_read(struct comedi_device *dev, struct comedi_subdevic
 	return i;
 	return i;
 }
 }
 
 
-static int dt282x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int dt282x_ai_cmdtest(struct comedi_device *dev,
+			     struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -746,7 +779,7 @@ static int dt282x_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 
 
 	/* note that mutual compatiblity is not an issue here */
 	/* note that mutual compatiblity is not an issue here */
 	if (cmd->scan_begin_src != TRIG_FOLLOW &&
 	if (cmd->scan_begin_src != TRIG_FOLLOW &&
-		cmd->scan_begin_src != TRIG_EXT)
+	    cmd->scan_begin_src != TRIG_EXT)
 		err++;
 		err++;
 	if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
 	if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
 		err++;
 		err++;
@@ -825,7 +858,7 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
 
 	if (devpriv->usedma == 0) {
 	if (devpriv->usedma == 0) {
 		comedi_error(dev,
 		comedi_error(dev,
-			"driver requires 2 dma channels to execute command");
+			     "driver requires 2 dma channels to execute command");
 		return -EIO;
 		return -EIO;
 	}
 	}
 
 
@@ -865,9 +898,7 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	update_adcsr(0);
 	update_adcsr(0);
 
 
 	update_supcsr(DT2821_PRLD);
 	update_supcsr(DT2821_PRLD);
-	wait_for(!mux_busy(), comedi_error(dev, "timeout\n");
-		return -ETIME;
-		);
+	wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;);
 
 
 	if (cmd->scan_begin_src == TRIG_FOLLOW) {
 	if (cmd->scan_begin_src == TRIG_FOLLOW) {
 		update_supcsr(DT2821_STRIG);
 		update_supcsr(DT2821_STRIG);
@@ -887,7 +918,8 @@ static void dt282x_disable_dma(struct comedi_device *dev)
 	}
 	}
 }
 }
 
 
-static int dt282x_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int dt282x_ai_cancel(struct comedi_device *dev,
+			    struct comedi_subdevice *s)
 {
 {
 	dt282x_disable_dma(dev);
 	dt282x_disable_dma(dev);
 
 
@@ -937,16 +969,18 @@ static int dt282x_ns_to_timer(int *nanosec, int round_mode)
  *      offset binary if necessary, loads the data into the DAC
  *      offset binary if necessary, loads the data into the DAC
  *      data register, and performs the conversion.
  *      data register, and performs the conversion.
  */
  */
-static int dt282x_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt282x_ao_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	data[0] = devpriv->ao[CR_CHAN(insn->chanspec)];
 	data[0] = devpriv->ao[CR_CHAN(insn->chanspec)];
 
 
 	return 1;
 	return 1;
 }
 }
 
 
-static int dt282x_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt282x_ao_insn_write(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	short d;
 	short d;
 	unsigned int chan;
 	unsigned int chan;
@@ -978,8 +1012,8 @@ static int dt282x_ao_insn_write(struct comedi_device *dev, struct comedi_subdevi
 	return 1;
 	return 1;
 }
 }
 
 
-static int dt282x_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int dt282x_ao_cmdtest(struct comedi_device *dev,
+			     struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -1029,7 +1063,7 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 		cmd->start_arg = 0;
 		cmd->start_arg = 0;
 		err++;
 		err++;
 	}
 	}
-	if (cmd->scan_begin_arg < 5000 /* XXX unknown */) {
+	if (cmd->scan_begin_arg < 5000 /* XXX unknown */ ) {
 		cmd->scan_begin_arg = 5000;
 		cmd->scan_begin_arg = 5000;
 		err++;
 		err++;
 	}
 	}
@@ -1069,8 +1103,8 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice
 
 
 }
 }
 
 
-static int dt282x_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int x)
+static int dt282x_ao_inttrig(struct comedi_device *dev,
+			     struct comedi_subdevice *s, unsigned int x)
 {
 {
 	int size;
 	int size;
 
 
@@ -1078,7 +1112,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice
 		return -EINVAL;
 		return -EINVAL;
 
 
 	size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf,
 	size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf,
-		devpriv->dma_maxsize);
+					  devpriv->dma_maxsize);
 	if (size == 0) {
 	if (size == 0) {
 		printk("dt282x: AO underrun\n");
 		printk("dt282x: AO underrun\n");
 		return -EPIPE;
 		return -EPIPE;
@@ -1086,7 +1120,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice
 	prep_ao_dma(dev, 0, size);
 	prep_ao_dma(dev, 0, size);
 
 
 	size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf,
 	size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf,
-		devpriv->dma_maxsize);
+					  devpriv->dma_maxsize);
 	if (size == 0) {
 	if (size == 0) {
 		printk("dt282x: AO underrun\n");
 		printk("dt282x: AO underrun\n");
 		return -EPIPE;
 		return -EPIPE;
@@ -1106,7 +1140,7 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
 
 	if (devpriv->usedma == 0) {
 	if (devpriv->usedma == 0) {
 		comedi_error(dev,
 		comedi_error(dev,
-			"driver requires 2 dma channels to execute command");
+			     "driver requires 2 dma channels to execute command");
 		return -EIO;
 		return -EIO;
 	}
 	}
 
 
@@ -1132,7 +1166,8 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	return 0;
 	return 0;
 }
 }
 
 
-static int dt282x_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int dt282x_ao_cancel(struct comedi_device *dev,
+			    struct comedi_subdevice *s)
 {
 {
 	dt282x_disable_dma(dev);
 	dt282x_disable_dma(dev);
 
 
@@ -1145,8 +1180,9 @@ static int dt282x_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *
 	return 0;
 	return 0;
 }
 }
 
 
-static int dt282x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt282x_dio_insn_bits(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (data[0]) {
 	if (data[0]) {
 		s->state &= ~data[0];
 		s->state &= ~data[0];
@@ -1159,8 +1195,9 @@ static int dt282x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevi
 	return 2;
 	return 2;
 }
 }
 
 
-static int dt282x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt282x_dio_insn_config(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int mask;
 	int mask;
 
 
@@ -1190,10 +1227,12 @@ static const struct comedi_lrange *const ai_range_table[] = {
 	&range_dt282x_ai_5_bipolar,
 	&range_dt282x_ai_5_bipolar,
 	&range_dt282x_ai_5_unipolar
 	&range_dt282x_ai_5_unipolar
 };
 };
+
 static const struct comedi_lrange *const ai_range_pgl_table[] = {
 static const struct comedi_lrange *const ai_range_pgl_table[] = {
 	&range_dt282x_ai_hi_bipolar,
 	&range_dt282x_ai_hi_bipolar,
 	&range_dt282x_ai_hi_unipolar
 	&range_dt282x_ai_hi_unipolar
 };
 };
+
 static const struct comedi_lrange *opt_ai_range_lkup(int ispgl, int x)
 static const struct comedi_lrange *opt_ai_range_lkup(int ispgl, int x)
 {
 {
 	if (ispgl) {
 	if (ispgl) {
@@ -1206,6 +1245,7 @@ static const struct comedi_lrange *opt_ai_range_lkup(int ispgl, int x)
 		return ai_range_table[x];
 		return ai_range_table[x];
 	}
 	}
 }
 }
+
 static const struct comedi_lrange *const ao_range_table[] = {
 static const struct comedi_lrange *const ao_range_table[] = {
 	&range_bipolar10,
 	&range_bipolar10,
 	&range_unipolar10,
 	&range_unipolar10,
@@ -1213,6 +1253,7 @@ static const struct comedi_lrange *const ao_range_table[] = {
 	&range_unipolar5,
 	&range_unipolar5,
 	&range_bipolar2_5
 	&range_bipolar2_5
 };
 };
+
 static const struct comedi_lrange *opt_ao_range_lkup(int x)
 static const struct comedi_lrange *opt_ao_range_lkup(int x)
 {
 {
 	if (x < 0 || x >= 5)
 	if (x < 0 || x >= 5)
@@ -1264,23 +1305,23 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	i = inw(dev->iobase + DT2821_ADCSR);
 	i = inw(dev->iobase + DT2821_ADCSR);
 #ifdef DEBUG
 #ifdef DEBUG
 	printk(" fingerprint=%x,%x,%x,%x,%x",
 	printk(" fingerprint=%x,%x,%x,%x,%x",
-		inw(dev->iobase + DT2821_ADCSR),
-		inw(dev->iobase + DT2821_CHANCSR),
-		inw(dev->iobase + DT2821_DACSR),
-		inw(dev->iobase + DT2821_SUPCSR),
-		inw(dev->iobase + DT2821_TMRCTR));
+	       inw(dev->iobase + DT2821_ADCSR),
+	       inw(dev->iobase + DT2821_CHANCSR),
+	       inw(dev->iobase + DT2821_DACSR),
+	       inw(dev->iobase + DT2821_SUPCSR),
+	       inw(dev->iobase + DT2821_TMRCTR));
 #endif
 #endif
 
 
 	if (((inw(dev->iobase + DT2821_ADCSR) & DT2821_ADCSR_MASK)
 	if (((inw(dev->iobase + DT2821_ADCSR) & DT2821_ADCSR_MASK)
-			!= DT2821_ADCSR_VAL) ||
-		((inw(dev->iobase + DT2821_CHANCSR) & DT2821_CHANCSR_MASK)
-			!= DT2821_CHANCSR_VAL) ||
-		((inw(dev->iobase + DT2821_DACSR) & DT2821_DACSR_MASK)
-			!= DT2821_DACSR_VAL) ||
-		((inw(dev->iobase + DT2821_SUPCSR) & DT2821_SUPCSR_MASK)
-			!= DT2821_SUPCSR_VAL) ||
-		((inw(dev->iobase + DT2821_TMRCTR) & DT2821_TMRCTR_MASK)
-			!= DT2821_TMRCTR_VAL)) {
+	     != DT2821_ADCSR_VAL) ||
+	    ((inw(dev->iobase + DT2821_CHANCSR) & DT2821_CHANCSR_MASK)
+	     != DT2821_CHANCSR_VAL) ||
+	    ((inw(dev->iobase + DT2821_DACSR) & DT2821_DACSR_MASK)
+	     != DT2821_DACSR_VAL) ||
+	    ((inw(dev->iobase + DT2821_SUPCSR) & DT2821_SUPCSR_MASK)
+	     != DT2821_SUPCSR_VAL) ||
+	    ((inw(dev->iobase + DT2821_TMRCTR) & DT2821_TMRCTR_MASK)
+	     != DT2821_TMRCTR_VAL)) {
 		printk(" board not found");
 		printk(" board not found");
 		return -EIO;
 		return -EIO;
 	}
 	}
@@ -1302,7 +1343,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 
 		irq = probe_irq_off(irqs);
 		irq = probe_irq_off(irqs);
 		restore_flags(flags);
 		restore_flags(flags);
-		if (0 /* error */) {
+		if (0 /* error */ ) {
 			printk(" error probing irq (bad)");
 			printk(" error probing irq (bad)");
 		}
 		}
 	}
 	}
@@ -1330,7 +1371,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		return ret;
 		return ret;
 
 
 	ret = dt282x_grab_dma(dev, it->options[opt_dma1],
 	ret = dt282x_grab_dma(dev, it->options[opt_dma1],
-		it->options[opt_dma2]);
+			      it->options[opt_dma2]);
 	if (ret < 0)
 	if (ret < 0)
 		return ret;
 		return ret;
 
 
@@ -1344,10 +1385,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	/* ai subdevice */
 	/* ai subdevice */
 	s->type = COMEDI_SUBD_AI;
 	s->type = COMEDI_SUBD_AI;
 	s->subdev_flags = SDF_READABLE | SDF_CMD_READ |
 	s->subdev_flags = SDF_READABLE | SDF_CMD_READ |
-		((it->options[opt_diff]) ? SDF_DIFF : SDF_COMMON);
+	    ((it->options[opt_diff]) ? SDF_DIFF : SDF_COMMON);
 	s->n_chan =
 	s->n_chan =
-		(it->options[opt_diff]) ? boardtype.adchan_di : boardtype.
-		adchan_se;
+	    (it->options[opt_diff]) ? boardtype.adchan_di : boardtype.adchan_se;
 	s->insn_read = dt282x_ai_insn_read;
 	s->insn_read = dt282x_ai_insn_read;
 	s->do_cmdtest = dt282x_ai_cmdtest;
 	s->do_cmdtest = dt282x_ai_cmdtest;
 	s->do_cmd = dt282x_ai_cmd;
 	s->do_cmd = dt282x_ai_cmd;
@@ -1355,7 +1395,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	s->maxdata = (1 << boardtype.adbits) - 1;
 	s->maxdata = (1 << boardtype.adbits) - 1;
 	s->len_chanlist = 16;
 	s->len_chanlist = 16;
 	s->range_table =
 	s->range_table =
-		opt_ai_range_lkup(boardtype.ispgl, it->options[opt_ai_range]);
+	    opt_ai_range_lkup(boardtype.ispgl, it->options[opt_ai_range]);
 	devpriv->ad_2scomp = it->options[opt_ai_twos];
 	devpriv->ad_2scomp = it->options[opt_ai_twos];
 
 
 	s++;
 	s++;
@@ -1375,9 +1415,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		s->len_chanlist = 2;
 		s->len_chanlist = 2;
 		s->range_table_list = devpriv->darangelist;
 		s->range_table_list = devpriv->darangelist;
 		devpriv->darangelist[0] =
 		devpriv->darangelist[0] =
-			opt_ao_range_lkup(it->options[opt_ao0_range]);
+		    opt_ao_range_lkup(it->options[opt_ao0_range]);
 		devpriv->darangelist[1] =
 		devpriv->darangelist[1] =
-			opt_ao_range_lkup(it->options[opt_ao1_range]);
+		    opt_ao_range_lkup(it->options[opt_ao1_range]);
 		devpriv->da0_2scomp = it->options[opt_ao0_twos];
 		devpriv->da0_2scomp = it->options[opt_ao0_twos];
 		devpriv->da1_2scomp = it->options[opt_ao1_twos];
 		devpriv->da1_2scomp = it->options[opt_ao1_twos];
 	} else {
 	} else {

+ 79 - 66
drivers/staging/comedi/drivers/dt3000.c

@@ -68,18 +68,19 @@ AO commands are not supported.
 #define PCI_VENDOR_ID_DT	0x1116
 #define PCI_VENDOR_ID_DT	0x1116
 
 
 static const struct comedi_lrange range_dt3000_ai = { 4, {
 static const struct comedi_lrange range_dt3000_ai = { 4, {
-			RANGE(-10, 10),
-			RANGE(-5, 5),
-			RANGE(-2.5, 2.5),
-			RANGE(-1.25, 1.25)
-	}
+							  RANGE(-10, 10),
+							  RANGE(-5, 5),
+							  RANGE(-2.5, 2.5),
+							  RANGE(-1.25, 1.25)
+							  }
 };
 };
+
 static const struct comedi_lrange range_dt3000_ai_pgl = { 4, {
 static const struct comedi_lrange range_dt3000_ai_pgl = { 4, {
-			RANGE(-10, 10),
-			RANGE(-1, 1),
-			RANGE(-0.1, 0.1),
-			RANGE(-0.02, 0.02)
-	}
+							      RANGE(-10, 10),
+							      RANGE(-1, 1),
+							      RANGE(-0.1, 0.1),
+							      RANGE(-0.02, 0.02)
+							      }
 };
 };
 
 
 struct dt3k_boardtype {
 struct dt3k_boardtype {
@@ -94,7 +95,6 @@ struct dt3k_boardtype {
 	int dabits;
 	int dabits;
 };
 };
 
 
-
 static const struct dt3k_boardtype dt3k_boardtypes[] = {
 static const struct dt3k_boardtype dt3k_boardtypes[] = {
 	{.name = "dt3001",
 	{.name = "dt3001",
 	 .device_id = 0x22,
 	 .device_id = 0x22,
@@ -104,7 +104,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
 	 .ai_speed = 3000,
 	 .ai_speed = 3000,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt3001-pgl",
 	{.name = "dt3001-pgl",
 	 .device_id = 0x27,
 	 .device_id = 0x27,
 	 .adchan = 16,
 	 .adchan = 16,
@@ -113,7 +113,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
 	 .ai_speed = 3000,
 	 .ai_speed = 3000,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt3002",
 	{.name = "dt3002",
 	 .device_id = 0x23,
 	 .device_id = 0x23,
 	 .adchan = 32,
 	 .adchan = 32,
@@ -122,7 +122,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
 	 .ai_speed = 3000,
 	 .ai_speed = 3000,
 	 .dachan = 0,
 	 .dachan = 0,
 	 .dabits = 0,
 	 .dabits = 0,
-	},
+	 },
 	{.name = "dt3003",
 	{.name = "dt3003",
 	 .device_id = 0x24,
 	 .device_id = 0x24,
 	 .adchan = 64,
 	 .adchan = 64,
@@ -131,7 +131,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
 	 .ai_speed = 3000,
 	 .ai_speed = 3000,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt3003-pgl",
 	{.name = "dt3003-pgl",
 	 .device_id = 0x28,
 	 .device_id = 0x28,
 	 .adchan = 64,
 	 .adchan = 64,
@@ -140,7 +140,7 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
 	 .ai_speed = 3000,
 	 .ai_speed = 3000,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 	{.name = "dt3004",
 	{.name = "dt3004",
 	 .device_id = 0x25,
 	 .device_id = 0x25,
 	 .adchan = 16,
 	 .adchan = 16,
@@ -149,8 +149,8 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
 	 .ai_speed = 10000,
 	 .ai_speed = 10000,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
-        {.name = "dt3005",		/* a.k.a. 3004-200 */
+	 },
+	{.name = "dt3005",	/* a.k.a. 3004-200 */
 	 .device_id = 0x26,
 	 .device_id = 0x26,
 	 .adchan = 16,
 	 .adchan = 16,
 	 .adbits = 16,
 	 .adbits = 16,
@@ -158,21 +158,22 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
 	 .ai_speed = 5000,
 	 .ai_speed = 5000,
 	 .dachan = 2,
 	 .dachan = 2,
 	 .dabits = 12,
 	 .dabits = 12,
-	},
+	 },
 };
 };
 
 
 #define n_dt3k_boards sizeof(dt3k_boardtypes)/sizeof(struct dt3k_boardtype)
 #define n_dt3k_boards sizeof(dt3k_boardtypes)/sizeof(struct dt3k_boardtype)
 #define this_board ((const struct dt3k_boardtype *)dev->board_ptr)
 #define this_board ((const struct dt3k_boardtype *)dev->board_ptr)
 
 
 static DEFINE_PCI_DEVICE_TABLE(dt3k_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(dt3k_pci_table) = {
-	{PCI_VENDOR_ID_DT, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_DT, 0x0027, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_DT, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_DT, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_DT, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_DT, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_DT, 0x0026, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_DT, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_DT, 0x0027, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_DT, 0x0023, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_DT, 0x0024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_DT, 0x0028, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_DT, 0x0025, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_DT, 0x0026, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, dt3k_pci_table);
 MODULE_DEVICE_TABLE(pci, dt3k_pci_table);
@@ -276,7 +277,8 @@ struct dt3k_private {
 
 
 #define devpriv ((struct dt3k_private *)dev->private)
 #define devpriv ((struct dt3k_private *)dev->private)
 
 
-static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int dt3000_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int dt3000_detach(struct comedi_device *dev);
 static int dt3000_detach(struct comedi_device *dev);
 static struct comedi_driver driver_dt3000 = {
 static struct comedi_driver driver_dt3000 = {
 	.driver_name = "dt3000",
 	.driver_name = "dt3000",
@@ -287,10 +289,12 @@ static struct comedi_driver driver_dt3000 = {
 
 
 COMEDI_PCI_INITCLEANUP(driver_dt3000, dt3k_pci_table);
 COMEDI_PCI_INITCLEANUP(driver_dt3000, dt3k_pci_table);
 
 
-static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevice *s);
+static void dt3k_ai_empty_fifo(struct comedi_device *dev,
+			       struct comedi_subdevice *s);
 static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *arg,
 static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *arg,
-	unsigned int round_mode);
-static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
+			    unsigned int round_mode);
+static int dt3k_ai_cancel(struct comedi_device *dev,
+			  struct comedi_subdevice *s);
 #ifdef DEBUG
 #ifdef DEBUG
 static void debug_intr_flags(unsigned int flags);
 static void debug_intr_flags(unsigned int flags);
 #endif
 #endif
@@ -319,8 +323,9 @@ static int dt3k_send_cmd(struct comedi_device *dev, unsigned int cmd)
 	return -ETIME;
 	return -ETIME;
 }
 }
 
 
-static unsigned int dt3k_readsingle(struct comedi_device *dev, unsigned int subsys,
-	unsigned int chan, unsigned int gain)
+static unsigned int dt3k_readsingle(struct comedi_device *dev,
+				    unsigned int subsys, unsigned int chan,
+				    unsigned int gain)
 {
 {
 	writew(subsys, devpriv->io_addr + DPR_SubSys);
 	writew(subsys, devpriv->io_addr + DPR_SubSys);
 
 
@@ -333,7 +338,7 @@ static unsigned int dt3k_readsingle(struct comedi_device *dev, unsigned int subs
 }
 }
 
 
 static void dt3k_writesingle(struct comedi_device *dev, unsigned int subsys,
 static void dt3k_writesingle(struct comedi_device *dev, unsigned int subsys,
-	unsigned int chan, unsigned int data)
+			     unsigned int chan, unsigned int data)
 {
 {
 	writew(subsys, devpriv->io_addr + DPR_SubSys);
 	writew(subsys, devpriv->io_addr + DPR_SubSys);
 
 
@@ -388,6 +393,7 @@ static char *intr_flags[] = {
 	"AdFull", "AdSwError", "AdHwError", "DaEmpty",
 	"AdFull", "AdSwError", "AdHwError", "DaEmpty",
 	"DaSwError", "DaHwError", "CtDone", "CmDone",
 	"DaSwError", "DaHwError", "CtDone", "CmDone",
 };
 };
+
 static void debug_intr_flags(unsigned int flags)
 static void debug_intr_flags(unsigned int flags)
 {
 {
 	int i;
 	int i;
@@ -401,7 +407,8 @@ static void debug_intr_flags(unsigned int flags)
 }
 }
 #endif
 #endif
 
 
-static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevice *s)
+static void dt3k_ai_empty_fifo(struct comedi_device *dev,
+			       struct comedi_subdevice *s)
 {
 {
 	int front;
 	int front;
 	int rear;
 	int rear;
@@ -430,8 +437,8 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevic
 	writew(rear, devpriv->io_addr + DPR_AD_Buf_Rear);
 	writew(rear, devpriv->io_addr + DPR_AD_Buf_Rear);
 }
 }
 
 
-static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int dt3k_ai_cmdtest(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -528,7 +535,7 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		tmp = cmd->scan_begin_arg;
 		tmp = cmd->scan_begin_arg;
 		dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
 		dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
-			cmd->flags & TRIG_ROUND_MASK);
+				 cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->scan_begin_arg)
 		if (tmp != cmd->scan_begin_arg)
 			err++;
 			err++;
 	} else {
 	} else {
@@ -537,14 +544,14 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
 	if (cmd->convert_src == TRIG_TIMER) {
 	if (cmd->convert_src == TRIG_TIMER) {
 		tmp = cmd->convert_arg;
 		tmp = cmd->convert_arg;
 		dt3k_ns_to_timer(50, &cmd->convert_arg,
 		dt3k_ns_to_timer(50, &cmd->convert_arg,
-			cmd->flags & TRIG_ROUND_MASK);
+				 cmd->flags & TRIG_ROUND_MASK);
 		if (tmp != cmd->convert_arg)
 		if (tmp != cmd->convert_arg)
 			err++;
 			err++;
 		if (cmd->scan_begin_src == TRIG_TIMER &&
 		if (cmd->scan_begin_src == TRIG_TIMER &&
-			cmd->scan_begin_arg <
-			cmd->convert_arg * cmd->scan_end_arg) {
+		    cmd->scan_begin_arg <
+		    cmd->convert_arg * cmd->scan_end_arg) {
 			cmd->scan_begin_arg =
 			cmd->scan_begin_arg =
-				cmd->convert_arg * cmd->scan_end_arg;
+			    cmd->convert_arg * cmd->scan_end_arg;
 			err++;
 			err++;
 		}
 		}
 	} else {
 	} else {
@@ -558,7 +565,7 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s
 }
 }
 
 
 static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec,
 static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec,
-	unsigned int round_mode)
+			    unsigned int round_mode)
 {
 {
 	int divider, base, prescale;
 	int divider, base, prescale;
 
 
@@ -608,7 +615,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 		range = CR_RANGE(cmd->chanlist[i]);
 		range = CR_RANGE(cmd->chanlist[i]);
 
 
 		writew((range << 6) | chan,
 		writew((range << 6) | chan,
-			devpriv->io_addr + DPR_ADC_buffer + i);
+		       devpriv->io_addr + DPR_ADC_buffer + i);
 	}
 	}
 	aref = CR_AREF(cmd->chanlist[0]);
 	aref = CR_AREF(cmd->chanlist[0]);
 
 
@@ -617,7 +624,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
 
 	if (cmd->convert_src == TRIG_TIMER) {
 	if (cmd->convert_src == TRIG_TIMER) {
 		divider = dt3k_ns_to_timer(50, &cmd->convert_arg,
 		divider = dt3k_ns_to_timer(50, &cmd->convert_arg,
-			cmd->flags & TRIG_ROUND_MASK);
+					   cmd->flags & TRIG_ROUND_MASK);
 		writew((divider >> 16), devpriv->io_addr + DPR_Params(1));
 		writew((divider >> 16), devpriv->io_addr + DPR_Params(1));
 		printk("param[1]=0x%04x\n", divider >> 16);
 		printk("param[1]=0x%04x\n", divider >> 16);
 		writew((divider & 0xffff), devpriv->io_addr + DPR_Params(2));
 		writew((divider & 0xffff), devpriv->io_addr + DPR_Params(2));
@@ -628,7 +635,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		tscandiv = dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
 		tscandiv = dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
-			cmd->flags & TRIG_ROUND_MASK);
+					    cmd->flags & TRIG_ROUND_MASK);
 		writew((tscandiv >> 16), devpriv->io_addr + DPR_Params(3));
 		writew((tscandiv >> 16), devpriv->io_addr + DPR_Params(3));
 		printk("param[3]=0x%04x\n", tscandiv >> 16);
 		printk("param[3]=0x%04x\n", tscandiv >> 16);
 		writew((tscandiv & 0xffff), devpriv->io_addr + DPR_Params(4));
 		writew((tscandiv & 0xffff), devpriv->io_addr + DPR_Params(4));
@@ -650,7 +657,7 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	ret = dt3k_send_cmd(dev, CMD_CONFIG);
 	ret = dt3k_send_cmd(dev, CMD_CONFIG);
 
 
 	writew(DT3000_ADFULL | DT3000_ADSWERR | DT3000_ADHWERR,
 	writew(DT3000_ADFULL | DT3000_ADSWERR | DT3000_ADHWERR,
-		devpriv->io_addr + DPR_Int_Mask);
+	       devpriv->io_addr + DPR_Int_Mask);
 
 
 	debug_n_ints = 0;
 	debug_n_ints = 0;
 
 
@@ -673,7 +680,7 @@ static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 }
 }
 
 
 static int dt3k_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int dt3k_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	unsigned int chan, gain, aref;
 	unsigned int chan, gain, aref;
@@ -691,7 +698,7 @@ static int dt3k_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 }
 }
 
 
 static int dt3k_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int dt3k_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	unsigned int chan;
 	unsigned int chan;
@@ -705,8 +712,9 @@ static int dt3k_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
 	return i;
 	return i;
 }
 }
 
 
-static int dt3k_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt3k_ao_insn_read(struct comedi_device *dev,
+			     struct comedi_subdevice *s,
+			     struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	unsigned int chan;
 	unsigned int chan;
@@ -734,8 +742,9 @@ static void dt3k_dio_config(struct comedi_device *dev, int bits)
 	dt3k_send_cmd(dev, CMD_CONFIG);
 	dt3k_send_cmd(dev, CMD_CONFIG);
 }
 }
 
 
-static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt3k_dio_insn_config(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int mask;
 	int mask;
 
 
@@ -750,9 +759,9 @@ static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
 		break;
 		break;
 	case INSN_CONFIG_DIO_QUERY:
 	case INSN_CONFIG_DIO_QUERY:
 		data[1] =
 		data[1] =
-			(s->io_bits & (1 << CR_CHAN(insn->
-					chanspec))) ? COMEDI_OUTPUT :
-			COMEDI_INPUT;
+		    (s->
+		     io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT :
+		    COMEDI_INPUT;
 		return insn->n;
 		return insn->n;
 		break;
 		break;
 	default:
 	default:
@@ -765,8 +774,9 @@ static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
 	return insn->n;
 	return insn->n;
 }
 }
 
 
-static int dt3k_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt3k_dio_insn_bits(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -781,8 +791,9 @@ static int dt3k_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice
 	return 2;
 	return 2;
 }
 }
 
 
-static int dt3k_mem_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dt3k_mem_insn_read(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int addr = CR_CHAN(insn->chanspec);
 	unsigned int addr = CR_CHAN(insn->chanspec);
 	int i;
 	int i;
@@ -925,8 +936,8 @@ static int dt_pci_probe(struct comedi_device *dev, int bus, int slot)
 	pcidev = NULL;
 	pcidev = NULL;
 	while ((pcidev = dt_pci_find_device(pcidev, &board)) != NULL) {
 	while ((pcidev = dt_pci_find_device(pcidev, &board)) != NULL) {
 		if ((bus == 0 && slot == 0) ||
 		if ((bus == 0 && slot == 0) ||
-			(pcidev->bus->number == bus &&
-			 PCI_SLOT(pcidev->devfn) == slot)) {
+		    (pcidev->bus->number == bus &&
+		     PCI_SLOT(pcidev->devfn) == slot)) {
 			break;
 			break;
 		}
 		}
 	}
 	}
@@ -961,7 +972,7 @@ static int setup_pci(struct comedi_device *dev)
 		return -ENOMEM;
 		return -ENOMEM;
 #if DEBUG
 #if DEBUG
 	printk("0x%08llx mapped to %p, ",
 	printk("0x%08llx mapped to %p, ",
-		(unsigned long long)devpriv->phys_addr, devpriv->io_addr);
+	       (unsigned long long)devpriv->phys_addr, devpriv->io_addr);
 #endif
 #endif
 
 
 	return 0;
 	return 0;
@@ -972,15 +983,17 @@ static struct pci_dev *dt_pci_find_device(struct pci_dev *from, int *board)
 	int i;
 	int i;
 
 
 	for (from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from);
 	for (from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from);
-		from != NULL;
-		from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from)) {
+	     from != NULL;
+	     from = pci_get_device(PCI_VENDOR_ID_DT, PCI_ANY_ID, from)) {
 		for (i = 0; i < n_dt3k_boards; i++) {
 		for (i = 0; i < n_dt3k_boards; i++) {
 			if (from->device == dt3k_boardtypes[i].device_id) {
 			if (from->device == dt3k_boardtypes[i].device_id) {
 				*board = i;
 				*board = i;
 				return from;
 				return from;
 			}
 			}
 		}
 		}
-		printk("unknown Data Translation PCI device found with device_id=0x%04x\n", from->device);
+		printk
+		    ("unknown Data Translation PCI device found with device_id=0x%04x\n",
+		     from->device);
 	}
 	}
 	*board = -1;
 	*board = -1;
 	return from;
 	return from;

+ 44 - 41
drivers/staging/comedi/drivers/dt9812.c

@@ -89,9 +89,9 @@ for my needs.
 #define F020_MASK_DACxCN_DACxEN		0x80
 #define F020_MASK_DACxCN_DACxEN		0x80
 
 
 enum {
 enum {
-				/* A/D  D/A  DI  DO  CT */
+	/* A/D  D/A  DI  DO  CT */
 	DT9812_DEVID_DT9812_10,	/*  8    2   8   8   1  +/- 10V */
 	DT9812_DEVID_DT9812_10,	/*  8    2   8   8   1  +/- 10V */
-	DT9812_DEVID_DT9812_2PT5,/* 8    2   8   8   1  0-2.44V */
+	DT9812_DEVID_DT9812_2PT5,	/* 8    2   8   8   1  0-2.44V */
 #if 0
 #if 0
 	DT9812_DEVID_DT9813,	/*  16   2   4   4   1  +/- 10V */
 	DT9812_DEVID_DT9813,	/*  16   2   4   4   1  +/- 10V */
 	DT9812_DEVID_DT9814	/*  24   2   0   0   1  +/- 10V */
 	DT9812_DEVID_DT9814	/*  24   2   0   0   1  +/- 10V */
@@ -266,7 +266,7 @@ static DECLARE_MUTEX(dt9812_mutex);
 
 
 static struct usb_device_id dt9812_table[] = {
 static struct usb_device_id dt9812_table[] = {
 	{USB_DEVICE(0x0867, 0x9812)},
 	{USB_DEVICE(0x0867, 0x9812)},
-	{ }			/* Terminating entry */
+	{}			/* Terminating entry */
 };
 };
 
 
 MODULE_DEVICE_TABLE(usb, dt9812_table);
 MODULE_DEVICE_TABLE(usb, dt9812_table);
@@ -301,23 +301,23 @@ struct slot_dt9812 {
 };
 };
 
 
 static const struct comedi_lrange dt9812_10_ain_range = { 1, {
 static const struct comedi_lrange dt9812_10_ain_range = { 1, {
-			BIP_RANGE(10),
-	}
+							      BIP_RANGE(10),
+							      }
 };
 };
 
 
 static const struct comedi_lrange dt9812_2pt5_ain_range = { 1, {
 static const struct comedi_lrange dt9812_2pt5_ain_range = { 1, {
-			UNI_RANGE(2.5),
-	}
+								UNI_RANGE(2.5),
+								}
 };
 };
 
 
 static const struct comedi_lrange dt9812_10_aout_range = { 1, {
 static const struct comedi_lrange dt9812_10_aout_range = { 1, {
-			BIP_RANGE(10),
-	}
+							       BIP_RANGE(10),
+							       }
 };
 };
 
 
 static const struct comedi_lrange dt9812_2pt5_aout_range = { 1, {
 static const struct comedi_lrange dt9812_2pt5_aout_range = { 1, {
-			UNI_RANGE(2.5),
-	}
+								 UNI_RANGE(2.5),
+								 }
 };
 };
 
 
 static struct slot_dt9812 dt9812[DT9812_NUM_SLOTS];
 static struct slot_dt9812 dt9812[DT9812_NUM_SLOTS];
@@ -346,7 +346,7 @@ static int dt9812_read_info(struct usb_dt9812 *dev, int offset, void *buf,
 
 
 	cmd.cmd = cpu_to_le32(DT9812_R_FLASH_DATA);
 	cmd.cmd = cpu_to_le32(DT9812_R_FLASH_DATA);
 	cmd.u.flash_data_info.address =
 	cmd.u.flash_data_info.address =
-		cpu_to_le16(DT9812_DIAGS_BOARD_INFO_ADDR + offset);
+	    cpu_to_le16(DT9812_DIAGS_BOARD_INFO_ADDR + offset);
 	cmd.u.flash_data_info.numbytes = cpu_to_le16(buf_size);
 	cmd.u.flash_data_info.numbytes = cpu_to_le16(buf_size);
 
 
 	/* DT9812 only responds to 32 byte writes!! */
 	/* DT9812 only responds to 32 byte writes!! */
@@ -365,7 +365,7 @@ static int dt9812_read_info(struct usb_dt9812 *dev, int offset, void *buf,
 }
 }
 
 
 static int dt9812_read_multiple_registers(struct usb_dt9812 *dev, int reg_count,
 static int dt9812_read_multiple_registers(struct usb_dt9812 *dev, int reg_count,
-					  u8 *address, u8 *value)
+					  u8 * address, u8 * value)
 {
 {
 	struct dt9812_usb_cmd cmd;
 	struct dt9812_usb_cmd cmd;
 	int i, count, retval;
 	int i, count, retval;
@@ -391,8 +391,8 @@ static int dt9812_read_multiple_registers(struct usb_dt9812 *dev, int reg_count,
 }
 }
 
 
 static int dt9812_write_multiple_registers(struct usb_dt9812 *dev,
 static int dt9812_write_multiple_registers(struct usb_dt9812 *dev,
-					   int reg_count, u8 *address,
-					   u8 *value)
+					   int reg_count, u8 * address,
+					   u8 * value)
 {
 {
 	struct dt9812_usb_cmd cmd;
 	struct dt9812_usb_cmd cmd;
 	int i, count, retval;
 	int i, count, retval;
@@ -430,7 +430,7 @@ static int dt9812_rmw_multiple_registers(struct usb_dt9812 *dev, int reg_count,
 	return retval;
 	return retval;
 }
 }
 
 
-static int dt9812_digital_in(struct slot_dt9812 *slot, u8 *bits)
+static int dt9812_digital_in(struct slot_dt9812 *slot, u8 * bits)
 {
 {
 	int result = -ENODEV;
 	int result = -ENODEV;
 
 
@@ -449,7 +449,7 @@ static int dt9812_digital_in(struct slot_dt9812 *slot, u8 *bits)
 			 */
 			 */
 			*bits = (value[0] & 0x7f) | ((value[1] & 0x08) << 4);
 			*bits = (value[0] & 0x7f) | ((value[1] & 0x08) << 4);
 			/* printk("%2.2x, %2.2x -> %2.2x\n",
 			/* printk("%2.2x, %2.2x -> %2.2x\n",
-				  value[0], value[1], *bits); */
+			   value[0], value[1], *bits); */
 		}
 		}
 	}
 	}
 	up(&slot->mutex);
 	up(&slot->mutex);
@@ -476,7 +476,7 @@ static int dt9812_digital_out(struct slot_dt9812 *slot, u8 bits)
 	return result;
 	return result;
 }
 }
 
 
-static int dt9812_digital_out_shadow(struct slot_dt9812 *slot, u8 *bits)
+static int dt9812_digital_out_shadow(struct slot_dt9812 *slot, u8 * bits)
 {
 {
 	int result = -ENODEV;
 	int result = -ENODEV;
 
 
@@ -516,8 +516,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
 
 
 	rmw->address = F020_SFR_ADC0CF;
 	rmw->address = F020_SFR_ADC0CF;
 	rmw->and_mask = F020_MASK_ADC0CF_AMP0GN2 |
 	rmw->and_mask = F020_MASK_ADC0CF_AMP0GN2 |
-			F020_MASK_ADC0CF_AMP0GN1 |
-			F020_MASK_ADC0CF_AMP0GN0;
+	    F020_MASK_ADC0CF_AMP0GN1 | F020_MASK_ADC0CF_AMP0GN0;
 	switch (gain) {
 	switch (gain) {
 		/*
 		/*
 		 * 000 -> Gain =  1
 		 * 000 -> Gain =  1
@@ -529,7 +528,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
 		 */
 		 */
 	case DT9812_GAIN_0PT5:
 	case DT9812_GAIN_0PT5:
 		rmw->or_value = F020_MASK_ADC0CF_AMP0GN2 ||
 		rmw->or_value = F020_MASK_ADC0CF_AMP0GN2 ||
-				F020_MASK_ADC0CF_AMP0GN1;
+		    F020_MASK_ADC0CF_AMP0GN1;
 		break;
 		break;
 	case DT9812_GAIN_1:
 	case DT9812_GAIN_1:
 		rmw->or_value = 0x00;
 		rmw->or_value = 0x00;
@@ -542,7 +541,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
 		break;
 		break;
 	case DT9812_GAIN_8:
 	case DT9812_GAIN_8:
 		rmw->or_value = F020_MASK_ADC0CF_AMP0GN1 ||
 		rmw->or_value = F020_MASK_ADC0CF_AMP0GN1 ||
-				F020_MASK_ADC0CF_AMP0GN0;
+		    F020_MASK_ADC0CF_AMP0GN0;
 		break;
 		break;
 	case DT9812_GAIN_16:
 	case DT9812_GAIN_16:
 		rmw->or_value = F020_MASK_ADC0CF_AMP0GN2;
 		rmw->or_value = F020_MASK_ADC0CF_AMP0GN2;
@@ -553,7 +552,7 @@ static void dt9812_configure_gain(struct usb_dt9812 *dev,
 	}
 	}
 }
 }
 
 
-static int dt9812_analog_in(struct slot_dt9812 *slot, int channel, u16 *value,
+static int dt9812_analog_in(struct slot_dt9812 *slot, int channel, u16 * value,
 			    enum dt9812_gain gain)
 			    enum dt9812_gain gain)
 {
 {
 	struct dt9812_rmw_byte rmw[3];
 	struct dt9812_rmw_byte rmw[3];
@@ -620,7 +619,7 @@ exit:
 }
 }
 
 
 static int dt9812_analog_out_shadow(struct slot_dt9812 *slot, int channel,
 static int dt9812_analog_out_shadow(struct slot_dt9812 *slot, int channel,
-				    u16 *value)
+				    u16 * value)
 {
 {
 	int result = -ENODEV;
 	int result = -ENODEV;
 
 
@@ -729,32 +728,32 @@ static int dt9812_probe(struct usb_interface *interface,
 			direction = USB_DIR_IN;
 			direction = USB_DIR_IN;
 			dev->message_pipe.addr = endpoint->bEndpointAddress;
 			dev->message_pipe.addr = endpoint->bEndpointAddress;
 			dev->message_pipe.size =
 			dev->message_pipe.size =
-					le16_to_cpu(endpoint->wMaxPacketSize);
+			    le16_to_cpu(endpoint->wMaxPacketSize);
 
 
 			break;
 			break;
 		case 1:
 		case 1:
 			direction = USB_DIR_OUT;
 			direction = USB_DIR_OUT;
 			dev->command_write.addr = endpoint->bEndpointAddress;
 			dev->command_write.addr = endpoint->bEndpointAddress;
 			dev->command_write.size =
 			dev->command_write.size =
-					le16_to_cpu(endpoint->wMaxPacketSize);
+			    le16_to_cpu(endpoint->wMaxPacketSize);
 			break;
 			break;
 		case 2:
 		case 2:
 			direction = USB_DIR_IN;
 			direction = USB_DIR_IN;
 			dev->command_read.addr = endpoint->bEndpointAddress;
 			dev->command_read.addr = endpoint->bEndpointAddress;
 			dev->command_read.size =
 			dev->command_read.size =
-					le16_to_cpu(endpoint->wMaxPacketSize);
+			    le16_to_cpu(endpoint->wMaxPacketSize);
 			break;
 			break;
 		case 3:
 		case 3:
 			direction = USB_DIR_OUT;
 			direction = USB_DIR_OUT;
 			dev->write_stream.addr = endpoint->bEndpointAddress;
 			dev->write_stream.addr = endpoint->bEndpointAddress;
 			dev->write_stream.size =
 			dev->write_stream.size =
-					le16_to_cpu(endpoint->wMaxPacketSize);
+			    le16_to_cpu(endpoint->wMaxPacketSize);
 			break;
 			break;
 		case 4:
 		case 4:
 			direction = USB_DIR_IN;
 			direction = USB_DIR_IN;
 			dev->read_stream.addr = endpoint->bEndpointAddress;
 			dev->read_stream.addr = endpoint->bEndpointAddress;
 			dev->read_stream.size =
 			dev->read_stream.size =
-					le16_to_cpu(endpoint->wMaxPacketSize);
+			    le16_to_cpu(endpoint->wMaxPacketSize);
 			break;
 			break;
 		}
 		}
 		if ((endpoint->bEndpointAddress & USB_DIR_IN) != direction) {
 		if ((endpoint->bEndpointAddress & USB_DIR_IN) != direction) {
@@ -786,8 +785,7 @@ static int dt9812_probe(struct usb_interface *interface,
 		retval = -ENODEV;
 		retval = -ENODEV;
 		goto error;
 		goto error;
 	}
 	}
-	if (dt9812_read_info(dev, 3, &dev->product,
-			     sizeof(dev->product)) != 0) {
+	if (dt9812_read_info(dev, 3, &dev->product, sizeof(dev->product)) != 0) {
 		err("Failed to read product.");
 		err("Failed to read product.");
 		retval = -ENODEV;
 		retval = -ENODEV;
 		goto error;
 		goto error;
@@ -940,8 +938,9 @@ static void dt9812_comedi_open(struct comedi_device *dev)
 	up(&devpriv->slot->mutex);
 	up(&devpriv->slot->mutex);
 }
 }
 
 
-static int dt9812_di_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-			   struct comedi_insn *insn, unsigned int *data)
+static int dt9812_di_rinsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	int n;
 	int n;
 	u8 bits = 0;
 	u8 bits = 0;
@@ -952,8 +951,9 @@ static int dt9812_di_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
 	return n;
 	return n;
 }
 }
 
 
-static int dt9812_do_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-			   struct comedi_insn *insn, unsigned int *data)
+static int dt9812_do_winsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	int n;
 	int n;
 	u8 bits = 0;
 	u8 bits = 0;
@@ -970,8 +970,9 @@ static int dt9812_do_winsn(struct comedi_device *dev, struct comedi_subdevice *s
 	return n;
 	return n;
 }
 }
 
 
-static int dt9812_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-			   struct comedi_insn *insn, unsigned int *data)
+static int dt9812_ai_rinsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	int n;
 	int n;
 
 
@@ -985,8 +986,9 @@ static int dt9812_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
 	return n;
 	return n;
 }
 }
 
 
-static int dt9812_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-			   struct comedi_insn *insn, unsigned int *data)
+static int dt9812_ao_rinsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	int n;
 	int n;
 	u16 value;
 	u16 value;
@@ -999,8 +1001,9 @@ static int dt9812_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
 	return n;
 	return n;
 }
 }
 
 
-static int dt9812_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-			   struct comedi_insn *insn, unsigned int *data)
+static int dt9812_ao_winsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	int n;
 	int n;
 
 

+ 21 - 16
drivers/staging/comedi/drivers/fl512.c

@@ -32,14 +32,14 @@ struct fl512_private {
 #define devpriv ((struct fl512_private *) dev->private)
 #define devpriv ((struct fl512_private *) dev->private)
 
 
 static const struct comedi_lrange range_fl512 = { 4, {
 static const struct comedi_lrange range_fl512 = { 4, {
-			BIP_RANGE(0.5),
-			BIP_RANGE(1),
-			BIP_RANGE(5),
-			BIP_RANGE(10),
-			UNI_RANGE(1),
-			UNI_RANGE(5),
-			UNI_RANGE(10),
-	}
+						      BIP_RANGE(0.5),
+						      BIP_RANGE(1),
+						      BIP_RANGE(5),
+						      BIP_RANGE(10),
+						      UNI_RANGE(1),
+						      UNI_RANGE(5),
+						      UNI_RANGE(10),
+						      }
 };
 };
 
 
 static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it);
 static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it);
@@ -55,17 +55,20 @@ static struct comedi_driver driver_fl512 = {
 COMEDI_INITCLEANUP(driver_fl512);
 COMEDI_INITCLEANUP(driver_fl512);
 
 
 static int fl512_ai_insn(struct comedi_device *dev,
 static int fl512_ai_insn(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
-static int fl512_ao_insn(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+			 struct comedi_subdevice *s, struct comedi_insn *insn,
+			 unsigned int *data);
+static int fl512_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s,
+			 struct comedi_insn *insn, unsigned int *data);
 static int fl512_ao_insn_readback(struct comedi_device *dev,
 static int fl512_ao_insn_readback(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data);
 
 
 /*
 /*
  * fl512_ai_insn : this is the analog input function
  * fl512_ai_insn : this is the analog input function
  */
  */
 static int fl512_ai_insn(struct comedi_device *dev,
 static int fl512_ai_insn(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+			 struct comedi_subdevice *s, struct comedi_insn *insn,
+			 unsigned int *data)
 {
 {
 	int n;
 	int n;
 	unsigned int lo_byte, hi_byte;
 	unsigned int lo_byte, hi_byte;
@@ -90,7 +93,8 @@ static int fl512_ai_insn(struct comedi_device *dev,
  * fl512_ao_insn : used to write to a DA port n times
  * fl512_ao_insn : used to write to a DA port n times
  */
  */
 static int fl512_ao_insn(struct comedi_device *dev,
 static int fl512_ao_insn(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+			 struct comedi_subdevice *s, struct comedi_insn *insn,
+			 unsigned int *data)
 {
 {
 	int n;
 	int n;
 	int chan = CR_CHAN(insn->chanspec);	/* get chan to write */
 	int chan = CR_CHAN(insn->chanspec);	/* get chan to write */
@@ -111,7 +115,8 @@ static int fl512_ao_insn(struct comedi_device *dev,
  * DA port
  * DA port
  */
  */
 static int fl512_ao_insn_readback(struct comedi_device *dev,
 static int fl512_ao_insn_readback(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n;
 	int n;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -130,7 +135,7 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
 {
 	unsigned long iobase;
 	unsigned long iobase;
 	struct comedi_subdevice *s;	/* pointer to the subdevice:
 	struct comedi_subdevice *s;	/* pointer to the subdevice:
-				   Analog in, Analog out, ( not made ->and Digital IO) */
+					   Analog in, Analog out, ( not made ->and Digital IO) */
 
 
 	iobase = it->options[0];
 	iobase = it->options[0];
 	printk("comedi:%d fl512: 0x%04lx", dev->minor, iobase);
 	printk("comedi:%d fl512: 0x%04lx", dev->minor, iobase);

+ 123 - 113
drivers/staging/comedi/drivers/gsc_hpdi.c

@@ -58,7 +58,7 @@ static int hpdi_detach(struct comedi_device *dev);
 void abort_dma(struct comedi_device *dev, unsigned int channel);
 void abort_dma(struct comedi_device *dev, unsigned int channel);
 static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
 static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
 static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
 static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd);
+			 struct comedi_cmd *cmd);
 static int hpdi_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
 static int hpdi_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
 static irqreturn_t handle_interrupt(int irq, void *d);
 static irqreturn_t handle_interrupt(int irq, void *d);
 static int dio_config_block_size(struct comedi_device *dev, unsigned int *data);
 static int dio_config_block_size(struct comedi_device *dev, unsigned int *data);
@@ -149,7 +149,7 @@ enum board_control_bits {
 	TEST_MODE_ENABLE_BIT = 0x80000000,
 	TEST_MODE_ENABLE_BIT = 0x80000000,
 };
 };
 uint32_t command_discrete_output_bits(unsigned int channel, int output,
 uint32_t command_discrete_output_bits(unsigned int channel, int output,
-	int output_value)
+				      int output_value)
 {
 {
 	uint32_t bits = 0;
 	uint32_t bits = 0;
 
 
@@ -193,11 +193,13 @@ uint32_t almost_empty_bits(unsigned int num_words)
 {
 {
 	return num_words & 0xffff;
 	return num_words & 0xffff;
 }
 }
+
 unsigned int almost_full_num_words(uint32_t bits)
 unsigned int almost_full_num_words(uint32_t bits)
 {
 {
 /* XXX need to add or subtract one? */
 /* XXX need to add or subtract one? */
 	return (bits >> 16) & 0xffff;
 	return (bits >> 16) & 0xffff;
 }
 }
+
 unsigned int almost_empty_num_words(uint32_t bits)
 unsigned int almost_empty_num_words(uint32_t bits)
 {
 {
 	return bits & 0xffff;
 	return bits & 0xffff;
@@ -268,33 +270,33 @@ struct hpdi_board {
 	int subdevice_id;	/*  pci subdevice id */
 	int subdevice_id;	/*  pci subdevice id */
 };
 };
 
 
-
 static const struct hpdi_board hpdi_boards[] = {
 static const struct hpdi_board hpdi_boards[] = {
 	{
 	{
-	.name = "pci-hpdi32",
-	.device_id = PCI_DEVICE_ID_PLX_9080,
-	.subdevice_id = 0x2400,
-		},
+	 .name = "pci-hpdi32",
+	 .device_id = PCI_DEVICE_ID_PLX_9080,
+	 .subdevice_id = 0x2400,
+	 },
 #if 0
 #if 0
 	{
 	{
-	.name = "pxi-hpdi32",
-	.device_id = 0x9656,
-	.subdevice_id = 0x2705,
-		},
+	 .name = "pxi-hpdi32",
+	 .device_id = 0x9656,
+	 .subdevice_id = 0x2705,
+	 },
 #endif
 #endif
 };
 };
 
 
 static DEFINE_PCI_DEVICE_TABLE(hpdi_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(hpdi_pci_table) = {
-	{PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX, 0x2400,
-		0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX,
+		    0x2400, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, hpdi_pci_table);
 MODULE_DEVICE_TABLE(pci, hpdi_pci_table);
 
 
-static inline struct hpdi_board *board(const struct comedi_device * dev)
+static inline struct hpdi_board *board(const struct comedi_device *dev)
 {
 {
-	return (struct hpdi_board *) dev->board_ptr;
+	return (struct hpdi_board *)dev->board_ptr;
 }
 }
 
 
 struct hpdi_private {
 struct hpdi_private {
@@ -321,8 +323,7 @@ struct hpdi_private {
 	unsigned dio_config_output:1;
 	unsigned dio_config_output:1;
 };
 };
 
 
-
-static inline struct hpdi_private *priv(struct comedi_device * dev)
+static inline struct hpdi_private *priv(struct comedi_device *dev)
 {
 {
 	return dev->private;
 	return dev->private;
 }
 }
@@ -336,8 +337,9 @@ static struct comedi_driver driver_hpdi = {
 
 
 COMEDI_PCI_INITCLEANUP(driver_hpdi, hpdi_pci_table);
 COMEDI_PCI_INITCLEANUP(driver_hpdi, hpdi_pci_table);
 
 
-static int dio_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int dio_config_insn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	switch (data[0]) {
 	switch (data[0]) {
 	case INSN_CONFIG_DIO_OUTPUT:
 	case INSN_CONFIG_DIO_OUTPUT:
@@ -350,8 +352,7 @@ static int dio_config_insn(struct comedi_device *dev, struct comedi_subdevice *s
 		break;
 		break;
 	case INSN_CONFIG_DIO_QUERY:
 	case INSN_CONFIG_DIO_QUERY:
 		data[1] =
 		data[1] =
-			priv(dev)->
-			dio_config_output ? COMEDI_OUTPUT : COMEDI_INPUT;
+		    priv(dev)->dio_config_output ? COMEDI_OUTPUT : COMEDI_INPUT;
 		return insn->n;
 		return insn->n;
 		break;
 		break;
 	case INSN_CONFIG_BLOCK_SIZE:
 	case INSN_CONFIG_BLOCK_SIZE:
@@ -377,29 +378,29 @@ static void init_plx9080(struct comedi_device *dev)
 
 
 	/*  plx9080 dump */
 	/*  plx9080 dump */
 	DEBUG_PRINT(" plx interrupt status 0x%x\n",
 	DEBUG_PRINT(" plx interrupt status 0x%x\n",
-		readl(plx_iobase + PLX_INTRCS_REG));
+		    readl(plx_iobase + PLX_INTRCS_REG));
 	DEBUG_PRINT(" plx id bits 0x%x\n", readl(plx_iobase + PLX_ID_REG));
 	DEBUG_PRINT(" plx id bits 0x%x\n", readl(plx_iobase + PLX_ID_REG));
 	DEBUG_PRINT(" plx control reg 0x%x\n",
 	DEBUG_PRINT(" plx control reg 0x%x\n",
-		readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG));
+		    readl(priv(dev)->plx9080_iobase + PLX_CONTROL_REG));
 
 
 	DEBUG_PRINT(" plx revision 0x%x\n",
 	DEBUG_PRINT(" plx revision 0x%x\n",
-		readl(plx_iobase + PLX_REVISION_REG));
+		    readl(plx_iobase + PLX_REVISION_REG));
 	DEBUG_PRINT(" plx dma channel 0 mode 0x%x\n",
 	DEBUG_PRINT(" plx dma channel 0 mode 0x%x\n",
-		readl(plx_iobase + PLX_DMA0_MODE_REG));
+		    readl(plx_iobase + PLX_DMA0_MODE_REG));
 	DEBUG_PRINT(" plx dma channel 1 mode 0x%x\n",
 	DEBUG_PRINT(" plx dma channel 1 mode 0x%x\n",
-		readl(plx_iobase + PLX_DMA1_MODE_REG));
+		    readl(plx_iobase + PLX_DMA1_MODE_REG));
 	DEBUG_PRINT(" plx dma channel 0 pci address 0x%x\n",
 	DEBUG_PRINT(" plx dma channel 0 pci address 0x%x\n",
-		readl(plx_iobase + PLX_DMA0_PCI_ADDRESS_REG));
+		    readl(plx_iobase + PLX_DMA0_PCI_ADDRESS_REG));
 	DEBUG_PRINT(" plx dma channel 0 local address 0x%x\n",
 	DEBUG_PRINT(" plx dma channel 0 local address 0x%x\n",
-		readl(plx_iobase + PLX_DMA0_LOCAL_ADDRESS_REG));
+		    readl(plx_iobase + PLX_DMA0_LOCAL_ADDRESS_REG));
 	DEBUG_PRINT(" plx dma channel 0 transfer size 0x%x\n",
 	DEBUG_PRINT(" plx dma channel 0 transfer size 0x%x\n",
-		readl(plx_iobase + PLX_DMA0_TRANSFER_SIZE_REG));
+		    readl(plx_iobase + PLX_DMA0_TRANSFER_SIZE_REG));
 	DEBUG_PRINT(" plx dma channel 0 descriptor 0x%x\n",
 	DEBUG_PRINT(" plx dma channel 0 descriptor 0x%x\n",
-		readl(plx_iobase + PLX_DMA0_DESCRIPTOR_REG));
+		    readl(plx_iobase + PLX_DMA0_DESCRIPTOR_REG));
 	DEBUG_PRINT(" plx dma channel 0 command status 0x%x\n",
 	DEBUG_PRINT(" plx dma channel 0 command status 0x%x\n",
-		readb(plx_iobase + PLX_DMA0_CS_REG));
+		    readb(plx_iobase + PLX_DMA0_CS_REG));
 	DEBUG_PRINT(" plx dma channel 0 threshold 0x%x\n",
 	DEBUG_PRINT(" plx dma channel 0 threshold 0x%x\n",
-		readl(plx_iobase + PLX_DMA0_THRESHOLD_REG));
+		    readl(plx_iobase + PLX_DMA0_THRESHOLD_REG));
 	DEBUG_PRINT(" plx bigend 0x%x\n", readl(plx_iobase + PLX_BIGEND_REG));
 	DEBUG_PRINT(" plx bigend 0x%x\n", readl(plx_iobase + PLX_BIGEND_REG));
 #ifdef __BIG_ENDIAN
 #ifdef __BIG_ENDIAN
 	bits = BIGEND_DMA0 | BIGEND_DMA1;
 	bits = BIGEND_DMA0 | BIGEND_DMA1;
@@ -448,7 +449,7 @@ static int setup_subdevices(struct comedi_device *dev)
 /*	dev->write_subdev = s; */
 /*	dev->write_subdev = s; */
 	s->type = COMEDI_SUBD_DIO;
 	s->type = COMEDI_SUBD_DIO;
 	s->subdev_flags =
 	s->subdev_flags =
-		SDF_READABLE | SDF_WRITEABLE | SDF_LSAMPL | SDF_CMD_READ;
+	    SDF_READABLE | SDF_WRITEABLE | SDF_LSAMPL | SDF_CMD_READ;
 	s->n_chan = 32;
 	s->n_chan = 32;
 	s->len_chanlist = 32;
 	s->len_chanlist = 32;
 	s->maxdata = 1;
 	s->maxdata = 1;
@@ -469,21 +470,21 @@ static int init_hpdi(struct comedi_device *dev)
 	udelay(10);
 	udelay(10);
 
 
 	writel(almost_empty_bits(32) | almost_full_bits(32),
 	writel(almost_empty_bits(32) | almost_full_bits(32),
-		priv(dev)->hpdi_iobase + RX_PROG_ALMOST_REG);
+	       priv(dev)->hpdi_iobase + RX_PROG_ALMOST_REG);
 	writel(almost_empty_bits(32) | almost_full_bits(32),
 	writel(almost_empty_bits(32) | almost_full_bits(32),
-		priv(dev)->hpdi_iobase + TX_PROG_ALMOST_REG);
+	       priv(dev)->hpdi_iobase + TX_PROG_ALMOST_REG);
 
 
 	priv(dev)->tx_fifo_size = fifo_size(readl(priv(dev)->hpdi_iobase +
 	priv(dev)->tx_fifo_size = fifo_size(readl(priv(dev)->hpdi_iobase +
-			TX_FIFO_SIZE_REG));
+						  TX_FIFO_SIZE_REG));
 	priv(dev)->rx_fifo_size = fifo_size(readl(priv(dev)->hpdi_iobase +
 	priv(dev)->rx_fifo_size = fifo_size(readl(priv(dev)->hpdi_iobase +
-			RX_FIFO_SIZE_REG));
+						  RX_FIFO_SIZE_REG));
 
 
 	writel(0, priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG);
 	writel(0, priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG);
 
 
 	/*  enable interrupts */
 	/*  enable interrupts */
 	plx_intcsr_bits =
 	plx_intcsr_bits =
-		ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE |
-		ICS_DMA0_E;
+	    ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE |
+	    ICS_DMA0_E;
 	writel(plx_intcsr_bits, priv(dev)->plx9080_iobase + PLX_INTRCS_REG);
 	writel(plx_intcsr_bits, priv(dev)->plx9080_iobase + PLX_INTRCS_REG);
 
 
 	return 0;
 	return 0;
@@ -491,11 +492,11 @@ static int init_hpdi(struct comedi_device *dev)
 
 
 /* setup dma descriptors so a link completes every 'transfer_size' bytes */
 /* setup dma descriptors so a link completes every 'transfer_size' bytes */
 static int setup_dma_descriptors(struct comedi_device *dev,
 static int setup_dma_descriptors(struct comedi_device *dev,
-	unsigned int transfer_size)
+				 unsigned int transfer_size)
 {
 {
 	unsigned int buffer_index, buffer_offset;
 	unsigned int buffer_index, buffer_offset;
 	uint32_t next_bits = PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT |
 	uint32_t next_bits = PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT |
-		PLX_XFER_LOCAL_TO_PCI;
+	    PLX_XFER_LOCAL_TO_PCI;
 	unsigned int i;
 	unsigned int i;
 
 
 	if (transfer_size > DMA_BUFFER_SIZE)
 	if (transfer_size > DMA_BUFFER_SIZE)
@@ -506,26 +507,26 @@ static int setup_dma_descriptors(struct comedi_device *dev,
 
 
 	DEBUG_PRINT(" transfer_size %i\n", transfer_size);
 	DEBUG_PRINT(" transfer_size %i\n", transfer_size);
 	DEBUG_PRINT(" descriptors at 0x%lx\n",
 	DEBUG_PRINT(" descriptors at 0x%lx\n",
-		(unsigned long)priv(dev)->dma_desc_phys_addr);
+		    (unsigned long)priv(dev)->dma_desc_phys_addr);
 
 
 	buffer_offset = 0;
 	buffer_offset = 0;
 	buffer_index = 0;
 	buffer_index = 0;
 	for (i = 0; i < NUM_DMA_DESCRIPTORS &&
 	for (i = 0; i < NUM_DMA_DESCRIPTORS &&
-		buffer_index < NUM_DMA_BUFFERS; i++) {
+	     buffer_index < NUM_DMA_BUFFERS; i++) {
 		priv(dev)->dma_desc[i].pci_start_addr =
 		priv(dev)->dma_desc[i].pci_start_addr =
-			cpu_to_le32(priv(dev)->
-			dio_buffer_phys_addr[buffer_index] + buffer_offset);
+		    cpu_to_le32(priv(dev)->dio_buffer_phys_addr[buffer_index] +
+				buffer_offset);
 		priv(dev)->dma_desc[i].local_start_addr = cpu_to_le32(FIFO_REG);
 		priv(dev)->dma_desc[i].local_start_addr = cpu_to_le32(FIFO_REG);
 		priv(dev)->dma_desc[i].transfer_size =
 		priv(dev)->dma_desc[i].transfer_size =
-			cpu_to_le32(transfer_size);
+		    cpu_to_le32(transfer_size);
 		priv(dev)->dma_desc[i].next =
 		priv(dev)->dma_desc[i].next =
-			cpu_to_le32((priv(dev)->dma_desc_phys_addr + (i +
-					1) *
-				sizeof(priv(dev)->dma_desc[0])) | next_bits);
+		    cpu_to_le32((priv(dev)->dma_desc_phys_addr + (i +
+								  1) *
+				 sizeof(priv(dev)->dma_desc[0])) | next_bits);
 
 
 		priv(dev)->desc_dio_buffer[i] =
 		priv(dev)->desc_dio_buffer[i] =
-			priv(dev)->dio_buffer[buffer_index] +
-			(buffer_offset / sizeof(uint32_t));
+		    priv(dev)->dio_buffer[buffer_index] +
+		    (buffer_offset / sizeof(uint32_t));
 
 
 		buffer_offset += transfer_size;
 		buffer_offset += transfer_size;
 		if (transfer_size + buffer_offset > DMA_BUFFER_SIZE) {
 		if (transfer_size + buffer_offset > DMA_BUFFER_SIZE) {
@@ -535,17 +536,18 @@ static int setup_dma_descriptors(struct comedi_device *dev,
 
 
 		DEBUG_PRINT(" desc %i\n", i);
 		DEBUG_PRINT(" desc %i\n", i);
 		DEBUG_PRINT(" start addr virt 0x%p, phys 0x%lx\n",
 		DEBUG_PRINT(" start addr virt 0x%p, phys 0x%lx\n",
-			priv(dev)->desc_dio_buffer[i],
-			(unsigned long)priv(dev)->dma_desc[i].pci_start_addr);
+			    priv(dev)->desc_dio_buffer[i],
+			    (unsigned long)priv(dev)->dma_desc[i].
+			    pci_start_addr);
 		DEBUG_PRINT(" next 0x%lx\n",
 		DEBUG_PRINT(" next 0x%lx\n",
-			(unsigned long)priv(dev)->dma_desc[i].next);
+			    (unsigned long)priv(dev)->dma_desc[i].next);
 	}
 	}
 	priv(dev)->num_dma_descriptors = i;
 	priv(dev)->num_dma_descriptors = i;
 	/*  fix last descriptor to point back to first */
 	/*  fix last descriptor to point back to first */
 	priv(dev)->dma_desc[i - 1].next =
 	priv(dev)->dma_desc[i - 1].next =
-		cpu_to_le32(priv(dev)->dma_desc_phys_addr | next_bits);
+	    cpu_to_le32(priv(dev)->dma_desc_phys_addr | next_bits);
 	DEBUG_PRINT(" desc %i next fixup 0x%lx\n", i - 1,
 	DEBUG_PRINT(" desc %i next fixup 0x%lx\n", i - 1,
-		(unsigned long)priv(dev)->dma_desc[i - 1].next);
+		    (unsigned long)priv(dev)->dma_desc[i - 1].next);
 
 
 	priv(dev)->block_size = transfer_size;
 	priv(dev)->block_size = transfer_size;
 
 
@@ -567,14 +569,15 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	for (i = 0; i < ARRAY_SIZE(hpdi_boards) && dev->board_ptr == NULL; i++) {
 	for (i = 0; i < ARRAY_SIZE(hpdi_boards) && dev->board_ptr == NULL; i++) {
 		do {
 		do {
 			pcidev = pci_get_subsys(PCI_VENDOR_ID_PLX,
 			pcidev = pci_get_subsys(PCI_VENDOR_ID_PLX,
-				hpdi_boards[i].device_id, PCI_VENDOR_ID_PLX,
-				hpdi_boards[i].subdevice_id, pcidev);
+						hpdi_boards[i].device_id,
+						PCI_VENDOR_ID_PLX,
+						hpdi_boards[i].subdevice_id,
+						pcidev);
 			/*  was a particular bus/slot requested? */
 			/*  was a particular bus/slot requested? */
 			if (it->options[0] || it->options[1]) {
 			if (it->options[0] || it->options[1]) {
 				/*  are we on the wrong bus/slot? */
 				/*  are we on the wrong bus/slot? */
 				if (pcidev->bus->number != it->options[0] ||
 				if (pcidev->bus->number != it->options[0] ||
-					PCI_SLOT(pcidev->devfn) !=
-					it->options[1])
+				    PCI_SLOT(pcidev->devfn) != it->options[1])
 					continue;
 					continue;
 			}
 			}
 			if (pcidev) {
 			if (pcidev) {
@@ -590,11 +593,11 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	}
 	}
 
 
 	printk("gsc_hpdi: found %s on bus %i, slot %i\n", board(dev)->name,
 	printk("gsc_hpdi: found %s on bus %i, slot %i\n", board(dev)->name,
-		pcidev->bus->number, PCI_SLOT(pcidev->devfn));
+	       pcidev->bus->number, PCI_SLOT(pcidev->devfn));
 
 
 	if (comedi_pci_enable(pcidev, driver_hpdi.driver_name)) {
 	if (comedi_pci_enable(pcidev, driver_hpdi.driver_name)) {
 		printk(KERN_WARNING
 		printk(KERN_WARNING
-			" failed enable PCI device and request regions\n");
+		       " failed enable PCI device and request regions\n");
 		return -EIO;
 		return -EIO;
 	}
 	}
 	pci_set_master(pcidev);
 	pci_set_master(pcidev);
@@ -603,15 +606,17 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	dev->board_name = board(dev)->name;
 	dev->board_name = board(dev)->name;
 
 
 	priv(dev)->plx9080_phys_iobase =
 	priv(dev)->plx9080_phys_iobase =
-		pci_resource_start(pcidev, PLX9080_BADDRINDEX);
+	    pci_resource_start(pcidev, PLX9080_BADDRINDEX);
 	priv(dev)->hpdi_phys_iobase =
 	priv(dev)->hpdi_phys_iobase =
-		pci_resource_start(pcidev, HPDI_BADDRINDEX);
+	    pci_resource_start(pcidev, HPDI_BADDRINDEX);
 
 
 	/*  remap, won't work with 2.0 kernels but who cares */
 	/*  remap, won't work with 2.0 kernels but who cares */
 	priv(dev)->plx9080_iobase = ioremap(priv(dev)->plx9080_phys_iobase,
 	priv(dev)->plx9080_iobase = ioremap(priv(dev)->plx9080_phys_iobase,
-		pci_resource_len(pcidev, PLX9080_BADDRINDEX));
-	priv(dev)->hpdi_iobase = ioremap(priv(dev)->hpdi_phys_iobase,
-		pci_resource_len(pcidev, HPDI_BADDRINDEX));
+					    pci_resource_len(pcidev,
+							     PLX9080_BADDRINDEX));
+	priv(dev)->hpdi_iobase =
+	    ioremap(priv(dev)->hpdi_phys_iobase,
+		    pci_resource_len(pcidev, HPDI_BADDRINDEX));
 	if (!priv(dev)->plx9080_iobase || !priv(dev)->hpdi_iobase) {
 	if (!priv(dev)->plx9080_iobase || !priv(dev)->hpdi_iobase) {
 		printk(" failed to remap io memory\n");
 		printk(" failed to remap io memory\n");
 		return -ENOMEM;
 		return -ENOMEM;
@@ -635,16 +640,18 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	/*  alocate pci dma buffers */
 	/*  alocate pci dma buffers */
 	for (i = 0; i < NUM_DMA_BUFFERS; i++) {
 	for (i = 0; i < NUM_DMA_BUFFERS; i++) {
 		priv(dev)->dio_buffer[i] =
 		priv(dev)->dio_buffer[i] =
-			pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE,
-			&priv(dev)->dio_buffer_phys_addr[i]);
+		    pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE,
+					 &priv(dev)->dio_buffer_phys_addr[i]);
 		DEBUG_PRINT("dio_buffer at virt 0x%p, phys 0x%lx\n",
 		DEBUG_PRINT("dio_buffer at virt 0x%p, phys 0x%lx\n",
-			priv(dev)->dio_buffer[i],
-			(unsigned long)priv(dev)->dio_buffer_phys_addr[i]);
+			    priv(dev)->dio_buffer[i],
+			    (unsigned long)priv(dev)->dio_buffer_phys_addr[i]);
 	}
 	}
 	/*  allocate dma descriptors */
 	/*  allocate dma descriptors */
 	priv(dev)->dma_desc = pci_alloc_consistent(priv(dev)->hw_dev,
 	priv(dev)->dma_desc = pci_alloc_consistent(priv(dev)->hw_dev,
-		sizeof(struct plx_dma_desc) * NUM_DMA_DESCRIPTORS,
-		&priv(dev)->dma_desc_phys_addr);
+						   sizeof(struct plx_dma_desc) *
+						   NUM_DMA_DESCRIPTORS,
+						   &priv(dev)->
+						   dma_desc_phys_addr);
 	if (priv(dev)->dma_desc_phys_addr & 0xf) {
 	if (priv(dev)->dma_desc_phys_addr & 0xf) {
 		printk(" dma descriptors not quad-word aligned (bug)\n");
 		printk(" dma descriptors not quad-word aligned (bug)\n");
 		return -EIO;
 		return -EIO;
@@ -681,18 +688,21 @@ static int hpdi_detach(struct comedi_device *dev)
 			for (i = 0; i < NUM_DMA_BUFFERS; i++) {
 			for (i = 0; i < NUM_DMA_BUFFERS; i++) {
 				if (priv(dev)->dio_buffer[i])
 				if (priv(dev)->dio_buffer[i])
 					pci_free_consistent(priv(dev)->hw_dev,
 					pci_free_consistent(priv(dev)->hw_dev,
-						DMA_BUFFER_SIZE,
-						priv(dev)->dio_buffer[i],
-						priv(dev)->
-						dio_buffer_phys_addr[i]);
+							    DMA_BUFFER_SIZE,
+							    priv(dev)->
+							    dio_buffer[i],
+							    priv
+							    (dev)->dio_buffer_phys_addr
+							    [i]);
 			}
 			}
 			/*  free dma descriptors */
 			/*  free dma descriptors */
 			if (priv(dev)->dma_desc)
 			if (priv(dev)->dma_desc)
 				pci_free_consistent(priv(dev)->hw_dev,
 				pci_free_consistent(priv(dev)->hw_dev,
-					sizeof(struct plx_dma_desc) *
-					NUM_DMA_DESCRIPTORS,
-					priv(dev)->dma_desc,
-					priv(dev)->dma_desc_phys_addr);
+						    sizeof(struct plx_dma_desc)
+						    * NUM_DMA_DESCRIPTORS,
+						    priv(dev)->dma_desc,
+						    priv(dev)->
+						    dma_desc_phys_addr);
 			if (priv(dev)->hpdi_phys_iobase) {
 			if (priv(dev)->hpdi_phys_iobase) {
 				comedi_pci_disable(priv(dev)->hw_dev);
 				comedi_pci_disable(priv(dev)->hw_dev);
 			}
 			}
@@ -719,7 +729,7 @@ static int dio_config_block_size(struct comedi_device *dev, unsigned int *data)
 }
 }
 
 
 static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
 static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+		       struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -805,7 +815,7 @@ static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
 			if (CR_CHAN(cmd->chanlist[i]) != i) {
 			if (CR_CHAN(cmd->chanlist[i]) != i) {
 				/*  XXX could support 8 channels or 16 channels */
 				/*  XXX could support 8 channels or 16 channels */
 				comedi_error(dev,
 				comedi_error(dev,
-					"chanlist must be channels 0 to 31 in order");
+					     "chanlist must be channels 0 to 31 in order");
 				err++;
 				err++;
 				break;
 				break;
 			}
 			}
@@ -819,7 +829,7 @@ static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
 }
 }
 
 
 static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
 static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+			 struct comedi_cmd *cmd)
 {
 {
 	if (priv(dev)->dio_config_output) {
 	if (priv(dev)->dio_config_output) {
 		return -EINVAL;
 		return -EINVAL;
@@ -828,10 +838,10 @@ static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
 }
 }
 
 
 static inline void hpdi_writel(struct comedi_device *dev, uint32_t bits,
 static inline void hpdi_writel(struct comedi_device *dev, uint32_t bits,
-	unsigned int offset)
+			       unsigned int offset)
 {
 {
 	writel(bits | priv(dev)->bits[offset / sizeof(uint32_t)],
 	writel(bits | priv(dev)->bits[offset / sizeof(uint32_t)],
-		priv(dev)->hpdi_iobase + offset);
+	       priv(dev)->hpdi_iobase + offset);
 }
 }
 
 
 static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
@@ -857,16 +867,16 @@ static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG);
 	writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG);
 	writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_LOCAL_ADDRESS_REG);
 	writel(0, priv(dev)->plx9080_iobase + PLX_DMA0_LOCAL_ADDRESS_REG);
 	/*  give location of first dma descriptor */
 	/*  give location of first dma descriptor */
-	bits = priv(dev)->
-		dma_desc_phys_addr | PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT |
-		PLX_XFER_LOCAL_TO_PCI;
+	bits =
+	    priv(dev)->dma_desc_phys_addr | PLX_DESC_IN_PCI_BIT |
+	    PLX_INTR_TERM_COUNT | PLX_XFER_LOCAL_TO_PCI;
 	writel(bits, priv(dev)->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG);
 	writel(bits, priv(dev)->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG);
 
 
 	/*  spinlock for plx dma control/status reg */
 	/*  spinlock for plx dma control/status reg */
 	spin_lock_irqsave(&dev->spinlock, flags);
 	spin_lock_irqsave(&dev->spinlock, flags);
 	/*  enable dma transfer */
 	/*  enable dma transfer */
 	writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | PLX_CLEAR_DMA_INTR_BIT,
 	writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | PLX_CLEAR_DMA_INTR_BIT,
-		priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
+	       priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
 	spin_unlock_irqrestore(&dev->spinlock, flags);
 	spin_unlock_irqrestore(&dev->spinlock, flags);
 
 
 	if (cmd->stop_src == TRIG_COUNT)
 	if (cmd->stop_src == TRIG_COUNT)
@@ -876,10 +886,10 @@ static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
 
 	/*  clear over/under run status flags */
 	/*  clear over/under run status flags */
 	writel(RX_UNDERRUN_BIT | RX_OVERRUN_BIT,
 	writel(RX_UNDERRUN_BIT | RX_OVERRUN_BIT,
-		priv(dev)->hpdi_iobase + BOARD_STATUS_REG);
+	       priv(dev)->hpdi_iobase + BOARD_STATUS_REG);
 	/*  enable interrupts */
 	/*  enable interrupts */
 	writel(intr_bit(RX_FULL_INTR),
 	writel(intr_bit(RX_FULL_INTR),
-		priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG);
+	       priv(dev)->hpdi_iobase + INTERRUPT_CONTROL_REG);
 
 
 	DEBUG_PRINT("hpdi: starting rx\n");
 	DEBUG_PRINT("hpdi: starting rx\n");
 	hpdi_writel(dev, RX_ENABLE_BIT, BOARD_CONTROL_REG);
 	hpdi_writel(dev, RX_ENABLE_BIT, BOARD_CONTROL_REG);
@@ -905,22 +915,21 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
 
 
 	if (channel)
 	if (channel)
 		pci_addr_reg =
 		pci_addr_reg =
-			priv(dev)->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG;
+		    priv(dev)->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG;
 	else
 	else
 		pci_addr_reg =
 		pci_addr_reg =
-			priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG;
+		    priv(dev)->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG;
 
 
 	/*  loop until we have read all the full buffers */
 	/*  loop until we have read all the full buffers */
 	j = 0;
 	j = 0;
 	for (next_transfer_addr = readl(pci_addr_reg);
 	for (next_transfer_addr = readl(pci_addr_reg);
-		(next_transfer_addr <
-			le32_to_cpu(priv(dev)->dma_desc[priv(dev)->
-					dma_desc_index].pci_start_addr)
-			|| next_transfer_addr >=
-			le32_to_cpu(priv(dev)->dma_desc[priv(dev)->
-					dma_desc_index].pci_start_addr) +
-			priv(dev)->block_size)
-		&& j < priv(dev)->num_dma_descriptors; j++) {
+	     (next_transfer_addr <
+	      le32_to_cpu(priv(dev)->dma_desc[priv(dev)->dma_desc_index].
+			  pci_start_addr)
+	      || next_transfer_addr >=
+	      le32_to_cpu(priv(dev)->dma_desc[priv(dev)->dma_desc_index].
+			  pci_start_addr) + priv(dev)->block_size)
+	     && j < priv(dev)->num_dma_descriptors; j++) {
 		/*  transfer data from dma buffer to comedi buffer */
 		/*  transfer data from dma buffer to comedi buffer */
 		num_samples = priv(dev)->block_size / sizeof(uint32_t);
 		num_samples = priv(dev)->block_size / sizeof(uint32_t);
 		if (async->cmd.stop_src == TRIG_COUNT) {
 		if (async->cmd.stop_src == TRIG_COUNT) {
@@ -929,13 +938,15 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
 			priv(dev)->dio_count -= num_samples;
 			priv(dev)->dio_count -= num_samples;
 		}
 		}
 		cfc_write_array_to_buffer(dev->read_subdev,
 		cfc_write_array_to_buffer(dev->read_subdev,
-			priv(dev)->desc_dio_buffer[priv(dev)->dma_desc_index],
-			num_samples * sizeof(uint32_t));
+					  priv(dev)->desc_dio_buffer[priv(dev)->
+								     dma_desc_index],
+					  num_samples * sizeof(uint32_t));
 		priv(dev)->dma_desc_index++;
 		priv(dev)->dma_desc_index++;
 		priv(dev)->dma_desc_index %= priv(dev)->num_dma_descriptors;
 		priv(dev)->dma_desc_index %= priv(dev)->num_dma_descriptors;
 
 
 		DEBUG_PRINT("next desc addr 0x%lx\n", (unsigned long)
 		DEBUG_PRINT("next desc addr 0x%lx\n", (unsigned long)
-			priv(dev)->dma_desc[priv(dev)->dma_desc_index].next);
+			    priv(dev)->dma_desc[priv(dev)->dma_desc_index].
+			    next);
 		DEBUG_PRINT("pci addr reg 0x%x\n", next_transfer_addr);
 		DEBUG_PRINT("pci addr reg 0x%x\n", next_transfer_addr);
 	}
 	}
 	/*  XXX check for buffer overrun somehow */
 	/*  XXX check for buffer overrun somehow */
@@ -969,14 +980,14 @@ static irqreturn_t handle_interrupt(int irq, void *d)
 	if (hpdi_intr_status) {
 	if (hpdi_intr_status) {
 		DEBUG_PRINT("hpdi: intr status 0x%x, ", hpdi_intr_status);
 		DEBUG_PRINT("hpdi: intr status 0x%x, ", hpdi_intr_status);
 		writel(hpdi_intr_status,
 		writel(hpdi_intr_status,
-			priv(dev)->hpdi_iobase + INTERRUPT_STATUS_REG);
+		       priv(dev)->hpdi_iobase + INTERRUPT_STATUS_REG);
 	}
 	}
 	/*  spin lock makes sure noone else changes plx dma control reg */
 	/*  spin lock makes sure noone else changes plx dma control reg */
 	spin_lock_irqsave(&dev->spinlock, flags);
 	spin_lock_irqsave(&dev->spinlock, flags);
 	dma0_status = readb(priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
 	dma0_status = readb(priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
 	if (plx_status & ICS_DMA0_A) {	/*  dma chan 0 interrupt */
 	if (plx_status & ICS_DMA0_A) {	/*  dma chan 0 interrupt */
 		writeb((dma0_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT,
 		writeb((dma0_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT,
-			priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
+		       priv(dev)->plx9080_iobase + PLX_DMA0_CS_REG);
 
 
 		DEBUG_PRINT("dma0 status 0x%x\n", dma0_status);
 		DEBUG_PRINT("dma0 status 0x%x\n", dma0_status);
 		if (dma0_status & PLX_DMA_EN_BIT) {
 		if (dma0_status & PLX_DMA_EN_BIT) {
@@ -989,10 +1000,9 @@ static irqreturn_t handle_interrupt(int irq, void *d)
 	/*  spin lock makes sure noone else changes plx dma control reg */
 	/*  spin lock makes sure noone else changes plx dma control reg */
 	spin_lock_irqsave(&dev->spinlock, flags);
 	spin_lock_irqsave(&dev->spinlock, flags);
 	dma1_status = readb(priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
 	dma1_status = readb(priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
-	if (plx_status & ICS_DMA1_A)	/*  XXX */
-	{			/*  dma chan 1 interrupt */
+	if (plx_status & ICS_DMA1_A) {	/*  XXX *//*  dma chan 1 interrupt */
 		writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT,
 		writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT,
-			priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
+		       priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG);
 		DEBUG_PRINT("dma1 status 0x%x\n", dma1_status);
 		DEBUG_PRINT("dma1 status 0x%x\n", dma1_status);
 
 
 		DEBUG_PRINT(" cleared dma ch1 interrupt\n");
 		DEBUG_PRINT(" cleared dma ch1 interrupt\n");
@@ -1010,8 +1020,8 @@ static irqreturn_t handle_interrupt(int irq, void *d)
 		comedi_error(dev, "rx fifo overrun");
 		comedi_error(dev, "rx fifo overrun");
 		async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		DEBUG_PRINT("dma0_status 0x%x\n",
 		DEBUG_PRINT("dma0_status 0x%x\n",
-			(int)readb(priv(dev)->plx9080_iobase +
-				PLX_DMA0_CS_REG));
+			    (int)readb(priv(dev)->plx9080_iobase +
+				       PLX_DMA0_CS_REG));
 	}
 	}
 
 
 	if (hpdi_board_status & RX_UNDERRUN_BIT) {
 	if (hpdi_board_status & RX_UNDERRUN_BIT) {

+ 109 - 89
drivers/staging/comedi/drivers/icp_multi.c

@@ -110,11 +110,11 @@ Options:
 
 
 /*  Define analogue range */
 /*  Define analogue range */
 static const struct comedi_lrange range_analog = { 4, {
 static const struct comedi_lrange range_analog = { 4, {
-			UNI_RANGE(5),
-			UNI_RANGE(10),
-			BIP_RANGE(5),
-			BIP_RANGE(10)
-	}
+						       UNI_RANGE(5),
+						       UNI_RANGE(10),
+						       BIP_RANGE(5),
+						       BIP_RANGE(10)
+						       }
 };
 };
 
 
 static const char range_codes_analog[] = { 0x00, 0x20, 0x10, 0x30 };
 static const char range_codes_analog[] = { 0x00, 0x20, 0x10, 0x30 };
@@ -124,7 +124,8 @@ static const char range_codes_analog[] = { 0x00, 0x20, 0x10, 0x30 };
 	Forward declarations
 	Forward declarations
 ==============================================================================
 ==============================================================================
 */
 */
-static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int icp_multi_attach(struct comedi_device *dev,
+			    struct comedi_devconfig *it);
 static int icp_multi_detach(struct comedi_device *dev);
 static int icp_multi_detach(struct comedi_device *dev);
 
 
 /*
 /*
@@ -155,33 +156,33 @@ struct boardtype {
 
 
 static const struct boardtype boardtypes[] = {
 static const struct boardtype boardtypes[] = {
 	{"icp_multi",		/*  Driver name */
 	{"icp_multi",		/*  Driver name */
-			DEVICE_ID,	/*  PCI device ID */
-			IORANGE_ICP_MULTI,	/*  I/O range length */
-			1,	/*  1=Card supports interrupts */
-			TYPE_ICP_MULTI,	/*  Card type = ICP MULTI */
-			16,	/*  Num of A/D channels */
-			8,	/*  Num of A/D channels in diff mode */
-			4,	/*  Num of D/A channels */
-			16,	/*  Num of digital inputs */
-			8,	/*  Num of digital outputs */
-			4,	/*  Num of counters */
-			0x0fff,	/*  Resolution of A/D */
-			0x0fff,	/*  Resolution of D/A */
-			&range_analog,	/*  Rangelist for A/D */
-			range_codes_analog,	/*  Range codes for programming */
-		&range_analog},	/*  Rangelist for D/A */
+	 DEVICE_ID,		/*  PCI device ID */
+	 IORANGE_ICP_MULTI,	/*  I/O range length */
+	 1,			/*  1=Card supports interrupts */
+	 TYPE_ICP_MULTI,	/*  Card type = ICP MULTI */
+	 16,			/*  Num of A/D channels */
+	 8,			/*  Num of A/D channels in diff mode */
+	 4,			/*  Num of D/A channels */
+	 16,			/*  Num of digital inputs */
+	 8,			/*  Num of digital outputs */
+	 4,			/*  Num of counters */
+	 0x0fff,		/*  Resolution of A/D */
+	 0x0fff,		/*  Resolution of D/A */
+	 &range_analog,		/*  Rangelist for A/D */
+	 range_codes_analog,	/*  Range codes for programming */
+	 &range_analog},	/*  Rangelist for D/A */
 };
 };
 
 
 #define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
 #define n_boardtypes (sizeof(boardtypes)/sizeof(struct boardtype))
 
 
 static struct comedi_driver driver_icp_multi = {
 static struct comedi_driver driver_icp_multi = {
-      driver_name:"icp_multi",
-      module : THIS_MODULE,
-      attach : icp_multi_attach,
-      detach : icp_multi_detach,
-      num_names : n_boardtypes,
-      board_name : &boardtypes[0].name,
-      offset : sizeof(struct boardtype),
+driver_name:"icp_multi",
+module:THIS_MODULE,
+attach:icp_multi_attach,
+detach:icp_multi_detach,
+num_names:n_boardtypes,
+board_name:&boardtypes[0].name,
+offset:sizeof(struct boardtype),
 };
 };
 
 
 COMEDI_INITCLEANUP(driver_icp_multi);
 COMEDI_INITCLEANUP(driver_icp_multi);
@@ -199,9 +200,9 @@ struct icp_multi_private {
 	unsigned char act_chanlist_len;	/*  len of scanlist */
 	unsigned char act_chanlist_len;	/*  len of scanlist */
 	unsigned char act_chanlist_pos;	/*  actual position in MUX list */
 	unsigned char act_chanlist_pos;	/*  actual position in MUX list */
 	unsigned int *ai_chanlist;	/*  actaul chanlist */
 	unsigned int *ai_chanlist;	/*  actaul chanlist */
-	short *ai_data;	/*  data buffer */
+	short *ai_data;		/*  data buffer */
 	short ao_data[4];	/*  data output buffer */
 	short ao_data[4];	/*  data output buffer */
-	short di_data;	/*  Digital input data */
+	short di_data;		/*  Digital input data */
 	unsigned int do_data;	/*  Remember digital output data */
 	unsigned int do_data;	/*  Remember digital output data */
 };
 };
 
 
@@ -215,11 +216,13 @@ struct icp_multi_private {
 */
 */
 
 
 #if 0
 #if 0
-static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int *chanlist, unsigned int n_chan);
+static int check_channel_list(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      unsigned int *chanlist, unsigned int n_chan);
 #endif
 #endif
-static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int *chanlist, unsigned int n_chan);
+static void setup_channel_list(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       unsigned int *chanlist, unsigned int n_chan);
 static int icp_multi_reset(struct comedi_device *dev);
 static int icp_multi_reset(struct comedi_device *dev);
 
 
 /*
 /*
@@ -246,8 +249,9 @@ static int icp_multi_reset(struct comedi_device *dev);
 
 
 ==============================================================================
 ==============================================================================
 */
 */
-static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_read_ai(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, timeout;
 	int n, timeout;
 
 
@@ -267,42 +271,42 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subde
 
 
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
 	printk("icp_multi A ST=%4x IO=%p\n",
 	printk("icp_multi A ST=%4x IO=%p\n",
-		readw(devpriv->io_addr + ICP_MULTI_ADC_CSR),
-		devpriv->io_addr + ICP_MULTI_ADC_CSR);
+	       readw(devpriv->io_addr + ICP_MULTI_ADC_CSR),
+	       devpriv->io_addr + ICP_MULTI_ADC_CSR);
 #endif
 #endif
 
 
 	for (n = 0; n < insn->n; n++) {
 	for (n = 0; n < insn->n; n++) {
 		/*  Set start ADC bit */
 		/*  Set start ADC bit */
 		devpriv->AdcCmdStatus |= ADC_ST;
 		devpriv->AdcCmdStatus |= ADC_ST;
 		writew(devpriv->AdcCmdStatus,
 		writew(devpriv->AdcCmdStatus,
-			devpriv->io_addr + ICP_MULTI_ADC_CSR);
+		       devpriv->io_addr + ICP_MULTI_ADC_CSR);
 		devpriv->AdcCmdStatus &= ~ADC_ST;
 		devpriv->AdcCmdStatus &= ~ADC_ST;
 
 
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
 		printk("icp multi B n=%d ST=%4x\n", n,
 		printk("icp multi B n=%d ST=%4x\n", n,
-			readw(devpriv->io_addr + ICP_MULTI_ADC_CSR));
+		       readw(devpriv->io_addr + ICP_MULTI_ADC_CSR));
 #endif
 #endif
 
 
 		udelay(1);
 		udelay(1);
 
 
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
 		printk("icp multi C n=%d ST=%4x\n", n,
 		printk("icp multi C n=%d ST=%4x\n", n,
-			readw(devpriv->io_addr + ICP_MULTI_ADC_CSR));
+		       readw(devpriv->io_addr + ICP_MULTI_ADC_CSR));
 #endif
 #endif
 
 
 		/*  Wait for conversion to complete, or get fed up waiting */
 		/*  Wait for conversion to complete, or get fed up waiting */
 		timeout = 100;
 		timeout = 100;
 		while (timeout--) {
 		while (timeout--) {
 			if (!(readw(devpriv->io_addr +
 			if (!(readw(devpriv->io_addr +
-						ICP_MULTI_ADC_CSR) & ADC_BSY))
+				    ICP_MULTI_ADC_CSR) & ADC_BSY))
 				goto conv_finish;
 				goto conv_finish;
 
 
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
 			if (!(timeout % 10))
 			if (!(timeout % 10))
 				printk("icp multi D n=%d tm=%d ST=%4x\n", n,
 				printk("icp multi D n=%d tm=%d ST=%4x\n", n,
-					timeout,
-					readw(devpriv->io_addr +
-						ICP_MULTI_ADC_CSR));
+				       timeout,
+				       readw(devpriv->io_addr +
+					     ICP_MULTI_ADC_CSR));
 #endif
 #endif
 
 
 			udelay(1);
 			udelay(1);
@@ -318,19 +322,21 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subde
 		/*  Clear interrupt status */
 		/*  Clear interrupt status */
 		devpriv->IntStatus |= ADC_READY;
 		devpriv->IntStatus |= ADC_READY;
 		writew(devpriv->IntStatus,
 		writew(devpriv->IntStatus,
-			devpriv->io_addr + ICP_MULTI_INT_STAT);
+		       devpriv->io_addr + ICP_MULTI_INT_STAT);
 
 
 		/*  Clear data received */
 		/*  Clear data received */
 		data[n] = 0;
 		data[n] = 0;
 
 
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
-		printk("icp multi EDBG: END: icp_multi_insn_read_ai(...) n=%d\n", n);
+		printk
+		    ("icp multi EDBG: END: icp_multi_insn_read_ai(...) n=%d\n",
+		     n);
 #endif
 #endif
 		return -ETIME;
 		return -ETIME;
 
 
-	      conv_finish:
+conv_finish:
 		data[n] =
 		data[n] =
-			(readw(devpriv->io_addr + ICP_MULTI_AI) >> 4) & 0x0fff;
+		    (readw(devpriv->io_addr + ICP_MULTI_AI) >> 4) & 0x0fff;
 	}
 	}
 
 
 	/*  Disable interrupt */
 	/*  Disable interrupt */
@@ -365,8 +371,9 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subde
 
 
 ==============================================================================
 ==============================================================================
 */
 */
-static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_write_ao(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, chan, range, timeout;
 	int n, chan, range, timeout;
 
 
@@ -401,15 +408,15 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subd
 		timeout = 100;
 		timeout = 100;
 		while (timeout--) {
 		while (timeout--) {
 			if (!(readw(devpriv->io_addr +
 			if (!(readw(devpriv->io_addr +
-						ICP_MULTI_DAC_CSR) & DAC_BSY))
+				    ICP_MULTI_DAC_CSR) & DAC_BSY))
 				goto dac_ready;
 				goto dac_ready;
 
 
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
 			if (!(timeout % 10))
 			if (!(timeout % 10))
 				printk("icp multi A n=%d tm=%d ST=%4x\n", n,
 				printk("icp multi A n=%d tm=%d ST=%4x\n", n,
-					timeout,
-					readw(devpriv->io_addr +
-						ICP_MULTI_DAC_CSR));
+				       timeout,
+				       readw(devpriv->io_addr +
+					     ICP_MULTI_DAC_CSR));
 #endif
 #endif
 
 
 			udelay(1);
 			udelay(1);
@@ -425,24 +432,26 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subd
 		/*  Clear interrupt status */
 		/*  Clear interrupt status */
 		devpriv->IntStatus |= DAC_READY;
 		devpriv->IntStatus |= DAC_READY;
 		writew(devpriv->IntStatus,
 		writew(devpriv->IntStatus,
-			devpriv->io_addr + ICP_MULTI_INT_STAT);
+		       devpriv->io_addr + ICP_MULTI_INT_STAT);
 
 
 		/*  Clear data received */
 		/*  Clear data received */
 		devpriv->ao_data[chan] = 0;
 		devpriv->ao_data[chan] = 0;
 
 
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
-		printk("icp multi EDBG: END: icp_multi_insn_write_ao(...) n=%d\n", n);
+		printk
+		    ("icp multi EDBG: END: icp_multi_insn_write_ao(...) n=%d\n",
+		     n);
 #endif
 #endif
 		return -ETIME;
 		return -ETIME;
 
 
-	      dac_ready:
+dac_ready:
 		/*  Write data to analogue output data register */
 		/*  Write data to analogue output data register */
 		writew(data[n], devpriv->io_addr + ICP_MULTI_AO);
 		writew(data[n], devpriv->io_addr + ICP_MULTI_AO);
 
 
 		/*  Set DAC_ST bit to write the data to selected channel */
 		/*  Set DAC_ST bit to write the data to selected channel */
 		devpriv->DacCmdStatus |= DAC_ST;
 		devpriv->DacCmdStatus |= DAC_ST;
 		writew(devpriv->DacCmdStatus,
 		writew(devpriv->DacCmdStatus,
-			devpriv->io_addr + ICP_MULTI_DAC_CSR);
+		       devpriv->io_addr + ICP_MULTI_DAC_CSR);
 		devpriv->DacCmdStatus &= ~DAC_ST;
 		devpriv->DacCmdStatus &= ~DAC_ST;
 
 
 		/*  Save analogue output data */
 		/*  Save analogue output data */
@@ -473,8 +482,9 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subd
 
 
 ==============================================================================
 ==============================================================================
 */
 */
-static int icp_multi_insn_read_ao(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_read_ao(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n, chan;
 	int n, chan;
 
 
@@ -506,8 +516,9 @@ static int icp_multi_insn_read_ao(struct comedi_device *dev, struct comedi_subde
 
 
 ==============================================================================
 ==============================================================================
 */
 */
-static int icp_multi_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_bits_di(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	data[1] = readw(devpriv->io_addr + ICP_MULTI_DI);
 	data[1] = readw(devpriv->io_addr + ICP_MULTI_DI);
 
 
@@ -532,8 +543,9 @@ static int icp_multi_insn_bits_di(struct comedi_device *dev, struct comedi_subde
 
 
 ==============================================================================
 ==============================================================================
 */
 */
-static int icp_multi_insn_bits_do(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_bits_do(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
 	printk("icp multi EDBG: BGN: icp_multi_insn_bits_do(...)\n");
 	printk("icp multi EDBG: BGN: icp_multi_insn_bits_do(...)\n");
@@ -574,8 +586,9 @@ static int icp_multi_insn_bits_do(struct comedi_device *dev, struct comedi_subde
 
 
 ==============================================================================
 ==============================================================================
 */
 */
-static int icp_multi_insn_read_ctr(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_read_ctr(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	return 0;
 	return 0;
 }
 }
@@ -598,8 +611,10 @@ static int icp_multi_insn_read_ctr(struct comedi_device *dev, struct comedi_subd
 
 
 ==============================================================================
 ==============================================================================
 */
 */
-static int icp_multi_insn_write_ctr(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int icp_multi_insn_write_ctr(struct comedi_device *dev,
+				    struct comedi_subdevice *s,
+				    struct comedi_insn *insn,
+				    unsigned int *data)
 {
 {
 	return 0;
 	return 0;
 }
 }
@@ -626,7 +641,7 @@ static irqreturn_t interrupt_service_icp_multi(int irq, void *d)
 
 
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
 	printk("icp multi EDBG: BGN: interrupt_service_icp_multi(%d,...)\n",
 	printk("icp multi EDBG: BGN: interrupt_service_icp_multi(%d,...)\n",
-		irq);
+	       irq);
 #endif
 #endif
 
 
 	/*  Is this interrupt from our board? */
 	/*  Is this interrupt from our board? */
@@ -637,7 +652,7 @@ static irqreturn_t interrupt_service_icp_multi(int irq, void *d)
 
 
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
 	printk("icp multi EDBG: interrupt_service_icp_multi() ST: %4x\n",
 	printk("icp multi EDBG: interrupt_service_icp_multi() ST: %4x\n",
-		readw(devpriv->io_addr + ICP_MULTI_INT_STAT));
+	       readw(devpriv->io_addr + ICP_MULTI_INT_STAT));
 #endif
 #endif
 
 
 	/*  Determine which interrupt is active & handle it */
 	/*  Determine which interrupt is active & handle it */
@@ -690,8 +705,9 @@ static irqreturn_t interrupt_service_icp_multi(int irq, void *d)
 
 
 ==============================================================================
 ==============================================================================
 */
 */
-static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int *chanlist, unsigned int n_chan)
+static int check_channel_list(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      unsigned int *chanlist, unsigned int n_chan)
 {
 {
 	unsigned int i;
 	unsigned int i;
 
 
@@ -709,13 +725,13 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
 		if (CR_AREF(chanlist[i]) == AREF_DIFF) {
 		if (CR_AREF(chanlist[i]) == AREF_DIFF) {
 			if (CR_CHAN(chanlist[i]) > this_board->n_aichand) {
 			if (CR_CHAN(chanlist[i]) > this_board->n_aichand) {
 				comedi_error(dev,
 				comedi_error(dev,
-					"Incorrect differential ai channel number");
+					     "Incorrect differential ai channel number");
 				return 0;
 				return 0;
 			}
 			}
 		} else {
 		} else {
 			if (CR_CHAN(chanlist[i]) > this_board->n_aichan) {
 			if (CR_CHAN(chanlist[i]) > this_board->n_aichan) {
 				comedi_error(dev,
 				comedi_error(dev,
-					"Incorrect ai channel number");
+					     "Incorrect ai channel number");
 				return 0;
 				return 0;
 			}
 			}
 		}
 		}
@@ -744,8 +760,9 @@ static int check_channel_list(struct comedi_device *dev, struct comedi_subdevice
 
 
 ==============================================================================
 ==============================================================================
 */
 */
-static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned int *chanlist, unsigned int n_chan)
+static void setup_channel_list(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       unsigned int *chanlist, unsigned int n_chan)
 {
 {
 	unsigned int i, range, chanprog;
 	unsigned int i, range, chanprog;
 	unsigned int diff;
 	unsigned int diff;
@@ -788,11 +805,11 @@ static void setup_channel_list(struct comedi_device *dev, struct comedi_subdevic
 
 
 		/* Output channel, range, mode to ICP Multi */
 		/* Output channel, range, mode to ICP Multi */
 		writew(devpriv->AdcCmdStatus,
 		writew(devpriv->AdcCmdStatus,
-			devpriv->io_addr + ICP_MULTI_ADC_CSR);
+		       devpriv->io_addr + ICP_MULTI_ADC_CSR);
 
 
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
 		printk("GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range,
 		printk("GS: %2d. [%4x]=%4x %4x\n", i, chanprog, range,
-			devpriv->act_chanlist[i]);
+		       devpriv->act_chanlist[i]);
 #endif
 #endif
 	}
 	}
 
 
@@ -840,7 +857,7 @@ static int icp_multi_reset(struct comedi_device *dev)
 
 
 			/*  Output to command / status register */
 			/*  Output to command / status register */
 			writew(devpriv->DacCmdStatus,
 			writew(devpriv->DacCmdStatus,
-				devpriv->io_addr + ICP_MULTI_DAC_CSR);
+			       devpriv->io_addr + ICP_MULTI_DAC_CSR);
 
 
 			/*  Delay to allow DAC time to recover */
 			/*  Delay to allow DAC time to recover */
 			udelay(1);
 			udelay(1);
@@ -871,7 +888,8 @@ static int icp_multi_reset(struct comedi_device *dev)
 
 
 ==============================================================================
 ==============================================================================
 */
 */
-static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int icp_multi_attach(struct comedi_device *dev,
+			    struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int ret, subdev, n_subdevices;
 	int ret, subdev, n_subdevices;
@@ -891,15 +909,15 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
 	if (pci_list_builded++ == 0) {
 	if (pci_list_builded++ == 0) {
 		pci_card_list_init(PCI_VENDOR_ID_ICP,
 		pci_card_list_init(PCI_VENDOR_ID_ICP,
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
-			1
+				   1
 #else
 #else
-			0
+				   0
 #endif
 #endif
-			);
+		    );
 	}
 	}
 
 
 	printk("Anne's comedi%d: icp_multi: board=%s", dev->minor,
 	printk("Anne's comedi%d: icp_multi: board=%s", dev->minor,
-		this_board->name);
+	       this_board->name);
 
 
 	card = select_and_alloc_pci_card(PCI_VENDOR_ID_ICP,
 	card = select_and_alloc_pci_card(PCI_VENDOR_ID_ICP,
 					 this_board->device_id, it->options[0],
 					 this_board->device_id, it->options[0],
@@ -911,7 +929,7 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
 	devpriv->card = card;
 	devpriv->card = card;
 
 
 	if ((pci_card_data(card, &pci_bus, &pci_slot, &pci_func, &io_addr[0],
 	if ((pci_card_data(card, &pci_bus, &pci_slot, &pci_func, &io_addr[0],
-				&irq)) < 0) {
+			   &irq)) < 0) {
 		printk(" - Can't get configuration data!\n");
 		printk(" - Can't get configuration data!\n");
 		return -EIO;
 		return -EIO;
 	}
 	}
@@ -920,7 +938,7 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
 	devpriv->phys_iobase = iobase;
 	devpriv->phys_iobase = iobase;
 
 
 	printk(", b:s:f=%d:%d:%d, io=0x%8llx \n", pci_bus, pci_slot, pci_func,
 	printk(", b:s:f=%d:%d:%d, io=0x%8llx \n", pci_bus, pci_slot, pci_func,
-		(unsigned long long)iobase);
+	       (unsigned long long)iobase);
 
 
 	devpriv->io_addr = ioremap(iobase, ICP_MULTI_SIZE);
 	devpriv->io_addr = ioremap(iobase, ICP_MULTI_SIZE);
 
 
@@ -930,7 +948,7 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
 	}
 	}
 #ifdef ICP_MULTI_EXTDEBUG
 #ifdef ICP_MULTI_EXTDEBUG
 	printk("0x%08llx mapped to %p, ", (unsigned long long)iobase,
 	printk("0x%08llx mapped to %p, ", (unsigned long long)iobase,
-		devpriv->io_addr);
+	       devpriv->io_addr);
 #endif
 #endif
 
 
 	dev->board_name = this_board->name;
 	dev->board_name = this_board->name;
@@ -957,7 +975,9 @@ static int icp_multi_attach(struct comedi_device *dev, struct comedi_devconfig *
 		if (irq) {
 		if (irq) {
 			if (request_irq(irq, interrupt_service_icp_multi,
 			if (request_irq(irq, interrupt_service_icp_multi,
 					IRQF_SHARED, "Inova Icp Multi", dev)) {
 					IRQF_SHARED, "Inova Icp Multi", dev)) {
-				printk(", unable to allocate IRQ %u, DISABLING IT", irq);
+				printk
+				    (", unable to allocate IRQ %u, DISABLING IT",
+				     irq);
 				irq = 0;	/* Can't use IRQ */
 				irq = 0;	/* Can't use IRQ */
 			} else
 			} else
 				printk(", irq=%u", irq);
 				printk(", irq=%u", irq);

+ 47 - 27
drivers/staging/comedi/drivers/icp_multi.h

@@ -36,20 +36,26 @@ struct pcilst_struct *inova_devices;
 static void pci_card_list_init(unsigned short pci_vendor, char display);
 static void pci_card_list_init(unsigned short pci_vendor, char display);
 static void pci_card_list_cleanup(unsigned short pci_vendor);
 static void pci_card_list_cleanup(unsigned short pci_vendor);
 static struct pcilst_struct *find_free_pci_card_by_device(unsigned short
 static struct pcilst_struct *find_free_pci_card_by_device(unsigned short
-	vendor_id, unsigned short device_id);
+							  vendor_id,
+							  unsigned short
+							  device_id);
 static int find_free_pci_card_by_position(unsigned short vendor_id,
 static int find_free_pci_card_by_position(unsigned short vendor_id,
-	unsigned short device_id, unsigned short pci_bus,
-	unsigned short pci_slot, struct pcilst_struct **card);
+					  unsigned short device_id,
+					  unsigned short pci_bus,
+					  unsigned short pci_slot,
+					  struct pcilst_struct **card);
 static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id,
 static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id,
-	unsigned short device_id, unsigned short pci_bus,
-	unsigned short pci_slot);
+						       unsigned short device_id,
+						       unsigned short pci_bus,
+						       unsigned short pci_slot);
 
 
 static int pci_card_alloc(struct pcilst_struct *amcc);
 static int pci_card_alloc(struct pcilst_struct *amcc);
 static int pci_card_free(struct pcilst_struct *amcc);
 static int pci_card_free(struct pcilst_struct *amcc);
 static void pci_card_list_display(void);
 static void pci_card_list_display(void);
 static int pci_card_data(struct pcilst_struct *amcc,
 static int pci_card_data(struct pcilst_struct *amcc,
-	unsigned char *pci_bus, unsigned char *pci_slot,
-	unsigned char *pci_func, resource_size_t * io_addr, unsigned int *irq);
+			 unsigned char *pci_bus, unsigned char *pci_slot,
+			 unsigned char *pci_func, resource_size_t * io_addr,
+			 unsigned int *irq);
 
 
 /****************************************************************************/
 /****************************************************************************/
 
 
@@ -64,12 +70,13 @@ static void pci_card_list_init(unsigned short pci_vendor, char display)
 	last = NULL;
 	last = NULL;
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 		if (pcidev->vendor == pci_vendor) {
 		if (pcidev->vendor == pci_vendor) {
 			inova = kmalloc(sizeof(*inova), GFP_KERNEL);
 			inova = kmalloc(sizeof(*inova), GFP_KERNEL);
 			if (!inova) {
 			if (!inova) {
-				printk("icp_multi: pci_card_list_init: allocation failed\n");
+				printk
+				    ("icp_multi: pci_card_list_init: allocation failed\n");
 				pci_dev_put(pcidev);
 				pci_dev_put(pcidev);
 				break;
 				break;
 			}
 			}
@@ -93,7 +100,7 @@ static void pci_card_list_init(unsigned short pci_vendor, char display)
 			 * pci_card_alloc. */
 			 * pci_card_alloc. */
 			for (i = 0; i < 5; i++)
 			for (i = 0; i < 5; i++)
 				inova->io_addr[i] =
 				inova->io_addr[i] =
-					pci_resource_start(pcidev, i);
+				    pci_resource_start(pcidev, i);
 			inova->irq = pcidev->irq;
 			inova->irq = pcidev->irq;
 		}
 		}
 	}
 	}
@@ -120,14 +127,16 @@ static void pci_card_list_cleanup(unsigned short pci_vendor)
 /****************************************************************************/
 /****************************************************************************/
 /* find first unused card with this device_id */
 /* find first unused card with this device_id */
 static struct pcilst_struct *find_free_pci_card_by_device(unsigned short
 static struct pcilst_struct *find_free_pci_card_by_device(unsigned short
-	vendor_id, unsigned short device_id)
+							  vendor_id,
+							  unsigned short
+							  device_id)
 {
 {
 	struct pcilst_struct *inova, *next;
 	struct pcilst_struct *inova, *next;
 
 
 	for (inova = inova_devices; inova; inova = next) {
 	for (inova = inova_devices; inova; inova = next) {
 		next = inova->next;
 		next = inova->next;
 		if ((!inova->used) && (inova->device == device_id)
 		if ((!inova->used) && (inova->device == device_id)
-			&& (inova->vendor == vendor_id))
+		    && (inova->vendor == vendor_id))
 			return inova;
 			return inova;
 
 
 	}
 	}
@@ -138,8 +147,10 @@ static struct pcilst_struct *find_free_pci_card_by_device(unsigned short
 /****************************************************************************/
 /****************************************************************************/
 /* find card on requested position */
 /* find card on requested position */
 static int find_free_pci_card_by_position(unsigned short vendor_id,
 static int find_free_pci_card_by_position(unsigned short vendor_id,
-	unsigned short device_id, unsigned short pci_bus,
-	unsigned short pci_slot, struct pcilst_struct **card)
+					  unsigned short device_id,
+					  unsigned short pci_bus,
+					  unsigned short pci_slot,
+					  struct pcilst_struct **card)
 {
 {
 	struct pcilst_struct *inova, *next;
 	struct pcilst_struct *inova, *next;
 
 
@@ -147,8 +158,8 @@ static int find_free_pci_card_by_position(unsigned short vendor_id,
 	for (inova = inova_devices; inova; inova = next) {
 	for (inova = inova_devices; inova; inova = next) {
 		next = inova->next;
 		next = inova->next;
 		if ((inova->vendor == vendor_id) && (inova->device == device_id)
 		if ((inova->vendor == vendor_id) && (inova->device == device_id)
-			&& (inova->pci_bus == pci_bus)
-			&& (inova->pci_slot == pci_slot)) {
+		    && (inova->pci_bus == pci_bus)
+		    && (inova->pci_slot == pci_slot)) {
 			if (!(inova->used)) {
 			if (!(inova->used)) {
 				*card = inova;
 				*card = inova;
 				return 0;	/* ok, card is found */
 				return 0;	/* ok, card is found */
@@ -211,7 +222,13 @@ static void pci_card_list_display(void)
 
 
 	for (inova = inova_devices; inova; inova = next) {
 	for (inova = inova_devices; inova; inova = next) {
 		next = inova->next;
 		next = inova->next;
-		printk("%2d   %2d   %2d  0x%4x 0x%4x   0x%8llx 0x%8llx  %2u  %2d\n", inova->pci_bus, inova->pci_slot, inova->pci_func, inova->vendor, inova->device, (unsigned long long)inova->io_addr[0], (unsigned long long)inova->io_addr[2], inova->irq, inova->used);
+		printk
+		    ("%2d   %2d   %2d  0x%4x 0x%4x   0x%8llx 0x%8llx  %2u  %2d\n",
+		     inova->pci_bus, inova->pci_slot, inova->pci_func,
+		     inova->vendor, inova->device,
+		     (unsigned long long)inova->io_addr[0],
+		     (unsigned long long)inova->io_addr[2], inova->irq,
+		     inova->used);
 
 
 	}
 	}
 }
 }
@@ -219,8 +236,9 @@ static void pci_card_list_display(void)
 /****************************************************************************/
 /****************************************************************************/
 /* return all card information for driver */
 /* return all card information for driver */
 static int pci_card_data(struct pcilst_struct *inova,
 static int pci_card_data(struct pcilst_struct *inova,
-	unsigned char *pci_bus, unsigned char *pci_slot,
-	unsigned char *pci_func, resource_size_t * io_addr, unsigned int *irq)
+			 unsigned char *pci_bus, unsigned char *pci_slot,
+			 unsigned char *pci_func, resource_size_t * io_addr,
+			 unsigned int *irq)
 {
 {
 	int i;
 	int i;
 
 
@@ -238,8 +256,9 @@ static int pci_card_data(struct pcilst_struct *inova,
 /****************************************************************************/
 /****************************************************************************/
 /* select and alloc card */
 /* select and alloc card */
 static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id,
 static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id,
-	unsigned short device_id, unsigned short pci_bus,
-	unsigned short pci_slot)
+						       unsigned short device_id,
+						       unsigned short pci_bus,
+						       unsigned short pci_slot)
 {
 {
 	struct pcilst_struct *card;
 	struct pcilst_struct *card;
 	int err;
 	int err;
@@ -253,16 +272,17 @@ static struct pcilst_struct *select_and_alloc_pci_card(unsigned short vendor_id,
 		}
 		}
 	} else {
 	} else {
 		switch (find_free_pci_card_by_position(vendor_id, device_id,
 		switch (find_free_pci_card_by_position(vendor_id, device_id,
-				pci_bus, pci_slot, &card)) {
+						       pci_bus, pci_slot,
+						       &card)) {
 		case 1:
 		case 1:
 			printk
 			printk
-				(" - Card not found on requested position b:s %d:%d!\n",
-				pci_bus, pci_slot);
+			    (" - Card not found on requested position b:s %d:%d!\n",
+			     pci_bus, pci_slot);
 			return NULL;
 			return NULL;
 		case 2:
 		case 2:
 			printk
 			printk
-				(" - Card on requested position is used b:s %d:%d!\n",
-				pci_bus, pci_slot);
+			    (" - Card on requested position is used b:s %d:%d!\n",
+			     pci_bus, pci_slot);
 			return NULL;
 			return NULL;
 		}
 		}
 	}
 	}

+ 76 - 51
drivers/staging/comedi/drivers/ii_pci20kc.c

@@ -154,11 +154,11 @@ struct pci20xxx_private {
 	union pci20xxx_subdev_private subdev_private[PCI20000_MODULES];
 	union pci20xxx_subdev_private subdev_private[PCI20000_MODULES];
 };
 };
 
 
-
 #define devpriv ((struct pci20xxx_private *)dev->private)
 #define devpriv ((struct pci20xxx_private *)dev->private)
 #define CHAN (CR_CHAN(it->chanlist[0]))
 #define CHAN (CR_CHAN(it->chanlist[0]))
 
 
-static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int pci20xxx_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it);
 static int pci20xxx_detach(struct comedi_device *dev);
 static int pci20xxx_detach(struct comedi_device *dev);
 
 
 static struct comedi_driver driver_pci20xxx = {
 static struct comedi_driver driver_pci20xxx = {
@@ -169,10 +169,11 @@ static struct comedi_driver driver_pci20xxx = {
 };
 };
 
 
 static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
 static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
-	int opt0, int opt1);
+			 int opt0, int opt1);
 static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
 static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
-	int opt0, int opt1);
-static int pci20xxx_dio_init(struct comedi_device *dev, struct comedi_subdevice *s);
+			 int opt0, int opt1);
+static int pci20xxx_dio_init(struct comedi_device *dev,
+			     struct comedi_subdevice *s);
 
 
 /*
 /*
   options[0]	Board base address
   options[0]	Board base address
@@ -201,7 +202,8 @@ static int pci20xxx_dio_init(struct comedi_device *dev, struct comedi_subdevice
 		1 == unipolar 10V  (0V -- +10V)
 		1 == unipolar 10V  (0V -- +10V)
 		2 == bipolar 5V  (-5V -- +5V)
 		2 == bipolar 5V  (-5V -- +5V)
 */
 */
-static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int pci20xxx_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it)
 {
 {
 	unsigned char i;
 	unsigned char i;
 	int ret;
 	int ret;
@@ -223,7 +225,9 @@ static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *i
 	/* Check PCI-20001 C-2A Carrier Board ID */
 	/* Check PCI-20001 C-2A Carrier Board ID */
 	if ((readb(devpriv->ioaddr) & PCI20000_ID) != PCI20000_ID) {
 	if ((readb(devpriv->ioaddr) & PCI20000_ID) != PCI20000_ID) {
 		printk("comedi%d: ii_pci20kc", dev->minor);
 		printk("comedi%d: ii_pci20kc", dev->minor);
-		printk(" PCI-20001 C-2A Carrier Board at base=0x%p not found !\n", devpriv->ioaddr);
+		printk
+		    (" PCI-20001 C-2A Carrier Board at base=0x%p not found !\n",
+		     devpriv->ioaddr);
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 	printk("comedi%d:\n", dev->minor);
 	printk("comedi%d:\n", dev->minor);
@@ -237,22 +241,24 @@ static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *i
 		switch (id) {
 		switch (id) {
 		case PCI20006_ID:
 		case PCI20006_ID:
 			sdp->pci20006.iobase =
 			sdp->pci20006.iobase =
-				devpriv->ioaddr + (i + 1) * PCI20000_OFFSET;
+			    devpriv->ioaddr + (i + 1) * PCI20000_OFFSET;
 			pci20006_init(dev, s, it->options[2 * i + 2],
 			pci20006_init(dev, s, it->options[2 * i + 2],
-				it->options[2 * i + 3]);
+				      it->options[2 * i + 3]);
 			printk("comedi%d: ii_pci20kc", dev->minor);
 			printk("comedi%d: ii_pci20kc", dev->minor);
 			printk(" PCI-20006 module in slot %d \n", i + 1);
 			printk(" PCI-20006 module in slot %d \n", i + 1);
 			break;
 			break;
 		case PCI20341_ID:
 		case PCI20341_ID:
 			sdp->pci20341.iobase =
 			sdp->pci20341.iobase =
-				devpriv->ioaddr + (i + 1) * PCI20000_OFFSET;
+			    devpriv->ioaddr + (i + 1) * PCI20000_OFFSET;
 			pci20341_init(dev, s, it->options[2 * i + 2],
 			pci20341_init(dev, s, it->options[2 * i + 2],
-				it->options[2 * i + 3]);
+				      it->options[2 * i + 3]);
 			printk("comedi%d: ii_pci20kc", dev->minor);
 			printk("comedi%d: ii_pci20kc", dev->minor);
 			printk(" PCI-20341 module in slot %d \n", i + 1);
 			printk(" PCI-20341 module in slot %d \n", i + 1);
 			break;
 			break;
 		default:
 		default:
-			printk("ii_pci20kc: unknown module code 0x%02x in slot %d: module disabled\n", id, i);
+			printk
+			    ("ii_pci20kc: unknown module code 0x%02x in slot %d: module disabled\n",
+			     id, i);
 			/* fall through */
 			/* fall through */
 		case PCI20xxx_EMPTY_ID:
 		case PCI20xxx_EMPTY_ID:
 			s->type = COMEDI_SUBD_UNUSED;
 			s->type = COMEDI_SUBD_UNUSED;
@@ -275,10 +281,12 @@ static int pci20xxx_detach(struct comedi_device *dev)
 
 
 /* pci20006m */
 /* pci20006m */
 
 
-static int pci20006_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int pci20006_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int pci20006_insn_read(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data);
+static int pci20006_insn_write(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
 
 
 static const struct comedi_lrange *pci20006_range_list[] = {
 static const struct comedi_lrange *pci20006_range_list[] = {
 	&range_bipolar10,
 	&range_bipolar10,
@@ -287,7 +295,7 @@ static const struct comedi_lrange *pci20006_range_list[] = {
 };
 };
 
 
 static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
 static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
-	int opt0, int opt1)
+			 int opt0, int opt1)
 {
 {
 	union pci20xxx_subdev_private *sdp = s->private;
 	union pci20xxx_subdev_private *sdp = s->private;
 
 
@@ -311,8 +319,9 @@ static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
 	return 0;
 	return 0;
 }
 }
 
 
-static int pci20006_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci20006_insn_read(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data)
 {
 {
 	union pci20xxx_subdev_private *sdp = s->private;
 	union pci20xxx_subdev_private *sdp = s->private;
 
 
@@ -321,8 +330,9 @@ static int pci20006_insn_read(struct comedi_device *dev, struct comedi_subdevice
 	return 1;
 	return 1;
 }
 }
 
 
-static int pci20006_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci20006_insn_write(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	union pci20xxx_subdev_private *sdp = s->private;
 	union pci20xxx_subdev_private *sdp = s->private;
 	int hi, lo;
 	int hi, lo;
@@ -354,15 +364,17 @@ static int pci20006_insn_write(struct comedi_device *dev, struct comedi_subdevic
 
 
 /* PCI20341M */
 /* PCI20341M */
 
 
-static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int pci20341_insn_read(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data);
 
 
 static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 };
 static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 };
 static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 };
 static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 };
 
 
 static const struct comedi_lrange range_bipolar0_5 = { 1, {BIP_RANGE(0.5)} };
 static const struct comedi_lrange range_bipolar0_5 = { 1, {BIP_RANGE(0.5)} };
 static const struct comedi_lrange range_bipolar0_05 = { 1, {BIP_RANGE(0.05)} };
 static const struct comedi_lrange range_bipolar0_05 = { 1, {BIP_RANGE(0.05)} };
-static const struct comedi_lrange range_bipolar0_025 = { 1, {BIP_RANGE(0.025)} };
+static const struct comedi_lrange range_bipolar0_025 =
+    { 1, {BIP_RANGE(0.025)} };
 
 
 static const struct comedi_lrange *const pci20341_ranges[] = {
 static const struct comedi_lrange *const pci20341_ranges[] = {
 	&range_bipolar5,
 	&range_bipolar5,
@@ -372,7 +384,7 @@ static const struct comedi_lrange *const pci20341_ranges[] = {
 };
 };
 
 
 static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
 static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
-	int opt0, int opt1)
+			 int opt0, int opt1)
 {
 {
 	union pci20xxx_subdev_private *sdp = s->private;
 	union pci20xxx_subdev_private *sdp = s->private;
 	int option;
 	int option;
@@ -402,10 +414,11 @@ static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
 	return 0;
 	return 0;
 }
 }
 
 
-static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci20341_insn_read(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data)
 {
 {
-        union pci20xxx_subdev_private *sdp = s->private;
+	union pci20xxx_subdev_private *sdp = s->private;
 	unsigned int i = 0, j = 0;
 	unsigned int i = 0, j = 0;
 	int lo, hi;
 	int lo, hi;
 	unsigned char eoc;	/* end of conversion */
 	unsigned char eoc;	/* end of conversion */
@@ -414,7 +427,7 @@ static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice
 
 
 	writeb(1, sdp->iobase + PCI20341_LCHAN_ADDR_REG);	/* write number of input channels */
 	writeb(1, sdp->iobase + PCI20341_LCHAN_ADDR_REG);	/* write number of input channels */
 	clb = PCI20341_DAISY_CHAIN | PCI20341_MUX | (sdp->pci20341.ai_gain << 3)
 	clb = PCI20341_DAISY_CHAIN | PCI20341_MUX | (sdp->pci20341.ai_gain << 3)
-		| CR_CHAN(insn->chanspec);
+	    | CR_CHAN(insn->chanspec);
 	writeb(clb, sdp->iobase + PCI20341_CHAN_LIST);
 	writeb(clb, sdp->iobase + PCI20341_CHAN_LIST);
 	writeb(0x00, sdp->iobase + PCI20341_CC_RESET);	/* reset settling time counter and trigger delay counter */
 	writeb(0x00, sdp->iobase + PCI20341_CC_RESET);	/* reset settling time counter and trigger delay counter */
 	writeb(0x00, sdp->iobase + PCI20341_CHAN_RESET);
 	writeb(0x00, sdp->iobase + PCI20341_CHAN_RESET);
@@ -434,13 +447,15 @@ static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice
 			eoc = readb(sdp->iobase + PCI20341_STATUS_REG);
 			eoc = readb(sdp->iobase + PCI20341_STATUS_REG);
 		}
 		}
 		if (j >= 100) {
 		if (j >= 100) {
-			printk("comedi%d:  pci20xxx: AI interrupt channel %i polling exit !\n", dev->minor, i);
+			printk
+			    ("comedi%d:  pci20xxx: AI interrupt channel %i polling exit !\n",
+			     dev->minor, i);
 			return -EINVAL;
 			return -EINVAL;
 		}
 		}
 		lo = readb(sdp->iobase + PCI20341_LDATA);
 		lo = readb(sdp->iobase + PCI20341_LDATA);
 		hi = readb(sdp->iobase + PCI20341_LDATA + 1);
 		hi = readb(sdp->iobase + PCI20341_LDATA + 1);
 		boarddata = lo + 0x100 * hi;
 		boarddata = lo + 0x100 * hi;
-		data[i] = (short) ((boarddata + 0x8000) & 0xffff);	/* board-data -> comedi-data */
+		data[i] = (short)((boarddata + 0x8000) & 0xffff);	/* board-data -> comedi-data */
 	}
 	}
 
 
 	return i;
 	return i;
@@ -448,14 +463,19 @@ static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice
 
 
 /* native DIO */
 /* native DIO */
 
 
-static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevice *s);
-static int pci20xxx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int pci20xxx_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static void pci20xxx_dio_config(struct comedi_device *dev,
+				struct comedi_subdevice *s);
+static int pci20xxx_dio_insn_bits(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data);
+static int pci20xxx_dio_insn_config(struct comedi_device *dev,
+				    struct comedi_subdevice *s,
+				    struct comedi_insn *insn,
+				    unsigned int *data);
 
 
 /* initialize struct pci20xxx_private */
 /* initialize struct pci20xxx_private */
-static int pci20xxx_dio_init(struct comedi_device *dev, struct comedi_subdevice *s)
+static int pci20xxx_dio_init(struct comedi_device *dev,
+			     struct comedi_subdevice *s)
 {
 {
 
 
 	s->type = COMEDI_SUBD_DIO;
 	s->type = COMEDI_SUBD_DIO;
@@ -474,8 +494,10 @@ static int pci20xxx_dio_init(struct comedi_device *dev, struct comedi_subdevice
 	return 0;
 	return 0;
 }
 }
 
 
-static int pci20xxx_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci20xxx_dio_insn_config(struct comedi_device *dev,
+				    struct comedi_subdevice *s,
+				    struct comedi_insn *insn,
+				    unsigned int *data)
 {
 {
 	int mask, bits;
 	int mask, bits;
 
 
@@ -499,8 +521,9 @@ static int pci20xxx_dio_insn_config(struct comedi_device *dev, struct comedi_sub
 	return 1;
 	return 1;
 }
 }
 
 
-static int pci20xxx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int pci20xxx_dio_insn_bits(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int mask = data[0];
 	unsigned int mask = data[0];
 
 
@@ -510,16 +533,16 @@ static int pci20xxx_dio_insn_bits(struct comedi_device *dev, struct comedi_subde
 	mask &= s->io_bits;
 	mask &= s->io_bits;
 	if (mask & 0x000000ff)
 	if (mask & 0x000000ff)
 		writeb((s->state >> 0) & 0xff,
 		writeb((s->state >> 0) & 0xff,
-			devpriv->ioaddr + PCI20000_DIO_0);
+		       devpriv->ioaddr + PCI20000_DIO_0);
 	if (mask & 0x0000ff00)
 	if (mask & 0x0000ff00)
 		writeb((s->state >> 8) & 0xff,
 		writeb((s->state >> 8) & 0xff,
-			devpriv->ioaddr + PCI20000_DIO_1);
+		       devpriv->ioaddr + PCI20000_DIO_1);
 	if (mask & 0x00ff0000)
 	if (mask & 0x00ff0000)
 		writeb((s->state >> 16) & 0xff,
 		writeb((s->state >> 16) & 0xff,
-			devpriv->ioaddr + PCI20000_DIO_2);
+		       devpriv->ioaddr + PCI20000_DIO_2);
 	if (mask & 0xff000000)
 	if (mask & 0xff000000)
 		writeb((s->state >> 24) & 0xff,
 		writeb((s->state >> 24) & 0xff,
-			devpriv->ioaddr + PCI20000_DIO_3);
+		       devpriv->ioaddr + PCI20000_DIO_3);
 
 
 	data[1] = readb(devpriv->ioaddr + PCI20000_DIO_0);
 	data[1] = readb(devpriv->ioaddr + PCI20000_DIO_0);
 	data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8;
 	data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8;
@@ -529,7 +552,8 @@ static int pci20xxx_dio_insn_bits(struct comedi_device *dev, struct comedi_subde
 	return 2;
 	return 2;
 }
 }
 
 
-static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevice *s)
+static void pci20xxx_dio_config(struct comedi_device *dev,
+				struct comedi_subdevice *s)
 {
 {
 	unsigned char control_01;
 	unsigned char control_01;
 	unsigned char control_23;
 	unsigned char control_23;
@@ -543,7 +567,7 @@ static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevi
 		/* output port 0 */
 		/* output port 0 */
 		control_01 &= PCI20000_DIO_EOC;
 		control_01 &= PCI20000_DIO_EOC;
 		buffer = (buffer & (~(DIO_BE << DIO_PS_0))) | (DIO_BO <<
 		buffer = (buffer & (~(DIO_BE << DIO_PS_0))) | (DIO_BO <<
-			DIO_PS_0);
+							       DIO_PS_0);
 	} else {
 	} else {
 		/* input port 0 */
 		/* input port 0 */
 		control_01 = (control_01 & DIO_CAND) | PCI20000_DIO_EIC;
 		control_01 = (control_01 & DIO_CAND) | PCI20000_DIO_EIC;
@@ -553,7 +577,7 @@ static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevi
 		/* output port 1 */
 		/* output port 1 */
 		control_01 &= PCI20000_DIO_OOC;
 		control_01 &= PCI20000_DIO_OOC;
 		buffer = (buffer & (~(DIO_BE << DIO_PS_1))) | (DIO_BO <<
 		buffer = (buffer & (~(DIO_BE << DIO_PS_1))) | (DIO_BO <<
-			DIO_PS_1);
+							       DIO_PS_1);
 	} else {
 	} else {
 		/* input port 1 */
 		/* input port 1 */
 		control_01 = (control_01 & DIO_CAND) | PCI20000_DIO_OIC;
 		control_01 = (control_01 & DIO_CAND) | PCI20000_DIO_OIC;
@@ -563,7 +587,7 @@ static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevi
 		/* output port 2 */
 		/* output port 2 */
 		control_23 &= PCI20000_DIO_EOC;
 		control_23 &= PCI20000_DIO_EOC;
 		buffer = (buffer & (~(DIO_BE << DIO_PS_2))) | (DIO_BO <<
 		buffer = (buffer & (~(DIO_BE << DIO_PS_2))) | (DIO_BO <<
-			DIO_PS_2);
+							       DIO_PS_2);
 	} else {
 	} else {
 		/* input port 2 */
 		/* input port 2 */
 		control_23 = (control_23 & DIO_CAND) | PCI20000_DIO_EIC;
 		control_23 = (control_23 & DIO_CAND) | PCI20000_DIO_EIC;
@@ -573,7 +597,7 @@ static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevi
 		/* output port 3 */
 		/* output port 3 */
 		control_23 &= PCI20000_DIO_OOC;
 		control_23 &= PCI20000_DIO_OOC;
 		buffer = (buffer & (~(DIO_BE << DIO_PS_3))) | (DIO_BO <<
 		buffer = (buffer & (~(DIO_BE << DIO_PS_3))) | (DIO_BO <<
-			DIO_PS_3);
+							       DIO_PS_3);
 	} else {
 	} else {
 		/* input port 3 */
 		/* input port 3 */
 		control_23 = (control_23 & DIO_CAND) | PCI20000_DIO_OIC;
 		control_23 = (control_23 & DIO_CAND) | PCI20000_DIO_OIC;
@@ -598,7 +622,8 @@ static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s)
 	writeb((s->state >> 24) & 0xff, devpriv->ioaddr + PCI20000_DIO_3);
 	writeb((s->state >> 24) & 0xff, devpriv->ioaddr + PCI20000_DIO_3);
 }
 }
 
 
-static unsigned int pci20xxx_di(struct comedi_device *dev, struct comedi_subdevice *s)
+static unsigned int pci20xxx_di(struct comedi_device *dev,
+				struct comedi_subdevice *s)
 {
 {
 	/* XXX same note as above */
 	/* XXX same note as above */
 	unsigned int bits;
 	unsigned int bits;

+ 156 - 142
drivers/staging/comedi/drivers/jr3_pci.c

@@ -56,7 +56,8 @@ Devices: [JR3] PCI force sensor board (jr3_pci)
 #define PCI_DEVICE_ID_JR3_3_CHANNEL 0x3113
 #define PCI_DEVICE_ID_JR3_3_CHANNEL 0x3113
 #define PCI_DEVICE_ID_JR3_4_CHANNEL 0x3114
 #define PCI_DEVICE_ID_JR3_4_CHANNEL 0x3114
 
 
-static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int jr3_pci_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int jr3_pci_detach(struct comedi_device *dev);
 static int jr3_pci_detach(struct comedi_device *dev);
 
 
 static struct comedi_driver driver_jr3_pci = {
 static struct comedi_driver driver_jr3_pci = {
@@ -67,15 +68,16 @@ static struct comedi_driver driver_jr3_pci = {
 };
 };
 
 
 static DEFINE_PCI_DEVICE_TABLE(jr3_pci_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(jr3_pci_pci_table) = {
-	{PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL,
-		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_2_CHANNEL,
-		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_3_CHANNEL,
-		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_4_CHANNEL,
-		PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_1_CHANNEL,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_2_CHANNEL,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_3_CHANNEL,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_JR3, PCI_DEVICE_ID_JR3_4_CHANNEL,
+		    PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, jr3_pci_pci_table);
 MODULE_DEVICE_TABLE(pci, jr3_pci_pci_table);
@@ -89,14 +91,12 @@ struct jr3_pci_dev_private {
 	struct timer_list timer;
 	struct timer_list timer;
 };
 };
 
 
-
 struct poll_delay_t {
 struct poll_delay_t {
 
 
 	int min;
 	int min;
 	int max;
 	int max;
 };
 };
 
 
-
 struct jr3_pci_subdev_private {
 struct jr3_pci_subdev_private {
 	volatile struct jr3_channel *channel;
 	volatile struct jr3_channel *channel;
 	unsigned long next_time_min;
 	unsigned long next_time_min;
@@ -124,7 +124,7 @@ struct jr3_pci_subdev_private {
 /* Hotplug firmware loading stuff */
 /* Hotplug firmware loading stuff */
 
 
 typedef int comedi_firmware_callback(struct comedi_device *dev,
 typedef int comedi_firmware_callback(struct comedi_device *dev,
-				     const u8 *data, size_t size);
+				     const u8 * data, size_t size);
 
 
 static int comedi_load_firmware(struct comedi_device *dev, char *name,
 static int comedi_load_firmware(struct comedi_device *dev, char *name,
 				comedi_firmware_callback cb)
 				comedi_firmware_callback cb)
@@ -143,7 +143,7 @@ static int comedi_load_firmware(struct comedi_device *dev, char *name,
 		strcat(firmware_path, prefix);
 		strcat(firmware_path, prefix);
 		strcat(firmware_path, name);
 		strcat(firmware_path, name);
 		result = request_firmware(&fw, firmware_path,
 		result = request_firmware(&fw, firmware_path,
-			&devpriv->pci_dev->dev);
+					  &devpriv->pci_dev->dev);
 		if (result == 0) {
 		if (result == 0) {
 			if (!cb)
 			if (!cb)
 				result = -EINVAL;
 				result = -EINVAL;
@@ -178,7 +178,7 @@ struct transform_t {
 };
 };
 
 
 static void set_transforms(volatile struct jr3_channel *channel,
 static void set_transforms(volatile struct jr3_channel *channel,
-	struct transform_t transf, short num)
+			   struct transform_t transf, short num)
 {
 {
 	int i;
 	int i;
 
 
@@ -197,7 +197,8 @@ static void set_transforms(volatile struct jr3_channel *channel,
 	}
 	}
 }
 }
 
 
-static void use_transform(volatile struct jr3_channel *channel, short transf_num)
+static void use_transform(volatile struct jr3_channel *channel,
+			  short transf_num)
 {
 {
 	set_s16(&channel->command_word0, 0x0500 + (transf_num & 0x000f));
 	set_s16(&channel->command_word0, 0x0500 + (transf_num & 0x000f));
 }
 }
@@ -222,12 +223,12 @@ struct six_axis_t {
 };
 };
 
 
 static void set_full_scales(volatile struct jr3_channel *channel,
 static void set_full_scales(volatile struct jr3_channel *channel,
-	struct six_axis_t full_scale)
+			    struct six_axis_t full_scale)
 {
 {
 	printk("%d %d %d %d %d %d\n",
 	printk("%d %d %d %d %d %d\n",
-		full_scale.fx,
-		full_scale.fy,
-		full_scale.fz, full_scale.mx, full_scale.my, full_scale.mz);
+	       full_scale.fx,
+	       full_scale.fy,
+	       full_scale.fz, full_scale.mx, full_scale.my, full_scale.mz);
 	set_s16(&channel->full_scale.fx, full_scale.fx);
 	set_s16(&channel->full_scale.fx, full_scale.fx);
 	set_s16(&channel->full_scale.fy, full_scale.fy);
 	set_s16(&channel->full_scale.fy, full_scale.fy);
 	set_s16(&channel->full_scale.fz, full_scale.fz);
 	set_s16(&channel->full_scale.fz, full_scale.fz);
@@ -237,7 +238,8 @@ static void set_full_scales(volatile struct jr3_channel *channel,
 	set_s16(&channel->command_word0, 0x0a00);
 	set_s16(&channel->command_word0, 0x0a00);
 }
 }
 
 
-static struct six_axis_t get_min_full_scales(volatile struct jr3_channel *channel)
+static struct six_axis_t get_min_full_scales(volatile struct jr3_channel
+					     *channel)
 {
 {
 	struct six_axis_t result;
 	struct six_axis_t result;
 	result.fx = get_s16(&channel->min_full_scale.fx);
 	result.fx = get_s16(&channel->min_full_scale.fx);
@@ -249,7 +251,8 @@ static struct six_axis_t get_min_full_scales(volatile struct jr3_channel *channe
 	return result;
 	return result;
 }
 }
 
 
-static struct six_axis_t get_max_full_scales(volatile struct jr3_channel *channel)
+static struct six_axis_t get_max_full_scales(volatile struct jr3_channel
+					     *channel)
 {
 {
 	struct six_axis_t result;
 	struct six_axis_t result;
 	result.fx = get_s16(&channel->max_full_scale.fx);
 	result.fx = get_s16(&channel->max_full_scale.fx);
@@ -261,8 +264,9 @@ static struct six_axis_t get_max_full_scales(volatile struct jr3_channel *channe
 	return result;
 	return result;
 }
 }
 
 
-static int jr3_pci_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int jr3_pci_ai_insn_read(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int result;
 	int result;
 	struct jr3_pci_subdev_private *p;
 	struct jr3_pci_subdev_private *p;
@@ -277,9 +281,8 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
 
 
 		result = insn->n;
 		result = insn->n;
 		if (p->state != state_jr3_done ||
 		if (p->state != state_jr3_done ||
-			(get_u16(&p->channel->
-					errors) & (watch_dog | watch_dog2 |
-					sensor_change))) {
+		    (get_u16(&p->channel->errors) & (watch_dog | watch_dog2 |
+						     sensor_change))) {
 			/* No sensor or sensor changed */
 			/* No sensor or sensor changed */
 			if (p->state == state_jr3_done) {
 			if (p->state == state_jr3_done) {
 				/* Restart polling */
 				/* Restart polling */
@@ -299,59 +302,51 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
 					int F = 0;
 					int F = 0;
 					switch (axis) {
 					switch (axis) {
 					case 0:{
 					case 0:{
-							F = get_s16(&p->
-								channel->
-								filter[filter].
-								fx);
+							F = get_s16
+							    (&p->channel->filter
+							     [filter].fx);
 						}
 						}
 						break;
 						break;
 					case 1:{
 					case 1:{
-							F = get_s16(&p->
-								channel->
-								filter[filter].
-								fy);
+							F = get_s16
+							    (&p->channel->filter
+							     [filter].fy);
 						}
 						}
 						break;
 						break;
 					case 2:{
 					case 2:{
-							F = get_s16(&p->
-								channel->
-								filter[filter].
-								fz);
+							F = get_s16
+							    (&p->channel->filter
+							     [filter].fz);
 						}
 						}
 						break;
 						break;
 					case 3:{
 					case 3:{
-							F = get_s16(&p->
-								channel->
-								filter[filter].
-								mx);
+							F = get_s16
+							    (&p->channel->filter
+							     [filter].mx);
 						}
 						}
 						break;
 						break;
 					case 4:{
 					case 4:{
-							F = get_s16(&p->
-								channel->
-								filter[filter].
-								my);
+							F = get_s16
+							    (&p->channel->filter
+							     [filter].my);
 						}
 						}
 						break;
 						break;
 					case 5:{
 					case 5:{
-							F = get_s16(&p->
-								channel->
-								filter[filter].
-								mz);
+							F = get_s16
+							    (&p->channel->filter
+							     [filter].mz);
 						}
 						}
 						break;
 						break;
 					case 6:{
 					case 6:{
-							F = get_s16(&p->
-								channel->
-								filter[filter].
-								v1);
+							F = get_s16
+							    (&p->channel->filter
+							     [filter].v1);
 						}
 						}
 						break;
 						break;
 					case 7:{
 					case 7:{
-							F = get_s16(&p->
-								channel->
-								filter[filter].
-								v2);
+							F = get_s16
+							    (&p->channel->filter
+							     [filter].v2);
 						}
 						}
 						break;
 						break;
 					}
 					}
@@ -362,14 +357,14 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
 					data[i] = 0;
 					data[i] = 0;
 				} else {
 				} else {
 					data[i] =
 					data[i] =
-						get_u16(&p->channel->model_no);
+					    get_u16(&p->channel->model_no);
 				}
 				}
 			} else if (channel == 57) {
 			} else if (channel == 57) {
 				if (p->state != state_jr3_done) {
 				if (p->state != state_jr3_done) {
 					data[i] = 0;
 					data[i] = 0;
 				} else {
 				} else {
 					data[i] =
 					data[i] =
-						get_u16(&p->channel->serial_no);
+					    get_u16(&p->channel->serial_no);
 				}
 				}
 			}
 			}
 		}
 		}
@@ -389,12 +384,12 @@ static void jr3_pci_open(struct comedi_device *dev)
 		p = dev->subdevices[i].private;
 		p = dev->subdevices[i].private;
 		if (p) {
 		if (p) {
 			printk("serial: %p %d (%d)\n", p, p->serial_no,
 			printk("serial: %p %d (%d)\n", p, p->serial_no,
-				p->channel_no);
+			       p->channel_no);
 		}
 		}
 	}
 	}
 }
 }
 
 
-int read_idm_word(const u8 *data, size_t size, int *pos, unsigned int *val)
+int read_idm_word(const u8 * data, size_t size, int *pos, unsigned int *val)
 {
 {
 	int result = 0;
 	int result = 0;
 	if (pos != 0 && val != 0) {
 	if (pos != 0 && val != 0) {
@@ -416,8 +411,8 @@ int read_idm_word(const u8 *data, size_t size, int *pos, unsigned int *val)
 	return result;
 	return result;
 }
 }
 
 
-static int jr3_download_firmware(struct comedi_device *dev, const u8 *data,
-	size_t size)
+static int jr3_download_firmware(struct comedi_device *dev, const u8 * data,
+				 size_t size)
 {
 {
 	/*
 	/*
 	 * IDM file format is:
 	 * IDM file format is:
@@ -461,24 +456,23 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 *data,
 			while (more) {
 			while (more) {
 				unsigned int count, addr;
 				unsigned int count, addr;
 				more = more
 				more = more
-					&& read_idm_word(data, size, &pos,
-					&count);
+				    && read_idm_word(data, size, &pos, &count);
 				if (more && count == 0xffff) {
 				if (more && count == 0xffff) {
 					break;
 					break;
 				}
 				}
 				more = more
 				more = more
-					&& read_idm_word(data, size, &pos,
-					&addr);
+				    && read_idm_word(data, size, &pos, &addr);
 				printk("Loading#%d %4.4x bytes at %4.4x\n", i,
 				printk("Loading#%d %4.4x bytes at %4.4x\n", i,
-					count, addr);
+				       count, addr);
 				while (more && count > 0) {
 				while (more && count > 0) {
 					if (addr & 0x4000) {
 					if (addr & 0x4000) {
 						/*  16 bit data, never seen in real life!! */
 						/*  16 bit data, never seen in real life!! */
 						unsigned int data1;
 						unsigned int data1;
 
 
 						more = more
 						more = more
-							&& read_idm_word(data,
-							size, &pos, &data1);
+						    && read_idm_word(data,
+								     size, &pos,
+								     &data1);
 						count--;
 						count--;
 						/* printk("jr3_data, not tested\n"); */
 						/* printk("jr3_data, not tested\n"); */
 						/* jr3[addr + 0x20000 * pnum] = data1; */
 						/* jr3[addr + 0x20000 * pnum] = data1; */
@@ -487,21 +481,23 @@ static int jr3_download_firmware(struct comedi_device *dev, const u8 *data,
 						unsigned int data1, data2;
 						unsigned int data1, data2;
 
 
 						more = more
 						more = more
-							&& read_idm_word(data,
-							size, &pos, &data1);
+						    && read_idm_word(data,
+								     size, &pos,
+								     &data1);
 						more = more
 						more = more
-							&& read_idm_word(data,
-							size, &pos, &data2);
+						    && read_idm_word(data, size,
+								     &pos,
+								     &data2);
 						count -= 2;
 						count -= 2;
 						if (more) {
 						if (more) {
-							set_u16(&p->iobase->
-								channel[i].
-								program_low
+							set_u16(&p->
+								iobase->channel
+								[i].program_low
 								[addr], data1);
 								[addr], data1);
 							udelay(1);
 							udelay(1);
-							set_u16(&p->iobase->
-								channel[i].
-								program_high
+							set_u16(&p->
+								iobase->channel
+								[i].program_high
 								[addr], data2);
 								[addr], data2);
 							udelay(1);
 							udelay(1);
 
 
@@ -538,7 +534,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 				u16 model_no = get_u16(&channel->model_no);
 				u16 model_no = get_u16(&channel->model_no);
 				u16 serial_no = get_u16(&channel->serial_no);
 				u16 serial_no = get_u16(&channel->serial_no);
 				if ((errors & (watch_dog | watch_dog2)) ||
 				if ((errors & (watch_dog | watch_dog2)) ||
-					model_no == 0 || serial_no == 0) {
+				    model_no == 0 || serial_no == 0) {
 /*
 /*
  * Still no sensor, keep on polling. Since it takes up to 10 seconds
  * Still no sensor, keep on polling. Since it takes up to 10 seconds
  * for offsets to stabilize, polling each second should suffice.
  * for offsets to stabilize, polling each second should suffice.
@@ -547,7 +543,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 				} else {
 				} else {
 					p->retries = 0;
 					p->retries = 0;
 					p->state =
 					p->state =
-						state_jr3_init_wait_for_offset;
+					    state_jr3_init_wait_for_offset;
 					result = poll_delay_min_max(1000, 2000);
 					result = poll_delay_min_max(1000, 2000);
 				}
 				}
 			}
 			}
@@ -561,40 +557,44 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 					struct transform_t transf;
 					struct transform_t transf;
 
 
 					p->model_no =
 					p->model_no =
-						get_u16(&channel->model_no);
+					    get_u16(&channel->model_no);
 					p->serial_no =
 					p->serial_no =
-						get_u16(&channel->serial_no);
+					    get_u16(&channel->serial_no);
 
 
-					printk("Setting transform for channel %d\n", p->channel_no);
+					printk
+					    ("Setting transform for channel %d\n",
+					     p->channel_no);
 					printk("Sensor Model     = %i\n",
 					printk("Sensor Model     = %i\n",
-						p->model_no);
+					       p->model_no);
 					printk("Sensor Serial    = %i\n",
 					printk("Sensor Serial    = %i\n",
-						p->serial_no);
+					       p->serial_no);
 
 
 					/*  Transformation all zeros */
 					/*  Transformation all zeros */
 					transf.link[0].link_type =
 					transf.link[0].link_type =
-						(enum link_types)0;
+					    (enum link_types)0;
 					transf.link[0].link_amount = 0;
 					transf.link[0].link_amount = 0;
 					transf.link[1].link_type =
 					transf.link[1].link_type =
-						(enum link_types)0;
+					    (enum link_types)0;
 					transf.link[1].link_amount = 0;
 					transf.link[1].link_amount = 0;
 					transf.link[2].link_type =
 					transf.link[2].link_type =
-						(enum link_types)0;
+					    (enum link_types)0;
 					transf.link[2].link_amount = 0;
 					transf.link[2].link_amount = 0;
 					transf.link[3].link_type =
 					transf.link[3].link_type =
-						(enum link_types)0;
+					    (enum link_types)0;
 					transf.link[3].link_amount = 0;
 					transf.link[3].link_amount = 0;
 
 
 					set_transforms(channel, transf, 0);
 					set_transforms(channel, transf, 0);
 					use_transform(channel, 0);
 					use_transform(channel, 0);
 					p->state =
 					p->state =
-						state_jr3_init_transform_complete;
+					    state_jr3_init_transform_complete;
 					result = poll_delay_min_max(20, 100);	/*  Allow 20 ms for completion */
 					result = poll_delay_min_max(20, 100);	/*  Allow 20 ms for completion */
 				}
 				}
 			} break;
 			} break;
 		case state_jr3_init_transform_complete:{
 		case state_jr3_init_transform_complete:{
 				if (!is_complete(channel)) {
 				if (!is_complete(channel)) {
-					printk("state_jr3_init_transform_complete complete = %d\n", is_complete(channel));
+					printk
+					    ("state_jr3_init_transform_complete complete = %d\n",
+					     is_complete(channel));
 					result = poll_delay_min_max(20, 100);
 					result = poll_delay_min_max(20, 100);
 				} else {
 				} else {
 					/*  Set full scale */
 					/*  Set full scale */
@@ -602,7 +602,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 					struct six_axis_t max_full_scale;
 					struct six_axis_t max_full_scale;
 
 
 					min_full_scale =
 					min_full_scale =
-						get_min_full_scales(channel);
+					    get_min_full_scales(channel);
 					printk("Obtained Min. Full Scales:\n");
 					printk("Obtained Min. Full Scales:\n");
 					printk("%i   ", (min_full_scale).fx);
 					printk("%i   ", (min_full_scale).fx);
 					printk("%i   ", (min_full_scale).fy);
 					printk("%i   ", (min_full_scale).fy);
@@ -613,7 +613,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 					printk("\n");
 					printk("\n");
 
 
 					max_full_scale =
 					max_full_scale =
-						get_max_full_scales(channel);
+					    get_max_full_scales(channel);
 					printk("Obtained Max. Full Scales:\n");
 					printk("Obtained Max. Full Scales:\n");
 					printk("%i   ", (max_full_scale).fx);
 					printk("%i   ", (max_full_scale).fx);
 					printk("%i   ", (max_full_scale).fy);
 					printk("%i   ", (max_full_scale).fy);
@@ -624,17 +624,19 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 					printk("\n");
 					printk("\n");
 
 
 					set_full_scales(channel,
 					set_full_scales(channel,
-						max_full_scale);
+							max_full_scale);
 
 
 					p->state =
 					p->state =
-						state_jr3_init_set_full_scale_complete;
+					    state_jr3_init_set_full_scale_complete;
 					result = poll_delay_min_max(20, 100);	/*  Allow 20 ms for completion */
 					result = poll_delay_min_max(20, 100);	/*  Allow 20 ms for completion */
 				}
 				}
 			}
 			}
 			break;
 			break;
 		case state_jr3_init_set_full_scale_complete:{
 		case state_jr3_init_set_full_scale_complete:{
 				if (!is_complete(channel)) {
 				if (!is_complete(channel)) {
-					printk("state_jr3_init_set_full_scale_complete complete = %d\n", is_complete(channel));
+					printk
+					    ("state_jr3_init_set_full_scale_complete complete = %d\n",
+					     is_complete(channel));
 					result = poll_delay_min_max(20, 100);
 					result = poll_delay_min_max(20, 100);
 				} else {
 				} else {
 					volatile struct force_array *full_scale;
 					volatile struct force_array *full_scale;
@@ -642,32 +644,29 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 					/*  Use ranges in kN or we will overflow arount 2000N! */
 					/*  Use ranges in kN or we will overflow arount 2000N! */
 					full_scale = &channel->full_scale;
 					full_scale = &channel->full_scale;
 					p->range[0].range.min =
 					p->range[0].range.min =
-						-get_s16(&full_scale->fx) *
-						1000;
+					    -get_s16(&full_scale->fx) * 1000;
 					p->range[0].range.max =
 					p->range[0].range.max =
-						get_s16(&full_scale->fx) * 1000;
+					    get_s16(&full_scale->fx) * 1000;
 					p->range[1].range.min =
 					p->range[1].range.min =
-						-get_s16(&full_scale->fy) *
-						1000;
+					    -get_s16(&full_scale->fy) * 1000;
 					p->range[1].range.max =
 					p->range[1].range.max =
-						get_s16(&full_scale->fy) * 1000;
+					    get_s16(&full_scale->fy) * 1000;
 					p->range[2].range.min =
 					p->range[2].range.min =
-						-get_s16(&full_scale->fz) *
-						1000;
+					    -get_s16(&full_scale->fz) * 1000;
 					p->range[2].range.max =
 					p->range[2].range.max =
-						get_s16(&full_scale->fz) * 1000;
+					    get_s16(&full_scale->fz) * 1000;
 					p->range[3].range.min =
 					p->range[3].range.min =
-						-get_s16(&full_scale->mx) * 100;
+					    -get_s16(&full_scale->mx) * 100;
 					p->range[3].range.max =
 					p->range[3].range.max =
-						get_s16(&full_scale->mx) * 100;
+					    get_s16(&full_scale->mx) * 100;
 					p->range[4].range.min =
 					p->range[4].range.min =
-						-get_s16(&full_scale->my) * 100;
+					    -get_s16(&full_scale->my) * 100;
 					p->range[4].range.max =
 					p->range[4].range.max =
-						get_s16(&full_scale->my) * 100;
+					    get_s16(&full_scale->my) * 100;
 					p->range[5].range.min =
 					p->range[5].range.min =
-						-get_s16(&full_scale->mz) * 100;
+					    -get_s16(&full_scale->mz) * 100;
 					p->range[5].range.max =
 					p->range[5].range.max =
-						get_s16(&full_scale->mz) * 100;
+					    get_s16(&full_scale->mz) * 100;
 					p->range[6].range.min = -get_s16(&full_scale->v1) * 100;	/*  ?? */
 					p->range[6].range.min = -get_s16(&full_scale->v1) * 100;	/*  ?? */
 					p->range[6].range.max = get_s16(&full_scale->v1) * 100;	/*  ?? */
 					p->range[6].range.max = get_s16(&full_scale->v1) * 100;	/*  ?? */
 					p->range[7].range.min = -get_s16(&full_scale->v2) * 100;	/*  ?? */
 					p->range[7].range.min = -get_s16(&full_scale->v2) * 100;	/*  ?? */
@@ -679,27 +678,38 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 						int i;
 						int i;
 						for (i = 0; i < 9; i++) {
 						for (i = 0; i < 9; i++) {
 							printk("%d %d - %d\n",
 							printk("%d %d - %d\n",
-								i,
-								p->range[i].
-								range.min,
-								p->range[i].
-								range.max);
+							       i,
+							       p->
+							       range[i].range.
+							       min,
+							       p->
+							       range[i].range.
+							       max);
 						}
 						}
 					}
 					}
 
 
 					use_offset(channel, 0);
 					use_offset(channel, 0);
 					p->state =
 					p->state =
-						state_jr3_init_use_offset_complete;
+					    state_jr3_init_use_offset_complete;
 					result = poll_delay_min_max(40, 100);	/*  Allow 40 ms for completion */
 					result = poll_delay_min_max(40, 100);	/*  Allow 40 ms for completion */
 				}
 				}
 			}
 			}
 			break;
 			break;
 		case state_jr3_init_use_offset_complete:{
 		case state_jr3_init_use_offset_complete:{
 				if (!is_complete(channel)) {
 				if (!is_complete(channel)) {
-					printk("state_jr3_init_use_offset_complete complete = %d\n", is_complete(channel));
+					printk
+					    ("state_jr3_init_use_offset_complete complete = %d\n",
+					     is_complete(channel));
 					result = poll_delay_min_max(20, 100);
 					result = poll_delay_min_max(20, 100);
 				} else {
 				} else {
-					printk("Default offsets %d %d %d %d %d %d\n", get_s16(&channel->offsets.fx), get_s16(&channel->offsets.fy), get_s16(&channel->offsets.fz), get_s16(&channel->offsets.mx), get_s16(&channel->offsets.my), get_s16(&channel->offsets.mz));
+					printk
+					    ("Default offsets %d %d %d %d %d %d\n",
+					     get_s16(&channel->offsets.fx),
+					     get_s16(&channel->offsets.fy),
+					     get_s16(&channel->offsets.fz),
+					     get_s16(&channel->offsets.mx),
+					     get_s16(&channel->offsets.my),
+					     get_s16(&channel->offsets.mz));
 
 
 					set_s16(&channel->offsets.fx, 0);
 					set_s16(&channel->offsets.fx, 0);
 					set_s16(&channel->offsets.fy, 0);
 					set_s16(&channel->offsets.fy, 0);
@@ -730,7 +740,7 @@ static struct poll_delay_t jr3_pci_poll_subdevice(struct comedi_subdevice *s)
 static void jr3_pci_poll_dev(unsigned long data)
 static void jr3_pci_poll_dev(unsigned long data)
 {
 {
 	unsigned long flags;
 	unsigned long flags;
-	struct comedi_device *dev = (struct comedi_device *) data;
+	struct comedi_device *dev = (struct comedi_device *)data;
 	struct jr3_pci_dev_private *devpriv = dev->private;
 	struct jr3_pci_dev_private *devpriv = dev->private;
 	unsigned long now;
 	unsigned long now;
 	int delay;
 	int delay;
@@ -741,15 +751,16 @@ static void jr3_pci_poll_dev(unsigned long data)
 	now = jiffies;
 	now = jiffies;
 	/*  Poll all channels that are ready to be polled */
 	/*  Poll all channels that are ready to be polled */
 	for (i = 0; i < devpriv->n_channels; i++) {
 	for (i = 0; i < devpriv->n_channels; i++) {
-		struct jr3_pci_subdev_private *subdevpriv = dev->subdevices[i].private;
+		struct jr3_pci_subdev_private *subdevpriv =
+		    dev->subdevices[i].private;
 		if (now > subdevpriv->next_time_min) {
 		if (now > subdevpriv->next_time_min) {
 			struct poll_delay_t sub_delay;
 			struct poll_delay_t sub_delay;
 
 
 			sub_delay = jr3_pci_poll_subdevice(&dev->subdevices[i]);
 			sub_delay = jr3_pci_poll_subdevice(&dev->subdevices[i]);
 			subdevpriv->next_time_min =
 			subdevpriv->next_time_min =
-				jiffies + msecs_to_jiffies(sub_delay.min);
+			    jiffies + msecs_to_jiffies(sub_delay.min);
 			subdevpriv->next_time_max =
 			subdevpriv->next_time_max =
-				jiffies + msecs_to_jiffies(sub_delay.max);
+			    jiffies + msecs_to_jiffies(sub_delay.max);
 			if (sub_delay.max && sub_delay.max < delay) {
 			if (sub_delay.max && sub_delay.max < delay) {
 /*
 /*
 * Wake up as late as possible -> poll as many channels as possible
 * Wake up as late as possible -> poll as many channels as possible
@@ -765,7 +776,8 @@ static void jr3_pci_poll_dev(unsigned long data)
 	add_timer(&devpriv->timer);
 	add_timer(&devpriv->timer);
 }
 }
 
 
-static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int jr3_pci_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	int result = 0;
 	int result = 0;
 	struct pci_dev *card = NULL;
 	struct pci_dev *card = NULL;
@@ -779,7 +791,7 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
 
 
 	if (sizeof(struct jr3_channel) != 0xc00) {
 	if (sizeof(struct jr3_channel) != 0xc00) {
 		printk("sizeof(struct jr3_channel) = %x [expected %x]\n",
 		printk("sizeof(struct jr3_channel) = %x [expected %x]\n",
-			(unsigned)sizeof(struct jr3_channel), 0xc00);
+		       (unsigned)sizeof(struct jr3_channel), 0xc00);
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 
 
@@ -822,7 +834,7 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
 					/* Take first available card */
 					/* Take first available card */
 					break;
 					break;
 				} else if (opt_bus == card->bus->number &&
 				} else if (opt_bus == card->bus->number &&
-					opt_slot == PCI_SLOT(card->devfn)) {
+					   opt_slot == PCI_SLOT(card->devfn)) {
 					/* Take requested card */
 					/* Take requested card */
 					break;
 					break;
 				}
 				}
@@ -843,7 +855,8 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	}
 	}
 
 
 	devpriv->pci_enabled = 1;
 	devpriv->pci_enabled = 1;
-	devpriv->iobase = ioremap(pci_resource_start(card, 0), sizeof(struct jr3_t));
+	devpriv->iobase =
+	    ioremap(pci_resource_start(card, 0), sizeof(struct jr3_t));
 	result = alloc_subdevices(dev, devpriv->n_channels);
 	result = alloc_subdevices(dev, devpriv->n_channels);
 	if (result < 0)
 	if (result < 0)
 		goto out;
 		goto out;
@@ -855,7 +868,7 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		dev->subdevices[i].n_chan = 8 * 7 + 2;
 		dev->subdevices[i].n_chan = 8 * 7 + 2;
 		dev->subdevices[i].insn_read = jr3_pci_ai_insn_read;
 		dev->subdevices[i].insn_read = jr3_pci_ai_insn_read;
 		dev->subdevices[i].private =
 		dev->subdevices[i].private =
-			kzalloc(sizeof(struct jr3_pci_subdev_private), GFP_KERNEL);
+		    kzalloc(sizeof(struct jr3_pci_subdev_private), GFP_KERNEL);
 		if (dev->subdevices[i].private) {
 		if (dev->subdevices[i].private) {
 			struct jr3_pci_subdev_private *p;
 			struct jr3_pci_subdev_private *p;
 			int j;
 			int j;
@@ -863,9 +876,9 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
 			p = dev->subdevices[i].private;
 			p = dev->subdevices[i].private;
 			p->channel = &devpriv->iobase->channel[i].data;
 			p->channel = &devpriv->iobase->channel[i].data;
 			printk("p->channel %p %p (%tx)\n",
 			printk("p->channel %p %p (%tx)\n",
-				p->channel, devpriv->iobase,
-				((char *)(p->channel) -
-					(char *)(devpriv->iobase)));
+			       p->channel, devpriv->iobase,
+			       ((char *)(p->channel) -
+				(char *)(devpriv->iobase)));
 			p->channel_no = i;
 			p->channel_no = i;
 			for (j = 0; j < 8; j++) {
 			for (j = 0; j < 8; j++) {
 				int k;
 				int k;
@@ -875,7 +888,8 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
 				p->range[j].range.max = 1000000;
 				p->range[j].range.max = 1000000;
 				for (k = 0; k < 7; k++) {
 				for (k = 0; k < 7; k++) {
 					p->range_table_list[j + k * 8] =
 					p->range_table_list[j + k * 8] =
-						(struct comedi_lrange *) &p->range[j];
+					    (struct comedi_lrange *)&p->
+					    range[j];
 					p->maxdata_list[j + k * 8] = 0x7fff;
 					p->maxdata_list[j + k * 8] = 0x7fff;
 				}
 				}
 			}
 			}
@@ -884,15 +898,15 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
 			p->range[8].range.max = 65536;
 			p->range[8].range.max = 65536;
 
 
 			p->range_table_list[56] =
 			p->range_table_list[56] =
-				(struct comedi_lrange *) &p->range[8];
+			    (struct comedi_lrange *)&p->range[8];
 			p->range_table_list[57] =
 			p->range_table_list[57] =
-				(struct comedi_lrange *) &p->range[8];
+			    (struct comedi_lrange *)&p->range[8];
 			p->maxdata_list[56] = 0xffff;
 			p->maxdata_list[56] = 0xffff;
 			p->maxdata_list[57] = 0xffff;
 			p->maxdata_list[57] = 0xffff;
 			/*  Channel specific range and maxdata */
 			/*  Channel specific range and maxdata */
 			dev->subdevices[i].range_table = 0;
 			dev->subdevices[i].range_table = 0;
 			dev->subdevices[i].range_table_list =
 			dev->subdevices[i].range_table_list =
-				p->range_table_list;
+			    p->range_table_list;
 			dev->subdevices[i].maxdata = 0;
 			dev->subdevices[i].maxdata = 0;
 			dev->subdevices[i].maxdata_list = p->maxdata_list;
 			dev->subdevices[i].maxdata_list = p->maxdata_list;
 		}
 		}
@@ -922,8 +936,8 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	msleep_interruptible(25);
 	msleep_interruptible(25);
 	for (i = 0; i < 0x18; i++) {
 	for (i = 0; i < 0x18; i++) {
 		printk("%c",
 		printk("%c",
-			get_u16(&devpriv->iobase->channel[0].data.
-				copyright[i]) >> 8);
+		       get_u16(&devpriv->iobase->channel[0].
+			       data.copyright[i]) >> 8);
 	}
 	}
 
 
 	/*  Start card timer */
 	/*  Start card timer */
@@ -939,7 +953,7 @@ static int jr3_pci_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	devpriv->timer.expires = jiffies + msecs_to_jiffies(1000);
 	devpriv->timer.expires = jiffies + msecs_to_jiffies(1000);
 	add_timer(&devpriv->timer);
 	add_timer(&devpriv->timer);
 
 
-      out:
+out:
 	return result;
 	return result;
 }
 }
 
 

+ 20 - 20
drivers/staging/comedi/drivers/jr3_pci.h

@@ -2,22 +2,22 @@
  * is 16 bits, but aligned on a 32 bit PCI boundary
  * is 16 bits, but aligned on a 32 bit PCI boundary
  */
  */
 
 
-static inline u16 get_u16(volatile const u32 *p)
+static inline u16 get_u16(volatile const u32 * p)
 {
 {
 	return (u16) readl(p);
 	return (u16) readl(p);
 }
 }
 
 
-static inline void set_u16(volatile u32 *p, u16 val)
+static inline void set_u16(volatile u32 * p, u16 val)
 {
 {
 	writel(val, p);
 	writel(val, p);
 }
 }
 
 
-static inline s16 get_s16(volatile const s32 *p)
+static inline s16 get_s16(volatile const s32 * p)
 {
 {
 	return (s16) readl(p);
 	return (s16) readl(p);
 }
 }
 
 
-static inline void set_s16(volatile s32 *p, s16 val)
+static inline void set_s16(volatile s32 * p, s16 val)
 {
 {
 	writel(val, p);
 	writel(val, p);
 }
 }
@@ -304,7 +304,7 @@ struct jr3_channel {
 	/* not set a full scale. */
 	/* not set a full scale. */
 
 
 	struct six_axis_array default_FS;	/* offset 0x0068 */
 	struct six_axis_array default_FS;	/* offset 0x0068 */
-	s32 reserved3;	/* offset 0x006e */
+	s32 reserved3;		/* offset 0x006e */
 
 
 	/* Load_envelope_num is the load envelope number that is currently
 	/* Load_envelope_num is the load envelope number that is currently
 	 * in use. This value is set by the user after one of the load
 	 * in use. This value is set by the user after one of the load
@@ -341,7 +341,7 @@ struct jr3_channel {
 	 */
 	 */
 
 
 	struct six_axis_array min_full_scale;	/* offset 0x0070 */
 	struct six_axis_array min_full_scale;	/* offset 0x0070 */
-	s32 reserved4;	/* offset 0x0076 */
+	s32 reserved4;		/* offset 0x0076 */
 
 
 	/* Transform_num is the transform number that is currently in use.
 	/* Transform_num is the transform number that is currently in use.
 	 * This value is set by the JR3 DSP after the user has used command
 	 * This value is set by the JR3 DSP after the user has used command
@@ -354,7 +354,7 @@ struct jr3_channel {
 	/*  min_full_scale (pg. 9) for more details. */
 	/*  min_full_scale (pg. 9) for more details. */
 
 
 	struct six_axis_array max_full_scale;	/* offset 0x0078 */
 	struct six_axis_array max_full_scale;	/* offset 0x0078 */
-	s32 reserved5;	/* offset 0x007e */
+	s32 reserved5;		/* offset 0x007e */
 
 
 	/* Peak_address is the address of the data which will be monitored
 	/* Peak_address is the address of the data which will be monitored
 	 * by the peak routine. This value is set by the user. The peak
 	 * by the peak routine. This value is set by the user. The peak
@@ -398,14 +398,14 @@ struct jr3_channel {
 	 * offset # command (pg. 34). It can vary between 0 and 15.
 	 * offset # command (pg. 34). It can vary between 0 and 15.
 	 */
 	 */
 
 
-	s32 offset_num;	/* offset 0x008e */
+	s32 offset_num;		/* offset 0x008e */
 
 
 	/* Vect_axes is a bit map showing which of the axes are being used
 	/* Vect_axes is a bit map showing which of the axes are being used
 	 * in the vector calculations. This value is set by the JR3 DSP
 	 * in the vector calculations. This value is set by the JR3 DSP
 	 * after the user has executed the set vector axes command (pg. 37).
 	 * after the user has executed the set vector axes command (pg. 37).
 	 */
 	 */
 
 
-	u32 vect_axes;	/* offset 0x008f */
+	u32 vect_axes;		/* offset 0x008f */
 
 
 	/* Filter0 is the decoupled, unfiltered data from the JR3 sensor.
 	/* Filter0 is the decoupled, unfiltered data from the JR3 sensor.
 	 * This data has had the offsets removed.
 	 * This data has had the offsets removed.
@@ -465,7 +465,7 @@ struct jr3_channel {
 	 */
 	 */
 
 
 	s32 near_sat_value;	/* offset 0x00e0 */
 	s32 near_sat_value;	/* offset 0x00e0 */
-	s32 sat_value;	/* offset 0x00e1 */
+	s32 sat_value;		/* offset 0x00e1 */
 
 
 	/* Rate_address, rate_divisor & rate_count contain the data used to
 	/* Rate_address, rate_divisor & rate_count contain the data used to
 	 * control the calculations of the rates. Rate_address is the
 	 * control the calculations of the rates. Rate_address is the
@@ -486,7 +486,7 @@ struct jr3_channel {
 
 
 	s32 rate_address;	/* offset 0x00e2 */
 	s32 rate_address;	/* offset 0x00e2 */
 	u32 rate_divisor;	/* offset 0x00e3 */
 	u32 rate_divisor;	/* offset 0x00e3 */
-	u32 rate_count;	/* offset 0x00e4 */
+	u32 rate_count;		/* offset 0x00e4 */
 
 
 	/* Command_word2 through command_word0 are the locations used to
 	/* Command_word2 through command_word0 are the locations used to
 	 * send commands to the JR3 DSP. Their usage varies with the command
 	 * send commands to the JR3 DSP. Their usage varies with the command
@@ -543,14 +543,14 @@ struct jr3_channel {
 	 * Issues section on pg. 49 for more details.
 	 * Issues section on pg. 49 for more details.
 	 */
 	 */
 
 
-	u32 count_x;	/* offset 0x00ef */
+	u32 count_x;		/* offset 0x00ef */
 
 
 	/* Warnings & errors contain the warning and error bits
 	/* Warnings & errors contain the warning and error bits
 	 * respectively. The format of these two words is discussed on page
 	 * respectively. The format of these two words is discussed on page
 	 * 21 under the headings warnings_bits and error_bits.
 	 * 21 under the headings warnings_bits and error_bits.
 	 */
 	 */
 
 
-	u32 warnings;	/* offset 0x00f0 */
+	u32 warnings;		/* offset 0x00f0 */
 	u32 errors;		/* offset 0x00f1 */
 	u32 errors;		/* offset 0x00f1 */
 
 
 	/* Threshold_bits is a word containing the bits that are set by the
 	/* Threshold_bits is a word containing the bits that are set by the
@@ -565,7 +565,7 @@ struct jr3_channel {
 	 * description for cal_crc_bad (pg. 21) for more information.
 	 * description for cal_crc_bad (pg. 21) for more information.
 	 */
 	 */
 
 
-	s32 last_CRC;	/* offset 0x00f3 */
+	s32 last_CRC;		/* offset 0x00f3 */
 
 
 	/* EEProm_ver_no contains the version number of the sensor EEProm.
 	/* EEProm_ver_no contains the version number of the sensor EEProm.
 	 * EEProm version numbers can vary between 0 and 255.
 	 * EEProm version numbers can vary between 0 and 255.
@@ -591,16 +591,16 @@ struct jr3_channel {
 	 * different sensor configurations.
 	 * different sensor configurations.
 	 */
 	 */
 
 
-	u32 serial_no;	/* offset 0x00f8 */
-	u32 model_no;	/* offset 0x00f9 */
+	u32 serial_no;		/* offset 0x00f8 */
+	u32 model_no;		/* offset 0x00f9 */
 
 
 	/* Cal_day & cal_year are the sensor calibration date. Day is the
 	/* Cal_day & cal_year are the sensor calibration date. Day is the
 	 * day of the year, with January 1 being 1, and December 31, being
 	 * day of the year, with January 1 being 1, and December 31, being
 	 * 366 for leap years.
 	 * 366 for leap years.
 	 */
 	 */
 
 
-	s32 cal_day;	/* offset 0x00fa */
-	s32 cal_year;	/* offset 0x00fb */
+	s32 cal_day;		/* offset 0x00fa */
+	s32 cal_year;		/* offset 0x00fb */
 
 
 	/* Units is an enumerated read only value defining the engineering
 	/* Units is an enumerated read only value defining the engineering
 	 * units used in the sensor full scale. The meanings of particular
 	 * units used in the sensor full scale. The meanings of particular
@@ -627,7 +627,7 @@ struct jr3_channel {
 
 
 	u32 units;		/* offset 0x00fc */
 	u32 units;		/* offset 0x00fc */
 	s32 bits;		/* offset 0x00fd */
 	s32 bits;		/* offset 0x00fd */
-	s32 channels;	/* offset 0x00fe */
+	s32 channels;		/* offset 0x00fe */
 
 
 	/* Thickness specifies the overall thickness of the sensor from
 	/* Thickness specifies the overall thickness of the sensor from
 	 * flange to flange. The engineering units for this value are
 	 * flange to flange. The engineering units for this value are
@@ -636,7 +636,7 @@ struct jr3_channel {
 	 * transformation from the center of the sensor to either flange.
 	 * transformation from the center of the sensor to either flange.
 	 */
 	 */
 
 
-	s32 thickness;	/* offset 0x00ff */
+	s32 thickness;		/* offset 0x00ff */
 
 
 	/* Load_envelopes is a table containing the load envelope
 	/* Load_envelopes is a table containing the load envelope
 	 * descriptions. There are 16 possible load envelope slots in the
 	 * descriptions. There are 16 possible load envelope slots in the

+ 35 - 32
drivers/staging/comedi/drivers/ke_counter.c

@@ -52,9 +52,10 @@ static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it);
 static int cnt_detach(struct comedi_device *dev);
 static int cnt_detach(struct comedi_device *dev);
 
 
 static DEFINE_PCI_DEVICE_TABLE(cnt_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(cnt_pci_table) = {
-	{PCI_VENDOR_ID_KOLTER, CNT_CARD_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-		0},
-	{0}
+	{
+	PCI_VENDOR_ID_KOLTER, CNT_CARD_DEVICE_ID, PCI_ANY_ID,
+		    PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, cnt_pci_table);
 MODULE_DEVICE_TABLE(pci, cnt_pci_table);
@@ -69,13 +70,12 @@ struct cnt_board_struct {
 	int cnt_bits;
 	int cnt_bits;
 };
 };
 
 
-
 static const struct cnt_board_struct cnt_boards[] = {
 static const struct cnt_board_struct cnt_boards[] = {
 	{
 	{
-	.name = CNT_DRIVER_NAME,
-	.device_id = CNT_CARD_DEVICE_ID,
-	.cnt_channel_nbr = 3,
-	.cnt_bits = 24}
+	 .name = CNT_DRIVER_NAME,
+	 .device_id = CNT_CARD_DEVICE_ID,
+	 .cnt_channel_nbr = 3,
+	 .cnt_bits = 24}
 };
 };
 
 
 #define cnt_board_nbr (sizeof(cnt_boards)/sizeof(struct cnt_board_struct))
 #define cnt_board_nbr (sizeof(cnt_boards)/sizeof(struct cnt_board_struct))
@@ -87,7 +87,6 @@ struct cnt_device_private {
 	struct pci_dev *pcidev;
 	struct pci_dev *pcidev;
 };
 };
 
 
-
 #define devpriv ((struct cnt_device_private *)dev->private)
 #define devpriv ((struct cnt_device_private *)dev->private)
 
 
 static struct comedi_driver cnt_driver = {
 static struct comedi_driver cnt_driver = {
@@ -104,18 +103,19 @@ COMEDI_PCI_INITCLEANUP(cnt_driver, cnt_pci_table);
 /* This should be used only for resetting the counters; maybe it is better
 /* This should be used only for resetting the counters; maybe it is better
    to make a special command 'reset'. */
    to make a special command 'reset'. */
 static int cnt_winsn(struct comedi_device *dev,
 static int cnt_winsn(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+		     struct comedi_subdevice *s, struct comedi_insn *insn,
+		     unsigned int *data)
 {
 {
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
 
 
 	outb((unsigned char)((data[0] >> 24) & 0xff),
 	outb((unsigned char)((data[0] >> 24) & 0xff),
-		dev->iobase + chan * 0x20 + 0x10);
+	     dev->iobase + chan * 0x20 + 0x10);
 	outb((unsigned char)((data[0] >> 16) & 0xff),
 	outb((unsigned char)((data[0] >> 16) & 0xff),
-		dev->iobase + chan * 0x20 + 0x0c);
+	     dev->iobase + chan * 0x20 + 0x0c);
 	outb((unsigned char)((data[0] >> 8) & 0xff),
 	outb((unsigned char)((data[0] >> 8) & 0xff),
-		dev->iobase + chan * 0x20 + 0x08);
+	     dev->iobase + chan * 0x20 + 0x08);
 	outb((unsigned char)((data[0] >> 0) & 0xff),
 	outb((unsigned char)((data[0] >> 0) & 0xff),
-		dev->iobase + chan * 0x20 + 0x04);
+	     dev->iobase + chan * 0x20 + 0x04);
 
 
 	/* return the number of samples written */
 	/* return the number of samples written */
 	return 1;
 	return 1;
@@ -124,7 +124,8 @@ static int cnt_winsn(struct comedi_device *dev,
 /*-- counter read -----------------------------------------------------------*/
 /*-- counter read -----------------------------------------------------------*/
 
 
 static int cnt_rinsn(struct comedi_device *dev,
 static int cnt_rinsn(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+		     struct comedi_subdevice *s, struct comedi_insn *insn,
+		     unsigned int *data)
 {
 {
 	unsigned char a0, a1, a2, a3, a4;
 	unsigned char a0, a1, a2, a3, a4;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -140,7 +141,7 @@ static int cnt_rinsn(struct comedi_device *dev,
 	if (a4 > 0)
 	if (a4 > 0)
 		result = result - s->maxdata;
 		result = result - s->maxdata;
 
 
-	*data = (unsigned int) result;
+	*data = (unsigned int)result;
 
 
 	/* return the number of samples read */
 	/* return the number of samples read */
 	return 1;
 	return 1;
@@ -163,49 +164,51 @@ static int cnt_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 
 	/* Probe the device to determine what device in the series it is. */
 	/* Probe the device to determine what device in the series it is. */
 	for (pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pci_device != NULL;
-		pci_device =
-		pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
+	     pci_device != NULL;
+	     pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
 		if (pci_device->vendor == PCI_VENDOR_ID_KOLTER) {
 		if (pci_device->vendor == PCI_VENDOR_ID_KOLTER) {
 			for (i = 0; i < cnt_board_nbr; i++) {
 			for (i = 0; i < cnt_board_nbr; i++) {
 				if (cnt_boards[i].device_id ==
 				if (cnt_boards[i].device_id ==
-					pci_device->device) {
+				    pci_device->device) {
 					/* was a particular bus/slot requested? */
 					/* was a particular bus/slot requested? */
 					if ((it->options[0] != 0)
 					if ((it->options[0] != 0)
-						|| (it->options[1] != 0)) {
+					    || (it->options[1] != 0)) {
 						/* are we on the wrong bus/slot? */
 						/* are we on the wrong bus/slot? */
 						if (pci_device->bus->number !=
 						if (pci_device->bus->number !=
-							it->options[0]
-							|| PCI_SLOT(pci_device->
-								devfn) !=
-							it->options[1]) {
+						    it->options[0]
+						    ||
+						    PCI_SLOT(pci_device->devfn)
+						    != it->options[1]) {
 							continue;
 							continue;
 						}
 						}
 					}
 					}
 
 
 					dev->board_ptr = cnt_boards + i;
 					dev->board_ptr = cnt_boards + i;
-					board = (struct cnt_board_struct *) dev->
-						board_ptr;
+					board =
+					    (struct cnt_board_struct *)
+					    dev->board_ptr;
 					goto found;
 					goto found;
 				}
 				}
 			}
 			}
 		}
 		}
 	}
 	}
 	printk("comedi%d: no supported board found! (req. bus/slot: %d/%d)\n",
 	printk("comedi%d: no supported board found! (req. bus/slot: %d/%d)\n",
-		dev->minor, it->options[0], it->options[1]);
+	       dev->minor, it->options[0], it->options[1]);
 	return -EIO;
 	return -EIO;
 
 
-      found:
+found:
 	printk("comedi%d: found %s at PCI bus %d, slot %d\n", dev->minor,
 	printk("comedi%d: found %s at PCI bus %d, slot %d\n", dev->minor,
-		board->name, pci_device->bus->number,
-		PCI_SLOT(pci_device->devfn));
+	       board->name, pci_device->bus->number,
+	       PCI_SLOT(pci_device->devfn));
 	devpriv->pcidev = pci_device;
 	devpriv->pcidev = pci_device;
 	dev->board_name = board->name;
 	dev->board_name = board->name;
 
 
 	/* enable PCI device and request regions */
 	/* enable PCI device and request regions */
 	error = comedi_pci_enable(pci_device, CNT_DRIVER_NAME);
 	error = comedi_pci_enable(pci_device, CNT_DRIVER_NAME);
 	if (error < 0) {
 	if (error < 0) {
-		printk("comedi%d: failed to enable PCI device and request regions!\n", dev->minor);
+		printk
+		    ("comedi%d: failed to enable PCI device and request regions!\n",
+		     dev->minor);
 		return error;
 		return error;
 	}
 	}
 
 

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 244 - 224
drivers/staging/comedi/drivers/me4000.c


+ 114 - 104
drivers/staging/comedi/drivers/me_daq.c

@@ -151,46 +151,47 @@ static int me_detach(struct comedi_device *dev);
 static const struct comedi_lrange me2000_ai_range = {
 static const struct comedi_lrange me2000_ai_range = {
 	8,
 	8,
 	{
 	{
-		BIP_RANGE(10),
-		BIP_RANGE(5),
-		BIP_RANGE(2.5),
-		BIP_RANGE(1.25),
-		UNI_RANGE(10),
-		UNI_RANGE(5),
-		UNI_RANGE(2.5),
-		UNI_RANGE(1.25)
-	}
+	 BIP_RANGE(10),
+	 BIP_RANGE(5),
+	 BIP_RANGE(2.5),
+	 BIP_RANGE(1.25),
+	 UNI_RANGE(10),
+	 UNI_RANGE(5),
+	 UNI_RANGE(2.5),
+	 UNI_RANGE(1.25)
+	 }
 };
 };
 
 
 static const struct comedi_lrange me2600_ai_range = {
 static const struct comedi_lrange me2600_ai_range = {
 	8,
 	8,
 	{
 	{
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-			BIP_RANGE(2.5),
-			BIP_RANGE(1.25),
-			UNI_RANGE(10),
-			UNI_RANGE(5),
-			UNI_RANGE(2.5),
-			UNI_RANGE(1.25)
-		}
+	 BIP_RANGE(10),
+	 BIP_RANGE(5),
+	 BIP_RANGE(2.5),
+	 BIP_RANGE(1.25),
+	 UNI_RANGE(10),
+	 UNI_RANGE(5),
+	 UNI_RANGE(2.5),
+	 UNI_RANGE(1.25)
+	 }
 };
 };
 
 
 static const struct comedi_lrange me2600_ao_range = {
 static const struct comedi_lrange me2600_ao_range = {
 	3,
 	3,
 	{
 	{
-			BIP_RANGE(10),
-			BIP_RANGE(5),
-			UNI_RANGE(10)
-		}
+	 BIP_RANGE(10),
+	 BIP_RANGE(5),
+	 UNI_RANGE(10)
+	 }
 };
 };
 
 
 static DEFINE_PCI_DEVICE_TABLE(me_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(me_pci_table) = {
-	{PCI_VENDOR_ID_MEILHAUS, ME2600_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-		0},
-	{PCI_VENDOR_ID_MEILHAUS, ME2000_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
-		0},
-	{0}
+	{
+	PCI_VENDOR_ID_MEILHAUS, ME2600_DEVICE_ID, PCI_ANY_ID,
+		    PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_MEILHAUS, ME2000_DEVICE_ID, PCI_ANY_ID,
+		    PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, me_pci_table);
 MODULE_DEVICE_TABLE(pci, me_pci_table);
@@ -212,48 +213,48 @@ struct me_board {
 
 
 static const struct me_board me_boards[] = {
 static const struct me_board me_boards[] = {
 	{
 	{
-		/* -- ME-2600i -- */
-		.name = 		ME_DRIVER_NAME,
-		.device_id =		ME2600_DEVICE_ID,
-		/* Analog Output */
-		.ao_channel_nbr =	4,
-		.ao_resolution =	12,
-		.ao_resolution_mask =	0x0fff,
-		.ao_range_list =	&me2600_ao_range,
-		.ai_channel_nbr =	16,
-		/* Analog Input */
-		.ai_resolution =	12,
-		.ai_resolution_mask =	0x0fff,
-		.ai_range_list =	&me2600_ai_range,
-		.dio_channel_nbr =	32,
-		},
+	 /* -- ME-2600i -- */
+	 .name = ME_DRIVER_NAME,
+	 .device_id = ME2600_DEVICE_ID,
+	 /* Analog Output */
+	 .ao_channel_nbr = 4,
+	 .ao_resolution = 12,
+	 .ao_resolution_mask = 0x0fff,
+	 .ao_range_list = &me2600_ao_range,
+	 .ai_channel_nbr = 16,
+	 /* Analog Input */
+	 .ai_resolution = 12,
+	 .ai_resolution_mask = 0x0fff,
+	 .ai_range_list = &me2600_ai_range,
+	 .dio_channel_nbr = 32,
+	 },
 	{
 	{
-		/* -- ME-2000i -- */
-		.name =			ME_DRIVER_NAME,
-		.device_id =		ME2000_DEVICE_ID,
-		/* Analog Output */
-		.ao_channel_nbr =	0,
-		.ao_resolution =	0,
-		.ao_resolution_mask =	0,
-		.ao_range_list =	NULL,
-		.ai_channel_nbr =	16,
-		/* Analog Input */
-		.ai_resolution =	12,
-		.ai_resolution_mask =	0x0fff,
-		.ai_range_list =	&me2000_ai_range,
-		.dio_channel_nbr =	32,
-		}
+	 /* -- ME-2000i -- */
+	 .name = ME_DRIVER_NAME,
+	 .device_id = ME2000_DEVICE_ID,
+	 /* Analog Output */
+	 .ao_channel_nbr = 0,
+	 .ao_resolution = 0,
+	 .ao_resolution_mask = 0,
+	 .ao_range_list = NULL,
+	 .ai_channel_nbr = 16,
+	 /* Analog Input */
+	 .ai_resolution = 12,
+	 .ai_resolution_mask = 0x0fff,
+	 .ai_range_list = &me2000_ai_range,
+	 .dio_channel_nbr = 32,
+	 }
 };
 };
 
 
 #define me_board_nbr (sizeof(me_boards)/sizeof(struct me_board))
 #define me_board_nbr (sizeof(me_boards)/sizeof(struct me_board))
 
 
-
 static struct comedi_driver me_driver = {
 static struct comedi_driver me_driver = {
-      .driver_name =	ME_DRIVER_NAME,
-      .module =		THIS_MODULE,
-      .attach =		me_attach,
-      .detach =		me_detach,
+	.driver_name = ME_DRIVER_NAME,
+	.module = THIS_MODULE,
+	.attach = me_attach,
+	.detach = me_detach,
 };
 };
+
 COMEDI_PCI_INITCLEANUP(me_driver, me_pci_table);
 COMEDI_PCI_INITCLEANUP(me_driver, me_pci_table);
 
 
 /* Private data structure */
 /* Private data structure */
@@ -292,7 +293,8 @@ static inline void sleep(unsigned sec)
  *
  *
  * ------------------------------------------------------------------
  * ------------------------------------------------------------------
  */
  */
-static int me_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
+static int me_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)
 {
 {
 	int bits;
 	int bits;
@@ -305,7 +307,7 @@ static int me_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice
 		/* Enable Port A */
 		/* Enable Port A */
 		dev_private->control_2 |= ENABLE_PORT_A;
 		dev_private->control_2 |= ENABLE_PORT_A;
 		writew(dev_private->control_2,
 		writew(dev_private->control_2,
-			dev_private->me_regbase + ME_CONTROL_2);
+		       dev_private->me_regbase + ME_CONTROL_2);
 	} else {		/* Port B in use */
 	} else {		/* Port B in use */
 
 
 		bits = 0xffff0000;
 		bits = 0xffff0000;
@@ -313,7 +315,7 @@ static int me_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice
 		/* Enable Port B */
 		/* Enable Port B */
 		dev_private->control_2 |= ENABLE_PORT_B;
 		dev_private->control_2 |= ENABLE_PORT_B;
 		writew(dev_private->control_2,
 		writew(dev_private->control_2,
-			dev_private->me_regbase + ME_CONTROL_2);
+		       dev_private->me_regbase + ME_CONTROL_2);
 	}
 	}
 
 
 	if (data[0]) {
 	if (data[0]) {
@@ -328,7 +330,8 @@ static int me_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice
 }
 }
 
 
 /* Digital instant input/outputs */
 /* Digital instant input/outputs */
-static int me_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
+static int me_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)
 {
 {
 	unsigned int mask = data[0];
 	unsigned int mask = data[0];
@@ -338,7 +341,7 @@ static int me_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *
 	mask &= s->io_bits;
 	mask &= s->io_bits;
 	if (mask & 0x0000ffff) {	/* Port A */
 	if (mask & 0x0000ffff) {	/* Port A */
 		writew((s->state & 0xffff),
 		writew((s->state & 0xffff),
-			dev_private->me_regbase + ME_DIO_PORT_A);
+		       dev_private->me_regbase + ME_DIO_PORT_A);
 	} else {
 	} else {
 		data[1] &= ~0x0000ffff;
 		data[1] &= ~0x0000ffff;
 		data[1] |= readw(dev_private->me_regbase + ME_DIO_PORT_A);
 		data[1] |= readw(dev_private->me_regbase + ME_DIO_PORT_A);
@@ -346,7 +349,7 @@ static int me_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *
 
 
 	if (mask & 0xffff0000) {	/* Port B */
 	if (mask & 0xffff0000) {	/* Port B */
 		writew(((s->state >> 16) & 0xffff),
 		writew(((s->state >> 16) & 0xffff),
-			dev_private->me_regbase + ME_DIO_PORT_B);
+		       dev_private->me_regbase + ME_DIO_PORT_B);
 	} else {
 	} else {
 		data[1] &= ~0xffff0000;
 		data[1] &= ~0xffff0000;
 		data[1] |= readw(dev_private->me_regbase + ME_DIO_PORT_B) << 16;
 		data[1] |= readw(dev_private->me_regbase + ME_DIO_PORT_B) << 16;
@@ -364,7 +367,8 @@ static int me_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *
  */
  */
 
 
 /* Analog instant input */
 /* Analog instant input */
-static int me_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *subdevice,
+static int me_ai_insn_read(struct comedi_device *dev,
+			   struct comedi_subdevice *subdevice,
 			   struct comedi_insn *insn, unsigned int *data)
 			   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned short value;
 	unsigned short value;
@@ -414,8 +418,8 @@ static int me_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s
 	/* get value from ADC fifo */
 	/* get value from ADC fifo */
 	if (i) {
 	if (i) {
 		data[0] =
 		data[0] =
-			(readw(dev_private->me_regbase +
-				ME_READ_AD_FIFO) ^ 0x800) & 0x0FFF;
+		    (readw(dev_private->me_regbase +
+			   ME_READ_AD_FIFO) ^ 0x800) & 0x0FFF;
 	} else {
 	} else {
 		printk(KERN_ERR "comedi%d: Cannot get single value\n",
 		printk(KERN_ERR "comedi%d: Cannot get single value\n",
 		       dev->minor);
 		       dev->minor);
@@ -450,14 +454,15 @@ static int me_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 }
 }
 
 
 /* Test analog input command */
 /* Test analog input command */
-static int me_ai_do_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
-			     struct comedi_cmd *cmd)
+static int me_ai_do_cmd_test(struct comedi_device *dev,
+			     struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
 {
 	return 0;
 	return 0;
 }
 }
 
 
 /* Analog input command */
 /* Analog input command */
-static int me_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *subdevice)
+static int me_ai_do_cmd(struct comedi_device *dev,
+			struct comedi_subdevice *subdevice)
 {
 {
 	return 0;
 	return 0;
 }
 }
@@ -471,7 +476,8 @@ static int me_ai_do_cmd(struct comedi_device *dev, struct comedi_subdevice *subd
  */
  */
 
 
 /* Analog instant output */
 /* Analog instant output */
-static int me_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
+static int me_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)
 {
 {
 	int chan;
 	int chan;
@@ -495,13 +501,13 @@ static int me_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *
 		dev_private->dac_control &= ~(0x0880 >> chan);
 		dev_private->dac_control &= ~(0x0880 >> chan);
 		if (rang == 0)
 		if (rang == 0)
 			dev_private->dac_control |=
 			dev_private->dac_control |=
-				((DAC_BIPOLAR_A | DAC_GAIN_1_A) >> chan);
+			    ((DAC_BIPOLAR_A | DAC_GAIN_1_A) >> chan);
 		else if (rang == 1)
 		else if (rang == 1)
 			dev_private->dac_control |=
 			dev_private->dac_control |=
-				((DAC_BIPOLAR_A | DAC_GAIN_0_A) >> chan);
+			    ((DAC_BIPOLAR_A | DAC_GAIN_0_A) >> chan);
 	}
 	}
 	writew(dev_private->dac_control,
 	writew(dev_private->dac_control,
-		dev_private->me_regbase + ME_DAC_CONTROL);
+	       dev_private->me_regbase + ME_DAC_CONTROL);
 
 
 	/* Update dac-control register */
 	/* Update dac-control register */
 	readw(dev_private->me_regbase + ME_DAC_CONTROL_UPDATE);
 	readw(dev_private->me_regbase + ME_DAC_CONTROL_UPDATE);
@@ -510,7 +516,7 @@ static int me_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *
 	for (i = 0; i < insn->n; i++) {
 	for (i = 0; i < insn->n; i++) {
 		chan = CR_CHAN((&insn->chanspec)[i]);
 		chan = CR_CHAN((&insn->chanspec)[i]);
 		writew((data[0] & s->maxdata),
 		writew((data[0] & s->maxdata),
-			dev_private->me_regbase + ME_DAC_DATA_A + (chan << 1));
+		       dev_private->me_regbase + ME_DAC_DATA_A + (chan << 1));
 		dev_private->ao_readback[chan] = (data[0] & s->maxdata);
 		dev_private->ao_readback[chan] = (data[0] & s->maxdata);
 	}
 	}
 
 
@@ -521,14 +527,15 @@ static int me_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *
 }
 }
 
 
 /* Analog output readback */
 /* Analog output readback */
-static int me_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-			   struct comedi_insn *insn, unsigned int *data)
+static int me_ao_insn_read(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	int i;
 	int i;
 
 
 	for (i = 0; i < insn->n; i++) {
 	for (i = 0; i < insn->n; i++) {
 		data[i] =
 		data[i] =
-			dev_private->ao_readback[CR_CHAN((&insn->chanspec)[i])];
+		    dev_private->ao_readback[CR_CHAN((&insn->chanspec)[i])];
 	}
 	}
 
 
 	return 1;
 	return 1;
@@ -575,9 +582,9 @@ static int me2600_xilinx_download(struct comedi_device *dev,
 	if (length < 16)
 	if (length < 16)
 		return -EINVAL;
 		return -EINVAL;
 	file_length = (((unsigned int)me2600_firmware[0] & 0xff) << 24) +
 	file_length = (((unsigned int)me2600_firmware[0] & 0xff) << 24) +
-		      (((unsigned int)me2600_firmware[1] & 0xff) << 16) +
-		      (((unsigned int)me2600_firmware[2] & 0xff) << 8) +
-		      ((unsigned int)me2600_firmware[3] & 0xff);
+	    (((unsigned int)me2600_firmware[1] & 0xff) << 16) +
+	    (((unsigned int)me2600_firmware[2] & 0xff) << 8) +
+	    ((unsigned int)me2600_firmware[3] & 0xff);
 
 
 	/*
 	/*
 	 * Loop for writing firmware byte by byte to xilinx
 	 * Loop for writing firmware byte by byte to xilinx
@@ -585,7 +592,7 @@ static int me2600_xilinx_download(struct comedi_device *dev,
 	 */
 	 */
 	for (i = 0; i < file_length; i++)
 	for (i = 0; i < file_length; i++)
 		writeb((me2600_firmware[16 + i] & 0xff),
 		writeb((me2600_firmware[16 + i] & 0xff),
-			dev_private->me_regbase + 0x0);
+		       dev_private->me_regbase + 0x0);
 
 
 	/* Write 5 dummy values to xilinx */
 	/* Write 5 dummy values to xilinx */
 	for (i = 0; i < 5; i++)
 	for (i = 0; i < 5; i++)
@@ -653,33 +660,32 @@ static int me_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 
 	/* Probe the device to determine what device in the series it is. */
 	/* Probe the device to determine what device in the series it is. */
 	for (pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pci_device != NULL;
-		pci_device =
-		pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
+	     pci_device != NULL;
+	     pci_device = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_device)) {
 		if (pci_device->vendor == PCI_VENDOR_ID_MEILHAUS) {
 		if (pci_device->vendor == PCI_VENDOR_ID_MEILHAUS) {
 			for (i = 0; i < me_board_nbr; i++) {
 			for (i = 0; i < me_board_nbr; i++) {
 				if (me_boards[i].device_id ==
 				if (me_boards[i].device_id ==
-					pci_device->device) {
+				    pci_device->device) {
 					/*
 					/*
 					 * was a particular bus/slot requested?
 					 * was a particular bus/slot requested?
 					 */
 					 */
 					if ((it->options[0] != 0)
 					if ((it->options[0] != 0)
-						|| (it->options[1] != 0)) {
+					    || (it->options[1] != 0)) {
 						/*
 						/*
 						 * are we on the wrong bus/slot?
 						 * are we on the wrong bus/slot?
 						 */
 						 */
 						if (pci_device->bus->number !=
 						if (pci_device->bus->number !=
-							it->options[0]
-							|| PCI_SLOT(pci_device->
-								devfn) !=
-							it->options[1]) {
+						    it->options[0]
+						    ||
+						    PCI_SLOT(pci_device->devfn)
+						    != it->options[1]) {
 							continue;
 							continue;
 						}
 						}
 					}
 					}
 
 
 					dev->board_ptr = me_boards + i;
 					dev->board_ptr = me_boards + i;
-					board = (struct me_board *) dev->
-						board_ptr;
+					board =
+					    (struct me_board *)dev->board_ptr;
 					dev_private->pci_device = pci_device;
 					dev_private->pci_device = pci_device;
 					goto found;
 					goto found;
 				}
 				}
@@ -694,8 +700,8 @@ static int me_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 
 
 found:
 found:
 	printk(KERN_INFO "comedi%d: found %s at PCI bus %d, slot %d\n",
 	printk(KERN_INFO "comedi%d: found %s at PCI bus %d, slot %d\n",
-		dev->minor, me_boards[i].name,
-		pci_device->bus->number, PCI_SLOT(pci_device->devfn));
+	       dev->minor, me_boards[i].name,
+	       pci_device->bus->number, PCI_SLOT(pci_device->devfn));
 
 
 	/* Enable PCI device and request PCI regions */
 	/* Enable PCI device and request PCI regions */
 	if (comedi_pci_enable(pci_device, ME_DRIVER_NAME) < 0) {
 	if (comedi_pci_enable(pci_device, ME_DRIVER_NAME) < 0) {
@@ -711,7 +717,7 @@ found:
 	plx_regbase_tmp = pci_resource_start(pci_device, 0);
 	plx_regbase_tmp = pci_resource_start(pci_device, 0);
 	plx_regbase_size_tmp = pci_resource_len(pci_device, 0);
 	plx_regbase_size_tmp = pci_resource_len(pci_device, 0);
 	dev_private->plx_regbase =
 	dev_private->plx_regbase =
-		ioremap(plx_regbase_tmp, plx_regbase_size_tmp);
+	    ioremap(plx_regbase_tmp, plx_regbase_size_tmp);
 	dev_private->plx_regbase_size = plx_regbase_size_tmp;
 	dev_private->plx_regbase_size = plx_regbase_size_tmp;
 	if (!dev_private->plx_regbase) {
 	if (!dev_private->plx_regbase) {
 		printk("comedi%d: Failed to remap I/O memory\n", dev->minor);
 		printk("comedi%d: Failed to remap I/O memory\n", dev->minor);
@@ -736,18 +742,21 @@ found:
 			swap_regbase_tmp = regbase_tmp;
 			swap_regbase_tmp = regbase_tmp;
 
 
 			result = pci_write_config_dword(pci_device,
 			result = pci_write_config_dword(pci_device,
-				PCI_BASE_ADDRESS_0, plx_regbase_tmp);
+							PCI_BASE_ADDRESS_0,
+							plx_regbase_tmp);
 			if (result != PCIBIOS_SUCCESSFUL)
 			if (result != PCIBIOS_SUCCESSFUL)
 				return -EIO;
 				return -EIO;
 
 
 			result = pci_write_config_dword(pci_device,
 			result = pci_write_config_dword(pci_device,
-				PCI_BASE_ADDRESS_5, swap_regbase_tmp);
+							PCI_BASE_ADDRESS_5,
+							swap_regbase_tmp);
 			if (result != PCIBIOS_SUCCESSFUL)
 			if (result != PCIBIOS_SUCCESSFUL)
 				return -EIO;
 				return -EIO;
 		} else {
 		} else {
 			plx_regbase_tmp -= 0x80;
 			plx_regbase_tmp -= 0x80;
 			result = pci_write_config_dword(pci_device,
 			result = pci_write_config_dword(pci_device,
-				PCI_BASE_ADDRESS_0, plx_regbase_tmp);
+							PCI_BASE_ADDRESS_0,
+							plx_regbase_tmp);
 			if (result != PCIBIOS_SUCCESSFUL)
 			if (result != PCIBIOS_SUCCESSFUL)
 				return -EIO;
 				return -EIO;
 		}
 		}
@@ -822,7 +831,8 @@ found:
 	subdevice->insn_config = me_dio_insn_config;
 	subdevice->insn_config = me_dio_insn_config;
 	subdevice->io_bits = 0;
 	subdevice->io_bits = 0;
 
 
-	printk(KERN_INFO "comedi%d: "ME_DRIVER_NAME" attached.\n", dev->minor);
+	printk(KERN_INFO "comedi%d: " ME_DRIVER_NAME " attached.\n",
+	       dev->minor);
 	return 0;
 	return 0;
 }
 }
 
 

+ 75 - 63
drivers/staging/comedi/drivers/mite.c

@@ -73,8 +73,8 @@ void mite_init(void)
 	struct mite_struct *mite;
 	struct mite_struct *mite;
 
 
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
 	for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
-		pcidev != NULL;
-		pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
+	     pcidev != NULL;
+	     pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
 		if (pcidev->vendor == PCI_VENDOR_ID_NATINST) {
 		if (pcidev->vendor == PCI_VENDOR_ID_NATINST) {
 			unsigned i;
 			unsigned i;
 
 
@@ -99,14 +99,19 @@ void mite_init(void)
 
 
 static void dump_chip_signature(u32 csigr_bits)
 static void dump_chip_signature(u32 csigr_bits)
 {
 {
-	printk("mite: version = %i, type = %i, mite mode = %i, interface mode = %i\n", mite_csigr_version(csigr_bits), mite_csigr_type(csigr_bits), mite_csigr_mmode(csigr_bits), mite_csigr_imode(csigr_bits));
-	printk("mite: num channels = %i, write post fifo depth = %i, wins = %i, iowins = %i\n", mite_csigr_dmac(csigr_bits), mite_csigr_wpdep(csigr_bits), mite_csigr_wins(csigr_bits), mite_csigr_iowins(csigr_bits));
+	printk
+	    ("mite: version = %i, type = %i, mite mode = %i, interface mode = %i\n",
+	     mite_csigr_version(csigr_bits), mite_csigr_type(csigr_bits),
+	     mite_csigr_mmode(csigr_bits), mite_csigr_imode(csigr_bits));
+	printk
+	    ("mite: num channels = %i, write post fifo depth = %i, wins = %i, iowins = %i\n",
+	     mite_csigr_dmac(csigr_bits), mite_csigr_wpdep(csigr_bits),
+	     mite_csigr_wins(csigr_bits), mite_csigr_iowins(csigr_bits));
 }
 }
 
 
 unsigned mite_fifo_size(struct mite_struct *mite, unsigned channel)
 unsigned mite_fifo_size(struct mite_struct *mite, unsigned channel)
 {
 {
-	unsigned fcr_bits = readl(mite->mite_io_addr +
-		MITE_FCR(channel));
+	unsigned fcr_bits = readl(mite->mite_io_addr + MITE_FCR(channel));
 	unsigned empty_count = (fcr_bits >> 16) & 0xff;
 	unsigned empty_count = (fcr_bits >> 16) & 0xff;
 	unsigned full_count = fcr_bits & 0xff;
 	unsigned full_count = fcr_bits & 0xff;
 	return empty_count + full_count;
 	return empty_count + full_count;
@@ -134,7 +139,7 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 	printk("MITE:0x%08llx mapped to %p ",
 	printk("MITE:0x%08llx mapped to %p ",
-		(unsigned long long)mite->mite_phys_addr, mite->mite_io_addr);
+	       (unsigned long long)mite->mite_phys_addr, mite->mite_io_addr);
 
 
 	addr = pci_resource_start(mite->pcidev, 1);
 	addr = pci_resource_start(mite->pcidev, 1);
 	mite->daq_phys_addr = addr;
 	mite->daq_phys_addr = addr;
@@ -146,19 +151,18 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 	printk("DAQ:0x%08llx mapped to %p\n",
 	printk("DAQ:0x%08llx mapped to %p\n",
-		(unsigned long long)mite->daq_phys_addr, mite->daq_io_addr);
+	       (unsigned long long)mite->daq_phys_addr, mite->daq_io_addr);
 
 
 	if (use_iodwbsr_1) {
 	if (use_iodwbsr_1) {
 		writel(0, mite->mite_io_addr + MITE_IODWBSR);
 		writel(0, mite->mite_io_addr + MITE_IODWBSR);
 		printk("mite: using I/O Window Base Size register 1\n");
 		printk("mite: using I/O Window Base Size register 1\n");
-		writel(mite->
-			daq_phys_addr | WENAB |
-			MITE_IODWBSR_1_WSIZE_bits(length),
-			mite->mite_io_addr + MITE_IODWBSR_1);
+		writel(mite->daq_phys_addr | WENAB |
+		       MITE_IODWBSR_1_WSIZE_bits(length),
+		       mite->mite_io_addr + MITE_IODWBSR_1);
 		writel(0, mite->mite_io_addr + MITE_IODWCR_1);
 		writel(0, mite->mite_io_addr + MITE_IODWCR_1);
 	} else {
 	} else {
 		writel(mite->daq_phys_addr | WENAB,
 		writel(mite->daq_phys_addr | WENAB,
-			mite->mite_io_addr + MITE_IODWBSR);
+		       mite->mite_io_addr + MITE_IODWBSR);
 	}
 	}
 	/* make sure dma bursts work.  I got this from running a bus analyzer
 	/* make sure dma bursts work.  I got this from running a bus analyzer
 	   on a pxi-6281 and a pxi-6713.  6713 powered up with register value
 	   on a pxi-6281 and a pxi-6713.  6713 powered up with register value
@@ -167,15 +171,17 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
 	   then does a bitwise-or of 0x600 with it and writes it back.
 	   then does a bitwise-or of 0x600 with it and writes it back.
 	 */
 	 */
 	unknown_dma_burst_bits =
 	unknown_dma_burst_bits =
-		readl(mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
+	    readl(mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
 	unknown_dma_burst_bits |= UNKNOWN_DMA_BURST_ENABLE_BITS;
 	unknown_dma_burst_bits |= UNKNOWN_DMA_BURST_ENABLE_BITS;
 	writel(unknown_dma_burst_bits,
 	writel(unknown_dma_burst_bits,
-		mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
+	       mite->mite_io_addr + MITE_UNKNOWN_DMA_BURST_REG);
 
 
 	csigr_bits = readl(mite->mite_io_addr + MITE_CSIGR);
 	csigr_bits = readl(mite->mite_io_addr + MITE_CSIGR);
 	mite->num_channels = mite_csigr_dmac(csigr_bits);
 	mite->num_channels = mite_csigr_dmac(csigr_bits);
 	if (mite->num_channels > MAX_MITE_DMA_CHANNELS) {
 	if (mite->num_channels > MAX_MITE_DMA_CHANNELS) {
-		printk("mite: bug? chip claims to have %i dma channels.  Setting to %i.\n", mite->num_channels, MAX_MITE_DMA_CHANNELS);
+		printk
+		    ("mite: bug? chip claims to have %i dma channels.  Setting to %i.\n",
+		     mite->num_channels, MAX_MITE_DMA_CHANNELS);
 		mite->num_channels = MAX_MITE_DMA_CHANNELS;
 		mite->num_channels = MAX_MITE_DMA_CHANNELS;
 	}
 	}
 	dump_chip_signature(csigr_bits);
 	dump_chip_signature(csigr_bits);
@@ -183,9 +189,9 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1)
 		writel(CHOR_DMARESET, mite->mite_io_addr + MITE_CHOR(i));
 		writel(CHOR_DMARESET, mite->mite_io_addr + MITE_CHOR(i));
 		/* disable interrupts */
 		/* disable interrupts */
 		writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE |
 		writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE |
-			CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
-			CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
-			mite->mite_io_addr + MITE_CHCR(i));
+		       CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
+		       CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
+		       mite->mite_io_addr + MITE_CHCR(i));
 	}
 	}
 	mite->fifo_size = mite_fifo_size(mite, 0);
 	mite->fifo_size = mite_fifo_size(mite, 0);
 	printk("mite: fifo size is %i.\n", mite->fifo_size);
 	printk("mite: fifo size is %i.\n", mite->fifo_size);
@@ -250,8 +256,10 @@ void mite_list_devices(void)
 }
 }
 
 
 struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
 struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
-	struct mite_dma_descriptor_ring *ring, unsigned min_channel,
-	unsigned max_channel)
+						   struct
+						   mite_dma_descriptor_ring
+						   *ring, unsigned min_channel,
+						   unsigned max_channel)
 {
 {
 	int i;
 	int i;
 	unsigned long flags;
 	unsigned long flags;
@@ -284,10 +292,10 @@ void mite_release_channel(struct mite_channel *mite_chan)
 /* disable all channel's interrupts (do it after disarm/reset so
 /* disable all channel's interrupts (do it after disarm/reset so
 MITE_CHCR reg isn't changed while dma is still active!) */
 MITE_CHCR reg isn't changed while dma is still active!) */
 		writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE |
 		writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE |
-			CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
-			CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
-			CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
-			mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
+		       CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
+		       CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
+		       CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
+		       mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
 		mite->channel_allocated[mite_chan->channel] = 0;
 		mite->channel_allocated[mite_chan->channel] = 0;
 		mite_chan->ring = NULL;
 		mite_chan->ring = NULL;
 		mmiowb();
 		mmiowb();
@@ -317,15 +325,18 @@ void mite_dma_arm(struct mite_channel *mite_chan)
 
 
 /**************************************/
 /**************************************/
 
 
-int mite_buf_change(struct mite_dma_descriptor_ring *ring, struct comedi_async * async)
+int mite_buf_change(struct mite_dma_descriptor_ring *ring,
+		    struct comedi_async *async)
 {
 {
 	unsigned int n_links;
 	unsigned int n_links;
 	int i;
 	int i;
 
 
 	if (ring->descriptors) {
 	if (ring->descriptors) {
 		dma_free_coherent(ring->hw_dev,
 		dma_free_coherent(ring->hw_dev,
-			ring->n_links * sizeof(struct mite_dma_descriptor),
-			ring->descriptors, ring->descriptors_dma_addr);
+				  ring->n_links *
+				  sizeof(struct mite_dma_descriptor),
+				  ring->descriptors,
+				  ring->descriptors_dma_addr);
 	}
 	}
 	ring->descriptors = NULL;
 	ring->descriptors = NULL;
 	ring->descriptors_dma_addr = 0;
 	ring->descriptors_dma_addr = 0;
@@ -339,9 +350,9 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring, struct comedi_async *
 	MDPRINTK("ring->hw_dev=%p, n_links=0x%04x\n", ring->hw_dev, n_links);
 	MDPRINTK("ring->hw_dev=%p, n_links=0x%04x\n", ring->hw_dev, n_links);
 
 
 	ring->descriptors =
 	ring->descriptors =
-		dma_alloc_coherent(ring->hw_dev,
-		n_links * sizeof(struct mite_dma_descriptor),
-		&ring->descriptors_dma_addr, GFP_KERNEL);
+	    dma_alloc_coherent(ring->hw_dev,
+			       n_links * sizeof(struct mite_dma_descriptor),
+			       &ring->descriptors_dma_addr, GFP_KERNEL);
 	if (!ring->descriptors) {
 	if (!ring->descriptors) {
 		printk("mite: ring buffer allocation failed\n");
 		printk("mite: ring buffer allocation failed\n");
 		return -ENOMEM;
 		return -ENOMEM;
@@ -351,13 +362,14 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring, struct comedi_async *
 	for (i = 0; i < n_links; i++) {
 	for (i = 0; i < n_links; i++) {
 		ring->descriptors[i].count = cpu_to_le32(PAGE_SIZE);
 		ring->descriptors[i].count = cpu_to_le32(PAGE_SIZE);
 		ring->descriptors[i].addr =
 		ring->descriptors[i].addr =
-			cpu_to_le32(async->buf_page_list[i].dma_addr);
+		    cpu_to_le32(async->buf_page_list[i].dma_addr);
 		ring->descriptors[i].next =
 		ring->descriptors[i].next =
-			cpu_to_le32(ring->descriptors_dma_addr + (i +
-				1) * sizeof(struct mite_dma_descriptor));
+		    cpu_to_le32(ring->descriptors_dma_addr + (i +
+							      1) *
+				sizeof(struct mite_dma_descriptor));
 	}
 	}
 	ring->descriptors[n_links - 1].next =
 	ring->descriptors[n_links - 1].next =
-		cpu_to_le32(ring->descriptors_dma_addr);
+	    cpu_to_le32(ring->descriptors_dma_addr);
 	/* barrier is meant to insure that all the writes to the dma descriptors
 	/* barrier is meant to insure that all the writes to the dma descriptors
 	   have completed before the dma controller is commanded to read them */
 	   have completed before the dma controller is commanded to read them */
 	smp_wmb();
 	smp_wmb();
@@ -365,7 +377,7 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring, struct comedi_async *
 }
 }
 
 
 void mite_prep_dma(struct mite_channel *mite_chan,
 void mite_prep_dma(struct mite_channel *mite_chan,
-	unsigned int num_device_bits, unsigned int num_memory_bits)
+		   unsigned int num_device_bits, unsigned int num_memory_bits)
 {
 {
 	unsigned int chor, chcr, mcr, dcr, lkcr;
 	unsigned int chor, chcr, mcr, dcr, lkcr;
 	struct mite_struct *mite = mite_chan->mite;
 	struct mite_struct *mite = mite_chan->mite;
@@ -378,7 +390,7 @@ void mite_prep_dma(struct mite_channel *mite_chan,
 
 
 	/* short link chaining mode */
 	/* short link chaining mode */
 	chcr = CHCR_SET_DMA_IE | CHCR_LINKSHORT | CHCR_SET_DONE_IE |
 	chcr = CHCR_SET_DMA_IE | CHCR_LINKSHORT | CHCR_SET_DONE_IE |
-		CHCR_BURSTEN;
+	    CHCR_BURSTEN;
 	/*
 	/*
 	 * Link Complete Interrupt: interrupt every time a link
 	 * Link Complete Interrupt: interrupt every time a link
 	 * in MITE_RING is completed. This can generate a lot of
 	 * in MITE_RING is completed. This can generate a lot of
@@ -413,8 +425,7 @@ void mite_prep_dma(struct mite_channel *mite_chan,
 		mcr |= CR_PSIZE32;
 		mcr |= CR_PSIZE32;
 		break;
 		break;
 	default:
 	default:
-		printk
-			("mite: bug! invalid mem bit width for dma transfer\n");
+		printk("mite: bug! invalid mem bit width for dma transfer\n");
 		break;
 		break;
 	}
 	}
 	writel(mcr, mite->mite_io_addr + MITE_MCR(mite_chan->channel));
 	writel(mcr, mite->mite_io_addr + MITE_MCR(mite_chan->channel));
@@ -433,8 +444,7 @@ void mite_prep_dma(struct mite_channel *mite_chan,
 		dcr |= CR_PSIZE32;
 		dcr |= CR_PSIZE32;
 		break;
 		break;
 	default:
 	default:
-		printk
-			("mite: bug! invalid dev bit width for dma transfer\n");
+		printk("mite: bug! invalid dev bit width for dma transfer\n");
 		break;
 		break;
 	}
 	}
 	writel(dcr, mite->mite_io_addr + MITE_DCR(mite_chan->channel));
 	writel(dcr, mite->mite_io_addr + MITE_DCR(mite_chan->channel));
@@ -448,7 +458,7 @@ void mite_prep_dma(struct mite_channel *mite_chan,
 
 
 	/* starting address for link chaining */
 	/* starting address for link chaining */
 	writel(mite_chan->ring->descriptors_dma_addr,
 	writel(mite_chan->ring->descriptors_dma_addr,
-		mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
+	       mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
 
 
 	MDPRINTK("exit mite_prep_dma\n");
 	MDPRINTK("exit mite_prep_dma\n");
 }
 }
@@ -459,15 +469,15 @@ u32 mite_device_bytes_transferred(struct mite_channel *mite_chan)
 	return readl(mite->mite_io_addr + MITE_DAR(mite_chan->channel));
 	return readl(mite->mite_io_addr + MITE_DAR(mite_chan->channel));
 }
 }
 
 
-u32 mite_bytes_in_transit(struct mite_channel *mite_chan)
+u32 mite_bytes_in_transit(struct mite_channel * mite_chan)
 {
 {
 	struct mite_struct *mite = mite_chan->mite;
 	struct mite_struct *mite = mite_chan->mite;
 	return readl(mite->mite_io_addr +
 	return readl(mite->mite_io_addr +
-		MITE_FCR(mite_chan->channel)) & 0x000000FF;
+		     MITE_FCR(mite_chan->channel)) & 0x000000FF;
 }
 }
 
 
 /*  returns lower bound for number of bytes transferred from device to memory */
 /*  returns lower bound for number of bytes transferred from device to memory */
-u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan)
+u32 mite_bytes_written_to_memory_lb(struct mite_channel * mite_chan)
 {
 {
 	u32 device_byte_count;
 	u32 device_byte_count;
 
 
@@ -476,7 +486,7 @@ u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan)
 }
 }
 
 
 /*  returns upper bound for number of bytes transferred from device to memory */
 /*  returns upper bound for number of bytes transferred from device to memory */
-u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan)
+u32 mite_bytes_written_to_memory_ub(struct mite_channel * mite_chan)
 {
 {
 	u32 in_transit_count;
 	u32 in_transit_count;
 
 
@@ -485,7 +495,7 @@ u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan)
 }
 }
 
 
 /*  returns lower bound for number of bytes read from memory for transfer to device */
 /*  returns lower bound for number of bytes read from memory for transfer to device */
-u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan)
+u32 mite_bytes_read_from_memory_lb(struct mite_channel * mite_chan)
 {
 {
 	u32 device_byte_count;
 	u32 device_byte_count;
 
 
@@ -494,7 +504,7 @@ u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan)
 }
 }
 
 
 /*  returns upper bound for number of bytes read from memory for transfer to device */
 /*  returns upper bound for number of bytes read from memory for transfer to device */
-u32 mite_bytes_read_from_memory_ub(struct mite_channel *mite_chan)
+u32 mite_bytes_read_from_memory_ub(struct mite_channel * mite_chan)
 {
 {
 	u32 in_transit_count;
 	u32 in_transit_count;
 
 
@@ -511,7 +521,7 @@ unsigned mite_dma_tcr(struct mite_channel *mite_chan)
 	lkar = readl(mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
 	lkar = readl(mite->mite_io_addr + MITE_LKAR(mite_chan->channel));
 	tcr = readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel));
 	tcr = readl(mite->mite_io_addr + MITE_TCR(mite_chan->channel));
 	MDPRINTK("mite_dma_tcr ch%i, lkar=0x%08x tcr=%d\n", mite_chan->channel,
 	MDPRINTK("mite_dma_tcr ch%i, lkar=0x%08x tcr=%d\n", mite_chan->channel,
-		lkar, tcr);
+		 lkar, tcr);
 
 
 	return tcr;
 	return tcr;
 }
 }
@@ -526,7 +536,8 @@ void mite_dma_disarm(struct mite_channel *mite_chan)
 	writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
 	writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
 }
 }
 
 
-int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_async * async)
+int mite_sync_input_dma(struct mite_channel *mite_chan,
+			struct comedi_async *async)
 {
 {
 	int count;
 	int count;
 	unsigned int nbytes, old_alloc_count;
 	unsigned int nbytes, old_alloc_count;
@@ -538,7 +549,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_async * as
 
 
 	nbytes = mite_bytes_written_to_memory_lb(mite_chan);
 	nbytes = mite_bytes_written_to_memory_lb(mite_chan);
 	if ((int)(mite_bytes_written_to_memory_ub(mite_chan) -
 	if ((int)(mite_bytes_written_to_memory_ub(mite_chan) -
-			old_alloc_count) > 0) {
+		  old_alloc_count) > 0) {
 		printk("mite: DMA overwrite of free area\n");
 		printk("mite: DMA overwrite of free area\n");
 		async->events |= COMEDI_CB_OVERFLOW;
 		async->events |= COMEDI_CB_OVERFLOW;
 		return -1;
 		return -1;
@@ -561,24 +572,25 @@ int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_async * as
 	return 0;
 	return 0;
 }
 }
 
 
-int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_async * async)
+int mite_sync_output_dma(struct mite_channel *mite_chan,
+			 struct comedi_async *async)
 {
 {
 	int count;
 	int count;
 	u32 nbytes_ub, nbytes_lb;
 	u32 nbytes_ub, nbytes_lb;
 	unsigned int old_alloc_count;
 	unsigned int old_alloc_count;
 	u32 stop_count =
 	u32 stop_count =
-		async->cmd.stop_arg * cfc_bytes_per_scan(async->subdevice);
+	    async->cmd.stop_arg * cfc_bytes_per_scan(async->subdevice);
 
 
 	old_alloc_count = async->buf_read_alloc_count;
 	old_alloc_count = async->buf_read_alloc_count;
 	/*  read alloc as much as we can */
 	/*  read alloc as much as we can */
 	comedi_buf_read_alloc(async, async->prealloc_bufsz);
 	comedi_buf_read_alloc(async, async->prealloc_bufsz);
 	nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan);
 	nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan);
 	if (async->cmd.stop_src == TRIG_COUNT &&
 	if (async->cmd.stop_src == TRIG_COUNT &&
-		(int)(nbytes_lb - stop_count) > 0)
+	    (int)(nbytes_lb - stop_count) > 0)
 		nbytes_lb = stop_count;
 		nbytes_lb = stop_count;
 	nbytes_ub = mite_bytes_read_from_memory_ub(mite_chan);
 	nbytes_ub = mite_bytes_read_from_memory_ub(mite_chan);
 	if (async->cmd.stop_src == TRIG_COUNT &&
 	if (async->cmd.stop_src == TRIG_COUNT &&
-		(int)(nbytes_ub - stop_count) > 0)
+	    (int)(nbytes_ub - stop_count) > 0)
 		nbytes_ub = stop_count;
 		nbytes_ub = stop_count;
 	if ((int)(nbytes_ub - old_alloc_count) > 0) {
 	if ((int)(nbytes_ub - old_alloc_count) > 0) {
 		printk("mite: DMA underrun\n");
 		printk("mite: DMA underrun\n");
@@ -607,7 +619,7 @@ unsigned mite_get_status(struct mite_channel *mite_chan)
 	if (status & CHSR_DONE) {
 	if (status & CHSR_DONE) {
 		mite_chan->done = 1;
 		mite_chan->done = 1;
 		writel(CHOR_CLRDONE,
 		writel(CHOR_CLRDONE,
-			mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
+		       mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
 	}
 	}
 	mmiowb();
 	mmiowb();
 	spin_unlock_irqrestore(&mite->lock, flags);
 	spin_unlock_irqrestore(&mite->lock, flags);
@@ -703,7 +715,7 @@ static const char *const mite_CHSR_strings[] = {
 void mite_dump_regs(struct mite_channel *mite_chan)
 void mite_dump_regs(struct mite_channel *mite_chan)
 {
 {
 	unsigned long mite_io_addr =
 	unsigned long mite_io_addr =
-		(unsigned long)mite_chan->mite->mite_io_addr;
+	    (unsigned long)mite_chan->mite->mite_io_addr;
 	unsigned long addr = 0;
 	unsigned long addr = 0;
 	unsigned long temp = 0;
 	unsigned long temp = 0;
 
 
@@ -712,37 +724,37 @@ void mite_dump_regs(struct mite_channel *mite_chan)
 
 
 	addr = mite_io_addr + MITE_CHOR(channel);
 	addr = mite_io_addr + MITE_CHOR(channel);
 	printk("mite status[CHOR]at 0x%08lx =0x%08lx\n", addr, temp =
 	printk("mite status[CHOR]at 0x%08lx =0x%08lx\n", addr, temp =
-		readl(addr));
+	       readl(addr));
 	mite_decode(mite_CHOR_strings, temp);
 	mite_decode(mite_CHOR_strings, temp);
 	addr = mite_io_addr + MITE_CHCR(channel);
 	addr = mite_io_addr + MITE_CHCR(channel);
 	printk("mite status[CHCR]at 0x%08lx =0x%08lx\n", addr, temp =
 	printk("mite status[CHCR]at 0x%08lx =0x%08lx\n", addr, temp =
-		readl(addr));
+	       readl(addr));
 	mite_decode(mite_CHCR_strings, temp);
 	mite_decode(mite_CHCR_strings, temp);
 	addr = mite_io_addr + MITE_TCR(channel);
 	addr = mite_io_addr + MITE_TCR(channel);
 	printk("mite status[TCR] at 0x%08lx =0x%08x\n", addr, readl(addr));
 	printk("mite status[TCR] at 0x%08lx =0x%08x\n", addr, readl(addr));
 	addr = mite_io_addr + MITE_MCR(channel);
 	addr = mite_io_addr + MITE_MCR(channel);
 	printk("mite status[MCR] at 0x%08lx =0x%08lx\n", addr, temp =
 	printk("mite status[MCR] at 0x%08lx =0x%08lx\n", addr, temp =
-		readl(addr));
+	       readl(addr));
 	mite_decode(mite_MCR_strings, temp);
 	mite_decode(mite_MCR_strings, temp);
 
 
 	addr = mite_io_addr + MITE_MAR(channel);
 	addr = mite_io_addr + MITE_MAR(channel);
 	printk("mite status[MAR] at 0x%08lx =0x%08x\n", addr, readl(addr));
 	printk("mite status[MAR] at 0x%08lx =0x%08x\n", addr, readl(addr));
 	addr = mite_io_addr + MITE_DCR(channel);
 	addr = mite_io_addr + MITE_DCR(channel);
 	printk("mite status[DCR] at 0x%08lx =0x%08lx\n", addr, temp =
 	printk("mite status[DCR] at 0x%08lx =0x%08lx\n", addr, temp =
-		readl(addr));
+	       readl(addr));
 	mite_decode(mite_DCR_strings, temp);
 	mite_decode(mite_DCR_strings, temp);
 	addr = mite_io_addr + MITE_DAR(channel);
 	addr = mite_io_addr + MITE_DAR(channel);
 	printk("mite status[DAR] at 0x%08lx =0x%08x\n", addr, readl(addr));
 	printk("mite status[DAR] at 0x%08lx =0x%08x\n", addr, readl(addr));
 	addr = mite_io_addr + MITE_LKCR(channel);
 	addr = mite_io_addr + MITE_LKCR(channel);
 	printk("mite status[LKCR]at 0x%08lx =0x%08lx\n", addr, temp =
 	printk("mite status[LKCR]at 0x%08lx =0x%08lx\n", addr, temp =
-		readl(addr));
+	       readl(addr));
 	mite_decode(mite_LKCR_strings, temp);
 	mite_decode(mite_LKCR_strings, temp);
 	addr = mite_io_addr + MITE_LKAR(channel);
 	addr = mite_io_addr + MITE_LKAR(channel);
 	printk("mite status[LKAR]at 0x%08lx =0x%08x\n", addr, readl(addr));
 	printk("mite status[LKAR]at 0x%08lx =0x%08x\n", addr, readl(addr));
 
 
 	addr = mite_io_addr + MITE_CHSR(channel);
 	addr = mite_io_addr + MITE_CHSR(channel);
 	printk("mite status[CHSR]at 0x%08lx =0x%08lx\n", addr, temp =
 	printk("mite status[CHSR]at 0x%08lx =0x%08lx\n", addr, temp =
-		readl(addr));
+	       readl(addr));
 	mite_decode(mite_CHSR_strings, temp);
 	mite_decode(mite_CHSR_strings, temp);
 	addr = mite_io_addr + MITE_FCR(channel);
 	addr = mite_io_addr + MITE_FCR(channel);
 	printk("mite status[FCR] at 0x%08lx =0x%08x\n\n", addr, readl(addr));
 	printk("mite status[FCR] at 0x%08lx =0x%08x\n\n", addr, readl(addr));

+ 90 - 54
drivers/staging/comedi/drivers/mite.h

@@ -80,10 +80,11 @@ struct mite_struct {
 };
 };
 
 
 static inline struct mite_dma_descriptor_ring *mite_alloc_ring(struct
 static inline struct mite_dma_descriptor_ring *mite_alloc_ring(struct
-	mite_struct *mite)
+							       mite_struct
+							       *mite)
 {
 {
 	struct mite_dma_descriptor_ring *ring =
 	struct mite_dma_descriptor_ring *ring =
-		kmalloc(sizeof(struct mite_dma_descriptor_ring), GFP_KERNEL);
+	    kmalloc(sizeof(struct mite_dma_descriptor_ring), GFP_KERNEL);
 	if (ring == NULL)
 	if (ring == NULL)
 		return ring;
 		return ring;
 	ring->hw_dev = get_device(&mite->pcidev->dev);
 	ring->hw_dev = get_device(&mite->pcidev->dev);
@@ -102,9 +103,10 @@ static inline void mite_free_ring(struct mite_dma_descriptor_ring *ring)
 	if (ring) {
 	if (ring) {
 		if (ring->descriptors) {
 		if (ring->descriptors) {
 			dma_free_coherent(ring->hw_dev,
 			dma_free_coherent(ring->hw_dev,
-				ring->n_links *
-				sizeof(struct mite_dma_descriptor),
-				ring->descriptors, ring->descriptors_dma_addr);
+					  ring->n_links *
+					  sizeof(struct mite_dma_descriptor),
+					  ring->descriptors,
+					  ring->descriptors_dma_addr);
 		}
 		}
 		put_device(ring->hw_dev);
 		put_device(ring->hw_dev);
 		kfree(ring);
 		kfree(ring);
@@ -117,6 +119,7 @@ static inline unsigned int mite_irq(struct mite_struct *mite)
 {
 {
 	return mite->pcidev->irq;
 	return mite->pcidev->irq;
 };
 };
+
 static inline unsigned int mite_device_id(struct mite_struct *mite)
 static inline unsigned int mite_device_id(struct mite_struct *mite)
 {
 {
 	return mite->pcidev->device;
 	return mite->pcidev->device;
@@ -129,21 +132,29 @@ int mite_setup2(struct mite_struct *mite, unsigned use_iodwbsr_1);
 void mite_unsetup(struct mite_struct *mite);
 void mite_unsetup(struct mite_struct *mite);
 void mite_list_devices(void);
 void mite_list_devices(void);
 struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
 struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
-	struct mite_dma_descriptor_ring *ring, unsigned min_channel,
-	unsigned max_channel);
+						   struct
+						   mite_dma_descriptor_ring
+						   *ring, unsigned min_channel,
+						   unsigned max_channel);
 static inline struct mite_channel *mite_request_channel(struct mite_struct
 static inline struct mite_channel *mite_request_channel(struct mite_struct
-	*mite, struct mite_dma_descriptor_ring *ring)
+							*mite,
+							struct
+							mite_dma_descriptor_ring
+							*ring)
 {
 {
 	return mite_request_channel_in_range(mite, ring, 0,
 	return mite_request_channel_in_range(mite, ring, 0,
-		mite->num_channels - 1);
+					     mite->num_channels - 1);
 }
 }
+
 void mite_release_channel(struct mite_channel *mite_chan);
 void mite_release_channel(struct mite_channel *mite_chan);
 
 
 unsigned mite_dma_tcr(struct mite_channel *mite_chan);
 unsigned mite_dma_tcr(struct mite_channel *mite_chan);
 void mite_dma_arm(struct mite_channel *mite_chan);
 void mite_dma_arm(struct mite_channel *mite_chan);
 void mite_dma_disarm(struct mite_channel *mite_chan);
 void mite_dma_disarm(struct mite_channel *mite_chan);
-int mite_sync_input_dma(struct mite_channel *mite_chan, struct comedi_async * async);
-int mite_sync_output_dma(struct mite_channel *mite_chan, struct comedi_async * async);
+int mite_sync_input_dma(struct mite_channel *mite_chan,
+			struct comedi_async *async);
+int mite_sync_output_dma(struct mite_channel *mite_chan,
+			 struct comedi_async *async);
 u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan);
 u32 mite_bytes_written_to_memory_lb(struct mite_channel *mite_chan);
 u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan);
 u32 mite_bytes_written_to_memory_ub(struct mite_channel *mite_chan);
 u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan);
 u32 mite_bytes_read_from_memory_lb(struct mite_channel *mite_chan);
@@ -153,16 +164,16 @@ unsigned mite_get_status(struct mite_channel *mite_chan);
 int mite_done(struct mite_channel *mite_chan);
 int mite_done(struct mite_channel *mite_chan);
 
 
 #if 0
 #if 0
-unsigned long mite_ll_from_kvmem(struct mite_struct *mite, struct comedi_async * async,
-	int len);
+unsigned long mite_ll_from_kvmem(struct mite_struct *mite,
+				 struct comedi_async *async, int len);
 void mite_setregs(struct mite_struct *mite, unsigned long ll_start, int chan,
 void mite_setregs(struct mite_struct *mite, unsigned long ll_start, int chan,
-	int dir);
+		  int dir);
 #endif
 #endif
 
 
 void mite_prep_dma(struct mite_channel *mite_chan,
 void mite_prep_dma(struct mite_channel *mite_chan,
-	unsigned int num_device_bits, unsigned int num_memory_bits);
+		   unsigned int num_device_bits, unsigned int num_memory_bits);
 int mite_buf_change(struct mite_dma_descriptor_ring *ring,
 int mite_buf_change(struct mite_dma_descriptor_ring *ring,
-	struct comedi_async *async);
+		    struct comedi_async *async);
 
 
 #ifdef DEBUG_MITE
 #ifdef DEBUG_MITE
 void mite_print_chsr(unsigned int chsr);
 void mite_print_chsr(unsigned int chsr);
@@ -185,72 +196,88 @@ enum mite_registers {
 	MITE_PCI_CONFIG_OFFSET = 0x300,
 	MITE_PCI_CONFIG_OFFSET = 0x300,
 	MITE_CSIGR = 0x460	/* chip signature */
 	MITE_CSIGR = 0x460	/* chip signature */
 };
 };
-static inline int MITE_CHOR(int channel)	/*  channel operation */
-{
+static inline int MITE_CHOR(int channel)
+{				/*  channel operation */
 	return CHAN_OFFSET(channel) + 0x0;
 	return CHAN_OFFSET(channel) + 0x0;
 };
 };
-static inline int MITE_CHCR(int channel)	/*  channel control */
-{
+
+static inline int MITE_CHCR(int channel)
+{				/*  channel control */
 	return CHAN_OFFSET(channel) + 0x4;
 	return CHAN_OFFSET(channel) + 0x4;
 };
 };
-static inline int MITE_TCR(int channel)	/*  transfer count */
-{
+
+static inline int MITE_TCR(int channel)
+{				/*  transfer count */
 	return CHAN_OFFSET(channel) + 0x8;
 	return CHAN_OFFSET(channel) + 0x8;
 };
 };
-static inline int MITE_MCR(int channel)	/*  memory configuration */
-{
+
+static inline int MITE_MCR(int channel)
+{				/*  memory configuration */
 	return CHAN_OFFSET(channel) + 0xc;
 	return CHAN_OFFSET(channel) + 0xc;
 };
 };
-static inline int MITE_MAR(int channel)	/*  memory address */
-{
+
+static inline int MITE_MAR(int channel)
+{				/*  memory address */
 	return CHAN_OFFSET(channel) + 0x10;
 	return CHAN_OFFSET(channel) + 0x10;
 };
 };
-static inline int MITE_DCR(int channel)	/*  device configuration */
-{
+
+static inline int MITE_DCR(int channel)
+{				/*  device configuration */
 	return CHAN_OFFSET(channel) + 0x14;
 	return CHAN_OFFSET(channel) + 0x14;
 };
 };
-static inline int MITE_DAR(int channel)	/*  device address */
-{
+
+static inline int MITE_DAR(int channel)
+{				/*  device address */
 	return CHAN_OFFSET(channel) + 0x18;
 	return CHAN_OFFSET(channel) + 0x18;
 };
 };
-static inline int MITE_LKCR(int channel)	/*  link configuration */
-{
+
+static inline int MITE_LKCR(int channel)
+{				/*  link configuration */
 	return CHAN_OFFSET(channel) + 0x1c;
 	return CHAN_OFFSET(channel) + 0x1c;
 };
 };
-static inline int MITE_LKAR(int channel)	/*  link address */
-{
+
+static inline int MITE_LKAR(int channel)
+{				/*  link address */
 	return CHAN_OFFSET(channel) + 0x20;
 	return CHAN_OFFSET(channel) + 0x20;
 };
 };
-static inline int MITE_LLKAR(int channel)	/*  see mite section of tnt5002 manual */
-{
+
+static inline int MITE_LLKAR(int channel)
+{				/*  see mite section of tnt5002 manual */
 	return CHAN_OFFSET(channel) + 0x24;
 	return CHAN_OFFSET(channel) + 0x24;
 };
 };
-static inline int MITE_BAR(int channel)	/*  base address */
-{
+
+static inline int MITE_BAR(int channel)
+{				/*  base address */
 	return CHAN_OFFSET(channel) + 0x28;
 	return CHAN_OFFSET(channel) + 0x28;
 };
 };
-static inline int MITE_BCR(int channel)	/*  base count */
-{
+
+static inline int MITE_BCR(int channel)
+{				/*  base count */
 	return CHAN_OFFSET(channel) + 0x2c;
 	return CHAN_OFFSET(channel) + 0x2c;
 };
 };
-static inline int MITE_SAR(int channel)	/*  ? address */
-{
+
+static inline int MITE_SAR(int channel)
+{				/*  ? address */
 	return CHAN_OFFSET(channel) + 0x30;
 	return CHAN_OFFSET(channel) + 0x30;
 };
 };
-static inline int MITE_WSCR(int channel)	/*  ? */
-{
+
+static inline int MITE_WSCR(int channel)
+{				/*  ? */
 	return CHAN_OFFSET(channel) + 0x34;
 	return CHAN_OFFSET(channel) + 0x34;
 };
 };
-static inline int MITE_WSER(int channel)	/*  ? */
-{
+
+static inline int MITE_WSER(int channel)
+{				/*  ? */
 	return CHAN_OFFSET(channel) + 0x38;
 	return CHAN_OFFSET(channel) + 0x38;
 };
 };
-static inline int MITE_CHSR(int channel)	/*  channel status */
-{
+
+static inline int MITE_CHSR(int channel)
+{				/*  channel status */
 	return CHAN_OFFSET(channel) + 0x3c;
 	return CHAN_OFFSET(channel) + 0x3c;
 };
 };
-static inline int MITE_FCR(int channel)	/*  fifo count */
-{
+
+static inline int MITE_FCR(int channel)
+{				/*  fifo count */
 	return CHAN_OFFSET(channel) + 0x40;
 	return CHAN_OFFSET(channel) + 0x40;
 };
 };
 
 
@@ -275,22 +302,27 @@ static inline int mite_csigr_version(u32 csigr_bits)
 {
 {
 	return csigr_bits & 0xf;
 	return csigr_bits & 0xf;
 };
 };
+
 static inline int mite_csigr_type(u32 csigr_bits)
 static inline int mite_csigr_type(u32 csigr_bits)
 {				/*  original mite = 0, minimite = 1 */
 {				/*  original mite = 0, minimite = 1 */
 	return (csigr_bits >> 4) & 0xf;
 	return (csigr_bits >> 4) & 0xf;
 };
 };
+
 static inline int mite_csigr_mmode(u32 csigr_bits)
 static inline int mite_csigr_mmode(u32 csigr_bits)
 {				/*  mite mode, minimite = 1 */
 {				/*  mite mode, minimite = 1 */
 	return (csigr_bits >> 8) & 0x3;
 	return (csigr_bits >> 8) & 0x3;
 };
 };
+
 static inline int mite_csigr_imode(u32 csigr_bits)
 static inline int mite_csigr_imode(u32 csigr_bits)
 {				/*  cpu port interface mode, pci = 0x3 */
 {				/*  cpu port interface mode, pci = 0x3 */
 	return (csigr_bits >> 12) & 0x3;
 	return (csigr_bits >> 12) & 0x3;
 };
 };
+
 static inline int mite_csigr_dmac(u32 csigr_bits)
 static inline int mite_csigr_dmac(u32 csigr_bits)
 {				/*  number of dma channels */
 {				/*  number of dma channels */
 	return (csigr_bits >> 16) & 0xf;
 	return (csigr_bits >> 16) & 0xf;
 };
 };
+
 static inline int mite_csigr_wpdep(u32 csigr_bits)
 static inline int mite_csigr_wpdep(u32 csigr_bits)
 {				/*  write post fifo depth */
 {				/*  write post fifo depth */
 	unsigned int wpdep_bits = (csigr_bits >> 20) & 0x7;
 	unsigned int wpdep_bits = (csigr_bits >> 20) & 0x7;
@@ -299,10 +331,12 @@ static inline int mite_csigr_wpdep(u32 csigr_bits)
 	else
 	else
 		return 1 << (wpdep_bits - 1);
 		return 1 << (wpdep_bits - 1);
 };
 };
+
 static inline int mite_csigr_wins(u32 csigr_bits)
 static inline int mite_csigr_wins(u32 csigr_bits)
 {
 {
 	return (csigr_bits >> 24) & 0x1f;
 	return (csigr_bits >> 24) & 0x1f;
 };
 };
+
 static inline int mite_csigr_iowins(u32 csigr_bits)
 static inline int mite_csigr_iowins(u32 csigr_bits)
 {				/*  number of io windows */
 {				/*  number of io windows */
 	return (csigr_bits >> 29) & 0x7;
 	return (csigr_bits >> 29) & 0x7;
@@ -366,9 +400,9 @@ enum MITE_CHCR_bits {
 	CHCR_LINKSHORT = (4 << 0),
 	CHCR_LINKSHORT = (4 << 0),
 	CHCR_LINKLONG = (5 << 0),
 	CHCR_LINKLONG = (5 << 0),
 	CHCRPON =
 	CHCRPON =
-		(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE |
-		CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
-		CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE),
+	    (CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE | CHCR_CLR_SAR_IE |
+	     CHCR_CLR_DONE_IE | CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
+	     CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE),
 };
 };
 
 
 enum ConfigRegister_bits {
 enum ConfigRegister_bits {
@@ -390,12 +424,14 @@ static inline int CR_REQS(int source)
 {
 {
 	return (source & 0x7) << 16;
 	return (source & 0x7) << 16;
 };
 };
+
 static inline int CR_REQSDRQ(unsigned drq_line)
 static inline int CR_REQSDRQ(unsigned drq_line)
 {
 {
 	/* This also works on m-series when
 	/* This also works on m-series when
 	   using channels (drq_line) 4 or 5. */
 	   using channels (drq_line) 4 or 5. */
 	return CR_REQS((drq_line & 0x3) | 0x4);
 	return CR_REQS((drq_line & 0x3) | 0x4);
 }
 }
+
 static inline int CR_RL(unsigned int retry_limit)
 static inline int CR_RL(unsigned int retry_limit)
 {
 {
 	int value = 0;
 	int value = 0;
@@ -447,7 +483,7 @@ enum CHSR_bits {
 static inline void mite_dma_reset(struct mite_channel *mite_chan)
 static inline void mite_dma_reset(struct mite_channel *mite_chan)
 {
 {
 	writel(CHOR_DMARESET | CHOR_FRESET,
 	writel(CHOR_DMARESET | CHOR_FRESET,
-		mite_chan->mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
+	       mite_chan->mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
 };
 };
 
 
 #endif
 #endif

+ 24 - 24
drivers/staging/comedi/drivers/mpc624.c

@@ -125,28 +125,29 @@ struct skel_private {
 	unsigned long int ulConvertionRate;	/*  set by mpc624_attach() from driver's parameters */
 	unsigned long int ulConvertionRate;	/*  set by mpc624_attach() from driver's parameters */
 };
 };
 
 
-
 #define devpriv ((struct skel_private *)dev->private)
 #define devpriv ((struct skel_private *)dev->private)
 /* ---------------------------------------------------------------------------- */
 /* ---------------------------------------------------------------------------- */
 static const struct comedi_lrange range_mpc624_bipolar1 = {
 static const struct comedi_lrange range_mpc624_bipolar1 = {
 	1,
 	1,
 	{
 	{
 /* BIP_RANGE(1.01)  this is correct, */
 /* BIP_RANGE(1.01)  this is correct, */
-			/*  but my MPC-624 actually seems to have a range of 2.02 */
-			BIP_RANGE(2.02)
-		}
+	 /*  but my MPC-624 actually seems to have a range of 2.02 */
+	 BIP_RANGE(2.02)
+	 }
 };
 };
+
 static const struct comedi_lrange range_mpc624_bipolar10 = {
 static const struct comedi_lrange range_mpc624_bipolar10 = {
 	1,
 	1,
 	{
 	{
 /* BIP_RANGE(10.1)   this is correct, */
 /* BIP_RANGE(10.1)   this is correct, */
-			/*  but my MPC-624 actually seems to have a range of 20.2 */
-			BIP_RANGE(20.2)
-		}
+	 /*  but my MPC-624 actually seems to have a range of 20.2 */
+	 BIP_RANGE(20.2)
+	 }
 };
 };
 
 
 /* ---------------------------------------------------------------------------- */
 /* ---------------------------------------------------------------------------- */
-static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int mpc624_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int mpc624_detach(struct comedi_device *dev);
 static int mpc624_detach(struct comedi_device *dev);
 /* ---------------------------------------------------------------------------- */
 /* ---------------------------------------------------------------------------- */
 static struct comedi_driver driver_mpc624 = {
 static struct comedi_driver driver_mpc624 = {
@@ -157,8 +158,9 @@ static struct comedi_driver driver_mpc624 = {
 };
 };
 
 
 /* ---------------------------------------------------------------------------- */
 /* ---------------------------------------------------------------------------- */
-static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int mpc624_ai_rinsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data);
 /* ---------------------------------------------------------------------------- */
 /* ---------------------------------------------------------------------------- */
 static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
 {
@@ -222,7 +224,7 @@ static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		break;
 		break;
 	default:
 	default:
 		printk
 		printk
-			("illegal convertion rate setting! Valid numbers are 0..9. Using 9 => 6.875 Hz, ");
+		    ("illegal convertion rate setting! Valid numbers are 0..9. Using 9 => 6.875 Hz, ");
 		devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
 		devpriv->ulConvertionRate = MPC624_SPEED_3_52_kHz;
 	}
 	}
 
 
@@ -270,8 +272,9 @@ static int mpc624_detach(struct comedi_device *dev)
 /* Timeout 200ms */
 /* Timeout 200ms */
 #define TIMEOUT 200
 #define TIMEOUT 200
 
 
-static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int mpc624_ai_rinsn(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   unsigned int *data)
 {
 {
 	int n, i;
 	int n, i;
 	unsigned long int data_in, data_out;
 	unsigned long int data_in, data_out;
@@ -316,16 +319,15 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
 			outb(0, dev->iobase + MPC624_ADC);
 			outb(0, dev->iobase + MPC624_ADC);
 			udelay(1);
 			udelay(1);
 
 
-			if (data_out & (1 << 31))	/*  the next bit is a 1 */
-			{
+			if (data_out & (1 << 31)) {	/*  the next bit is a 1 */
 				/*  Set the ADSDI line (send to MPC624) */
 				/*  Set the ADSDI line (send to MPC624) */
 				outb(MPC624_ADSDI, dev->iobase + MPC624_ADC);
 				outb(MPC624_ADSDI, dev->iobase + MPC624_ADC);
 				udelay(1);
 				udelay(1);
 				/*  Set the clock high */
 				/*  Set the clock high */
 				outb(MPC624_ADSCK | MPC624_ADSDI,
 				outb(MPC624_ADSCK | MPC624_ADSDI,
-					dev->iobase + MPC624_ADC);
-			} else	/*  the next bit is a 0 */
-			{
+				     dev->iobase + MPC624_ADC);
+			} else {	/*  the next bit is a 0 */
+
 				/*  Set the ADSDI line (send to MPC624) */
 				/*  Set the ADSDI line (send to MPC624) */
 				outb(0, dev->iobase + MPC624_ADC);
 				outb(0, dev->iobase + MPC624_ADC);
 				udelay(1);
 				udelay(1);
@@ -336,8 +338,7 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
 			udelay(1);
 			udelay(1);
 			data_in <<= 1;
 			data_in <<= 1;
 			data_in |=
 			data_in |=
-				(inb(dev->iobase +
-					MPC624_ADC) & MPC624_ADSDO) >> 4;
+			    (inb(dev->iobase + MPC624_ADC) & MPC624_ADSDO) >> 4;
 			udelay(1);
 			udelay(1);
 
 
 			data_out <<= 1;
 			data_out <<= 1;
@@ -358,12 +359,11 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s
 
 
 		if (data_in & MPC624_EOC_BIT)
 		if (data_in & MPC624_EOC_BIT)
 			printk("MPC624: EOC bit is set (data_in=%lu)!",
 			printk("MPC624: EOC bit is set (data_in=%lu)!",
-				data_in);
+			       data_in);
 		if (data_in & MPC624_DMY_BIT)
 		if (data_in & MPC624_DMY_BIT)
 			printk("MPC624: DMY bit is set (data_in=%lu)!",
 			printk("MPC624: DMY bit is set (data_in=%lu)!",
-				data_in);
-		if (data_in & MPC624_SGN_BIT)	/*  check the sign bit */
-		{		/*  The voltage is positive */
+			       data_in);
+		if (data_in & MPC624_SGN_BIT) {	/*  check the sign bit *//*  The voltage is positive */
 			data_in &= 0x3FFFFFFF;	/*  EOC and DMY should be 0, but we will mask them out just to be sure */
 			data_in &= 0x3FFFFFFF;	/*  EOC and DMY should be 0, but we will mask them out just to be sure */
 			data[n] = data_in;	/*  comedi operates on unsigned numbers, so we don't clear the SGN bit */
 			data[n] = data_in;	/*  comedi operates on unsigned numbers, so we don't clear the SGN bit */
 			/*  SGN bit is still set! It's correct, since we're converting to unsigned. */
 			/*  SGN bit is still set! It's correct, since we're converting to unsigned. */

+ 16 - 10
drivers/staging/comedi/drivers/mpc8260cpm.c

@@ -46,7 +46,8 @@ struct mpc8260cpm_private {
 
 
 #define devpriv ((struct mpc8260cpm_private *)dev->private)
 #define devpriv ((struct mpc8260cpm_private *)dev->private)
 
 
-static int mpc8260cpm_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int mpc8260cpm_attach(struct comedi_device *dev,
+			     struct comedi_devconfig *it);
 static int mpc8260cpm_detach(struct comedi_device *dev);
 static int mpc8260cpm_detach(struct comedi_device *dev);
 static struct comedi_driver driver_mpc8260cpm = {
 static struct comedi_driver driver_mpc8260cpm = {
 	.driver_name = "mpc8260cpm",
 	.driver_name = "mpc8260cpm",
@@ -57,12 +58,15 @@ static struct comedi_driver driver_mpc8260cpm = {
 
 
 COMEDI_INITCLEANUP(driver_mpc8260cpm);
 COMEDI_INITCLEANUP(driver_mpc8260cpm);
 
 
-static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int mpc8260cpm_dio_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+static int mpc8260cpm_dio_config(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data);
+static int mpc8260cpm_dio_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data);
 
 
-static int mpc8260cpm_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int mpc8260cpm_attach(struct comedi_device *dev,
+			     struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int i;
 	int i;
@@ -114,8 +118,9 @@ static unsigned long *cpm_pdat(int port)
 	}
 	}
 }
 }
 
 
-static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int mpc8260cpm_dio_config(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int n;
 	int n;
 	unsigned int d;
 	unsigned int d;
@@ -157,8 +162,9 @@ static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdev
 	return 1;
 	return 1;
 }
 }
 
 
-static int mpc8260cpm_dio_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int mpc8260cpm_dio_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int port;
 	int port;
 	unsigned long *p;
 	unsigned long *p;

+ 27 - 18
drivers/staging/comedi/drivers/multiq3.c

@@ -83,7 +83,8 @@ Devices: [Quanser Consulting] MultiQ-3 (multiq3)
 
 
 #define MULTIQ3_TIMEOUT 30
 #define MULTIQ3_TIMEOUT 30
 
 
-static int multiq3_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int multiq3_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int multiq3_detach(struct comedi_device *dev);
 static int multiq3_detach(struct comedi_device *dev);
 static struct comedi_driver driver_multiq3 = {
 static struct comedi_driver driver_multiq3 = {
 	.driver_name = "multiq3",
 	.driver_name = "multiq3",
@@ -99,8 +100,9 @@ struct multiq3_private {
 };
 };
 #define devpriv ((struct multiq3_private *)dev->private)
 #define devpriv ((struct multiq3_private *)dev->private)
 
 
-static int multiq3_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int multiq3_ai_insn_read(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i, n;
 	int i, n;
 	int chan;
 	int chan;
@@ -108,7 +110,7 @@ static int multiq3_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
 
 
 	chan = CR_CHAN(insn->chanspec);
 	chan = CR_CHAN(insn->chanspec);
 	outw(MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan << 3),
 	outw(MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan << 3),
-		dev->iobase + MULTIQ3_CONTROL);
+	     dev->iobase + MULTIQ3_CONTROL);
 
 
 	for (i = 0; i < MULTIQ3_TIMEOUT; i++) {
 	for (i = 0; i < MULTIQ3_TIMEOUT; i++) {
 		if (inw(dev->iobase + MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC)
 		if (inw(dev->iobase + MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC)
@@ -121,7 +123,7 @@ static int multiq3_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
 		outw(0, dev->iobase + MULTIQ3_AD_CS);
 		outw(0, dev->iobase + MULTIQ3_AD_CS);
 		for (i = 0; i < MULTIQ3_TIMEOUT; i++) {
 		for (i = 0; i < MULTIQ3_TIMEOUT; i++) {
 			if (inw(dev->iobase +
 			if (inw(dev->iobase +
-					MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC_I)
+				MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC_I)
 				break;
 				break;
 		}
 		}
 		if (i == MULTIQ3_TIMEOUT)
 		if (i == MULTIQ3_TIMEOUT)
@@ -135,8 +137,9 @@ static int multiq3_ai_insn_read(struct comedi_device *dev, struct comedi_subdevi
 	return n;
 	return n;
 }
 }
 
 
-static int multiq3_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int multiq3_ao_insn_read(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -148,15 +151,16 @@ static int multiq3_ao_insn_read(struct comedi_device *dev, struct comedi_subdevi
 	return i;
 	return i;
 }
 }
 
 
-static int multiq3_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int multiq3_ao_insn_write(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
 
 
 	for (i = 0; i < insn->n; i++) {
 	for (i = 0; i < insn->n; i++) {
 		outw(MULTIQ3_CONTROL_MUST | MULTIQ3_DA_LOAD | chan,
 		outw(MULTIQ3_CONTROL_MUST | MULTIQ3_DA_LOAD | chan,
-			dev->iobase + MULTIQ3_CONTROL);
+		     dev->iobase + MULTIQ3_CONTROL);
 		outw(data[i], dev->iobase + MULTIQ3_DAC_DATA);
 		outw(data[i], dev->iobase + MULTIQ3_DAC_DATA);
 		outw(MULTIQ3_CONTROL_MUST, dev->iobase + MULTIQ3_CONTROL);
 		outw(MULTIQ3_CONTROL_MUST, dev->iobase + MULTIQ3_CONTROL);
 
 
@@ -166,8 +170,9 @@ static int multiq3_ao_insn_write(struct comedi_device *dev, struct comedi_subdev
 	return i;
 	return i;
 }
 }
 
 
-static int multiq3_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int multiq3_di_insn_bits(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -177,8 +182,9 @@ static int multiq3_di_insn_bits(struct comedi_device *dev, struct comedi_subdevi
 	return 2;
 	return 2;
 }
 }
 
 
-static int multiq3_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int multiq3_do_insn_bits(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -192,8 +198,10 @@ static int multiq3_do_insn_bits(struct comedi_device *dev, struct comedi_subdevi
 	return 2;
 	return 2;
 }
 }
 
 
-static int multiq3_encoder_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int multiq3_encoder_insn_read(struct comedi_device *dev,
+				     struct comedi_subdevice *s,
+				     struct comedi_insn *insn,
+				     unsigned int *data)
 {
 {
 	int n;
 	int n;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -218,7 +226,7 @@ static void encoder_reset(struct comedi_device *dev)
 	int chan;
 	int chan;
 	for (chan = 0; chan < dev->subdevices[4].n_chan; chan++) {
 	for (chan = 0; chan < dev->subdevices[4].n_chan; chan++) {
 		int control =
 		int control =
-			MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan << 3);
+		    MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan << 3);
 		outw(control, dev->iobase + MULTIQ3_CONTROL);
 		outw(control, dev->iobase + MULTIQ3_CONTROL);
 		outb(MULTIQ3_EFLAG_RESET, dev->iobase + MULTIQ3_ENC_CONTROL);
 		outb(MULTIQ3_EFLAG_RESET, dev->iobase + MULTIQ3_ENC_CONTROL);
 		outb(MULTIQ3_BP_RESET, dev->iobase + MULTIQ3_ENC_CONTROL);
 		outb(MULTIQ3_BP_RESET, dev->iobase + MULTIQ3_ENC_CONTROL);
@@ -236,7 +244,8 @@ static void encoder_reset(struct comedi_device *dev)
    options[2] - number of encoder chips installed
    options[2] - number of encoder chips installed
  */
  */
 
 
-static int multiq3_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int multiq3_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	int result = 0;
 	int result = 0;
 	unsigned long iobase;
 	unsigned long iobase;

+ 58 - 51
drivers/staging/comedi/drivers/ni_6527.c

@@ -76,7 +76,8 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800
 #define Rising_Edge_Detection_Enable(x)		(0x018+(x))
 #define Rising_Edge_Detection_Enable(x)		(0x018+(x))
 #define Falling_Edge_Detection_Enable(x)	(0x020+(x))
 #define Falling_Edge_Detection_Enable(x)	(0x020+(x))
 
 
-static int ni6527_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int ni6527_attach(struct comedi_device *dev,
+			 struct comedi_devconfig *it);
 static int ni6527_detach(struct comedi_device *dev);
 static int ni6527_detach(struct comedi_device *dev);
 static struct comedi_driver driver_ni6527 = {
 static struct comedi_driver driver_ni6527 = {
 	.driver_name = "ni6527",
 	.driver_name = "ni6527",
@@ -93,22 +94,23 @@ struct ni6527_board {
 
 
 static const struct ni6527_board ni6527_boards[] = {
 static const struct ni6527_board ni6527_boards[] = {
 	{
 	{
-	.dev_id = 0x2b20,
-	.name = "pci-6527",
-		},
+	 .dev_id = 0x2b20,
+	 .name = "pci-6527",
+	 },
 	{
 	{
-	.dev_id = 0x2b10,
-	.name = "pxi-6527",
-		},
+	 .dev_id = 0x2b10,
+	 .name = "pxi-6527",
+	 },
 };
 };
 
 
-#define n_ni6527_boards (sizeof(ni6527_boards)/sizeof(ni6527_boards[0]))
+#define n_ni6527_boards ARRAY_SIZE(ni6527_boards)
 #define this_board ((const struct ni6527_board *)dev->board_ptr)
 #define this_board ((const struct ni6527_board *)dev->board_ptr)
 
 
 static DEFINE_PCI_DEVICE_TABLE(ni6527_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(ni6527_pci_table) = {
-	{PCI_VENDOR_ID_NATINST, 0x2b10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x2b20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_NATINST, 0x2b10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x2b20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, ni6527_pci_table);
 MODULE_DEVICE_TABLE(pci, ni6527_pci_table);
@@ -123,8 +125,9 @@ struct ni6527_private {
 
 
 static int ni6527_find_device(struct comedi_device *dev, int bus, int slot);
 static int ni6527_find_device(struct comedi_device *dev, int bus, int slot);
 
 
-static int ni6527_di_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni6527_di_insn_config(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
 	unsigned int interval;
 	unsigned int interval;
@@ -141,17 +144,14 @@ static int ni6527_di_insn_config(struct comedi_device *dev, struct comedi_subdev
 
 
 		if (interval != devpriv->filter_interval) {
 		if (interval != devpriv->filter_interval) {
 			writeb(interval & 0xff,
 			writeb(interval & 0xff,
-				devpriv->mite->daq_io_addr +
-				Filter_Interval(0));
+			       devpriv->mite->daq_io_addr + Filter_Interval(0));
 			writeb((interval >> 8) & 0xff,
 			writeb((interval >> 8) & 0xff,
-				devpriv->mite->daq_io_addr +
-				Filter_Interval(1));
+			       devpriv->mite->daq_io_addr + Filter_Interval(1));
 			writeb((interval >> 16) & 0x0f,
 			writeb((interval >> 16) & 0x0f,
-				devpriv->mite->daq_io_addr +
-				Filter_Interval(2));
+			       devpriv->mite->daq_io_addr + Filter_Interval(2));
 
 
 			writeb(ClrInterval,
 			writeb(ClrInterval,
-				devpriv->mite->daq_io_addr + Clear_Register);
+			       devpriv->mite->daq_io_addr + Clear_Register);
 
 
 			devpriv->filter_interval = interval;
 			devpriv->filter_interval = interval;
 		}
 		}
@@ -162,17 +162,18 @@ static int ni6527_di_insn_config(struct comedi_device *dev, struct comedi_subdev
 	}
 	}
 
 
 	writeb(devpriv->filter_enable,
 	writeb(devpriv->filter_enable,
-		devpriv->mite->daq_io_addr + Filter_Enable(0));
+	       devpriv->mite->daq_io_addr + Filter_Enable(0));
 	writeb(devpriv->filter_enable >> 8,
 	writeb(devpriv->filter_enable >> 8,
-		devpriv->mite->daq_io_addr + Filter_Enable(1));
+	       devpriv->mite->daq_io_addr + Filter_Enable(1));
 	writeb(devpriv->filter_enable >> 16,
 	writeb(devpriv->filter_enable >> 16,
-		devpriv->mite->daq_io_addr + Filter_Enable(2));
+	       devpriv->mite->daq_io_addr + Filter_Enable(2));
 
 
 	return 2;
 	return 2;
 }
 }
 
 
-static int ni6527_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni6527_di_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -184,8 +185,9 @@ static int ni6527_di_insn_bits(struct comedi_device *dev, struct comedi_subdevic
 	return 2;
 	return 2;
 }
 }
 
 
-static int ni6527_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni6527_do_insn_bits(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -197,15 +199,15 @@ static int ni6527_do_insn_bits(struct comedi_device *dev, struct comedi_subdevic
 		 * but in Comedi, it is represented by 0. */
 		 * but in Comedi, it is represented by 0. */
 		if (data[0] & 0x0000ff) {
 		if (data[0] & 0x0000ff) {
 			writeb((s->state ^ 0xff),
 			writeb((s->state ^ 0xff),
-				devpriv->mite->daq_io_addr + Port_Register(3));
+			       devpriv->mite->daq_io_addr + Port_Register(3));
 		}
 		}
 		if (data[0] & 0x00ff00) {
 		if (data[0] & 0x00ff00) {
 			writeb((s->state >> 8) ^ 0xff,
 			writeb((s->state >> 8) ^ 0xff,
-				devpriv->mite->daq_io_addr + Port_Register(4));
+			       devpriv->mite->daq_io_addr + Port_Register(4));
 		}
 		}
 		if (data[0] & 0xff0000) {
 		if (data[0] & 0xff0000) {
 			writeb((s->state >> 16) ^ 0xff,
 			writeb((s->state >> 16) ^ 0xff,
-				devpriv->mite->daq_io_addr + Port_Register(5));
+			       devpriv->mite->daq_io_addr + Port_Register(5));
 		}
 		}
 	}
 	}
 	data[1] = s->state;
 	data[1] = s->state;
@@ -226,7 +228,7 @@ static irqreturn_t ni6527_interrupt(int irq, void *d)
 		return IRQ_NONE;
 		return IRQ_NONE;
 
 
 	writeb(ClrEdge | ClrOverflow,
 	writeb(ClrEdge | ClrOverflow,
-		devpriv->mite->daq_io_addr + Clear_Register);
+	       devpriv->mite->daq_io_addr + Clear_Register);
 
 
 	comedi_buf_put(s->async, 0);
 	comedi_buf_put(s->async, 0);
 	s->async->events |= COMEDI_CB_EOS;
 	s->async->events |= COMEDI_CB_EOS;
@@ -234,8 +236,9 @@ static irqreturn_t ni6527_interrupt(int irq, void *d)
 	return IRQ_HANDLED;
 	return IRQ_HANDLED;
 }
 }
 
 
-static int ni6527_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int ni6527_intr_cmdtest(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -310,28 +313,31 @@ static int ni6527_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevic
 	return 0;
 	return 0;
 }
 }
 
 
-static int ni6527_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int ni6527_intr_cmd(struct comedi_device *dev,
+			   struct comedi_subdevice *s)
 {
 {
 	/* struct comedi_cmd *cmd = &s->async->cmd; */
 	/* struct comedi_cmd *cmd = &s->async->cmd; */
 
 
 	writeb(ClrEdge | ClrOverflow,
 	writeb(ClrEdge | ClrOverflow,
-		devpriv->mite->daq_io_addr + Clear_Register);
+	       devpriv->mite->daq_io_addr + Clear_Register);
 	writeb(FallingEdgeIntEnable | RisingEdgeIntEnable |
 	writeb(FallingEdgeIntEnable | RisingEdgeIntEnable |
-		MasterInterruptEnable | EdgeIntEnable,
-		devpriv->mite->daq_io_addr + Master_Interrupt_Control);
+	       MasterInterruptEnable | EdgeIntEnable,
+	       devpriv->mite->daq_io_addr + Master_Interrupt_Control);
 
 
 	return 0;
 	return 0;
 }
 }
 
 
-static int ni6527_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int ni6527_intr_cancel(struct comedi_device *dev,
+			      struct comedi_subdevice *s)
 {
 {
 	writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control);
 	writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control);
 
 
 	return 0;
 	return 0;
 }
 }
 
 
-static int ni6527_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni6527_intr_insn_bits(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n < 1)
 	if (insn->n < 1)
 		return -EINVAL;
 		return -EINVAL;
@@ -340,8 +346,9 @@ static int ni6527_intr_insn_bits(struct comedi_device *dev, struct comedi_subdev
 	return 2;
 	return 2;
 }
 }
 
 
-static int ni6527_intr_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni6527_intr_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n < 1)
 	if (insn->n < 1)
 		return -EINVAL;
 		return -EINVAL;
@@ -349,18 +356,18 @@ static int ni6527_intr_insn_config(struct comedi_device *dev, struct comedi_subd
 		return -EINVAL;
 		return -EINVAL;
 
 
 	writeb(data[1],
 	writeb(data[1],
-		devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(0));
+	       devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(0));
 	writeb(data[1] >> 8,
 	writeb(data[1] >> 8,
-		devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(1));
+	       devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(1));
 	writeb(data[1] >> 16,
 	writeb(data[1] >> 16,
-		devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(2));
+	       devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(2));
 
 
 	writeb(data[2],
 	writeb(data[2],
-		devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(0));
+	       devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(0));
 	writeb(data[2] >> 8,
 	writeb(data[2] >> 8,
-		devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(1));
+	       devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(1));
 	writeb(data[2] >> 16,
 	writeb(data[2] >> 16,
-		devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(2));
+	       devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(2));
 
 
 	return 2;
 	return 2;
 }
 }
@@ -430,7 +437,7 @@ static int ni6527_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	writeb(0x00, devpriv->mite->daq_io_addr + Filter_Enable(2));
 	writeb(0x00, devpriv->mite->daq_io_addr + Filter_Enable(2));
 
 
 	writeb(ClrEdge | ClrOverflow | ClrFilter | ClrInterval,
 	writeb(ClrEdge | ClrOverflow | ClrFilter | ClrInterval,
-		devpriv->mite->daq_io_addr + Clear_Register);
+	       devpriv->mite->daq_io_addr + Clear_Register);
 	writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control);
 	writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control);
 
 
 	ret = request_irq(mite_irq(devpriv->mite), ni6527_interrupt,
 	ret = request_irq(mite_irq(devpriv->mite), ni6527_interrupt,
@@ -449,7 +456,7 @@ static int ni6527_detach(struct comedi_device *dev)
 {
 {
 	if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr) {
 	if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr) {
 		writeb(0x00,
 		writeb(0x00,
-			devpriv->mite->daq_io_addr + Master_Interrupt_Control);
+		       devpriv->mite->daq_io_addr + Master_Interrupt_Control);
 	}
 	}
 
 
 	if (dev->irq) {
 	if (dev->irq) {
@@ -473,7 +480,7 @@ static int ni6527_find_device(struct comedi_device *dev, int bus, int slot)
 			continue;
 			continue;
 		if (bus || slot) {
 		if (bus || slot) {
 			if (bus != mite->pcidev->bus->number ||
 			if (bus != mite->pcidev->bus->number ||
-				slot != PCI_SLOT(mite->pcidev->devfn))
+			    slot != PCI_SLOT(mite->pcidev->devfn))
 				continue;
 				continue;
 		}
 		}
 		for (i = 0; i < n_ni6527_boards; i++) {
 		for (i = 0; i < n_ni6527_boards; i++) {

+ 211 - 191
drivers/staging/comedi/drivers/ni_65xx.c

@@ -66,18 +66,22 @@ static inline unsigned Port_Data(unsigned port)
 {
 {
 	return 0x40 + port * ni_65xx_port_offset;
 	return 0x40 + port * ni_65xx_port_offset;
 }
 }
+
 static inline unsigned Port_Select(unsigned port)
 static inline unsigned Port_Select(unsigned port)
 {
 {
 	return 0x41 + port * ni_65xx_port_offset;
 	return 0x41 + port * ni_65xx_port_offset;
 }
 }
+
 static inline unsigned Rising_Edge_Detection_Enable(unsigned port)
 static inline unsigned Rising_Edge_Detection_Enable(unsigned port)
 {
 {
 	return 0x42 + port * ni_65xx_port_offset;
 	return 0x42 + port * ni_65xx_port_offset;
 }
 }
+
 static inline unsigned Falling_Edge_Detection_Enable(unsigned port)
 static inline unsigned Falling_Edge_Detection_Enable(unsigned port)
 {
 {
 	return 0x43 + port * ni_65xx_port_offset;
 	return 0x43 + port * ni_65xx_port_offset;
 }
 }
+
 static inline unsigned Filter_Enable(unsigned port)
 static inline unsigned Filter_Enable(unsigned port)
 {
 {
 	return 0x44 + port * ni_65xx_port_offset;
 	return 0x44 + port * ni_65xx_port_offset;
@@ -103,7 +107,8 @@ static inline unsigned Filter_Enable(unsigned port)
 #define OverflowIntEnable		0x02
 #define OverflowIntEnable		0x02
 #define EdgeIntEnable			0x01
 #define EdgeIntEnable			0x01
 
 
-static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int ni_65xx_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int ni_65xx_detach(struct comedi_device *dev);
 static int ni_65xx_detach(struct comedi_device *dev);
 static struct comedi_driver driver_ni_65xx = {
 static struct comedi_driver driver_ni_65xx = {
 	.driver_name = "ni_65xx",
 	.driver_name = "ni_65xx",
@@ -124,161 +129,165 @@ struct ni_65xx_board {
 
 
 static const struct ni_65xx_board ni_65xx_boards[] = {
 static const struct ni_65xx_board ni_65xx_boards[] = {
 	{
 	{
-	.dev_id = 0x7085,
-	.name = "pci-6509",
-	.num_dio_ports = 12,
-	.invert_outputs = 0},
+	 .dev_id = 0x7085,
+	 .name = "pci-6509",
+	 .num_dio_ports = 12,
+	 .invert_outputs = 0},
 	{
 	{
-	.dev_id = 0x1710,
-	.name = "pxi-6509",
-	.num_dio_ports = 12,
-	.invert_outputs = 0},
+	 .dev_id = 0x1710,
+	 .name = "pxi-6509",
+	 .num_dio_ports = 12,
+	 .invert_outputs = 0},
 	{
 	{
-	.dev_id = 0x7124,
-	.name = "pci-6510",
-	.num_di_ports = 4},
+	 .dev_id = 0x7124,
+	 .name = "pci-6510",
+	 .num_di_ports = 4},
 	{
 	{
-	.dev_id = 0x70c3,
-	.name = "pci-6511",
-	.num_di_ports = 8},
+	 .dev_id = 0x70c3,
+	 .name = "pci-6511",
+	 .num_di_ports = 8},
 	{
 	{
-	.dev_id = 0x70d3,
-	.name = "pxi-6511",
-	.num_di_ports = 8},
+	 .dev_id = 0x70d3,
+	 .name = "pxi-6511",
+	 .num_di_ports = 8},
 	{
 	{
-	.dev_id = 0x70cc,
-	.name = "pci-6512",
-	.num_do_ports = 8},
+	 .dev_id = 0x70cc,
+	 .name = "pci-6512",
+	 .num_do_ports = 8},
 	{
 	{
-	.dev_id = 0x70d2,
-	.name = "pxi-6512",
-	.num_do_ports = 8},
+	 .dev_id = 0x70d2,
+	 .name = "pxi-6512",
+	 .num_do_ports = 8},
 	{
 	{
-	.dev_id = 0x70c8,
-	.name = "pci-6513",
-	.num_do_ports = 8,
-	.invert_outputs = 1},
+	 .dev_id = 0x70c8,
+	 .name = "pci-6513",
+	 .num_do_ports = 8,
+	 .invert_outputs = 1},
 	{
 	{
-	.dev_id = 0x70d1,
-	.name = "pxi-6513",
-	.num_do_ports = 8,
-	.invert_outputs = 1},
+	 .dev_id = 0x70d1,
+	 .name = "pxi-6513",
+	 .num_do_ports = 8,
+	 .invert_outputs = 1},
 	{
 	{
-	.dev_id = 0x7088,
-	.name = "pci-6514",
-	.num_di_ports = 4,
-	.num_do_ports = 4,
-	.invert_outputs = 1},
+	 .dev_id = 0x7088,
+	 .name = "pci-6514",
+	 .num_di_ports = 4,
+	 .num_do_ports = 4,
+	 .invert_outputs = 1},
 	{
 	{
-	.dev_id = 0x70CD,
-	.name = "pxi-6514",
-	.num_di_ports = 4,
-	.num_do_ports = 4,
-	.invert_outputs = 1},
+	 .dev_id = 0x70CD,
+	 .name = "pxi-6514",
+	 .num_di_ports = 4,
+	 .num_do_ports = 4,
+	 .invert_outputs = 1},
 	{
 	{
-	.dev_id = 0x7087,
-	.name = "pci-6515",
-	.num_di_ports = 4,
-	.num_do_ports = 4,
-	.invert_outputs = 1},
+	 .dev_id = 0x7087,
+	 .name = "pci-6515",
+	 .num_di_ports = 4,
+	 .num_do_ports = 4,
+	 .invert_outputs = 1},
 	{
 	{
-	.dev_id = 0x70c9,
-	.name = "pxi-6515",
-	.num_di_ports = 4,
-	.num_do_ports = 4,
-	.invert_outputs = 1},
+	 .dev_id = 0x70c9,
+	 .name = "pxi-6515",
+	 .num_di_ports = 4,
+	 .num_do_ports = 4,
+	 .invert_outputs = 1},
 	{
 	{
-	.dev_id = 0x7125,
-	.name = "pci-6516",
-	.num_do_ports = 4,
-	.invert_outputs = 1},
+	 .dev_id = 0x7125,
+	 .name = "pci-6516",
+	 .num_do_ports = 4,
+	 .invert_outputs = 1},
 	{
 	{
-	.dev_id = 0x7126,
-	.name = "pci-6517",
-	.num_do_ports = 4,
-	.invert_outputs = 1},
+	 .dev_id = 0x7126,
+	 .name = "pci-6517",
+	 .num_do_ports = 4,
+	 .invert_outputs = 1},
 	{
 	{
-	.dev_id = 0x7127,
-	.name = "pci-6518",
-	.num_di_ports = 2,
-	.num_do_ports = 2,
-	.invert_outputs = 1},
+	 .dev_id = 0x7127,
+	 .name = "pci-6518",
+	 .num_di_ports = 2,
+	 .num_do_ports = 2,
+	 .invert_outputs = 1},
 	{
 	{
-	.dev_id = 0x7128,
-	.name = "pci-6519",
-	.num_di_ports = 2,
-	.num_do_ports = 2,
-	.invert_outputs = 1},
+	 .dev_id = 0x7128,
+	 .name = "pci-6519",
+	 .num_di_ports = 2,
+	 .num_do_ports = 2,
+	 .invert_outputs = 1},
 	{
 	{
-	.dev_id = 0x71c5,
-	.name = "pci-6520",
-	.num_di_ports = 1,
-	.num_do_ports = 1,
-		},
+	 .dev_id = 0x71c5,
+	 .name = "pci-6520",
+	 .num_di_ports = 1,
+	 .num_do_ports = 1,
+	 },
 	{
 	{
-	.dev_id = 0x718b,
-	.name = "pci-6521",
-	.num_di_ports = 1,
-	.num_do_ports = 1,
-		},
+	 .dev_id = 0x718b,
+	 .name = "pci-6521",
+	 .num_di_ports = 1,
+	 .num_do_ports = 1,
+	 },
 	{
 	{
-	.dev_id = 0x718c,
-	.name = "pxi-6521",
-	.num_di_ports = 1,
-	.num_do_ports = 1,
-		},
+	 .dev_id = 0x718c,
+	 .name = "pxi-6521",
+	 .num_di_ports = 1,
+	 .num_do_ports = 1,
+	 },
 	{
 	{
-	.dev_id = 0x70a9,
-	.name = "pci-6528",
-	.num_di_ports = 3,
-	.num_do_ports = 3,
-		},
+	 .dev_id = 0x70a9,
+	 .name = "pci-6528",
+	 .num_di_ports = 3,
+	 .num_do_ports = 3,
+	 },
 	{
 	{
-	.dev_id = 0x7086,
-	.name = "pxi-6528",
-	.num_di_ports = 3,
-	.num_do_ports = 3,
-		},
+	 .dev_id = 0x7086,
+	 .name = "pxi-6528",
+	 .num_di_ports = 3,
+	 .num_do_ports = 3,
+	 },
 };
 };
 
 
-#define n_ni_65xx_boards (sizeof(ni_65xx_boards)/sizeof(ni_65xx_boards[0]))
-static inline const struct ni_65xx_board *board(struct comedi_device * dev)
+#define n_ni_65xx_boards ARRAY_SIZE(ni_65xx_boards)
+static inline const struct ni_65xx_board *board(struct comedi_device *dev)
 {
 {
 	return dev->board_ptr;
 	return dev->board_ptr;
 }
 }
+
 static inline unsigned ni_65xx_port_by_channel(unsigned channel)
 static inline unsigned ni_65xx_port_by_channel(unsigned channel)
 {
 {
 	return channel / ni_65xx_channels_per_port;
 	return channel / ni_65xx_channels_per_port;
 }
 }
-static inline unsigned ni_65xx_total_num_ports(const struct ni_65xx_board *board)
+
+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;
 	return board->num_dio_ports + board->num_di_ports + board->num_do_ports;
 }
 }
 
 
 static DEFINE_PCI_DEVICE_TABLE(ni_65xx_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(ni_65xx_pci_table) = {
-	{PCI_VENDOR_ID_NATINST, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x7085, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x7086, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x7087, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x7088, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x70a9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x70c3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x70c8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x70c9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x70cc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x70CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x70d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x70d2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x70d3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x7124, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x7125, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x7126, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x7127, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x7128, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x718b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x718c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x71c5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_NATINST, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x7085, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x7086, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x7087, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x7088, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x70a9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x70c3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x70c8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x70c9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x70cc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x70CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x70d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x70d2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x70d3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x7124, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x7125, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x7126, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x7127, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x7128, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x718b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x718c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x71c5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, ni_65xx_pci_table);
 MODULE_DEVICE_TABLE(pci, ni_65xx_pci_table);
@@ -291,7 +300,7 @@ struct ni_65xx_private {
 	unsigned short dio_direction[NI_65XX_MAX_NUM_PORTS];
 	unsigned short dio_direction[NI_65XX_MAX_NUM_PORTS];
 };
 };
 
 
-static inline struct ni_65xx_private *private(struct comedi_device * dev)
+static inline struct ni_65xx_private *private(struct comedi_device *dev)
 {
 {
 	return dev->private;
 	return dev->private;
 }
 }
@@ -300,14 +309,16 @@ struct ni_65xx_subdevice_private {
 	unsigned base_port;
 	unsigned base_port;
 };
 };
 
 
-static inline struct ni_65xx_subdevice_private *sprivate(struct comedi_subdevice * subdev)
+static inline struct ni_65xx_subdevice_private *sprivate(struct comedi_subdevice
+							 *subdev)
 {
 {
 	return subdev->private;
 	return subdev->private;
 }
 }
+
 static struct ni_65xx_subdevice_private *ni_65xx_alloc_subdevice_private(void)
 static struct ni_65xx_subdevice_private *ni_65xx_alloc_subdevice_private(void)
 {
 {
 	struct ni_65xx_subdevice_private *subdev_private =
 	struct ni_65xx_subdevice_private *subdev_private =
-		kzalloc(sizeof(struct ni_65xx_subdevice_private), GFP_KERNEL);
+	    kzalloc(sizeof(struct ni_65xx_subdevice_private), GFP_KERNEL);
 	if (subdev_private == NULL)
 	if (subdev_private == NULL)
 		return NULL;
 		return NULL;
 	return subdev_private;
 	return subdev_private;
@@ -315,12 +326,13 @@ static struct ni_65xx_subdevice_private *ni_65xx_alloc_subdevice_private(void)
 
 
 static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot);
 static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot);
 
 
-static int ni_65xx_config_filter(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni_65xx_config_filter(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	const unsigned chan = CR_CHAN(insn->chanspec);
 	const unsigned chan = CR_CHAN(insn->chanspec);
 	const unsigned port =
 	const unsigned port =
-		sprivate(s)->base_port + ni_65xx_port_by_channel(chan);
+	    sprivate(s)->base_port + ni_65xx_port_by_channel(chan);
 
 
 	if (data[0] != INSN_CONFIG_FILTER)
 	if (data[0] != INSN_CONFIG_FILTER)
 		return -EINVAL;
 		return -EINVAL;
@@ -328,41 +340,42 @@ static int ni_65xx_config_filter(struct comedi_device *dev, struct comedi_subdev
 		static const unsigned filter_resolution_ns = 200;
 		static const unsigned filter_resolution_ns = 200;
 		static const unsigned max_filter_interval = 0xfffff;
 		static const unsigned max_filter_interval = 0xfffff;
 		unsigned interval =
 		unsigned interval =
-			(data[1] +
-			(filter_resolution_ns / 2)) / filter_resolution_ns;
+		    (data[1] +
+		     (filter_resolution_ns / 2)) / filter_resolution_ns;
 		if (interval > max_filter_interval)
 		if (interval > max_filter_interval)
 			interval = max_filter_interval;
 			interval = max_filter_interval;
 		data[1] = interval * filter_resolution_ns;
 		data[1] = interval * filter_resolution_ns;
 
 
 		if (interval != private(dev)->filter_interval) {
 		if (interval != private(dev)->filter_interval) {
 			writeb(interval,
 			writeb(interval,
-				private(dev)->mite->daq_io_addr +
-				Filter_Interval);
+			       private(dev)->mite->daq_io_addr +
+			       Filter_Interval);
 			private(dev)->filter_interval = interval;
 			private(dev)->filter_interval = interval;
 		}
 		}
 
 
 		private(dev)->filter_enable[port] |=
 		private(dev)->filter_enable[port] |=
-			1 << (chan % ni_65xx_channels_per_port);
+		    1 << (chan % ni_65xx_channels_per_port);
 	} else {
 	} else {
 		private(dev)->filter_enable[port] &=
 		private(dev)->filter_enable[port] &=
-			~(1 << (chan % ni_65xx_channels_per_port));
+		    ~(1 << (chan % ni_65xx_channels_per_port));
 	}
 	}
 
 
 	writeb(private(dev)->filter_enable[port],
 	writeb(private(dev)->filter_enable[port],
-		private(dev)->mite->daq_io_addr + Filter_Enable(port));
+	       private(dev)->mite->daq_io_addr + Filter_Enable(port));
 
 
 	return 2;
 	return 2;
 }
 }
 
 
-static int ni_65xx_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni_65xx_dio_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned port;
 	unsigned port;
 
 
 	if (insn->n < 1)
 	if (insn->n < 1)
 		return -EINVAL;
 		return -EINVAL;
 	port = sprivate(s)->base_port +
 	port = sprivate(s)->base_port +
-		ni_65xx_port_by_channel(CR_CHAN(insn->chanspec));
+	    ni_65xx_port_by_channel(CR_CHAN(insn->chanspec));
 	switch (data[0]) {
 	switch (data[0]) {
 	case INSN_CONFIG_FILTER:
 	case INSN_CONFIG_FILTER:
 		return ni_65xx_config_filter(dev, s, insn, data);
 		return ni_65xx_config_filter(dev, s, insn, data);
@@ -393,8 +406,9 @@ static int ni_65xx_dio_insn_config(struct comedi_device *dev, struct comedi_subd
 	return -EINVAL;
 	return -EINVAL;
 }
 }
 
 
-static int ni_65xx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni_65xx_dio_insn_bits(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned base_bitfield_channel;
 	unsigned base_bitfield_channel;
 	const unsigned max_ports_per_bitfield = 5;
 	const unsigned max_ports_per_bitfield = 5;
@@ -405,8 +419,8 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
 	base_bitfield_channel = CR_CHAN(insn->chanspec);
 	base_bitfield_channel = CR_CHAN(insn->chanspec);
 	for (j = 0; j < max_ports_per_bitfield; ++j) {
 	for (j = 0; j < max_ports_per_bitfield; ++j) {
 		const unsigned port =
 		const unsigned port =
-			sprivate(s)->base_port +
-			ni_65xx_port_by_channel(base_bitfield_channel) + j;
+		    sprivate(s)->base_port +
+		    ni_65xx_port_by_channel(base_bitfield_channel) + j;
 		unsigned base_port_channel;
 		unsigned base_port_channel;
 		unsigned port_mask, port_data, port_read_bits;
 		unsigned port_mask, port_data, port_read_bits;
 		int bitshift;
 		int bitshift;
@@ -431,18 +445,17 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
 			unsigned bits;
 			unsigned bits;
 			private(dev)->output_bits[port] &= ~port_mask;
 			private(dev)->output_bits[port] &= ~port_mask;
 			private(dev)->output_bits[port] |=
 			private(dev)->output_bits[port] |=
-				port_data & port_mask;
+			    port_data & port_mask;
 			bits = private(dev)->output_bits[port];
 			bits = private(dev)->output_bits[port];
 			if (board(dev)->invert_outputs)
 			if (board(dev)->invert_outputs)
 				bits = ~bits;
 				bits = ~bits;
 			writeb(bits,
 			writeb(bits,
-				private(dev)->mite->daq_io_addr +
-				Port_Data(port));
+			       private(dev)->mite->daq_io_addr +
+			       Port_Data(port));
 /* printk("wrote 0x%x to port %i\n", bits, port); */
 /* printk("wrote 0x%x to port %i\n", bits, port); */
 		}
 		}
 		port_read_bits =
 		port_read_bits =
-			readb(private(dev)->mite->daq_io_addr +
-			Port_Data(port));
+		    readb(private(dev)->mite->daq_io_addr + Port_Data(port));
 /* printk("read 0x%x from port %i\n", port_read_bits, port); */
 /* printk("read 0x%x from port %i\n", port_read_bits, port); */
 		if (bitshift > 0) {
 		if (bitshift > 0) {
 			port_read_bits <<= bitshift;
 			port_read_bits <<= bitshift;
@@ -468,7 +481,7 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d)
 		return IRQ_NONE;
 		return IRQ_NONE;
 
 
 	writeb(ClrEdge | ClrOverflow,
 	writeb(ClrEdge | ClrOverflow,
-		private(dev)->mite->daq_io_addr + Clear_Register);
+	       private(dev)->mite->daq_io_addr + Clear_Register);
 
 
 	comedi_buf_put(s->async, 0);
 	comedi_buf_put(s->async, 0);
 	s->async->events |= COMEDI_CB_EOS;
 	s->async->events |= COMEDI_CB_EOS;
@@ -476,8 +489,9 @@ static irqreturn_t ni_65xx_interrupt(int irq, void *d)
 	return IRQ_HANDLED;
 	return IRQ_HANDLED;
 }
 }
 
 
-static int ni_65xx_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int ni_65xx_intr_cmdtest(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -552,29 +566,32 @@ static int ni_65xx_intr_cmdtest(struct comedi_device *dev, struct comedi_subdevi
 	return 0;
 	return 0;
 }
 }
 
 
-static int ni_65xx_intr_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
+static int ni_65xx_intr_cmd(struct comedi_device *dev,
+			    struct comedi_subdevice *s)
 {
 {
 	/* struct comedi_cmd *cmd = &s->async->cmd; */
 	/* struct comedi_cmd *cmd = &s->async->cmd; */
 
 
 	writeb(ClrEdge | ClrOverflow,
 	writeb(ClrEdge | ClrOverflow,
-		private(dev)->mite->daq_io_addr + Clear_Register);
+	       private(dev)->mite->daq_io_addr + Clear_Register);
 	writeb(FallingEdgeIntEnable | RisingEdgeIntEnable |
 	writeb(FallingEdgeIntEnable | RisingEdgeIntEnable |
-		MasterInterruptEnable | EdgeIntEnable,
-		private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
+	       MasterInterruptEnable | EdgeIntEnable,
+	       private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
 
 
 	return 0;
 	return 0;
 }
 }
 
 
-static int ni_65xx_intr_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
+static int ni_65xx_intr_cancel(struct comedi_device *dev,
+			       struct comedi_subdevice *s)
 {
 {
 	writeb(0x00,
 	writeb(0x00,
-		private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
+	       private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
 
 
 	return 0;
 	return 0;
 }
 }
 
 
-static int ni_65xx_intr_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni_65xx_intr_insn_bits(struct comedi_device *dev,
+				  struct comedi_subdevice *s,
+				  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n < 1)
 	if (insn->n < 1)
 		return -EINVAL;
 		return -EINVAL;
@@ -583,8 +600,10 @@ static int ni_65xx_intr_insn_bits(struct comedi_device *dev, struct comedi_subde
 	return 2;
 	return 2;
 }
 }
 
 
-static int ni_65xx_intr_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni_65xx_intr_insn_config(struct comedi_device *dev,
+				    struct comedi_subdevice *s,
+				    struct comedi_insn *insn,
+				    unsigned int *data)
 {
 {
 	if (insn->n < 1)
 	if (insn->n < 1)
 		return -EINVAL;
 		return -EINVAL;
@@ -592,35 +611,36 @@ static int ni_65xx_intr_insn_config(struct comedi_device *dev, struct comedi_sub
 		return -EINVAL;
 		return -EINVAL;
 
 
 	writeb(data[1],
 	writeb(data[1],
-		private(dev)->mite->daq_io_addr +
-		Rising_Edge_Detection_Enable(0));
+	       private(dev)->mite->daq_io_addr +
+	       Rising_Edge_Detection_Enable(0));
 	writeb(data[1] >> 8,
 	writeb(data[1] >> 8,
-		private(dev)->mite->daq_io_addr +
-		Rising_Edge_Detection_Enable(0x10));
+	       private(dev)->mite->daq_io_addr +
+	       Rising_Edge_Detection_Enable(0x10));
 	writeb(data[1] >> 16,
 	writeb(data[1] >> 16,
-		private(dev)->mite->daq_io_addr +
-		Rising_Edge_Detection_Enable(0x20));
+	       private(dev)->mite->daq_io_addr +
+	       Rising_Edge_Detection_Enable(0x20));
 	writeb(data[1] >> 24,
 	writeb(data[1] >> 24,
-		private(dev)->mite->daq_io_addr +
-		Rising_Edge_Detection_Enable(0x30));
+	       private(dev)->mite->daq_io_addr +
+	       Rising_Edge_Detection_Enable(0x30));
 
 
 	writeb(data[2],
 	writeb(data[2],
-		private(dev)->mite->daq_io_addr +
-		Falling_Edge_Detection_Enable(0));
+	       private(dev)->mite->daq_io_addr +
+	       Falling_Edge_Detection_Enable(0));
 	writeb(data[2] >> 8,
 	writeb(data[2] >> 8,
-		private(dev)->mite->daq_io_addr +
-		Falling_Edge_Detection_Enable(0x10));
+	       private(dev)->mite->daq_io_addr +
+	       Falling_Edge_Detection_Enable(0x10));
 	writeb(data[2] >> 16,
 	writeb(data[2] >> 16,
-		private(dev)->mite->daq_io_addr +
-		Falling_Edge_Detection_Enable(0x20));
+	       private(dev)->mite->daq_io_addr +
+	       Falling_Edge_Detection_Enable(0x20));
 	writeb(data[2] >> 24,
 	writeb(data[2] >> 24,
-		private(dev)->mite->daq_io_addr +
-		Falling_Edge_Detection_Enable(0x30));
+	       private(dev)->mite->daq_io_addr +
+	       Falling_Edge_Detection_Enable(0x30));
 
 
 	return 2;
 	return 2;
 }
 }
 
 
-static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int ni_65xx_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	unsigned i;
 	unsigned i;
@@ -647,7 +667,7 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	printk(" %s", dev->board_name);
 	printk(" %s", dev->board_name);
 
 
 	printk(" ID=0x%02x",
 	printk(" ID=0x%02x",
-		readb(private(dev)->mite->daq_io_addr + ID_Register));
+	       readb(private(dev)->mite->daq_io_addr + ID_Register));
 
 
 	ret = alloc_subdevices(dev, 4);
 	ret = alloc_subdevices(dev, 4);
 	if (ret < 0)
 	if (ret < 0)
@@ -658,7 +678,7 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		s->type = COMEDI_SUBD_DI;
 		s->type = COMEDI_SUBD_DI;
 		s->subdev_flags = SDF_READABLE;
 		s->subdev_flags = SDF_READABLE;
 		s->n_chan =
 		s->n_chan =
-			board(dev)->num_di_ports * ni_65xx_channels_per_port;
+		    board(dev)->num_di_ports * ni_65xx_channels_per_port;
 		s->range_table = &range_digital;
 		s->range_table = &range_digital;
 		s->maxdata = 1;
 		s->maxdata = 1;
 		s->insn_config = ni_65xx_dio_insn_config;
 		s->insn_config = ni_65xx_dio_insn_config;
@@ -676,7 +696,7 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		s->type = COMEDI_SUBD_DO;
 		s->type = COMEDI_SUBD_DO;
 		s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
 		s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
 		s->n_chan =
 		s->n_chan =
-			board(dev)->num_do_ports * ni_65xx_channels_per_port;
+		    board(dev)->num_do_ports * ni_65xx_channels_per_port;
 		s->range_table = &range_digital;
 		s->range_table = &range_digital;
 		s->maxdata = 1;
 		s->maxdata = 1;
 		s->insn_bits = ni_65xx_dio_insn_bits;
 		s->insn_bits = ni_65xx_dio_insn_bits;
@@ -693,7 +713,7 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		s->type = COMEDI_SUBD_DIO;
 		s->type = COMEDI_SUBD_DIO;
 		s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
 		s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
 		s->n_chan =
 		s->n_chan =
-			board(dev)->num_dio_ports * ni_65xx_channels_per_port;
+		    board(dev)->num_dio_ports * ni_65xx_channels_per_port;
 		s->range_table = &range_digital;
 		s->range_table = &range_digital;
 		s->maxdata = 1;
 		s->maxdata = 1;
 		s->insn_config = ni_65xx_dio_insn_config;
 		s->insn_config = ni_65xx_dio_insn_config;
@@ -705,8 +725,8 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		for (i = 0; i < board(dev)->num_dio_ports; ++i) {
 		for (i = 0; i < board(dev)->num_dio_ports; ++i) {
 			/*  configure all ports for input */
 			/*  configure all ports for input */
 			writeb(0x1,
 			writeb(0x1,
-				private(dev)->mite->daq_io_addr +
-				Port_Select(i));
+			       private(dev)->mite->daq_io_addr +
+			       Port_Select(i));
 		}
 		}
 	} else {
 	} else {
 		s->type = COMEDI_SUBD_UNUSED;
 		s->type = COMEDI_SUBD_UNUSED;
@@ -727,18 +747,18 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
 
 
 	for (i = 0; i < ni_65xx_total_num_ports(board(dev)); ++i) {
 	for (i = 0; i < ni_65xx_total_num_ports(board(dev)); ++i) {
 		writeb(0x00,
 		writeb(0x00,
-			private(dev)->mite->daq_io_addr + Filter_Enable(i));
+		       private(dev)->mite->daq_io_addr + Filter_Enable(i));
 		if (board(dev)->invert_outputs)
 		if (board(dev)->invert_outputs)
 			writeb(0x01,
 			writeb(0x01,
-				private(dev)->mite->daq_io_addr + Port_Data(i));
+			       private(dev)->mite->daq_io_addr + Port_Data(i));
 		else
 		else
 			writeb(0x00,
 			writeb(0x00,
-				private(dev)->mite->daq_io_addr + Port_Data(i));
+			       private(dev)->mite->daq_io_addr + Port_Data(i));
 	}
 	}
 	writeb(ClrEdge | ClrOverflow,
 	writeb(ClrEdge | ClrOverflow,
-		private(dev)->mite->daq_io_addr + Clear_Register);
+	       private(dev)->mite->daq_io_addr + Clear_Register);
 	writeb(0x00,
 	writeb(0x00,
-		private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
+	       private(dev)->mite->daq_io_addr + Master_Interrupt_Control);
 
 
 	/* Set filter interval to 0  (32bit reg) */
 	/* Set filter interval to 0  (32bit reg) */
 	writeb(0x00000000, private(dev)->mite->daq_io_addr + Filter_Interval);
 	writeb(0x00000000, private(dev)->mite->daq_io_addr + Filter_Interval);
@@ -758,10 +778,10 @@ static int ni_65xx_attach(struct comedi_device *dev, struct comedi_devconfig *it
 static int ni_65xx_detach(struct comedi_device *dev)
 static int ni_65xx_detach(struct comedi_device *dev)
 {
 {
 	if (private(dev) && private(dev)->mite
 	if (private(dev) && private(dev)->mite
-		&& private(dev)->mite->daq_io_addr) {
+	    && private(dev)->mite->daq_io_addr) {
 		writeb(0x00,
 		writeb(0x00,
-			private(dev)->mite->daq_io_addr +
-			Master_Interrupt_Control);
+		       private(dev)->mite->daq_io_addr +
+		       Master_Interrupt_Control);
 	}
 	}
 
 
 	if (dev->irq) {
 	if (dev->irq) {
@@ -793,7 +813,7 @@ static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot)
 			continue;
 			continue;
 		if (bus || slot) {
 		if (bus || slot) {
 			if (bus != mite->pcidev->bus->number ||
 			if (bus != mite->pcidev->bus->number ||
-				slot != PCI_SLOT(mite->pcidev->devfn))
+			    slot != PCI_SLOT(mite->pcidev->devfn))
 				continue;
 				continue;
 		}
 		}
 		for (i = 0; i < n_ni_65xx_boards; i++) {
 		for (i = 0; i < n_ni_65xx_boards; i++) {

+ 168 - 125
drivers/staging/comedi/drivers/ni_660x.c

@@ -201,7 +201,6 @@ struct NI_660xRegisterData {
 	enum ni_660x_register_width size;	/*  1 byte, 2 bytes, or 4 bytes */
 	enum ni_660x_register_width size;	/*  1 byte, 2 bytes, or 4 bytes */
 };
 };
 
 
-
 static const struct NI_660xRegisterData registerData[NumRegisters] = {
 static const struct NI_660xRegisterData registerData[NumRegisters] = {
 	{"G0 Interrupt Acknowledge", 0x004, NI_660x_WRITE, DATA_2B},
 	{"G0 Interrupt Acknowledge", 0x004, NI_660x_WRITE, DATA_2B},
 	{"G0 Status Register", 0x004, NI_660x_READ, DATA_2B},
 	{"G0 Status Register", 0x004, NI_660x_READ, DATA_2B},
@@ -316,21 +315,25 @@ static inline unsigned ioconfig_bitshift(unsigned pfi_channel)
 	else
 	else
 		return 8;
 		return 8;
 }
 }
+
 static inline unsigned pfi_output_select_mask(unsigned pfi_channel)
 static inline unsigned pfi_output_select_mask(unsigned pfi_channel)
 {
 {
 	return 0x3 << ioconfig_bitshift(pfi_channel);
 	return 0x3 << ioconfig_bitshift(pfi_channel);
 }
 }
+
 static inline unsigned pfi_output_select_bits(unsigned pfi_channel,
 static inline unsigned pfi_output_select_bits(unsigned pfi_channel,
-	unsigned output_select)
+					      unsigned output_select)
 {
 {
 	return (output_select & 0x3) << ioconfig_bitshift(pfi_channel);
 	return (output_select & 0x3) << ioconfig_bitshift(pfi_channel);
 }
 }
+
 static inline unsigned pfi_input_select_mask(unsigned pfi_channel)
 static inline unsigned pfi_input_select_mask(unsigned pfi_channel)
 {
 {
 	return 0x7 << (4 + ioconfig_bitshift(pfi_channel));
 	return 0x7 << (4 + ioconfig_bitshift(pfi_channel));
 }
 }
+
 static inline unsigned pfi_input_select_bits(unsigned pfi_channel,
 static inline unsigned pfi_input_select_bits(unsigned pfi_channel,
-	unsigned input_select)
+					     unsigned input_select)
 {
 {
 	return (input_select & 0x7) << (4 + ioconfig_bitshift(pfi_channel));
 	return (input_select & 0x7) << (4 + ioconfig_bitshift(pfi_channel));
 }
 }
@@ -341,6 +344,7 @@ static inline unsigned dma_select_mask(unsigned dma_channel)
 	BUG_ON(dma_channel >= MAX_DMA_CHANNEL);
 	BUG_ON(dma_channel >= MAX_DMA_CHANNEL);
 	return 0x1f << (8 * dma_channel);
 	return 0x1f << (8 * dma_channel);
 }
 }
+
 enum dma_selection {
 enum dma_selection {
 	dma_selection_none = 0x1f,
 	dma_selection_none = 0x1f,
 };
 };
@@ -349,11 +353,13 @@ static inline unsigned dma_selection_counter(unsigned counter_index)
 	BUG_ON(counter_index >= counters_per_chip);
 	BUG_ON(counter_index >= counters_per_chip);
 	return counter_index;
 	return counter_index;
 }
 }
+
 static inline unsigned dma_select_bits(unsigned dma_channel, unsigned selection)
 static inline unsigned dma_select_bits(unsigned dma_channel, unsigned selection)
 {
 {
 	BUG_ON(dma_channel >= MAX_DMA_CHANNEL);
 	BUG_ON(dma_channel >= MAX_DMA_CHANNEL);
 	return (selection << (8 * dma_channel)) & dma_select_mask(dma_channel);
 	return (selection << (8 * dma_channel)) & dma_select_mask(dma_channel);
 }
 }
+
 static inline unsigned dma_reset_bit(unsigned dma_channel)
 static inline unsigned dma_reset_bit(unsigned dma_channel)
 {
 {
 	BUG_ON(dma_channel >= MAX_DMA_CHANNEL);
 	BUG_ON(dma_channel >= MAX_DMA_CHANNEL);
@@ -388,36 +394,37 @@ struct ni_660x_board {
 
 
 static const struct ni_660x_board ni_660x_boards[] = {
 static const struct ni_660x_board ni_660x_boards[] = {
 	{
 	{
-	.dev_id = 0x2c60,
-	.name = "PCI-6601",
-	.n_chips = 1,
-		},
+	 .dev_id = 0x2c60,
+	 .name = "PCI-6601",
+	 .n_chips = 1,
+	 },
 	{
 	{
-	.dev_id = 0x1310,
-	.name = "PCI-6602",
-	.n_chips = 2,
-		},
+	 .dev_id = 0x1310,
+	 .name = "PCI-6602",
+	 .n_chips = 2,
+	 },
 	{
 	{
-	.dev_id = 0x1360,
-	.name = "PXI-6602",
-	.n_chips = 2,
-		},
+	 .dev_id = 0x1360,
+	 .name = "PXI-6602",
+	 .n_chips = 2,
+	 },
 	{
 	{
-	.dev_id = 0x2cc0,
-	.name = "PXI-6608",
-	.n_chips = 2,
-		},
+	 .dev_id = 0x2cc0,
+	 .name = "PXI-6608",
+	 .n_chips = 2,
+	 },
 };
 };
 
 
 #define NI_660X_MAX_NUM_CHIPS 2
 #define NI_660X_MAX_NUM_CHIPS 2
 #define NI_660X_MAX_NUM_COUNTERS (NI_660X_MAX_NUM_CHIPS * counters_per_chip)
 #define NI_660X_MAX_NUM_COUNTERS (NI_660X_MAX_NUM_CHIPS * counters_per_chip)
 
 
 static DEFINE_PCI_DEVICE_TABLE(ni_660x_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(ni_660x_pci_table) = {
-	{PCI_VENDOR_ID_NATINST, 0x2c60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x1310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x2cc0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{0}
+	{
+	PCI_VENDOR_ID_NATINST, 0x2c60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x1310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x2cc0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, ni_660x_pci_table);
 MODULE_DEVICE_TABLE(pci, ni_660x_pci_table);
@@ -436,24 +443,26 @@ struct ni_660x_private {
 	unsigned short pfi_output_selects[NUM_PFI_CHANNELS];
 	unsigned short pfi_output_selects[NUM_PFI_CHANNELS];
 };
 };
 
 
-static inline struct ni_660x_private *private(struct comedi_device * dev)
+static inline struct ni_660x_private *private(struct comedi_device *dev)
 {
 {
 	return dev->private;
 	return dev->private;
 }
 }
 
 
 /* initialized in ni_660x_find_device() */
 /* initialized in ni_660x_find_device() */
-static inline const struct ni_660x_board *board(struct comedi_device * dev)
+static inline const struct ni_660x_board *board(struct comedi_device *dev)
 {
 {
 	return dev->board_ptr;
 	return dev->board_ptr;
 }
 }
 
 
-#define n_ni_660x_boards (sizeof(ni_660x_boards)/sizeof(ni_660x_boards[0]))
+#define n_ni_660x_boards ARRAY_SIZE(ni_660x_boards)
 
 
-static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int ni_660x_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int ni_660x_detach(struct comedi_device *dev);
 static int ni_660x_detach(struct comedi_device *dev);
 static void init_tio_chip(struct comedi_device *dev, int chipset);
 static void init_tio_chip(struct comedi_device *dev, int chipset);
-static void ni_660x_select_pfi_output(struct comedi_device *dev, unsigned pfi_channel,
-	unsigned output_select);
+static void ni_660x_select_pfi_output(struct comedi_device *dev,
+				      unsigned pfi_channel,
+				      unsigned output_select);
 
 
 static struct comedi_driver driver_ni_660x = {
 static struct comedi_driver driver_ni_660x = {
 	.driver_name = "ni_660x",
 	.driver_name = "ni_660x",
@@ -466,21 +475,28 @@ COMEDI_PCI_INITCLEANUP(driver_ni_660x, ni_660x_pci_table);
 
 
 static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot);
 static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot);
 static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan,
 static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan,
-	unsigned source);
+				   unsigned source);
 
 
 /* Possible instructions for a GPCT */
 /* Possible instructions for a GPCT */
 static int ni_660x_GPCT_rinsn(struct comedi_device *dev,
 static int ni_660x_GPCT_rinsn(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data);
 static int ni_660x_GPCT_insn_config(struct comedi_device *dev,
 static int ni_660x_GPCT_insn_config(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+				    struct comedi_subdevice *s,
+				    struct comedi_insn *insn,
+				    unsigned int *data);
 static int ni_660x_GPCT_winsn(struct comedi_device *dev,
 static int ni_660x_GPCT_winsn(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data);
 
 
 /* Possible instructions for Digital IO */
 /* Possible instructions for Digital IO */
 static int ni_660x_dio_insn_config(struct comedi_device *dev,
 static int ni_660x_dio_insn_config(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn,
+				   unsigned int *data);
 static int ni_660x_dio_insn_bits(struct comedi_device *dev,
 static int ni_660x_dio_insn_bits(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data);
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data);
 
 
 static inline unsigned ni_660x_num_counters(struct comedi_device *dev)
 static inline unsigned ni_660x_num_counters(struct comedi_device *dev)
 {
 {
@@ -697,7 +713,7 @@ static enum NI_660x_Register ni_gpct_to_660x_register(enum ni_gpct_register reg)
 		break;
 		break;
 	default:
 	default:
 		printk("%s: unhandled register 0x%x in switch.\n",
 		printk("%s: unhandled register 0x%x in switch.\n",
-			__func__, reg);
+		       __func__, reg);
 		BUG();
 		BUG();
 		return 0;
 		return 0;
 		break;
 		break;
@@ -706,11 +722,12 @@ static enum NI_660x_Register ni_gpct_to_660x_register(enum ni_gpct_register reg)
 }
 }
 
 
 static inline void ni_660x_write_register(struct comedi_device *dev,
 static inline void ni_660x_write_register(struct comedi_device *dev,
-	unsigned chip_index, unsigned bits, enum NI_660x_Register reg)
+					  unsigned chip_index, unsigned bits,
+					  enum NI_660x_Register reg)
 {
 {
 	void *const write_address =
 	void *const write_address =
-		private(dev)->mite->daq_io_addr + GPCT_OFFSET[chip_index] +
-		registerData[reg].offset;
+	    private(dev)->mite->daq_io_addr + GPCT_OFFSET[chip_index] +
+	    registerData[reg].offset;
 
 
 	switch (registerData[reg].size) {
 	switch (registerData[reg].size) {
 	case DATA_2B:
 	case DATA_2B:
@@ -721,18 +738,19 @@ static inline void ni_660x_write_register(struct comedi_device *dev,
 		break;
 		break;
 	default:
 	default:
 		printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n",
 		printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n",
-			__FILE__, __func__, reg);
+		       __FILE__, __func__, reg);
 		BUG();
 		BUG();
 		break;
 		break;
 	}
 	}
 }
 }
 
 
 static inline unsigned ni_660x_read_register(struct comedi_device *dev,
 static inline unsigned ni_660x_read_register(struct comedi_device *dev,
-	unsigned chip_index, enum NI_660x_Register reg)
+					     unsigned chip_index,
+					     enum NI_660x_Register reg)
 {
 {
 	void *const read_address =
 	void *const read_address =
-		private(dev)->mite->daq_io_addr + GPCT_OFFSET[chip_index] +
-		registerData[reg].offset;
+	    private(dev)->mite->daq_io_addr + GPCT_OFFSET[chip_index] +
+	    registerData[reg].offset;
 
 
 	switch (registerData[reg].size) {
 	switch (registerData[reg].size) {
 	case DATA_2B:
 	case DATA_2B:
@@ -743,7 +761,7 @@ static inline unsigned ni_660x_read_register(struct comedi_device *dev,
 		break;
 		break;
 	default:
 	default:
 		printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n",
 		printk("%s: %s: bug! unhandled case (reg=0x%x) in switch.\n",
-			__FILE__, __func__, reg);
+		       __FILE__, __func__, reg);
 		BUG();
 		BUG();
 		break;
 		break;
 	}
 	}
@@ -751,65 +769,72 @@ static inline unsigned ni_660x_read_register(struct comedi_device *dev,
 }
 }
 
 
 static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits,
 static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits,
-	enum ni_gpct_register reg)
+				   enum ni_gpct_register reg)
 {
 {
 	struct comedi_device *dev = counter->counter_dev->dev;
 	struct comedi_device *dev = counter->counter_dev->dev;
 	enum NI_660x_Register ni_660x_register = ni_gpct_to_660x_register(reg);
 	enum NI_660x_Register ni_660x_register = ni_gpct_to_660x_register(reg);
 	ni_660x_write_register(dev, counter->chip_index, bits,
 	ni_660x_write_register(dev, counter->chip_index, bits,
-		ni_660x_register);
+			       ni_660x_register);
 }
 }
 
 
 static unsigned ni_gpct_read_register(struct ni_gpct *counter,
 static unsigned ni_gpct_read_register(struct ni_gpct *counter,
-	enum ni_gpct_register reg)
+				      enum ni_gpct_register reg)
 {
 {
 	struct comedi_device *dev = counter->counter_dev->dev;
 	struct comedi_device *dev = counter->counter_dev->dev;
 	enum NI_660x_Register ni_660x_register = ni_gpct_to_660x_register(reg);
 	enum NI_660x_Register ni_660x_register = ni_gpct_to_660x_register(reg);
 	return ni_660x_read_register(dev, counter->chip_index,
 	return ni_660x_read_register(dev, counter->chip_index,
-		ni_660x_register);
+				     ni_660x_register);
 }
 }
 
 
-static inline struct mite_dma_descriptor_ring *mite_ring(struct ni_660x_private * priv,
-	struct ni_gpct *counter)
+static inline struct mite_dma_descriptor_ring *mite_ring(struct ni_660x_private
+							 *priv,
+							 struct ni_gpct
+							 *counter)
 {
 {
 	return priv->mite_rings[counter->chip_index][counter->counter_index];
 	return priv->mite_rings[counter->chip_index][counter->counter_index];
 }
 }
 
 
 static inline void ni_660x_set_dma_channel(struct comedi_device *dev,
 static inline void ni_660x_set_dma_channel(struct comedi_device *dev,
-	unsigned mite_channel, struct ni_gpct *counter)
+					   unsigned mite_channel,
+					   struct ni_gpct *counter)
 {
 {
 	unsigned long flags;
 	unsigned long flags;
 	spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags);
 	spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags);
 	private(dev)->dma_configuration_soft_copies[counter->chip_index] &=
 	private(dev)->dma_configuration_soft_copies[counter->chip_index] &=
-		~dma_select_mask(mite_channel);
+	    ~dma_select_mask(mite_channel);
 	private(dev)->dma_configuration_soft_copies[counter->chip_index] |=
 	private(dev)->dma_configuration_soft_copies[counter->chip_index] |=
-		dma_select_bits(mite_channel,
-		dma_selection_counter(counter->counter_index));
+	    dma_select_bits(mite_channel,
+			    dma_selection_counter(counter->counter_index));
 	ni_660x_write_register(dev, counter->chip_index,
 	ni_660x_write_register(dev, counter->chip_index,
-		private(dev)->dma_configuration_soft_copies[counter->
-			chip_index] | dma_reset_bit(mite_channel),
-		DMAConfigRegister);
+			       private(dev)->
+			       dma_configuration_soft_copies
+			       [counter->chip_index] |
+			       dma_reset_bit(mite_channel), DMAConfigRegister);
 	mmiowb();
 	mmiowb();
 	spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags);
 	spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags);
 }
 }
 
 
 static inline void ni_660x_unset_dma_channel(struct comedi_device *dev,
 static inline void ni_660x_unset_dma_channel(struct comedi_device *dev,
-	unsigned mite_channel, struct ni_gpct *counter)
+					     unsigned mite_channel,
+					     struct ni_gpct *counter)
 {
 {
 	unsigned long flags;
 	unsigned long flags;
 	spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags);
 	spin_lock_irqsave(&private(dev)->soft_reg_copy_lock, flags);
 	private(dev)->dma_configuration_soft_copies[counter->chip_index] &=
 	private(dev)->dma_configuration_soft_copies[counter->chip_index] &=
-		~dma_select_mask(mite_channel);
+	    ~dma_select_mask(mite_channel);
 	private(dev)->dma_configuration_soft_copies[counter->chip_index] |=
 	private(dev)->dma_configuration_soft_copies[counter->chip_index] |=
-		dma_select_bits(mite_channel, dma_selection_none);
+	    dma_select_bits(mite_channel, dma_selection_none);
 	ni_660x_write_register(dev, counter->chip_index,
 	ni_660x_write_register(dev, counter->chip_index,
-		private(dev)->dma_configuration_soft_copies[counter->
-			chip_index], DMAConfigRegister);
+			       private(dev)->
+			       dma_configuration_soft_copies
+			       [counter->chip_index], DMAConfigRegister);
 	mmiowb();
 	mmiowb();
 	spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags);
 	spin_unlock_irqrestore(&private(dev)->soft_reg_copy_lock, flags);
 }
 }
 
 
 static int ni_660x_request_mite_channel(struct comedi_device *dev,
 static int ni_660x_request_mite_channel(struct comedi_device *dev,
-	struct ni_gpct *counter, enum comedi_io_direction direction)
+					struct ni_gpct *counter,
+					enum comedi_io_direction direction)
 {
 {
 	unsigned long flags;
 	unsigned long flags;
 	struct mite_channel *mite_chan;
 	struct mite_channel *mite_chan;
@@ -817,13 +842,12 @@ static int ni_660x_request_mite_channel(struct comedi_device *dev,
 	spin_lock_irqsave(&private(dev)->mite_channel_lock, flags);
 	spin_lock_irqsave(&private(dev)->mite_channel_lock, flags);
 	BUG_ON(counter->mite_chan);
 	BUG_ON(counter->mite_chan);
 	mite_chan =
 	mite_chan =
-		mite_request_channel(private(dev)->mite, mite_ring(private(dev),
-			counter));
+	    mite_request_channel(private(dev)->mite, mite_ring(private(dev),
+							       counter));
 	if (mite_chan == NULL) {
 	if (mite_chan == NULL) {
-		spin_unlock_irqrestore(&private(dev)->mite_channel_lock,
-			flags);
+		spin_unlock_irqrestore(&private(dev)->mite_channel_lock, flags);
 		comedi_error(dev,
 		comedi_error(dev,
-			"failed to reserve mite dma channel for counter.");
+			     "failed to reserve mite dma channel for counter.");
 		return -EBUSY;
 		return -EBUSY;
 	}
 	}
 	mite_chan->dir = direction;
 	mite_chan->dir = direction;
@@ -833,7 +857,8 @@ static int ni_660x_request_mite_channel(struct comedi_device *dev,
 	return 0;
 	return 0;
 }
 }
 
 
-void ni_660x_release_mite_channel(struct comedi_device *dev, struct ni_gpct *counter)
+void ni_660x_release_mite_channel(struct comedi_device *dev,
+				  struct ni_gpct *counter)
 {
 {
 	unsigned long flags;
 	unsigned long flags;
 
 
@@ -858,7 +883,7 @@ static int ni_660x_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	retval = ni_660x_request_mite_channel(dev, counter, COMEDI_INPUT);
 	retval = ni_660x_request_mite_channel(dev, counter, COMEDI_INPUT);
 	if (retval) {
 	if (retval) {
 		comedi_error(dev,
 		comedi_error(dev,
-			"no dma channel available for use by counter");
+			     "no dma channel available for use by counter");
 		return retval;
 		return retval;
 	}
 	}
 	ni_tio_acknowledge_and_confirm(counter, NULL, NULL, NULL, NULL);
 	ni_tio_acknowledge_and_confirm(counter, NULL, NULL, NULL, NULL);
@@ -867,8 +892,8 @@ static int ni_660x_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	return retval;
 	return retval;
 }
 }
 
 
-static int ni_660x_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int ni_660x_cmdtest(struct comedi_device *dev,
+			   struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
 {
 	struct ni_gpct *counter = subdev_to_counter(s);
 	struct ni_gpct *counter = subdev_to_counter(s);
 
 
@@ -893,19 +918,18 @@ static void set_tio_counterswap(struct comedi_device *dev, int chipset)
 	 */
 	 */
 	if (chipset)
 	if (chipset)
 		ni_660x_write_register(dev, chipset, CounterSwap,
 		ni_660x_write_register(dev, chipset, CounterSwap,
-			ClockConfigRegister);
+				       ClockConfigRegister);
 	else
 	else
 		ni_660x_write_register(dev, chipset, 0, ClockConfigRegister);
 		ni_660x_write_register(dev, chipset, 0, ClockConfigRegister);
 }
 }
 
 
 static void ni_660x_handle_gpct_interrupt(struct comedi_device *dev,
 static void ni_660x_handle_gpct_interrupt(struct comedi_device *dev,
-	struct comedi_subdevice *s)
+					  struct comedi_subdevice *s)
 {
 {
 	ni_tio_handle_interrupt(subdev_to_counter(s), s);
 	ni_tio_handle_interrupt(subdev_to_counter(s), s);
 	if (s->async->events) {
 	if (s->async->events) {
-		if (s->async->
-			events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
-				COMEDI_CB_OVERFLOW)) {
+		if (s->async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
+					COMEDI_CB_OVERFLOW)) {
 			ni_660x_cancel(dev, s);
 			ni_660x_cancel(dev, s);
 		}
 		}
 		comedi_event(dev, s);
 		comedi_event(dev, s);
@@ -943,13 +967,14 @@ static int ni_660x_input_poll(struct comedi_device *dev,
 	return comedi_buf_read_n_available(s->async);
 	return comedi_buf_read_n_available(s->async);
 }
 }
 
 
-static int ni_660x_buf_change(struct comedi_device *dev, struct comedi_subdevice *s,
-	unsigned long new_size)
+static int ni_660x_buf_change(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      unsigned long new_size)
 {
 {
 	int ret;
 	int ret;
 
 
 	ret = mite_buf_change(mite_ring(private(dev), subdev_to_counter(s)),
 	ret = mite_buf_change(mite_ring(private(dev), subdev_to_counter(s)),
-		s->async);
+			      s->async);
 	if (ret < 0)
 	if (ret < 0)
 		return ret;
 		return ret;
 
 
@@ -982,7 +1007,7 @@ static int ni_660x_alloc_mite_rings(struct comedi_device *dev)
 	for (i = 0; i < board(dev)->n_chips; ++i) {
 	for (i = 0; i < board(dev)->n_chips; ++i) {
 		for (j = 0; j < counters_per_chip; ++j) {
 		for (j = 0; j < counters_per_chip; ++j) {
 			private(dev)->mite_rings[i][j] =
 			private(dev)->mite_rings[i][j] =
-				mite_alloc_ring(private(dev)->mite);
+			    mite_alloc_ring(private(dev)->mite);
 			if (private(dev)->mite_rings[i][j] == NULL) {
 			if (private(dev)->mite_rings[i][j] == NULL) {
 				return -ENOMEM;
 				return -ENOMEM;
 			}
 			}
@@ -1003,7 +1028,8 @@ static void ni_660x_free_mite_rings(struct comedi_device *dev)
 	}
 	}
 }
 }
 
 
-static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int ni_660x_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int ret;
 	int ret;
@@ -1056,8 +1082,11 @@ static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	ni_660x_write_register(dev, 0, 0, STCDIOControl);
 	ni_660x_write_register(dev, 0, 0, STCDIOControl);
 
 
 	private(dev)->counter_dev = ni_gpct_device_construct(dev,
 	private(dev)->counter_dev = ni_gpct_device_construct(dev,
-		&ni_gpct_write_register, &ni_gpct_read_register,
-		ni_gpct_variant_660x, ni_660x_num_counters(dev));
+							     &ni_gpct_write_register,
+							     &ni_gpct_read_register,
+							     ni_gpct_variant_660x,
+							     ni_660x_num_counters
+							     (dev));
 	if (private(dev)->counter_dev == NULL)
 	if (private(dev)->counter_dev == NULL)
 		return -ENOMEM;
 		return -ENOMEM;
 	for (i = 0; i < NI_660X_MAX_NUM_COUNTERS; ++i) {
 	for (i = 0; i < NI_660X_MAX_NUM_COUNTERS; ++i) {
@@ -1065,8 +1094,8 @@ static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		if (i < ni_660x_num_counters(dev)) {
 		if (i < ni_660x_num_counters(dev)) {
 			s->type = COMEDI_SUBD_COUNTER;
 			s->type = COMEDI_SUBD_COUNTER;
 			s->subdev_flags =
 			s->subdev_flags =
-				SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL |
-				SDF_CMD_READ /* | SDF_CMD_WRITE */ ;
+			    SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL |
+			    SDF_CMD_READ /* | SDF_CMD_WRITE */ ;
 			s->n_chan = 3;
 			s->n_chan = 3;
 			s->maxdata = 0xffffffff;
 			s->maxdata = 0xffffffff;
 			s->insn_read = ni_660x_GPCT_rinsn;
 			s->insn_read = ni_660x_GPCT_rinsn;
@@ -1082,9 +1111,9 @@ static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it
 			s->private = &private(dev)->counter_dev->counters[i];
 			s->private = &private(dev)->counter_dev->counters[i];
 
 
 			private(dev)->counter_dev->counters[i].chip_index =
 			private(dev)->counter_dev->counters[i].chip_index =
-				i / counters_per_chip;
+			    i / counters_per_chip;
 			private(dev)->counter_dev->counters[i].counter_index =
 			private(dev)->counter_dev->counters[i].counter_index =
-				i % counters_per_chip;
+			    i % counters_per_chip;
 		} else {
 		} else {
 			s->type = COMEDI_SUBD_UNUSED;
 			s->type = COMEDI_SUBD_UNUSED;
 		}
 		}
@@ -1100,7 +1129,7 @@ static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it
 			ni_660x_set_pfi_routing(dev, i, pfi_output_select_do);
 			ni_660x_set_pfi_routing(dev, i, pfi_output_select_do);
 		else
 		else
 			ni_660x_set_pfi_routing(dev, i,
 			ni_660x_set_pfi_routing(dev, i,
-				pfi_output_select_counter);
+						pfi_output_select_counter);
 		ni_660x_select_pfi_output(dev, i, pfi_output_select_high_Z);
 		ni_660x_select_pfi_output(dev, i, pfi_output_select_high_Z);
 	}
 	}
 	/* to be safe, set counterswap bits on tio chips after all the counter
 	/* to be safe, set counterswap bits on tio chips after all the counter
@@ -1119,7 +1148,7 @@ static int ni_660x_attach(struct comedi_device *dev, struct comedi_devconfig *it
 	if (board(dev)->n_chips > 1)
 	if (board(dev)->n_chips > 1)
 		global_interrupt_config_bits |= Cascade_Int_Enable_Bit;
 		global_interrupt_config_bits |= Cascade_Int_Enable_Bit;
 	ni_660x_write_register(dev, 0, global_interrupt_config_bits,
 	ni_660x_write_register(dev, 0, global_interrupt_config_bits,
-		GlobalInterruptConfigRegister);
+			       GlobalInterruptConfigRegister);
 	printk("attached\n");
 	printk("attached\n");
 	return 0;
 	return 0;
 }
 }
@@ -1145,7 +1174,7 @@ static int ni_660x_detach(struct comedi_device *dev)
 
 
 static int
 static int
 ni_660x_GPCT_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 ni_660x_GPCT_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+		   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	return ni_tio_rinsn(subdev_to_counter(s), insn, data);
 	return ni_tio_rinsn(subdev_to_counter(s), insn, data);
 }
 }
@@ -1158,27 +1187,27 @@ static void init_tio_chip(struct comedi_device *dev, int chipset)
 	private(dev)->dma_configuration_soft_copies[chipset] = 0;
 	private(dev)->dma_configuration_soft_copies[chipset] = 0;
 	for (i = 0; i < MAX_DMA_CHANNEL; ++i) {
 	for (i = 0; i < MAX_DMA_CHANNEL; ++i) {
 		private(dev)->dma_configuration_soft_copies[chipset] |=
 		private(dev)->dma_configuration_soft_copies[chipset] |=
-			dma_select_bits(i,
-			dma_selection_none) & dma_select_mask(i);
+		    dma_select_bits(i, dma_selection_none) & dma_select_mask(i);
 	}
 	}
 	ni_660x_write_register(dev, chipset,
 	ni_660x_write_register(dev, chipset,
-		private(dev)->dma_configuration_soft_copies[chipset],
-		DMAConfigRegister);
-	for (i = 0; i < NUM_PFI_CHANNELS; ++i)
-	{
+			       private(dev)->
+			       dma_configuration_soft_copies[chipset],
+			       DMAConfigRegister);
+	for (i = 0; i < NUM_PFI_CHANNELS; ++i) {
 		ni_660x_write_register(dev, chipset, 0, IOConfigReg(i));
 		ni_660x_write_register(dev, chipset, 0, IOConfigReg(i));
 	}
 	}
 }
 }
 
 
 static int
 static int
 ni_660x_GPCT_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
 ni_660x_GPCT_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	return ni_tio_insn_config(subdev_to_counter(s), insn, data);
 	return ni_tio_insn_config(subdev_to_counter(s), insn, data);
 }
 }
 
 
 static int ni_660x_GPCT_winsn(struct comedi_device *dev,
 static int ni_660x_GPCT_winsn(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data)
 {
 {
 	return ni_tio_winsn(subdev_to_counter(s), insn, data);
 	return ni_tio_winsn(subdev_to_counter(s), insn, data);
 }
 }
@@ -1193,7 +1222,7 @@ static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot)
 			continue;
 			continue;
 		if (bus || slot) {
 		if (bus || slot) {
 			if (bus != mite->pcidev->bus->number ||
 			if (bus != mite->pcidev->bus->number ||
-				slot != PCI_SLOT(mite->pcidev->devfn))
+			    slot != PCI_SLOT(mite->pcidev->devfn))
 				continue;
 				continue;
 		}
 		}
 
 
@@ -1211,7 +1240,8 @@ static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot)
 }
 }
 
 
 static int ni_660x_dio_insn_bits(struct comedi_device *dev,
 static int ni_660x_dio_insn_bits(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned base_bitfield_channel = CR_CHAN(insn->chanspec);
 	unsigned base_bitfield_channel = CR_CHAN(insn->chanspec);
 
 
@@ -1225,13 +1255,14 @@ static int ni_660x_dio_insn_bits(struct comedi_device *dev,
 	/* on return, data[1] contains the value of the digital
 	/* on return, data[1] contains the value of the digital
 	 * input and output lines. */
 	 * input and output lines. */
 	data[1] =
 	data[1] =
-		(ni_660x_read_register(dev, 0,
-			DIO32Input) >> base_bitfield_channel);
+	    (ni_660x_read_register(dev, 0,
+				   DIO32Input) >> base_bitfield_channel);
 	return 2;
 	return 2;
 }
 }
 
 
-static void ni_660x_select_pfi_output(struct comedi_device *dev, unsigned pfi_channel,
-	unsigned output_select)
+static void ni_660x_select_pfi_output(struct comedi_device *dev,
+				      unsigned pfi_channel,
+				      unsigned output_select)
 {
 {
 	static const unsigned counter_4_7_first_pfi = 8;
 	static const unsigned counter_4_7_first_pfi = 8;
 	static const unsigned counter_4_7_last_pfi = 23;
 	static const unsigned counter_4_7_last_pfi = 23;
@@ -1240,33 +1271,41 @@ static void ni_660x_select_pfi_output(struct comedi_device *dev, unsigned pfi_ch
 	unsigned active_bits;
 	unsigned active_bits;
 	unsigned idle_bits;
 	unsigned idle_bits;
 
 
-	if (board (dev)->n_chips > 1) {
+	if (board(dev)->n_chips > 1) {
 		if (output_select == pfi_output_select_counter &&
 		if (output_select == pfi_output_select_counter &&
-			pfi_channel >= counter_4_7_first_pfi &&
-			pfi_channel <= counter_4_7_last_pfi) {
+		    pfi_channel >= counter_4_7_first_pfi &&
+		    pfi_channel <= counter_4_7_last_pfi) {
 			active_chipset = 1;
 			active_chipset = 1;
 			idle_chipset = 0;
 			idle_chipset = 0;
-		}else {
+		} else {
 			active_chipset = 0;
 			active_chipset = 0;
 			idle_chipset = 1;
 			idle_chipset = 1;
 		}
 		}
 	}
 	}
 
 
 	if (idle_chipset != active_chipset) {
 	if (idle_chipset != active_chipset) {
-		idle_bits = ni_660x_read_register(dev, idle_chipset, IOConfigReg(pfi_channel));
+		idle_bits =
+		    ni_660x_read_register(dev, idle_chipset,
+					  IOConfigReg(pfi_channel));
 		idle_bits &= ~pfi_output_select_mask(pfi_channel);
 		idle_bits &= ~pfi_output_select_mask(pfi_channel);
-		idle_bits |= pfi_output_select_bits(pfi_channel, pfi_output_select_high_Z);
-		ni_660x_write_register(dev, idle_chipset, idle_bits, IOConfigReg(pfi_channel));
+		idle_bits |=
+		    pfi_output_select_bits(pfi_channel,
+					   pfi_output_select_high_Z);
+		ni_660x_write_register(dev, idle_chipset, idle_bits,
+				       IOConfigReg(pfi_channel));
 	}
 	}
 
 
-	active_bits = ni_660x_read_register(dev, active_chipset, IOConfigReg(pfi_channel));
+	active_bits =
+	    ni_660x_read_register(dev, active_chipset,
+				  IOConfigReg(pfi_channel));
 	active_bits &= ~pfi_output_select_mask(pfi_channel);
 	active_bits &= ~pfi_output_select_mask(pfi_channel);
 	active_bits |= pfi_output_select_bits(pfi_channel, output_select);
 	active_bits |= pfi_output_select_bits(pfi_channel, output_select);
-	ni_660x_write_register(dev, active_chipset, active_bits, IOConfigReg(pfi_channel));
+	ni_660x_write_register(dev, active_chipset, active_bits,
+			       IOConfigReg(pfi_channel));
 }
 }
 
 
 static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan,
 static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan,
-	unsigned source)
+				   unsigned source)
 {
 {
 	if (source > num_pfi_output_selects)
 	if (source > num_pfi_output_selects)
 		return -EINVAL;
 		return -EINVAL;
@@ -1284,18 +1323,21 @@ static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan,
 	private(dev)->pfi_output_selects[chan] = source;
 	private(dev)->pfi_output_selects[chan] = source;
 	if (private(dev)->pfi_direction_bits & (((uint64_t) 1) << chan))
 	if (private(dev)->pfi_direction_bits & (((uint64_t) 1) << chan))
 		ni_660x_select_pfi_output(dev, chan,
 		ni_660x_select_pfi_output(dev, chan,
-			private(dev)->pfi_output_selects[chan]);
+					  private(dev)->
+					  pfi_output_selects[chan]);
 	return 0;
 	return 0;
 }
 }
 
 
-static unsigned ni_660x_get_pfi_routing(struct comedi_device *dev, unsigned chan)
+static unsigned ni_660x_get_pfi_routing(struct comedi_device *dev,
+					unsigned chan)
 {
 {
 	BUG_ON(chan >= NUM_PFI_CHANNELS);
 	BUG_ON(chan >= NUM_PFI_CHANNELS);
 	return private(dev)->pfi_output_selects[chan];
 	return private(dev)->pfi_output_selects[chan];
 }
 }
 
 
-static void ni660x_config_filter(struct comedi_device *dev, unsigned pfi_channel,
-	enum ni_gpct_filter_select filter)
+static void ni660x_config_filter(struct comedi_device *dev,
+				 unsigned pfi_channel,
+				 enum ni_gpct_filter_select filter)
 {
 {
 	unsigned bits = ni_660x_read_register(dev, 0, IOConfigReg(pfi_channel));
 	unsigned bits = ni_660x_read_register(dev, 0, IOConfigReg(pfi_channel));
 	bits &= ~pfi_input_select_mask(pfi_channel);
 	bits &= ~pfi_input_select_mask(pfi_channel);
@@ -1304,7 +1346,8 @@ static void ni660x_config_filter(struct comedi_device *dev, unsigned pfi_channel
 }
 }
 
 
 static int ni_660x_dio_insn_config(struct comedi_device *dev,
 static int ni_660x_dio_insn_config(struct comedi_device *dev,
-	struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data)
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
 
 
@@ -1317,7 +1360,8 @@ static int ni_660x_dio_insn_config(struct comedi_device *dev,
 	case INSN_CONFIG_DIO_OUTPUT:
 	case INSN_CONFIG_DIO_OUTPUT:
 		private(dev)->pfi_direction_bits |= ((uint64_t) 1) << chan;
 		private(dev)->pfi_direction_bits |= ((uint64_t) 1) << chan;
 		ni_660x_select_pfi_output(dev, chan,
 		ni_660x_select_pfi_output(dev, chan,
-			private(dev)->pfi_output_selects[chan]);
+					  private(dev)->
+					  pfi_output_selects[chan]);
 		break;
 		break;
 	case INSN_CONFIG_DIO_INPUT:
 	case INSN_CONFIG_DIO_INPUT:
 		private(dev)->pfi_direction_bits &= ~(((uint64_t) 1) << chan);
 		private(dev)->pfi_direction_bits &= ~(((uint64_t) 1) << chan);
@@ -1325,9 +1369,8 @@ static int ni_660x_dio_insn_config(struct comedi_device *dev,
 		break;
 		break;
 	case INSN_CONFIG_DIO_QUERY:
 	case INSN_CONFIG_DIO_QUERY:
 		data[1] =
 		data[1] =
-			(private(dev)->
-			pfi_direction_bits & (((uint64_t) 1) << chan)) ?
-			COMEDI_OUTPUT : COMEDI_INPUT;
+		    (private(dev)->pfi_direction_bits &
+		     (((uint64_t) 1) << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
 		return 0;
 		return 0;
 	case INSN_CONFIG_SET_ROUTING:
 	case INSN_CONFIG_SET_ROUTING:
 		return ni_660x_set_pfi_routing(dev, chan, data[1]);
 		return ni_660x_set_pfi_routing(dev, chan, data[1]);

+ 56 - 45
drivers/staging/comedi/drivers/ni_670x.c

@@ -70,30 +70,32 @@ struct ni_670x_board {
 
 
 static const struct ni_670x_board ni_670x_boards[] = {
 static const struct ni_670x_board ni_670x_boards[] = {
 	{
 	{
-	.dev_id = 0x2c90,
-	.name = "PCI-6703",
-	.ao_chans = 16,
-	.ao_bits = 16,
-		},
+	 .dev_id = 0x2c90,
+	 .name = "PCI-6703",
+	 .ao_chans = 16,
+	 .ao_bits = 16,
+	 },
 	{
 	{
-	.dev_id = 0x1920,
-	.name = "PXI-6704",
-	.ao_chans = 32,
-	.ao_bits = 16,
-		},
+	 .dev_id = 0x1920,
+	 .name = "PXI-6704",
+	 .ao_chans = 32,
+	 .ao_bits = 16,
+	 },
 	{
 	{
-	.dev_id = 0x1290,
-	.name = "PCI-6704",
-	.ao_chans = 32,
-	.ao_bits = 16,
-		},
+	 .dev_id = 0x1290,
+	 .name = "PCI-6704",
+	 .ao_chans = 32,
+	 .ao_bits = 16,
+	 },
 };
 };
 
 
 static DEFINE_PCI_DEVICE_TABLE(ni_670x_pci_table) = {
 static DEFINE_PCI_DEVICE_TABLE(ni_670x_pci_table) = {
-	{PCI_VENDOR_ID_NATINST, 0x2c90, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{PCI_VENDOR_ID_NATINST, 0x1920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	/* { PCI_VENDOR_ID_NATINST, 0x0000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
-	{0}
+	{
+	PCI_VENDOR_ID_NATINST, 0x2c90, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {
+	PCI_VENDOR_ID_NATINST, 0x1920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	    /* { PCI_VENDOR_ID_NATINST, 0x0000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, */
+	{
+	0}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pci, ni_670x_pci_table);
 MODULE_DEVICE_TABLE(pci, ni_670x_pci_table);
@@ -108,11 +110,11 @@ struct ni_670x_private {
 	unsigned int ao_readback[32];
 	unsigned int ao_readback[32];
 };
 };
 
 
-
 #define devpriv ((struct ni_670x_private *)dev->private)
 #define devpriv ((struct ni_670x_private *)dev->private)
-#define n_ni_670x_boards (sizeof(ni_670x_boards)/sizeof(ni_670x_boards[0]))
+#define n_ni_670x_boards ARRAY_SIZE(ni_670x_boards)
 
 
-static int ni_670x_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int ni_670x_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it);
 static int ni_670x_detach(struct comedi_device *dev);
 static int ni_670x_detach(struct comedi_device *dev);
 
 
 static struct comedi_driver driver_ni_670x = {
 static struct comedi_driver driver_ni_670x = {
@@ -128,16 +130,22 @@ static struct comedi_lrange range_0_20mA = { 1, {RANGE_mA(0, 20)} };
 
 
 static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot);
 static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot);
 
 
-static int ni_670x_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int ni_670x_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int ni_670x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-
-static int ni_670x_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int ni_670x_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int ni_670x_ao_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data);
+static int ni_670x_dio_insn_bits(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data);
+static int ni_670x_dio_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn,
+				   unsigned int *data);
+
+static int ni_670x_attach(struct comedi_device *dev,
+			  struct comedi_devconfig *it)
 {
 {
 	struct comedi_subdevice *s;
 	struct comedi_subdevice *s;
 	int ret;
 	int ret;
@@ -175,7 +183,7 @@ static int ni_670x_attach(struct comedi_device *dev, struct comedi_devconfig *it
 		const struct comedi_lrange **range_table_list;
 		const struct comedi_lrange **range_table_list;
 
 
 		range_table_list = kmalloc(sizeof(struct comedi_lrange *) * 32,
 		range_table_list = kmalloc(sizeof(struct comedi_lrange *) * 32,
-			GFP_KERNEL);
+					   GFP_KERNEL);
 		if (!range_table_list)
 		if (!range_table_list)
 			return -ENOMEM;
 			return -ENOMEM;
 		s->range_table_list = range_table_list;
 		s->range_table_list = range_table_list;
@@ -223,8 +231,9 @@ static int ni_670x_detach(struct comedi_device *dev)
 	return 0;
 	return 0;
 }
 }
 
 
-static int ni_670x_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni_670x_ao_winsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -249,8 +258,9 @@ static int ni_670x_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *
 	return i;
 	return i;
 }
 }
 
 
-static int ni_670x_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni_670x_ao_rinsn(struct comedi_device *dev,
+			    struct comedi_subdevice *s,
+			    struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -261,8 +271,9 @@ static int ni_670x_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *
 	return i;
 	return i;
 }
 }
 
 
-static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni_670x_dio_insn_bits(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -273,7 +284,7 @@ static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
 		s->state &= ~data[0];
 		s->state &= ~data[0];
 		s->state |= data[0] & data[1];
 		s->state |= data[0] & data[1];
 		writel(s->state,
 		writel(s->state,
-			devpriv->mite->daq_io_addr + DIO_PORT0_DATA_OFFSET);
+		       devpriv->mite->daq_io_addr + DIO_PORT0_DATA_OFFSET);
 	}
 	}
 
 
 	/* on return, data[1] contains the value of the digital
 	/* on return, data[1] contains the value of the digital
@@ -283,8 +294,9 @@ static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdev
 	return 2;
 	return 2;
 }
 }
 
 
-static int ni_670x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int ni_670x_dio_insn_config(struct comedi_device *dev,
+				   struct comedi_subdevice *s,
+				   struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
 
 
@@ -297,8 +309,7 @@ static int ni_670x_dio_insn_config(struct comedi_device *dev, struct comedi_subd
 		break;
 		break;
 	case INSN_CONFIG_DIO_QUERY:
 	case INSN_CONFIG_DIO_QUERY:
 		data[1] =
 		data[1] =
-			(s->
-			io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+		    (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
 		return insn->n;
 		return insn->n;
 		break;
 		break;
 	default:
 	default:
@@ -320,7 +331,7 @@ static int ni_670x_find_device(struct comedi_device *dev, int bus, int slot)
 			continue;
 			continue;
 		if (bus || slot) {
 		if (bus || slot) {
 			if (bus != mite->pcidev->bus->number
 			if (bus != mite->pcidev->bus->number
-				|| slot != PCI_SLOT(mite->pcidev->devfn))
+			    || slot != PCI_SLOT(mite->pcidev->devfn))
 				continue;
 				continue;
 		}
 		}
 
 

+ 47 - 46
drivers/staging/comedi/drivers/ni_at_a2150.c

@@ -131,25 +131,25 @@ struct a2150_board {
 static const struct comedi_lrange range_a2150 = {
 static const struct comedi_lrange range_a2150 = {
 	1,
 	1,
 	{
 	{
-			RANGE(-2.828, 2.828),
-		}
+	 RANGE(-2.828, 2.828),
+	 }
 };
 };
 
 
 /* enum must match board indices */
 /* enum must match board indices */
 enum { a2150_c, a2150_s };
 enum { a2150_c, a2150_s };
 static const struct a2150_board a2150_boards[] = {
 static const struct a2150_board a2150_boards[] = {
 	{
 	{
-	.name = "at-a2150c",
-	.clock = {31250, 22676, 20833, 19531},
-	.num_clocks = 4,
-	.ai_speed = 19531,
-		},
+	 .name = "at-a2150c",
+	 .clock = {31250, 22676, 20833, 19531},
+	 .num_clocks = 4,
+	 .ai_speed = 19531,
+	 },
 	{
 	{
-	.name = "at-a2150s",
-	.clock = {62500, 50000, 41667, 0},
-	.num_clocks = 3,
-	.ai_speed = 41667,
-		},
+	 .name = "at-a2150s",
+	 .clock = {62500, 50000, 41667, 0},
+	 .num_clocks = 3,
+	 .ai_speed = 41667,
+	 },
 };
 };
 
 
 /*
 /*
@@ -167,7 +167,6 @@ struct a2150_private {
 	int config_bits;	/*  config register bits */
 	int config_bits;	/*  config register bits */
 };
 };
 
 
-
 #define devpriv ((struct a2150_private *)dev->private)
 #define devpriv ((struct a2150_private *)dev->private)
 
 
 static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it);
 static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it);
@@ -182,16 +181,17 @@ static struct comedi_driver driver_a2150 = {
 };
 };
 
 
 static irqreturn_t a2150_interrupt(int irq, void *d);
 static irqreturn_t a2150_interrupt(int irq, void *d);
-static int a2150_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd);
+static int a2150_ai_cmdtest(struct comedi_device *dev,
+			    struct comedi_subdevice *s, struct comedi_cmd *cmd);
 static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
 static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
 static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+			  struct comedi_insn *insn, unsigned int *data);
 static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
 static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
-	int flags);
+			    int flags);
 static int a2150_probe(struct comedi_device *dev);
 static int a2150_probe(struct comedi_device *dev);
-static int a2150_set_chanlist(struct comedi_device *dev, unsigned int start_channel,
-	unsigned int num_channels);
+static int a2150_set_chanlist(struct comedi_device *dev,
+			      unsigned int start_channel,
+			      unsigned int num_channels);
 /*
 /*
  * A convenient macro that defines init_module() and cleanup_module(),
  * A convenient macro that defines init_module() and cleanup_module(),
  * as necessary.
  * as necessary.
@@ -335,7 +335,7 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	int i;
 	int i;
 
 
 	printk("comedi%d: %s: io 0x%lx", dev->minor, driver_a2150.driver_name,
 	printk("comedi%d: %s: io 0x%lx", dev->minor, driver_a2150.driver_name,
-		iobase);
+	       iobase);
 	if (irq) {
 	if (irq) {
 		printk(", irq %u", irq);
 		printk(", irq %u", irq);
 	} else {
 	} else {
@@ -391,7 +391,7 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		}
 		}
 		devpriv->dma = dma;
 		devpriv->dma = dma;
 		devpriv->dma_buffer =
 		devpriv->dma_buffer =
-			kmalloc(A2150_DMA_BUFFER_SIZE, GFP_KERNEL | GFP_DMA);
+		    kmalloc(A2150_DMA_BUFFER_SIZE, GFP_KERNEL | GFP_DMA);
 		if (devpriv->dma_buffer == NULL)
 		if (devpriv->dma_buffer == NULL)
 			return -ENOMEM;
 			return -ENOMEM;
 
 
@@ -441,7 +441,8 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		udelay(1000);
 		udelay(1000);
 	}
 	}
 	if (i == timeout) {
 	if (i == timeout) {
-		printk(" timed out waiting for offset calibration to complete\n");
+		printk
+		    (" timed out waiting for offset calibration to complete\n");
 		return -ETIME;
 		return -ETIME;
 	}
 	}
 	devpriv->config_bits |= ENABLE0_BIT | ENABLE1_BIT;
 	devpriv->config_bits |= ENABLE0_BIT | ENABLE1_BIT;
@@ -488,8 +489,8 @@ static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
 	return 0;
 	return 0;
 }
 }
 
 
-static int a2150_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_cmd *cmd)
+static int a2150_ai_cmdtest(struct comedi_device *dev,
+			    struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
 {
 	int err = 0;
 	int err = 0;
 	int tmp;
 	int tmp;
@@ -589,25 +590,24 @@ static int a2150_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *
 		for (i = 1; i < cmd->chanlist_len; i++) {
 		for (i = 1; i < cmd->chanlist_len; i++) {
 			if (CR_CHAN(cmd->chanlist[i]) != (startChan + i)) {
 			if (CR_CHAN(cmd->chanlist[i]) != (startChan + i)) {
 				comedi_error(dev,
 				comedi_error(dev,
-					"entries in chanlist must be consecutive channels, counting upwards\n");
+					     "entries in chanlist must be consecutive channels, counting upwards\n");
 				err++;
 				err++;
 			}
 			}
 		}
 		}
 		if (cmd->chanlist_len == 2 && CR_CHAN(cmd->chanlist[0]) == 1) {
 		if (cmd->chanlist_len == 2 && CR_CHAN(cmd->chanlist[0]) == 1) {
 			comedi_error(dev,
 			comedi_error(dev,
-				"length 2 chanlist must be channels 0,1 or channels 2,3");
+				     "length 2 chanlist must be channels 0,1 or channels 2,3");
 			err++;
 			err++;
 		}
 		}
 		if (cmd->chanlist_len == 3) {
 		if (cmd->chanlist_len == 3) {
 			comedi_error(dev,
 			comedi_error(dev,
-				"chanlist must have 1,2 or 4 channels");
+				     "chanlist must have 1,2 or 4 channels");
 			err++;
 			err++;
 		}
 		}
 		if (CR_AREF(cmd->chanlist[0]) != CR_AREF(cmd->chanlist[1]) ||
 		if (CR_AREF(cmd->chanlist[0]) != CR_AREF(cmd->chanlist[1]) ||
-			CR_AREF(cmd->chanlist[2]) != CR_AREF(cmd->chanlist[3]))
-		{
+		    CR_AREF(cmd->chanlist[2]) != CR_AREF(cmd->chanlist[3])) {
 			comedi_error(dev,
 			comedi_error(dev,
-				"channels 0/1 and 2/3 must have the same analog reference");
+				     "channels 0/1 and 2/3 must have the same analog reference");
 			err++;
 			err++;
 		}
 		}
 	}
 	}
@@ -628,12 +628,12 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
 
 	if (!dev->irq || !devpriv->dma) {
 	if (!dev->irq || !devpriv->dma) {
 		comedi_error(dev,
 		comedi_error(dev,
-			" irq and dma required, cannot do hardware conversions");
+			     " irq and dma required, cannot do hardware conversions");
 		return -1;
 		return -1;
 	}
 	}
 	if (cmd->flags & TRIG_RT) {
 	if (cmd->flags & TRIG_RT) {
 		comedi_error(dev,
 		comedi_error(dev,
-			" dma incompatible with hard real-time interrupt (TRIG_RT), aborting");
+			     " dma incompatible with hard real-time interrupt (TRIG_RT), aborting");
 		return -1;
 		return -1;
 	}
 	}
 	/*  clear fifo and reset triggering circuitry */
 	/*  clear fifo and reset triggering circuitry */
@@ -641,7 +641,7 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 
 
 	/* setup chanlist */
 	/* setup chanlist */
 	if (a2150_set_chanlist(dev, CR_CHAN(cmd->chanlist[0]),
 	if (a2150_set_chanlist(dev, CR_CHAN(cmd->chanlist[0]),
-			cmd->chanlist_len) < 0)
+			       cmd->chanlist_len) < 0)
 		return -1;
 		return -1;
 
 
 	/*  setup ac/dc coupling */
 	/*  setup ac/dc coupling */
@@ -673,14 +673,14 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	/*  set size of transfer to fill in 1/3 second */
 	/*  set size of transfer to fill in 1/3 second */
 #define ONE_THIRD_SECOND 333333333
 #define ONE_THIRD_SECOND 333333333
 	devpriv->dma_transfer_size =
 	devpriv->dma_transfer_size =
-		sizeof(devpriv->dma_buffer[0]) * cmd->chanlist_len *
-		ONE_THIRD_SECOND / cmd->scan_begin_arg;
+	    sizeof(devpriv->dma_buffer[0]) * cmd->chanlist_len *
+	    ONE_THIRD_SECOND / cmd->scan_begin_arg;
 	if (devpriv->dma_transfer_size > A2150_DMA_BUFFER_SIZE)
 	if (devpriv->dma_transfer_size > A2150_DMA_BUFFER_SIZE)
 		devpriv->dma_transfer_size = A2150_DMA_BUFFER_SIZE;
 		devpriv->dma_transfer_size = A2150_DMA_BUFFER_SIZE;
 	if (devpriv->dma_transfer_size < sizeof(devpriv->dma_buffer[0]))
 	if (devpriv->dma_transfer_size < sizeof(devpriv->dma_buffer[0]))
 		devpriv->dma_transfer_size = sizeof(devpriv->dma_buffer[0]);
 		devpriv->dma_transfer_size = sizeof(devpriv->dma_buffer[0]);
 	devpriv->dma_transfer_size -=
 	devpriv->dma_transfer_size -=
-		devpriv->dma_transfer_size % sizeof(devpriv->dma_buffer[0]);
+	    devpriv->dma_transfer_size % sizeof(devpriv->dma_buffer[0]);
 	set_dma_count(devpriv->dma, devpriv->dma_transfer_size);
 	set_dma_count(devpriv->dma, devpriv->dma_transfer_size);
 	enable_dma(devpriv->dma);
 	enable_dma(devpriv->dma);
 	release_dma_lock(lock_flags);
 	release_dma_lock(lock_flags);
@@ -700,8 +700,8 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 	trigger_bits = 0;
 	trigger_bits = 0;
 	/*  decide if we need to wait 72 periods for valid data */
 	/*  decide if we need to wait 72 periods for valid data */
 	if (cmd->start_src == TRIG_NOW &&
 	if (cmd->start_src == TRIG_NOW &&
-		(old_config_bits & CLOCK_MASK) !=
-		(devpriv->config_bits & CLOCK_MASK)) {
+	    (old_config_bits & CLOCK_MASK) !=
+	    (devpriv->config_bits & CLOCK_MASK)) {
 		/*  set trigger source to delay trigger */
 		/*  set trigger source to delay trigger */
 		trigger_bits |= DELAY_TRIGGER_BITS;
 		trigger_bits |= DELAY_TRIGGER_BITS;
 	} else {
 	} else {
@@ -730,7 +730,7 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 }
 }
 
 
 static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			  struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int i, n;
 	unsigned int i, n;
 	static const int timeout = 100000;
 	static const int timeout = 100000;
@@ -804,7 +804,7 @@ static int a2150_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 /* sets bits in devpriv->clock_bits to nearest approximation of requested period,
 /* sets bits in devpriv->clock_bits to nearest approximation of requested period,
  * adjusts requested period to actual timing. */
  * adjusts requested period to actual timing. */
 static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
 static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
-	int flags)
+			    int flags)
 {
 {
 	int lub, glb, temp;
 	int lub, glb, temp;
 	int lub_divisor_shift, lub_index, glb_divisor_shift, glb_index;
 	int lub_divisor_shift, lub_index, glb_divisor_shift, glb_index;
@@ -866,19 +866,20 @@ static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
 	devpriv->config_bits &= ~CLOCK_MASK;
 	devpriv->config_bits &= ~CLOCK_MASK;
 	if (*period == lub) {
 	if (*period == lub) {
 		devpriv->config_bits |=
 		devpriv->config_bits |=
-			CLOCK_SELECT_BITS(lub_index) |
-			CLOCK_DIVISOR_BITS(lub_divisor_shift);
+		    CLOCK_SELECT_BITS(lub_index) |
+		    CLOCK_DIVISOR_BITS(lub_divisor_shift);
 	} else {
 	} else {
 		devpriv->config_bits |=
 		devpriv->config_bits |=
-			CLOCK_SELECT_BITS(glb_index) |
-			CLOCK_DIVISOR_BITS(glb_divisor_shift);
+		    CLOCK_SELECT_BITS(glb_index) |
+		    CLOCK_DIVISOR_BITS(glb_divisor_shift);
 	}
 	}
 
 
 	return 0;
 	return 0;
 }
 }
 
 
-static int a2150_set_chanlist(struct comedi_device *dev, unsigned int start_channel,
-	unsigned int num_channels)
+static int a2150_set_chanlist(struct comedi_device *dev,
+			      unsigned int start_channel,
+			      unsigned int num_channels)
 {
 {
 	if (start_channel + num_channels > 4)
 	if (start_channel + num_channels > 4)
 		return -1;
 		return -1;

+ 38 - 31
drivers/staging/comedi/drivers/ni_at_ao.c

@@ -158,13 +158,13 @@ struct atao_board {
 
 
 static const struct atao_board atao_boards[] = {
 static const struct atao_board atao_boards[] = {
 	{
 	{
-	.name = "ai-ao-6",
-	.n_ao_chans = 6,
-		},
+	 .name = "ai-ao-6",
+	 .n_ao_chans = 6,
+	 },
 	{
 	{
-	.name = "ai-ao-10",
-	.n_ao_chans = 10,
-		},
+	 .name = "ai-ao-10",
+	 .n_ao_chans = 10,
+	 },
 };
 };
 
 
 #define thisboard ((struct atao_board *)dev->board_ptr)
 #define thisboard ((struct atao_board *)dev->board_ptr)
@@ -198,17 +198,21 @@ COMEDI_INITCLEANUP(driver_atao);
 static void atao_reset(struct comedi_device *dev);
 static void atao_reset(struct comedi_device *dev);
 
 
 static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+			 struct comedi_insn *insn, unsigned int *data);
 static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int atao_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int atao_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
-static int atao_calib_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data);
+			 struct comedi_insn *insn, unsigned int *data);
+static int atao_dio_insn_bits(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data);
+static int atao_dio_insn_config(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data);
+static int atao_calib_insn_read(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data);
+static int atao_calib_insn_write(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data);
 
 
 static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 {
 {
@@ -324,7 +328,7 @@ static void atao_reset(struct comedi_device *dev)
 }
 }
 
 
 static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -348,7 +352,7 @@ static int atao_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s,
 }
 }
 
 
 static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+			 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
@@ -359,8 +363,9 @@ static int atao_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 	return i;
 	return i;
 }
 }
 
 
-static int atao_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int atao_dio_insn_bits(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      struct comedi_insn *insn, unsigned int *data)
 {
 {
 	if (insn->n != 2)
 	if (insn->n != 2)
 		return -EINVAL;
 		return -EINVAL;
@@ -376,8 +381,9 @@ static int atao_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice
 	return 2;
 	return 2;
 }
 }
 
 
-static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int atao_dio_insn_config(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int chan = CR_CHAN(insn->chanspec);
 	int chan = CR_CHAN(insn->chanspec);
 	unsigned int mask, bit;
 	unsigned int mask, bit;
@@ -401,8 +407,7 @@ static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
 		break;
 		break;
 	case INSN_CONFIG_DIO_QUERY:
 	case INSN_CONFIG_DIO_QUERY:
 		data[1] =
 		data[1] =
-			(s->
-			io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+		    (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
 		return insn->n;
 		return insn->n;
 		break;
 		break;
 	default:
 	default:
@@ -421,8 +426,9 @@ static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevi
  * DACs.  It is not explicitly stated in the manual how to access
  * DACs.  It is not explicitly stated in the manual how to access
  * the caldacs, but we can guess.
  * the caldacs, but we can guess.
  */
  */
-static int atao_calib_insn_read(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int atao_calib_insn_read(struct comedi_device *dev,
+				struct comedi_subdevice *s,
+				struct comedi_insn *insn, unsigned int *data)
 {
 {
 	int i;
 	int i;
 	for (i = 0; i < insn->n; i++) {
 	for (i = 0; i < insn->n; i++) {
@@ -431,8 +437,9 @@ static int atao_calib_insn_read(struct comedi_device *dev, struct comedi_subdevi
 	return insn->n;
 	return insn->n;
 }
 }
 
 
-static int atao_calib_insn_write(struct comedi_device *dev, struct comedi_subdevice *s,
-	struct comedi_insn *insn, unsigned int *data)
+static int atao_calib_insn_write(struct comedi_device *dev,
+				 struct comedi_subdevice *s,
+				 struct comedi_insn *insn, unsigned int *data)
 {
 {
 	unsigned int bitstring, bit;
 	unsigned int bitstring, bit;
 	unsigned int chan = CR_CHAN(insn->chanspec);
 	unsigned int chan = CR_CHAN(insn->chanspec);
@@ -441,13 +448,13 @@ static int atao_calib_insn_write(struct comedi_device *dev, struct comedi_subdev
 
 
 	for (bit = 1 << (11 - 1); bit; bit >>= 1) {
 	for (bit = 1 << (11 - 1); bit; bit >>= 1) {
 		outw(devpriv->cfg2 | ((bit & bitstring) ? SDATA : 0),
 		outw(devpriv->cfg2 | ((bit & bitstring) ? SDATA : 0),
-			dev->iobase + ATAO_CFG2);
+		     dev->iobase + ATAO_CFG2);
 		outw(devpriv->cfg2 | SCLK | ((bit & bitstring) ? SDATA : 0),
 		outw(devpriv->cfg2 | SCLK | ((bit & bitstring) ? SDATA : 0),
-			dev->iobase + ATAO_CFG2);
+		     dev->iobase + ATAO_CFG2);
 	}
 	}
 	/* strobe the appropriate caldac */
 	/* strobe the appropriate caldac */
 	outw(devpriv->cfg2 | (((chan >> 3) + 1) << 14),
 	outw(devpriv->cfg2 | (((chan >> 3) + 1) << 14),
-		dev->iobase + ATAO_CFG2);
+	     dev->iobase + ATAO_CFG2);
 	outw(devpriv->cfg2, dev->iobase + ATAO_CFG2);
 	outw(devpriv->cfg2, dev->iobase + ATAO_CFG2);
 
 
 	return insn->n;
 	return insn->n;

+ 161 - 157
drivers/staging/comedi/drivers/ni_atmio.c

@@ -117,159 +117,159 @@ are not supported.
 
 
 static const struct ni_board_struct ni_boards[] = {
 static const struct ni_board_struct ni_boards[] = {
 	{.device_id = 44,
 	{.device_id = 44,
-	.isapnp_id = 0x0000,/* XXX unknown */
-	.name = "at-mio-16e-1",
-	.n_adchan = 16,
-	.adbits = 12,
-	.ai_fifo_depth = 8192,
-	.alwaysdither = 0,
-	.gainlkup = ai_gain_16,
-	.ai_speed = 800,
-	.n_aochan = 2,
-	.aobits = 12,
-	.ao_fifo_depth = 2048,
-			.ao_range_table = &range_ni_E_ao_ext,
-	.ao_unipolar = 1,
-	.ao_speed = 1000,
-	.has_8255 = 0,
-			.num_p0_dio_channels = 8,
-	.caldac = {mb88341},
-		},
+	 .isapnp_id = 0x0000,	/* XXX unknown */
+	 .name = "at-mio-16e-1",
+	 .n_adchan = 16,
+	 .adbits = 12,
+	 .ai_fifo_depth = 8192,
+	 .alwaysdither = 0,
+	 .gainlkup = ai_gain_16,
+	 .ai_speed = 800,
+	 .n_aochan = 2,
+	 .aobits = 12,
+	 .ao_fifo_depth = 2048,
+	 .ao_range_table = &range_ni_E_ao_ext,
+	 .ao_unipolar = 1,
+	 .ao_speed = 1000,
+	 .has_8255 = 0,
+	 .num_p0_dio_channels = 8,
+	 .caldac = {mb88341},
+	 },
 	{.device_id = 25,
 	{.device_id = 25,
-	.isapnp_id = 0x1900,
-	.name = "at-mio-16e-2",
-	.n_adchan = 16,
-	.adbits = 12,
-	.ai_fifo_depth = 2048,
-	.alwaysdither = 0,
-	.gainlkup = ai_gain_16,
-	.ai_speed = 2000,
-	.n_aochan = 2,
-	.aobits = 12,
-	.ao_fifo_depth = 2048,
-			.ao_range_table = &range_ni_E_ao_ext,
-	.ao_unipolar = 1,
-	.ao_speed = 1000,
-	.has_8255 = 0,
-			.num_p0_dio_channels = 8,
-	.caldac = {mb88341},
-		},
+	 .isapnp_id = 0x1900,
+	 .name = "at-mio-16e-2",
+	 .n_adchan = 16,
+	 .adbits = 12,
+	 .ai_fifo_depth = 2048,
+	 .alwaysdither = 0,
+	 .gainlkup = ai_gain_16,
+	 .ai_speed = 2000,
+	 .n_aochan = 2,
+	 .aobits = 12,
+	 .ao_fifo_depth = 2048,
+	 .ao_range_table = &range_ni_E_ao_ext,
+	 .ao_unipolar = 1,
+	 .ao_speed = 1000,
+	 .has_8255 = 0,
+	 .num_p0_dio_channels = 8,
+	 .caldac = {mb88341},
+	 },
 	{.device_id = 36,
 	{.device_id = 36,
-	.isapnp_id = 0x2400,
-	.name = "at-mio-16e-10",
-	.n_adchan = 16,
-	.adbits = 12,
-	.ai_fifo_depth = 512,
-	.alwaysdither = 0,
-	.gainlkup = ai_gain_16,
-	.ai_speed = 10000,
-	.n_aochan = 2,
-	.aobits = 12,
-	.ao_fifo_depth = 0,
-			.ao_range_table = &range_ni_E_ao_ext,
-	.ao_unipolar = 1,
-	.ao_speed = 10000,
-			.num_p0_dio_channels = 8,
-	.caldac = {ad8804_debug},
-	.has_8255 = 0,
-		},
+	 .isapnp_id = 0x2400,
+	 .name = "at-mio-16e-10",
+	 .n_adchan = 16,
+	 .adbits = 12,
+	 .ai_fifo_depth = 512,
+	 .alwaysdither = 0,
+	 .gainlkup = ai_gain_16,
+	 .ai_speed = 10000,
+	 .n_aochan = 2,
+	 .aobits = 12,
+	 .ao_fifo_depth = 0,
+	 .ao_range_table = &range_ni_E_ao_ext,
+	 .ao_unipolar = 1,
+	 .ao_speed = 10000,
+	 .num_p0_dio_channels = 8,
+	 .caldac = {ad8804_debug},
+	 .has_8255 = 0,
+	 },
 	{.device_id = 37,
 	{.device_id = 37,
-	.isapnp_id = 0x2500,
-	.name = "at-mio-16de-10",
-	.n_adchan = 16,
-	.adbits = 12,
-	.ai_fifo_depth = 512,
-	.alwaysdither = 0,
-	.gainlkup = ai_gain_16,
-	.ai_speed = 10000,
-	.n_aochan = 2,
-	.aobits = 12,
-	.ao_fifo_depth = 0,
-			.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,
-		},
+	 .isapnp_id = 0x2500,
+	 .name = "at-mio-16de-10",
+	 .n_adchan = 16,
+	 .adbits = 12,
+	 .ai_fifo_depth = 512,
+	 .alwaysdither = 0,
+	 .gainlkup = ai_gain_16,
+	 .ai_speed = 10000,
+	 .n_aochan = 2,
+	 .aobits = 12,
+	 .ao_fifo_depth = 0,
+	 .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,
+	 },
 	{.device_id = 38,
 	{.device_id = 38,
-	.isapnp_id = 0x2600,
-	.name = "at-mio-64e-3",
-	.n_adchan = 64,
-	.adbits = 12,
-	.ai_fifo_depth = 2048,
-	.alwaysdither = 0,
-	.gainlkup = ai_gain_16,
-	.ai_speed = 2000,
-	.n_aochan = 2,
-	.aobits = 12,
-	.ao_fifo_depth = 2048,
-			.ao_range_table = &range_ni_E_ao_ext,
-	.ao_unipolar = 1,
-	.ao_speed = 1000,
-	.has_8255 = 0,
-			.num_p0_dio_channels = 8,
-	.caldac = {ad8804_debug},
-		},
+	 .isapnp_id = 0x2600,
+	 .name = "at-mio-64e-3",
+	 .n_adchan = 64,
+	 .adbits = 12,
+	 .ai_fifo_depth = 2048,
+	 .alwaysdither = 0,
+	 .gainlkup = ai_gain_16,
+	 .ai_speed = 2000,
+	 .n_aochan = 2,
+	 .aobits = 12,
+	 .ao_fifo_depth = 2048,
+	 .ao_range_table = &range_ni_E_ao_ext,
+	 .ao_unipolar = 1,
+	 .ao_speed = 1000,
+	 .has_8255 = 0,
+	 .num_p0_dio_channels = 8,
+	 .caldac = {ad8804_debug},
+	 },
 	{.device_id = 39,
 	{.device_id = 39,
-	.isapnp_id = 0x2700,
-	.name = "at-mio-16xe-50",
-	.n_adchan = 16,
-	.adbits = 16,
-	.ai_fifo_depth = 512,
-	.alwaysdither = 1,
-	.gainlkup = ai_gain_8,
-	.ai_speed = 50000,
-	.n_aochan = 2,
-	.aobits = 12,
-	.ao_fifo_depth = 0,
-			.ao_range_table = &range_bipolar10,
-	.ao_unipolar = 0,
-	.ao_speed = 50000,
-			.num_p0_dio_channels = 8,
-	.caldac = {dac8800, dac8043},
-	.has_8255 = 0,
-		},
+	 .isapnp_id = 0x2700,
+	 .name = "at-mio-16xe-50",
+	 .n_adchan = 16,
+	 .adbits = 16,
+	 .ai_fifo_depth = 512,
+	 .alwaysdither = 1,
+	 .gainlkup = ai_gain_8,
+	 .ai_speed = 50000,
+	 .n_aochan = 2,
+	 .aobits = 12,
+	 .ao_fifo_depth = 0,
+	 .ao_range_table = &range_bipolar10,
+	 .ao_unipolar = 0,
+	 .ao_speed = 50000,
+	 .num_p0_dio_channels = 8,
+	 .caldac = {dac8800, dac8043},
+	 .has_8255 = 0,
+	 },
 	{.device_id = 50,
 	{.device_id = 50,
-	.isapnp_id = 0x0000,/* XXX unknown */
-	.name = "at-mio-16xe-10",
-	.n_adchan = 16,
-	.adbits = 16,
-	.ai_fifo_depth = 512,
-	.alwaysdither = 1,
-	.gainlkup = ai_gain_14,
-	.ai_speed = 10000,
-	.n_aochan = 2,
-	.aobits = 16,
-	.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},
-	.has_8255 = 0,
-		},
+	 .isapnp_id = 0x0000,	/* XXX unknown */
+	 .name = "at-mio-16xe-10",
+	 .n_adchan = 16,
+	 .adbits = 16,
+	 .ai_fifo_depth = 512,
+	 .alwaysdither = 1,
+	 .gainlkup = ai_gain_14,
+	 .ai_speed = 10000,
+	 .n_aochan = 2,
+	 .aobits = 16,
+	 .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},
+	 .has_8255 = 0,
+	 },
 	{.device_id = 51,
 	{.device_id = 51,
-	.isapnp_id = 0x0000,/* XXX unknown */
-	.name = "at-ai-16xe-10",
-	.n_adchan = 16,
-	.adbits = 16,
-	.ai_fifo_depth = 512,
-	.alwaysdither = 1,	/* unknown */
-	.gainlkup = ai_gain_14,
-	.ai_speed = 10000,
-	.n_aochan = 0,
-	.aobits = 0,
-	.ao_fifo_depth = 0,
-	.ao_unipolar = 0,
-			.num_p0_dio_channels = 8,
-	.caldac = {dac8800, dac8043, ad8522},
-	.has_8255 = 0,
-		}
+	 .isapnp_id = 0x0000,	/* XXX unknown */
+	 .name = "at-ai-16xe-10",
+	 .n_adchan = 16,
+	 .adbits = 16,
+	 .ai_fifo_depth = 512,
+	 .alwaysdither = 1,	/* unknown */
+	 .gainlkup = ai_gain_14,
+	 .ai_speed = 10000,
+	 .n_aochan = 0,
+	 .aobits = 0,
+	 .ao_fifo_depth = 0,
+	 .ao_unipolar = 0,
+	 .num_p0_dio_channels = 8,
+	 .caldac = {dac8800, dac8043, ad8522},
+	 .has_8255 = 0,
+	 }
 };
 };
 
 
 static const int ni_irqpin[] =
 static const int ni_irqpin[] =
-	{ -1, -1, -1, 0, 1, 2, -1, 3, -1, -1, 4, 5, 6, -1, -1, 7 };
+    { -1, -1, -1, 0, 1, 2, -1, 3, -1, -1, 4, 5, 6, -1, -1, 7 };
 
 
 #define interrupt_pin(a)	(ni_irqpin[(a)])
 #define interrupt_pin(a)	(ni_irqpin[(a)])
 
 
@@ -279,8 +279,7 @@ static const int ni_irqpin[] =
 
 
 struct ni_private {
 struct ni_private {
 	struct pnp_dev *isapnp_dev;
 	struct pnp_dev *isapnp_dev;
-	NI_PRIVATE_COMMON
-};
+ NI_PRIVATE_COMMON};
 #define devpriv ((struct ni_private *)dev->private)
 #define devpriv ((struct ni_private *)dev->private)
 
 
 /* How we access registers */
 /* How we access registers */
@@ -330,17 +329,18 @@ static uint16_t ni_atmio_win_in(struct comedi_device *dev, int addr)
 }
 }
 
 
 static struct pnp_device_id device_ids[] = {
 static struct pnp_device_id device_ids[] = {
-	{.id = "NIC1900", .driver_data = 0},
-	{.id = "NIC2400", .driver_data = 0},
-	{.id = "NIC2500", .driver_data = 0},
-	{.id = "NIC2600", .driver_data = 0},
-	{.id = "NIC2700", .driver_data = 0},
+	{.id = "NIC1900",.driver_data = 0},
+	{.id = "NIC2400",.driver_data = 0},
+	{.id = "NIC2500",.driver_data = 0},
+	{.id = "NIC2600",.driver_data = 0},
+	{.id = "NIC2700",.driver_data = 0},
 	{.id = ""}
 	{.id = ""}
 };
 };
 
 
 MODULE_DEVICE_TABLE(pnp, device_ids);
 MODULE_DEVICE_TABLE(pnp, device_ids);
 
 
-static int ni_atmio_attach(struct comedi_device *dev, struct comedi_devconfig *it);
+static int ni_atmio_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it);
 static int ni_atmio_detach(struct comedi_device *dev);
 static int ni_atmio_detach(struct comedi_device *dev);
 static struct comedi_driver driver_atmio = {
 static struct comedi_driver driver_atmio = {
 	.driver_name = "ni_atmio",
 	.driver_name = "ni_atmio",
@@ -378,14 +378,17 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
 
 
 	for (i = 0; i < n_ni_boards; i++) {
 	for (i = 0; i < n_ni_boards; i++) {
 		isapnp_dev = pnp_find_dev(NULL,
 		isapnp_dev = pnp_find_dev(NULL,
-			ISAPNP_VENDOR('N', 'I', 'C'),
-			ISAPNP_FUNCTION(ni_boards[i].isapnp_id), NULL);
+					  ISAPNP_VENDOR('N', 'I', 'C'),
+					  ISAPNP_FUNCTION(ni_boards[i].
+							  isapnp_id), NULL);
 
 
 		if (isapnp_dev == NULL || isapnp_dev->card == NULL)
 		if (isapnp_dev == NULL || isapnp_dev->card == NULL)
 			continue;
 			continue;
 
 
 		if (pnp_device_attach(isapnp_dev) < 0) {
 		if (pnp_device_attach(isapnp_dev) < 0) {
-			printk("ni_atmio: %s found but already active, skipping.\n", ni_boards[i].name);
+			printk
+			    ("ni_atmio: %s found but already active, skipping.\n",
+			     ni_boards[i].name);
 			continue;
 			continue;
 		}
 		}
 		if (pnp_activate_dev(isapnp_dev) < 0) {
 		if (pnp_activate_dev(isapnp_dev) < 0) {
@@ -393,7 +396,7 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
 			return -EAGAIN;
 			return -EAGAIN;
 		}
 		}
 		if (!pnp_port_valid(isapnp_dev, 0)
 		if (!pnp_port_valid(isapnp_dev, 0)
-			|| !pnp_irq_valid(isapnp_dev, 0)) {
+		    || !pnp_irq_valid(isapnp_dev, 0)) {
 			pnp_device_detach(isapnp_dev);
 			pnp_device_detach(isapnp_dev);
 			printk("ni_atmio: pnp invalid port or irq, aborting\n");
 			printk("ni_atmio: pnp invalid port or irq, aborting\n");
 			return -ENOMEM;
 			return -ENOMEM;
@@ -406,7 +409,8 @@ static int ni_isapnp_find_board(struct pnp_dev **dev)
 	return 0;
 	return 0;
 }
 }
 
 
-static int ni_atmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
+static int ni_atmio_attach(struct comedi_device *dev,
+			   struct comedi_devconfig *it)
 {
 {
 	struct pnp_dev *isapnp_dev;
 	struct pnp_dev *isapnp_dev;
 	int ret;
 	int ret;
@@ -455,7 +459,7 @@ static int ni_atmio_attach(struct comedi_device *dev, struct comedi_devconfig *i
 		printk(" board fingerprint:");
 		printk(" board fingerprint:");
 		for (i = 0; i < 16; i += 2) {
 		for (i = 0; i < 16; i += 2) {
 			printk(" %04x %02x", inw(dev->iobase + i),
 			printk(" %04x %02x", inw(dev->iobase + i),
-				inb(dev->iobase + i + 1));
+			       inb(dev->iobase + i + 1));
 		}
 		}
 	}
 	}
 #endif
 #endif

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است