[PATCH 2/2 v4] staging: comedi: addi_apci_1564: tidy up apci1564_reset()

2014-04-17 Thread Chase Southwood
The reset function for this driver is a bit of a mess; clean it up to
ensure that it is functioning properly.

Signed-off-by: Chase Southwood chase.southw...@yahoo.com
---
2: *Changed order of register accesses for digital input registers back to
original ordering.
*Removed read of digital output status register and reordered the accesses
of digital output registers to agree with the order found in addi_apci_2032.
*Fixed copy/paste error in the counter register reset lines.

3: *Returned the reset callback to the boardinfo...oops.
*Don't write APCI1564_DO_IRQ_REG (it's read only).
*Don't clear counter reload values...counters have already been
disabled.

4: Leave this in hwdrv_apci1564.c for now (it can be moved after separating
this driver from addi_common.c)

NB: This patch has been renamed in this version.  It was previously known
as staging: comedi: addi_apci_1564: fixup and absorb apci1564_reset()

 .../comedi/drivers/addi-data/hwdrv_apci1564.c  | 24 ++
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
index 4db3bea..7976a22a 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
@@ -21,6 +21,8 @@
  *
  */
 
+#include ../addi_watchdog.h
+
 #define APCI1564_ADDRESS_RANGE 128
 
 /* Digital Input IRQ Function Selection */
@@ -581,26 +583,30 @@ static int apci1564_reset(struct comedi_device *dev)
 {
struct addi_private *devpriv = dev-private;
 
-   /* disable the interrupts */
+   ui_Type = 0;
+
+   /* Disable the input interrupts and reset status register */
outl(0x0, devpriv-i_IobaseAmcc + APCI1564_DI_IRQ_REG);
-   /* Reset the interrupt status register */
inl(devpriv-i_IobaseAmcc + APCI1564_DI_INT_STATUS_REG);
-   /* Disable the and/or interrupt */
outl(0x0, devpriv-i_IobaseAmcc + APCI1564_DI_INT_MODE1_REG);
outl(0x0, devpriv-i_IobaseAmcc + APCI1564_DI_INT_MODE2_REG);
-   devpriv-b_DigitalOutputRegister = 0;
-   ui_Type = 0;
-   /* Resets the output channels */
+
+   /* Reset the output channels and disable interrupts */
outl(0x0, devpriv-i_IobaseAmcc + APCI1564_DO_REG);
-   /* Disables the interrupt. */
outl(0x0, devpriv-i_IobaseAmcc + APCI1564_DO_INT_CTRL_REG);
-   outl(0x0, devpriv-i_IobaseAmcc + APCI1564_WDOG_RELOAD_REG);
-   outl(0x0, devpriv-i_IobaseAmcc + APCI1564_TIMER_REG);
+
+   /* Reset the watchdog registers */
+   addi_watchdog_reset(devpriv-i_IobaseAmcc + APCI1564_WDOG_REG);
+
+   /* Reset the timer registers */
outl(0x0, devpriv-i_IobaseAmcc + APCI1564_TIMER_CTRL_REG);
+   outl(0x0, devpriv-i_IobaseAmcc + APCI1564_TIMER_RELOAD_REG);
 
+   /* Reset the counter registers */
outl(0x0, dev-iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER1));
outl(0x0, dev-iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER2));
outl(0x0, dev-iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER3));
outl(0x0, dev-iobase + APCI1564_TCW_CTRL_REG(APCI1564_COUNTER4));
+
return 0;
 }
-- 
1.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] vt6656/aes_ccmp.c: Fix a sparse symbol not declared warning

2014-04-17 Thread chihuanqi
sparse complains as follows:
drivers/staging/vt6656/aes_ccmp.c:221:6: warning: symbol 'AESbGenCCMP'
was not declared. Should it be static?
In order to suppress the warning, we include the aes_ccmp.h header file
which contains an appropriate extern declaration.

Signed-off-by: huanqi chi chihua...@gmail.com
---
 drivers/staging/vt6656/aes_ccmp.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/vt6656/aes_ccmp.c 
b/drivers/staging/vt6656/aes_ccmp.c
index e2bfa8d..a9d5168 100644
--- a/drivers/staging/vt6656/aes_ccmp.c
+++ b/drivers/staging/vt6656/aes_ccmp.c
@@ -32,6 +32,7 @@
 
 #include device.h
 #include 80211hdr.h
+#include aes_ccmp.h
 
 /*
  * SBOX Table
-- 
1.7.10.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/15] staging: comedi: drivers: cleanup step 5 of (*do_cmdtest)

2014-04-17 Thread Ian Abbott

On 2014-04-16 22:19, H Hartley Sweeten wrote:

Step 5 of the (*do_cmdtest) validates that the cmd-chanlist is compatible
with the hardware.

As pointed out by Ian Abbott, some of the step 5 operations are buggy because
they access the cmd-chanlist[] without checking the cmd-chanlist_len.

This series factors out step 5 from (*do_cmdtest) functions and cleans up the
code.

H Hartley Sweeten (15):
   staging: comedi: adl_pci9111: factor out chanlist checking from (*do_cmdtest)
   staging: comedi: amplc_pci224: factor out chanlist checking from 
(*do_cmdtest)
   staging: comedi: amplc_pci230: factor out chanlist checking from 
(*do_cmdtest)
   staging: comedi: cb_pcidas: factor out chanlist checking from (*do_cmdtest)
   staging: comedi: cb_pcidas64: factor out chanlist checking from (*do_cmdtest)
   staging: comedi: das16: factor out chanlist checking from (*do_cmdtest)
   staging: comedi: das16m1: factor out chanlist checking from (*do_cmdtest)
   staging: comedi: das1800: factor out chanlist checking from (*do_cmdtest)
   staging: comedi: das800: factor out chanlist checking from (*do_cmdtest)
   staging: comedi: dmm32at: factor out chanlist checking from (*do_cmdtest)
   staging: comedi: gsc_hpdi: factor out chanlist checking from (*do_cmdtest)
   staging: comedi: ni_at_a2150: factor out chanlist checking from (*do_cmdtest)
   staging: comedi: ni_mio_common: factor out chanlist checking from 
(*do_cmdtest)
   staging: comedi: me4000: tidy up the chanlist checking
   staging: comedi: ni_labpc: tidy up the chanlist checking

  drivers/staging/comedi/drivers/adl_pci9111.c   |  68 +++---
  drivers/staging/comedi/drivers/amplc_pci224.c  |  76 +++---
  drivers/staging/comedi/drivers/amplc_pci230.c  | 313 +++--
  drivers/staging/comedi/drivers/cb_pcidas.c |  80 ---
  drivers/staging/comedi/drivers/cb_pcidas64.c   | 110 +
  drivers/staging/comedi/drivers/das16.c |  51 ++--
  drivers/staging/comedi/drivers/das16m1.c   |  49 ++--
  drivers/staging/comedi/drivers/das1800.c   |  37 +--
  drivers/staging/comedi/drivers/das800.c|  52 ++--
  drivers/staging/comedi/drivers/dmm32at.c   |  51 ++--
  drivers/staging/comedi/drivers/gsc_hpdi.c  |  34 ++-
  drivers/staging/comedi/drivers/me4000.c|  75 ++
  drivers/staging/comedi/drivers/ni_at_a2150.c   |  74 +++---
  drivers/staging/comedi/drivers/ni_labpc.c  |  84 +++
  drivers/staging/comedi/drivers/ni_mio_common.c |  31 ++-
  15 files changed, 625 insertions(+), 560 deletions(-)



All looks fine to me!

Reviewed-by: Ian Abbott abbo...@mev.co.uk

--
-=( Ian Abbott @ MEV Ltd.E-mail: abbo...@mev.co.uk)=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587 )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [staging:staging-next 133/193] drivers/staging/rtl8723au/core/rtw_mlme_ext.c:1236 OnAssocReq23a() error: we previously assumed 'p' could be null (see line 1234)

2014-04-17 Thread Jes Sorensen
Dan Carpenter dan.carpen...@oracle.com writes:
 tree: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
 staging-next
 head:   dff222670ebebf1a7f147a23ccb5fc0312f2ae7e
 commit: da290c54610f49ef475f7f88668259216b08fc36 [133/193] staging:
 rtl8723au: OnAssocReq23a(): Clean up and use more ieee80211.h

 New smatch warnings:
 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:1236 OnAssocReq23a()
 error: we previously assumed 'p' could be null (see line 1234)

OUF! Nice catch!

 Old smatch warnings:
 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4362
 collect_bss_info23a() error: __builtin_memcpy() 'bssid-IEs' too small
 (768 vs u32max)
 drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4860 process_80211d()
 error: testing array offset 'i' after use.

We already have a check in palce here - do I need to make the
if (length  MAX_IE_SZ) check for length  0 to make this warning go
away?

Thanks,
Jes
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [staging:staging-next 133/193] drivers/staging/rtl8723au/core/rtw_mlme_ext.c:1236 OnAssocReq23a() error: we previously assumed 'p' could be null (see line 1234)

2014-04-17 Thread Dan Carpenter
On Thu, Apr 17, 2014 at 11:50:13AM +0200, Jes Sorensen wrote:
  Old smatch warnings:
  drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4362
  collect_bss_info23a() error: __builtin_memcpy() 'bssid-IEs' too small
  (768 vs u32max)
  drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4860 process_80211d()
  error: testing array offset 'i' after use.
 
 We already have a check in palce here - do I need to make the
 if (length  MAX_IE_SZ) check for length  0 to make this warning go
 away?

Yeah.  Sorry about this false positive.  I eventually want Smatch to be
able to parse this sort of code correctly, but it's pretty tricky logic.
I don't normally encourage people to hack around faulty tools but if you
wanted to then the patch would look like this.

regards,
dan carpenter

diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
index 68991dc..dfad657 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
@@ -4902,7 +4902,7 @@ static void process_80211d(struct rtw_adapter *padapter,
i = j = k = 0;
if (pregistrypriv-wireless_mode  WIRELESS_11G) {
do {
-   if (i == MAX_CHANNEL_NUM ||
+   if (i = MAX_CHANNEL_NUM ||
chplan_sta[i].ChannelNum == 0 ||
chplan_sta[i].ChannelNum  14)
break;
@@ -4975,7 +4975,7 @@ static void process_80211d(struct rtw_adapter *padapter,
 
if (pregistrypriv-wireless_mode  WIRELESS_11A) {
do {
-   if (i == MAX_CHANNEL_NUM ||
+   if (i = MAX_CHANNEL_NUM ||
chplan_sta[i].ChannelNum == 0)
break;
 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [staging:staging-next 133/193] drivers/staging/rtl8723au/core/rtw_mlme_ext.c:1236 OnAssocReq23a() error: we previously assumed 'p' could be null (see line 1234)

2014-04-17 Thread Dan Carpenter
On Thu, Apr 17, 2014 at 11:50:13AM +0200, Jes Sorensen wrote:
  Old smatch warnings:
  drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4362
  collect_bss_info23a() error: __builtin_memcpy() 'bssid-IEs' too small
  (768 vs u32max)
  drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4860 process_80211d()
  error: testing array offset 'i' after use.
 
 We already have a check in palce here - do I need to make the
 if (length  MAX_IE_SZ) check for length  0 to make this warning go
 away?

Oh.  Wait.  I responded to the wrong thing.

Yeah.  You could check for negatives or make length unsigned or you
could check skb-len to make sure it wasn't too short.  Any of those
would work.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] Staging:bcm: Fixes coding style issues in drivers/staging/bcm/Qos.c

2014-04-17 Thread Marcos A. Di Pietro
Fixes code style errors in drivers/staging/bcm/Qos.c

Signed-off-by: Marcos A. Di Pietro marcos...@gmail.com
---
 drivers/staging/bcm/Qos.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c
index 4f31583..1f5edef 100644
--- a/drivers/staging/bcm/Qos.c
+++ b/drivers/staging/bcm/Qos.c
@@ -4,11 +4,18 @@ This file contains the routines related to Quality of Service.
 */
 #include headers.h
 
-static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID 
pvEthPayload, struct bcm_eth_packet_info *pstEthCsPktInfo);
-static bool EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, struct sk_buff* 
skb, struct bcm_eth_packet_info *pstEthCsPktInfo, struct bcm_classifier_rule 
*pstClassifierRule, B_UINT8 EthCSCupport);
-
-static USHORT  IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd,
-  struct bcm_classifier_rule *pstClassifierRule);
+static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,
+   PVOID pvEthPayload,
+   struct bcm_eth_packet_info *pstEthCsPktInfo);
+
+static bool EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,
+struct sk_buff *skb,
+struct bcm_eth_packet_info *pstEthCsPktInfo,
+struct bcm_classifier_rule *pstClassifierRule,
+B_UINT8 EthCSCupport);
+
+static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd,
+struct bcm_classifier_rule *pstClassifierRule);
 
 static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex);
 
-- 
Fixes whitespace damage and aligns function parameters properly.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Staging: dgap: RFC

2014-04-17 Thread Mark Hounschell
The latest staging tree based on 3.15-rc1 has revealed a bug that I
introduced into the dgap driver way back. Various oops occur when
loading and unloading the driver multiple times in succession. The oops
never actually indicate anything dgap driver related. When I send a
patch to fix the problem, since the oops is rarely the same, do I need
to include an oops message with my patch or should I just indicate
various oops?

Thanks
Mark
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/02] linux-next: staging: gdm72xx: Fix naked sscanf

2014-04-17 Thread Alexandr Terekhov
Fix naked sscanf

Signed-off-by: Alexandr Terekhov  alexandr_terek...@epam.com

diff --git a/drivers/staging/gdm72xx/gdm_wimax.c 
b/drivers/staging/gdm72xx/gdm_wimax.c
index 05ce2a2..7f60da3 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -285,6 +285,7 @@ static void __gdm_wimax_event_send(struct work_struct *work)
int idx;
unsigned long flags;
struct evt_entry *e;
+   int rc;
 
spin_lock_irqsave(wm_event.evt_lock, flags);
 
@@ -292,7 +293,10 @@ static void __gdm_wimax_event_send(struct work_struct 
*work)
e = list_entry(wm_event.evtq.next, struct evt_entry, list);
spin_unlock_irqrestore(wm_event.evt_lock, flags);
 
-   sscanf(e-dev-name, wm%d, idx);
+   rc = sscanf(e-dev-name, wm%d, idx);
+   if (0 == rc)
+   pr_err(%s: sscanf() returned zero\n, __func__);
+
netlink_send(wm_event.sock, idx, 0, e-evt_data, e-size);
 
spin_lock_irqsave(wm_event.evt_lock, flags);
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: Staging: dgap: RFC

2014-04-17 Thread Dan Carpenter
On Thu, Apr 17, 2014 at 09:07:12AM -0400, Mark Hounschell wrote:
 The latest staging tree based on 3.15-rc1 has revealed a bug that I
 introduced into the dgap driver way back. Various oops occur when
 loading and unloading the driver multiple times in succession. The oops
 never actually indicate anything dgap driver related. When I send a
 patch to fix the problem, since the oops is rarely the same, do I need
 to include an oops message with my patch or should I just indicate
 various oops?

These things are not hard and fast rules.  Do whatever makes sense.
Give reporter credit if anyone else discovered it.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: r8188eu: Fix some sparse warnings

2014-04-17 Thread Larry Finger
In a patch entitles staging: r8188eu: Fix case where ethtype was never obtained
and always be checked against 0 (commit ID unknown), I introduce an endian 
error.
This patch fixes that, and removes two additional sparse warnings.

drivers/staging/rtl8188eu/core/rtw_recv.c:653:6: warning: symbol 
'process_pwrbit_data' was not declared. Should it be static?
drivers/staging/rtl8188eu/core/rtw_recv.c:1828:5: warning: symbol 
'enqueue_reorder_recvframe' was not declared. Should it be static?

Reported-by: Dan Carpenter dan.carpen...@oracle.com
Signed-off-by: Larry Finger larry.fin...@lwfinger.net
Cc: Dan Carpenter dan.carpen...@oracle.com
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c 
b/drivers/staging/rtl8188eu/core/rtw_recv.c
index aeb0053..9bb1790 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -554,6 +554,7 @@ static struct recv_frame *portctrl(struct adapter *adapter,
u16 ether_type;
u16  eapol_type = 0x888e;/* for Funia BD's WPA issue */
struct rx_pkt_attrib *pattrib;
+   __be16 be_tmp;
 
 
pstapriv = adapter-stapriv;
@@ -573,8 +574,8 @@ static struct recv_frame *portctrl(struct adapter *adapter,
if (auth_alg == 2) {
/* get ether_type */
ptr = ptr + pfhdr-attrib.hdrlen + LLC_HEADER_SIZE;
-   memcpy(ether_type, ptr, 2);
-   ether_type = ntohs((unsigned short)ether_type);
+   memcpy(be_tmp, ptr, 2);
+   ether_type = ntohs(be_tmp);
 
if ((psta != NULL)  (psta-ieee8021x_blocked)) {
/* blocked */
@@ -647,8 +648,8 @@ static int recv_decache(struct recv_frame *precv_frame, u8 
bretry,
return _SUCCESS;
 }
 
-void process_pwrbit_data(struct adapter *padapter,
-struct recv_frame *precv_frame)
+static void process_pwrbit_data(struct adapter *padapter,
+   struct recv_frame *precv_frame)
 {
 #ifdef CONFIG_88EU_AP_MODE
unsigned char pwrbit;
@@ -1822,8 +1823,8 @@ static int check_indicate_seq(struct recv_reorder_ctrl 
*preorder_ctrl, u16 seq_n
return true;
 }
 
-int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
- struct recv_frame *prframe)
+static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
+struct recv_frame *prframe)
 {
struct rx_pkt_attrib *pattrib = prframe-attrib;
struct __queue *ppending_recvframe_queue = 
preorder_ctrl-pending_recvframe_queue;
-- 
1.8.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 35/35] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore

2014-04-17 Thread Kumar Gaurav
dgap driver uses semaphore for obtaining lock. I upgraded it to use MUTEX.

Signed-off-by: Kumar Gaurav kumargauravgup...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c |   17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 2a7a372..0ca72a2 100755
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -52,7 +52,7 @@
 #include asm/uaccess.h   /* For copy_from_user/copy_to_user */
 #include asm/io.h/* For read[bwl]/write[bwl] */
 #include linux/pci.h
-
+#includelinux/mutex.h
 #include dgap_driver.h
 #include dgap_tty.h
 #include dgap_types.h
@@ -61,18 +61,12 @@
 #include dgap_conf.h
 #include dgap_sysfs.h
 
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,37)
-#define init_MUTEX(sem) sema_init(sem, 1)
-#define DECLARE_MUTEX(name) \
-struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-#endif
-
 /*
  * internal variables
  */
 static struct board_t  *dgap_BoardsByMajor[256];
 static uchar   *dgap_TmpWriteBuf = NULL;
-static DECLARE_MUTEX(dgap_TmpWriteSem);
+static DEFINE_MUTEX(dgap_TmpWriteSem);
 
 /*
  * Default transparent print information.
@@ -2004,12 +1998,11 @@ static int dgap_tty_write(struct tty_struct *tty, const 
unsigned char *buf, int
 * the board.
 */
/* we're allowed to block if it's from_user */
-   if (down_interruptible(dgap_TmpWriteSem)) {
+   if (mutex_lock_interruptible(dgap_TmpWriteSem))
return (-EINTR);
-   }
 
if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) 
buf, count)) {
-   up(dgap_TmpWriteSem);
+   mutex_unlock(dgap_TmpWriteSem);
printk(Write: Copy from user failed!\n);
return -EFAULT;
}
@@ -2093,7 +2086,7 @@ static int dgap_tty_write(struct tty_struct *tty, const 
unsigned char *buf, int
 
if (from_user) {
DGAP_UNLOCK(ch-ch_lock, lock_flags);
-   up(dgap_TmpWriteSem);
+   mutex_unlock(dgap_TmpWriteSem);
} 
else {
DGAP_UNLOCK(ch-ch_lock, lock_flags);
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 35/35] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore

2014-04-17 Thread Kumar Gaurav

Hi All,

Please ignore this patch. I'm sending with correct Subject Line
On Thursday 17 April 2014 09:21 PM, Kumar Gaurav wrote:

dgap driver uses semaphore for obtaining lock. I upgraded it to use MUTEX.

Signed-off-by: Kumar Gaurav kumargauravgup...@gmail.com
---
  drivers/staging/dgap/dgap_tty.c |   17 +
  1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 2a7a372..0ca72a2 100755
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -52,7 +52,7 @@
  #include asm/uaccess.h/* For copy_from_user/copy_to_user */
  #include asm/io.h /* For read[bwl]/write[bwl] */
  #include linux/pci.h
-
+#includelinux/mutex.h
  #include dgap_driver.h
  #include dgap_tty.h
  #include dgap_types.h
@@ -61,18 +61,12 @@
  #include dgap_conf.h
  #include dgap_sysfs.h
  
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,37)

-#define init_MUTEX(sem) sema_init(sem, 1)
-#define DECLARE_MUTEX(name) \
-struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-#endif
-
  /*
   * internal variables
   */
  static struct board_t *dgap_BoardsByMajor[256];
  static uchar  *dgap_TmpWriteBuf = NULL;
-static DECLARE_MUTEX(dgap_TmpWriteSem);
+static DEFINE_MUTEX(dgap_TmpWriteSem);
  
  /*

   * Default transparent print information.
@@ -2004,12 +1998,11 @@ static int dgap_tty_write(struct tty_struct *tty, const 
unsigned char *buf, int
 * the board.
 */
/* we're allowed to block if it's from_user */
-   if (down_interruptible(dgap_TmpWriteSem)) {
+   if (mutex_lock_interruptible(dgap_TmpWriteSem))
return (-EINTR);
-   }
  
  		if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) {

-   up(dgap_TmpWriteSem);
+   mutex_unlock(dgap_TmpWriteSem);
printk(Write: Copy from user failed!\n);
return -EFAULT;
}
@@ -2093,7 +2086,7 @@ static int dgap_tty_write(struct tty_struct *tty, const 
unsigned char *buf, int
  
  	if (from_user) {

DGAP_UNLOCK(ch-ch_lock, lock_flags);
-   up(dgap_TmpWriteSem);
+   mutex_unlock(dgap_TmpWriteSem);
}
else {
DGAP_UNLOCK(ch-ch_lock, lock_flags);


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore

2014-04-17 Thread Kumar Gaurav
dgap driver uses semaphore for obtaining lock. I upgraded it to use MUTEX.

Signed-off-by: Kumar Gaurav kumargauravgup...@gmail.com
---
 drivers/staging/dgap/dgap_tty.c |   17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c
index 2a7a372..0ca72a2 100755
--- a/drivers/staging/dgap/dgap_tty.c
+++ b/drivers/staging/dgap/dgap_tty.c
@@ -52,7 +52,7 @@
 #include asm/uaccess.h   /* For copy_from_user/copy_to_user */
 #include asm/io.h/* For read[bwl]/write[bwl] */
 #include linux/pci.h
-
+#includelinux/mutex.h
 #include dgap_driver.h
 #include dgap_tty.h
 #include dgap_types.h
@@ -61,18 +61,12 @@
 #include dgap_conf.h
 #include dgap_sysfs.h
 
-#if LINUX_VERSION_CODE = KERNEL_VERSION(2,6,37)
-#define init_MUTEX(sem) sema_init(sem, 1)
-#define DECLARE_MUTEX(name) \
-struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-#endif
-
 /*
  * internal variables
  */
 static struct board_t  *dgap_BoardsByMajor[256];
 static uchar   *dgap_TmpWriteBuf = NULL;
-static DECLARE_MUTEX(dgap_TmpWriteSem);
+static DEFINE_MUTEX(dgap_TmpWriteSem);
 
 /*
  * Default transparent print information.
@@ -2004,12 +1998,11 @@ static int dgap_tty_write(struct tty_struct *tty, const 
unsigned char *buf, int
 * the board.
 */
/* we're allowed to block if it's from_user */
-   if (down_interruptible(dgap_TmpWriteSem)) {
+   if (mutex_lock_interruptible(dgap_TmpWriteSem))
return (-EINTR);
-   }
 
if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) 
buf, count)) {
-   up(dgap_TmpWriteSem);
+   mutex_unlock(dgap_TmpWriteSem);
printk(Write: Copy from user failed!\n);
return -EFAULT;
}
@@ -2093,7 +2086,7 @@ static int dgap_tty_write(struct tty_struct *tty, const 
unsigned char *buf, int
 
if (from_user) {
DGAP_UNLOCK(ch-ch_lock, lock_flags);
-   up(dgap_TmpWriteSem);
+   mutex_unlock(dgap_TmpWriteSem);
} 
else {
DGAP_UNLOCK(ch-ch_lock, lock_flags);
-- 
1.7.9.5

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/26] staging: comedi: amplc_pci224: fix the ao cmd-start_arg use

2014-04-17 Thread H Hartley Sweeten
This driver supports two cmd-start_src values, TRIG_INT and TRIG_EXT. For
TRIG_INT sources, the cmd-start_arg is actually the valid trig_num that is
passed to the async (*inttrig) callback. This driver trivially validates the
arg for this source to be 0.

Refactor the (*inttrig) so that the cmd-start_arg is used to check the trig_num
instead of the open coded value.

For aesthetics, refactor the (*do_cmd) to use if/else instead of the switch when
handling the cmd-start_src. All code paths do the spin lock/unlock so move 
those
out of the if/else.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/amplc_pci224.c | 31 ++-
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c 
b/drivers/staging/comedi/drivers/amplc_pci224.c
index e99829e..3b9a8b9 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/staging/comedi/drivers/amplc_pci224.c
@@ -671,14 +671,13 @@ static void pci224_ao_handle_fifo(struct comedi_device 
*dev,
cfc_handle_events(dev, s);
 }
 
-/*
- * Internal trigger function to start acquisition on AO subdevice.
- */
-static int
-pci224_ao_inttrig_start(struct comedi_device *dev, struct comedi_subdevice *s,
-   unsigned int trignum)
+static int pci224_ao_inttrig_start(struct comedi_device *dev,
+  struct comedi_subdevice *s,
+  unsigned int trig_num)
 {
-   if (trignum != 0)
+   struct comedi_cmd *cmd = s-async-cmd;
+
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
s-async-inttrig = NULL;
@@ -1053,23 +1052,15 @@ static int pci224_ao_cmd(struct comedi_device *dev, 
struct comedi_subdevice *s)
break;
}
 
-   /*
-* Sort out start of acquisition.
-*/
-   switch (cmd-start_src) {
-   case TRIG_INT:
-   spin_lock_irqsave(devpriv-ao_spinlock, flags);
-   s-async-inttrig = pci224_ao_inttrig_start;
-   spin_unlock_irqrestore(devpriv-ao_spinlock, flags);
-   break;
-   case TRIG_EXT:
+   spin_lock_irqsave(devpriv-ao_spinlock, flags);
+   if (cmd-start_src == TRIG_INT) {
+   s-async-inttrig = pci224_ao_inttrig_start;
+   } else {/* TRIG_EXT */
/* Enable external interrupt trigger to start acquisition. */
-   spin_lock_irqsave(devpriv-ao_spinlock, flags);
devpriv-intsce |= PCI224_INTR_EXT;
outb(devpriv-intsce, devpriv-iobase1 + PCI224_INT_SCE);
-   spin_unlock_irqrestore(devpriv-ao_spinlock, flags);
-   break;
}
+   spin_unlock_irqrestore(devpriv-ao_spinlock, flags);
 
return 0;
 }
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/26] staging: comedi: adl_pci9118: fix the ai cmd-start_arg validation and use

2014-04-17 Thread H Hartley Sweeten
This driver supports three cmd-start_src values, TRIG_NOW, TRIG_EXT, and
TRIG_INT. TRIG_NOW sources should always have an arg of 0 and arg for TRIG_EXT
sources is driver specific. This driver does not use the cmd-start_arg with
the TRIG_EXT source so a trivial value of 0 is good.

When the cmd-start_src is TRIG_INT the cmd-start_arg is actually the valid
trig_num that is passed to the async (*inttrig) callback. This driver allows
any value to be used and currently carries that value in the private data.

Refactor the (*do_cmdtest) so that the trivial validation of the cmd-start_arg
is clear.

Refactor the (*inttrig) so that the cmd-start_arg is used directly to check
the trig_num and remove the then unused 'ai_inttrig_start' member from the
private data.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/adl_pci9118.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index 53bbc59..4be5f67 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -411,7 +411,6 @@ struct pci9118_private {
 */
unsigned int ai_maskerr;/* which warning was printed */
unsigned int ai_maskharderr;/* on which error bits stops */
-   unsigned int ai_inttrig_start;  /* TRIG_INT for start */
 };
 
 static int check_channel_list(struct comedi_device *dev,
@@ -1135,11 +1134,13 @@ static irqreturn_t interrupt_pci9118(int irq, void *d)
 }
 
 static int pci9118_ai_inttrig(struct comedi_device *dev,
- struct comedi_subdevice *s, unsigned int trignum)
+ struct comedi_subdevice *s,
+ unsigned int trig_num)
 {
struct pci9118_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
 
-   if (trignum != devpriv-ai_inttrig_start)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
devpriv-ai12_startstop = ~START_AI_INT;
@@ -1221,8 +1222,15 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
 
/* Step 3: check if arguments are trivially valid */
 
-   if (cmd-start_src  (TRIG_NOW | TRIG_EXT))
+   switch (cmd-start_src) {
+   case TRIG_NOW:
+   case TRIG_EXT:
err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+   break;
+   case TRIG_INT:
+   /* start_arg is the internal trigger (any value) */
+   break;
+   }
 
if (cmd-scan_begin_src  (TRIG_FOLLOW | TRIG_EXT))
err |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, 0);
@@ -1627,7 +1635,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, 
struct comedi_subdevice *s)
}
if (cmd-start_src == TRIG_INT) {
devpriv-ai12_startstop |= START_AI_INT;
-   devpriv-ai_inttrig_start = cmd-start_arg;
s-async-inttrig = pci9118_ai_inttrig;
}
 #if 0
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 13/26] staging: comedi: cb_pcidas64: validate the ai/ao cmd-start_arg

2014-04-17 Thread H Hartley Sweeten
The cmd-start_arg should be trivially validated in Step 3 of the
(*do_cmdtest) functions. Add the necessary code.

For the analog output, a cmd-start_src of TRIG_NOW and TRIG_INT is
supported. For both sources the cmd-start_arg is validated to be 0.
For a TRIG_INT source, the cmd-start_Arg is actually the valid trig_num
that is passed to the async (*inttrig) callback.

Refactor the (*inttrig) function so that the cmd-start_arg is used to
check the trig_num instead of the open coded value.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/cb_pcidas64.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c 
b/drivers/staging/comedi/drivers/cb_pcidas64.c
index 0a2b928..4061f04 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -2087,6 +2087,18 @@ static int ai_cmdtest(struct comedi_device *dev, struct 
comedi_subdevice *s,
 
/* Step 3: check if arguments are trivially valid */
 
+   switch (cmd-start_src) {
+   case TRIG_NOW:
+   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+   break;
+   case TRIG_EXT:
+   /*
+* start_arg is the CR_CHAN | CR_INVERT of the
+* external trigger.
+*/
+   break;
+   }
+
if (cmd-convert_src == TRIG_TIMER) {
if (thisboard-layout == LAYOUT_4020) {
err |= cfc_check_trigger_arg_is(cmd-convert_arg, 0);
@@ -3215,7 +3227,7 @@ static int ao_inttrig(struct comedi_device *dev, struct 
comedi_subdevice *s,
struct comedi_cmd *cmd = s-async-cmd;
int retval;
 
-   if (trig_num != 0)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
retval = prep_ao_dma(dev, cmd);
@@ -3315,6 +3327,8 @@ static int ao_cmdtest(struct comedi_device *dev, struct 
comedi_subdevice *s,
 
/* Step 3: check if arguments are trivially valid */
 
+   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+
if (cmd-scan_begin_src == TRIG_TIMER) {
err |= cfc_check_trigger_arg_min(cmd-scan_begin_arg,
 thisboard-ao_scan_speed);
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/26] staging: comedi: round 2 of async command support cleanup

2014-04-17 Thread H Hartley Sweeten
This series continues the cleanup of the comedi async command support.

H Hartley Sweeten (26):
  staging: comedi: drivers: core validates chanlist_len max
  staging: comedi: drivers: properly validate cmd-scan_end_arg
  staging: comedi: addi_apci_3xxx: fix ai subdevice 'len_chanlist'
  staging: comedi: adl_pci9111: rename local var in pci9111_ai_do_cmd_test()
  staging: comedi: comedi_test: ao subdevice does not support async commands
  staging: comedi: hwdrv_apci3200: properly validata the ai cmd-start_arg
  staging: comedi: adl_pci9118: fix the ai cmd-start_arg validation and use
  staging: comedi: amplc_dio200_common: fix the cmd-start_arg use
  staging: comedi: amplc_pci224: fix the ao cmd-start_arg use
  staging: comedi: amplc_pci230: fix the ai/ao cmd-start_arg use for TRIG_INT
  staging: comedi: cb_pcidas: clarify the ai cmd-start_arg validation
  staging: comedi: cb_pcidas: fix the ao cmd-start_arg use for TRIG_INT
  staging: comedi: cb_pcidas64: validate the ai/ao cmd-start_arg
  staging: comedi: dt282x: fix the ao cmd-start_arg use for TRIG_INT
  staging: comedi: gsc_hpdi: validate the cmd-start_arg
  staging: comedi: me4000: validate the cmd-start_arg
  staging: comedi: ni_pcidio: fix the cmd-start_arg use for TRIG_INT
  staging: comedi: ni_tiocmd: clarify the cmd-start_arg validation and use
  staging: comedi: ni_labpc: clarify the cmd-start_arg validation
  staging: comedi: pcmmio: fix the cmd-start_arg use for TRIG_INT
  staging: comedi: pcmuio: fix the cmd-start_arg use for TRIG_INT
  staging: comedi: s626: clarify the cmd-start_arg validation and use
  staging: comedi: usbduxsigma: fix the ai/ao cmd-start_arg use for TRIG_INT
  staging: comedi: usbduxfast: fix the cmd-start_arg validation and use
  staging: comedi: usbdux: fix the cmd-start_arg use
  staging: comedi: ni_mio_common: clarify the cmd-start_arg validation and use

 drivers/staging/comedi/drivers/8255.c  |  3 +-
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  |  4 +-
 .../comedi/drivers/addi-data/hwdrv_apci3200.c  | 43 -
 drivers/staging/comedi/drivers/addi_apci_1032.c|  3 +-
 drivers/staging/comedi/drivers/addi_apci_3xxx.c| 40 ++--
 drivers/staging/comedi/drivers/adl_pci9111.c   | 57 -
 drivers/staging/comedi/drivers/adl_pci9118.c   | 19 --
 .../staging/comedi/drivers/amplc_dio200_common.c   | 27 +++-
 drivers/staging/comedi/drivers/amplc_pc236.c   |  3 +-
 drivers/staging/comedi/drivers/amplc_pci224.c  | 31 -
 drivers/staging/comedi/drivers/amplc_pci230.c  | 14 ++--
 drivers/staging/comedi/drivers/cb_pcidas.c | 10 +--
 drivers/staging/comedi/drivers/cb_pcidas64.c   | 16 -
 drivers/staging/comedi/drivers/comedi_parport.c|  3 +-
 drivers/staging/comedi/drivers/comedi_test.c   |  4 --
 drivers/staging/comedi/drivers/dt282x.c|  8 ++-
 drivers/staging/comedi/drivers/gsc_hpdi.c  |  2 +
 drivers/staging/comedi/drivers/me4000.c|  2 +
 drivers/staging/comedi/drivers/ni_6527.c   |  3 +-
 drivers/staging/comedi/drivers/ni_65xx.c   |  3 +-
 drivers/staging/comedi/drivers/ni_labpc.c  |  8 ++-
 drivers/staging/comedi/drivers/ni_mio_common.c | 74 --
 drivers/staging/comedi/drivers/ni_pcidio.c |  6 +-
 drivers/staging/comedi/drivers/ni_tiocmd.c | 18 --
 drivers/staging/comedi/drivers/pcl726.c|  3 +-
 drivers/staging/comedi/drivers/pcl812.c|  1 -
 drivers/staging/comedi/drivers/pcmmio.c| 22 +++
 drivers/staging/comedi/drivers/pcmuio.c| 22 +++
 drivers/staging/comedi/drivers/rtd520.c|  6 +-
 drivers/staging/comedi/drivers/s626.c  | 19 --
 drivers/staging/comedi/drivers/usbdux.c| 22 ---
 drivers/staging/comedi/drivers/usbduxfast.c| 21 ++
 drivers/staging/comedi/drivers/usbduxsigma.c   | 12 ++--
 33 files changed, 283 insertions(+), 246 deletions(-)

-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/26] staging: comedi: amplc_dio200_common: fix the cmd-start_arg use

2014-04-17 Thread H Hartley Sweeten
This driver supports two cmd-start_src values, TRIG_NOW and TRIG_INT. TRIG_NOW
sources should always have an arg of 0. For TRIG_INT sources, the cmd-start_arg
is actually the valid trig_num that is passed to the async (*inttrig) callback.
This driver trivially validates the arg for both sources to be 0.

Refactor the (*inttrig) so that the cmd-start_arg is used to check the trig_num
instead of the open coded value.

For aesthetics, refactor the (*do_cmd) to use if/else instead of the switch when
handling the cmd-start_src.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../staging/comedi/drivers/amplc_dio200_common.c   | 27 --
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c 
b/drivers/staging/comedi/drivers/amplc_dio200_common.c
index 818a0d7..4ac3208 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_common.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c
@@ -281,22 +281,18 @@ static int dio200_start_intr(struct comedi_device *dev,
return retval;
 }
 
-/*
- * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice.
- */
-static int
-dio200_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice 
*s,
- unsigned int trignum)
+static int dio200_inttrig_start_intr(struct comedi_device *dev,
+struct comedi_subdevice *s,
+unsigned int trig_num)
 {
-   struct dio200_subdev_intr *subpriv;
+   struct dio200_subdev_intr *subpriv = s-private;
+   struct comedi_cmd *cmd = s-async-cmd;
unsigned long flags;
int event = 0;
 
-   if (trignum != 0)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
-   subpriv = s-private;
-
spin_lock_irqsave(subpriv-spinlock, flags);
s-async-inttrig = NULL;
if (subpriv-active)
@@ -528,16 +524,11 @@ static int dio200_subdev_intr_cmd(struct comedi_device 
*dev,
break;
}
 
-   /* Set up start of acquisition. */
-   switch (cmd-start_src) {
-   case TRIG_INT:
+   if (cmd-start_src == TRIG_INT)
s-async-inttrig = dio200_inttrig_start_intr;
-   break;
-   default:
-   /* TRIG_NOW */
+   else/* TRIG_NOW */
event = dio200_start_intr(dev, s);
-   break;
-   }
+
spin_unlock_irqrestore(subpriv-spinlock, flags);
 
if (event)
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 23/26] staging: comedi: usbduxsigma: fix the ai/ao cmd-start_arg use for TRIG_INT

2014-04-17 Thread H Hartley Sweeten
For both ai and ao commands this driver supports a cmd-start_src of
TRIG_NOW or TRIG_INT. The cmd-start_arg is trivially validated for
both sources to be 0.

For a TRIG_INT source, the cmd-start_arg is actually the valid
trig_num that is used by the async (*inttrig) callback.

Refactor the (*inttrig) functions so that the cmd-start_arg is used
to check the trig_num instead of the open coded values.

For aesthetics, remove some unnecessary comments in the (*do_cmd)
functions.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/usbduxsigma.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 88c60b6..b57c974 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -663,12 +663,13 @@ static int usbduxsigma_receive_cmd(struct comedi_device 
*dev, int command)
 
 static int usbduxsigma_ai_inttrig(struct comedi_device *dev,
  struct comedi_subdevice *s,
- unsigned int trignum)
+ unsigned int trig_num)
 {
struct usbduxsigma_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
int ret;
 
-   if (trignum != 0)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
down(devpriv-sem);
@@ -738,7 +739,6 @@ static int usbduxsigma_ai_cmd(struct comedi_device *dev,
}
s-async-inttrig = NULL;
} else {/* TRIG_INT */
-   /* wait for an internal signal and submit the urbs later */
s-async-inttrig = usbduxsigma_ai_inttrig;
}
 
@@ -856,12 +856,13 @@ static int usbduxsigma_ao_insn_write(struct comedi_device 
*dev,
 
 static int usbduxsigma_ao_inttrig(struct comedi_device *dev,
  struct comedi_subdevice *s,
- unsigned int trignum)
+ unsigned int trig_num)
 {
struct usbduxsigma_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
int ret;
 
-   if (trignum != 0)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
down(devpriv-sem);
@@ -1027,7 +1028,6 @@ static int usbduxsigma_ao_cmd(struct comedi_device *dev,
}
s-async-inttrig = NULL;
} else {/* TRIG_INT */
-   /* wait for an internal signal and submit the urbs later */
s-async-inttrig = usbduxsigma_ao_inttrig;
}
 
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/26] staging: comedi: ni_pcidio: fix the cmd-start_arg use for TRIG_INT

2014-04-17 Thread H Hartley Sweeten
This driver only a cmd-start_src of TRIG_NOW or TRIG_INT. The cmd-start_arg
is trivially validated for both sources to be 0. For a TRIG_INT source, the
cmd-start_arg is actually the valid trig_num that is passed to the async
(*inttrig) callback.

Refactor the (*inttrig) function so that the cmd-start_arg is used to check
the trig_num instead of the open coded value.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_pcidio.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c 
b/drivers/staging/comedi/drivers/ni_pcidio.c
index 85ac2d9..962c235 100644
--- a/drivers/staging/comedi/drivers/ni_pcidio.c
+++ b/drivers/staging/comedi/drivers/ni_pcidio.c
@@ -773,11 +773,13 @@ static int setup_mite_dma(struct comedi_device *dev, 
struct comedi_subdevice *s)
 }
 
 static int ni_pcidio_inttrig(struct comedi_device *dev,
-struct comedi_subdevice *s, unsigned int trignum)
+struct comedi_subdevice *s,
+unsigned int trig_num)
 {
struct nidio96_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
 
-   if (trignum != 0)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
writeb(devpriv-OpModeBits, devpriv-mite-daq_io_addr + OpMode);
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/26] staging: comedi: drivers: core validates chanlist_len max

2014-04-17 Thread H Hartley Sweeten
The comedi core checks if the (cmd-chanlist_len  s-len_chanlist) when the
comedi_cmd is copied from user to kernel space by __comedi_get_user_cmd().
If so, the core returns -EINVAL and will not call the subdevice (*do_cmdtest)
and (*do_cmd).

Remove the unnecessary max checks in the comedi driver (*do_cmdtest) and
helper functions.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 3 ---
 drivers/staging/comedi/drivers/adl_pci9118.c  | 2 --
 drivers/staging/comedi/drivers/pcl812.c   | 1 -
 drivers/staging/comedi/drivers/rtd520.c   | 4 
 4 files changed, 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 70e8f42..66c24e4 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -734,7 +734,6 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
   struct comedi_subdevice *s,
   struct comedi_cmd *cmd)
 {
-   const struct addi_board *this_board = comedi_board(dev);
int err = 0;
 
/* Step 1 : check if triggers are trivially valid */
@@ -779,8 +778,6 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
}
 
err |= cfc_check_trigger_arg_min(cmd-chanlist_len, 1);
-   err |= cfc_check_trigger_arg_max(cmd-chanlist_len,
-this_board-i_AiChannelList);
 
if (cmd-stop_src == TRIG_COUNT)
err |= cfc_check_trigger_arg_min(cmd-stop_arg, 1);
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index b6abef6..53bbc59 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -1259,8 +1259,6 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev,
err |= cfc_check_trigger_arg_is(cmd-stop_arg, 0);
 
err |= cfc_check_trigger_arg_min(cmd-chanlist_len, 1);
-   err |= cfc_check_trigger_arg_max(cmd-chanlist_len,
-this_board-n_aichanlist);
 
err |= cfc_check_trigger_arg_min(cmd-scan_end_arg,
 cmd-chanlist_len);
diff --git a/drivers/staging/comedi/drivers/pcl812.c 
b/drivers/staging/comedi/drivers/pcl812.c
index 5cc01fe..0cf115e 100644
--- a/drivers/staging/comedi/drivers/pcl812.c
+++ b/drivers/staging/comedi/drivers/pcl812.c
@@ -761,7 +761,6 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev,
err |= cfc_check_trigger_arg_is(cmd-convert_arg, 0);
 
err |= cfc_check_trigger_arg_min(cmd-chanlist_len, 1);
-   err |= cfc_check_trigger_arg_max(cmd-chanlist_len, MAX_CHANLIST_LEN);
err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, cmd-chanlist_len);
 
if (cmd-stop_src == TRIG_COUNT)
diff --git a/drivers/staging/comedi/drivers/rtd520.c 
b/drivers/staging/comedi/drivers/rtd520.c
index cd3fdf9..1b1c166 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -891,10 +891,6 @@ static int rtd_ai_cmdtest(struct comedi_device *dev,
 
/* step 4: fix up any arguments */
 
-   if (cmd-chanlist_len  RTD_MAX_CHANLIST) {
-   cmd-chanlist_len = RTD_MAX_CHANLIST;
-   err++;
-   }
if (cmd-scan_begin_src == TRIG_TIMER) {
tmp = cmd-scan_begin_arg;
rtd_ns_to_timer(cmd-scan_begin_arg,
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/26] staging: comedi: comedi_test: ao subdevice does not support async commands

2014-04-17 Thread H Hartley Sweeten
The comedi_subdevices array is kzalloc()'d so the async command callbacks do
not need to be set to NULL when the analog output subdevice is initialized.

Also, remove the initialzation of the subdevice 'len_chanlist' since this
value is only used by the async commands. The core will default it to 1.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/comedi_test.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index cd95625..ad5014a 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -413,11 +413,7 @@ static int waveform_attach(struct comedi_device *dev,
s-n_chan = N_CHANS;
s-maxdata = 0x;
s-range_table = waveform_ai_ranges;
-   s-len_chanlist = s-n_chan * 2;
s-insn_write = waveform_ao_insn_write;
-   s-do_cmd = NULL;
-   s-do_cmdtest = NULL;
-   s-cancel = NULL;
 
/* Our default loopback value is just a 0V flatline */
for (i = 0; i  s-n_chan; i++)
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 16/26] staging: comedi: me4000: validate the cmd-start_arg

2014-04-17 Thread H Hartley Sweeten
The cmd-start_arg should be trivially validated in Step 3 of the
(*do_cmdtest) functions. Add the necessary code.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/me4000.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index e146555..f43221f 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -918,6 +918,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
 
/* Step 3: check if arguments are trivially valid */
 
+   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+
if (cmd-chanlist_len  1) {
cmd-chanlist_len = 1;
err |= -EINVAL;
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 21/26] staging: comedi: pcmuio: fix the cmd-start_arg use for TRIG_INT

2014-04-17 Thread H Hartley Sweeten
This driver supports a cmd-start_src of TRIG_NOW or TRIG_INT. The
cmd-start_arg is trivially validated for both sources to be 0.

For a TRIG_INT source, the cmd-start_arg is actually the valid
trig_num that is used by the async (*inttrig) callback.

Refactor the (*inttrig) function so that the cmd-start_arg is used
to check the trig_num instead of the open coded value.

For aesthetics, refactor the (*do_cmd) to use if/else instead if the
switch when handling the cmd-start_src.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/pcmuio.c | 22 --
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcmuio.c 
b/drivers/staging/comedi/drivers/pcmuio.c
index a8f390f..ea45424 100644
--- a/drivers/staging/comedi/drivers/pcmuio.c
+++ b/drivers/staging/comedi/drivers/pcmuio.c
@@ -460,20 +460,18 @@ static int pcmuio_cancel(struct comedi_device *dev, 
struct comedi_subdevice *s)
return 0;
 }
 
-/*
- * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice.
- */
-static int
-pcmuio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice 
*s,
- unsigned int trignum)
+static int pcmuio_inttrig_start_intr(struct comedi_device *dev,
+struct comedi_subdevice *s,
+unsigned int trig_num)
 {
struct pcmuio_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
int asic = pcmuio_subdevice_to_asic(s);
struct pcmuio_asic *chip = devpriv-asics[asic];
unsigned long flags;
int event = 0;
 
-   if (trignum != 0)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
spin_lock_irqsave(chip-spinlock, flags);
@@ -518,15 +516,11 @@ static int pcmuio_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
}
 
/* Set up start of acquisition. */
-   switch (cmd-start_src) {
-   case TRIG_INT:
+   if (cmd-start_src == TRIG_INT)
s-async-inttrig = pcmuio_inttrig_start_intr;
-   break;
-   default:
-   /* TRIG_NOW */
+   else/* TRIG_NOW */
event = pcmuio_start_intr(dev, s);
-   break;
-   }
+
spin_unlock_irqrestore(chip-spinlock, flags);
 
if (event)
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/26] staging: comedi: adl_pci9111: rename local var in pci9111_ai_do_cmd_test()

2014-04-17 Thread H Hartley Sweeten
For aesthetics, rename the local variable 'error' to 'err'. This is the
normal name for this local variable in (*do_cmdtest) functions.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/adl_pci9111.c | 57 ++--
 1 file changed, 28 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c 
b/drivers/staging/comedi/drivers/adl_pci9111.c
index 575af74..6fc8593 100644
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/staging/comedi/drivers/adl_pci9111.c
@@ -354,68 +354,67 @@ static int pci9111_ai_do_cmd_test(struct comedi_device 
*dev,
  struct comedi_cmd *cmd)
 {
struct pci9111_private_data *dev_private = dev-private;
+   int err = 0;
int tmp;
-   int error = 0;
 
/* Step 1 : check if triggers are trivially valid */
 
-   error |= cfc_check_trigger_src(cmd-start_src, TRIG_NOW);
-   error |= cfc_check_trigger_src(cmd-scan_begin_src,
+   err |= cfc_check_trigger_src(cmd-start_src, TRIG_NOW);
+   err |= cfc_check_trigger_src(cmd-scan_begin_src,
TRIG_TIMER | TRIG_FOLLOW | TRIG_EXT);
-   error |= cfc_check_trigger_src(cmd-convert_src,
+   err |= cfc_check_trigger_src(cmd-convert_src,
TRIG_TIMER | TRIG_EXT);
-   error |= cfc_check_trigger_src(cmd-scan_end_src, TRIG_COUNT);
-   error |= cfc_check_trigger_src(cmd-stop_src,
+   err |= cfc_check_trigger_src(cmd-scan_end_src, TRIG_COUNT);
+   err |= cfc_check_trigger_src(cmd-stop_src,
TRIG_COUNT | TRIG_NONE);
 
-   if (error)
+   if (err)
return 1;
 
/* Step 2a : make sure trigger sources are unique */
 
-   error |= cfc_check_trigger_is_unique(cmd-scan_begin_src);
-   error |= cfc_check_trigger_is_unique(cmd-convert_src);
-   error |= cfc_check_trigger_is_unique(cmd-stop_src);
+   err |= cfc_check_trigger_is_unique(cmd-scan_begin_src);
+   err |= cfc_check_trigger_is_unique(cmd-convert_src);
+   err |= cfc_check_trigger_is_unique(cmd-stop_src);
 
/* Step 2b : and mutually compatible */
 
if ((cmd-convert_src == TRIG_TIMER) 
!((cmd-scan_begin_src == TRIG_TIMER) ||
  (cmd-scan_begin_src == TRIG_FOLLOW)))
-   error |= -EINVAL;
+   err |= -EINVAL;
if ((cmd-convert_src == TRIG_EXT) 
!((cmd-scan_begin_src == TRIG_EXT) ||
  (cmd-scan_begin_src == TRIG_FOLLOW)))
-   error |= -EINVAL;
+   err |= -EINVAL;
 
-   if (error)
+   if (err)
return 2;
 
/* Step 3: check if arguments are trivially valid */
 
-   error |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
 
if (cmd-convert_src == TRIG_TIMER)
-   error |= cfc_check_trigger_arg_min(cmd-convert_arg,
+   err |= cfc_check_trigger_arg_min(cmd-convert_arg,
PCI9111_AI_ACQUISITION_PERIOD_MIN_NS);
else/* TRIG_EXT */
-   error |= cfc_check_trigger_arg_is(cmd-convert_arg, 0);
+   err |= cfc_check_trigger_arg_is(cmd-convert_arg, 0);
 
if (cmd-scan_begin_src == TRIG_TIMER)
-   error |= cfc_check_trigger_arg_min(cmd-scan_begin_arg,
+   err |= cfc_check_trigger_arg_min(cmd-scan_begin_arg,
PCI9111_AI_ACQUISITION_PERIOD_MIN_NS);
else/* TRIG_FOLLOW || TRIG_EXT */
-   error |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, 0);
+   err |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, 0);
 
-   error |= cfc_check_trigger_arg_is(cmd-scan_end_arg,
- cmd-chanlist_len);
+   err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, cmd-chanlist_len);
 
if (cmd-stop_src == TRIG_COUNT)
-   error |= cfc_check_trigger_arg_min(cmd-stop_arg, 1);
+   err |= cfc_check_trigger_arg_min(cmd-stop_arg, 1);
else/* TRIG_NONE */
-   error |= cfc_check_trigger_arg_is(cmd-stop_arg, 0);
+   err |= cfc_check_trigger_arg_is(cmd-stop_arg, 0);
 
-   if (error)
+   if (err)
return 3;
 
/*  Step 4 : fix up any arguments */
@@ -427,7 +426,7 @@ static int pci9111_ai_do_cmd_test(struct comedi_device *dev,
  dev_private-div2,
  cmd-convert_arg, cmd-flags);
if (tmp != cmd-convert_arg)
-   error++;
+   err |= -EINVAL;
}
/*  There's only one timer on this card, so the scan_begin timer must */
/*  

[PATCH 12/26] staging: comedi: cb_pcidas: fix the ao cmd-start_arg use for TRIG_INT

2014-04-17 Thread H Hartley Sweeten
This driver only supports a cmd-start_src of TRIG_INT for ai commands. The
cmd-start_arg is trivially validated to be 0. For TRIG_INT source, the
cmd-start_arg is actually the valid trig_num that is passed to the async
(*inttrig) callback.

Refactor the (*inttrig) function so that the cmd-start_arg is used to check
the trig_num instead of the open coded value.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/cb_pcidas.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c 
b/drivers/staging/comedi/drivers/cb_pcidas.c
index 523378f..26fc00e 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -1169,7 +1169,7 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
struct comedi_cmd *cmd = s-async-cmd;
unsigned long flags;
 
-   if (trig_num != 0)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
/*  load up fifo */
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 20/26] staging: comedi: pcmmio: fix the cmd-start_arg use for TRIG_INT

2014-04-17 Thread H Hartley Sweeten
This driver supports a cmd-start_src of TRIG_NOW or TRIG_INT. The
cmd-start_arg is trivially validated for both sources to be 0.

For a TRIG_INT source, the cmd-start_arg is actually the valid
trig_num that is used by the async (*inttrig) callback.

Refactor the (*inttrig) function so that the cmd-start_arg is used
to check the trig_num instead of the open coded value.

For aesthetics, refactor the (*do_cmd) to use if/else instead if the
switch when handling the cmd-start_src.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/pcmmio.c | 22 --
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/pcmmio.c 
b/drivers/staging/comedi/drivers/pcmmio.c
index e89bca8..bb29ecf 100644
--- a/drivers/staging/comedi/drivers/pcmmio.c
+++ b/drivers/staging/comedi/drivers/pcmmio.c
@@ -464,18 +464,16 @@ static int pcmmio_cancel(struct comedi_device *dev, 
struct comedi_subdevice *s)
return 0;
 }
 
-/*
- * Internal trigger function to start acquisition for an 'INTERRUPT' subdevice.
- */
-static int
-pcmmio_inttrig_start_intr(struct comedi_device *dev, struct comedi_subdevice 
*s,
- unsigned int trignum)
+static int pcmmio_inttrig_start_intr(struct comedi_device *dev,
+struct comedi_subdevice *s,
+unsigned int trig_num)
 {
struct pcmmio_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
unsigned long flags;
int event = 0;
 
-   if (trignum != 0)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
spin_lock_irqsave(devpriv-spinlock, flags);
@@ -517,15 +515,11 @@ static int pcmmio_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
}
 
/* Set up start of acquisition. */
-   switch (cmd-start_src) {
-   case TRIG_INT:
+   if (cmd-start_src == TRIG_INT)
s-async-inttrig = pcmmio_inttrig_start_intr;
-   break;
-   default:
-   /* TRIG_NOW */
+   else/* TRIG_NOW */
event = pcmmio_start_intr(dev, s);
-   break;
-   }
+
spin_unlock_irqrestore(devpriv-spinlock, flags);
 
if (event)
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/26] staging: comedi: cb_pcidas: clarify the ai cmd-start_arg validation

2014-04-17 Thread H Hartley Sweeten
This driver supports two cmd-start_src values, TRIG_NOW and TRIG_EXT.

For aesthetics, replace the default case when validating the cmd-start_arg
with the proper case statement.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/cb_pcidas.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c 
b/drivers/staging/comedi/drivers/cb_pcidas.c
index 70d9267..523378f 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -872,9 +872,12 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
if (err)
return 2;
 
-   /* step 3: arguments are trivially compatible */
+   /* Step 3: check if arguments are trivially valid */
 
switch (cmd-start_src) {
+   case TRIG_NOW:
+   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+   break;
case TRIG_EXT:
/* External trigger, only CR_EDGE and CR_INVERT flags allowed */
if ((cmd-start_arg
@@ -888,9 +891,6 @@ static int cb_pcidas_ai_cmdtest(struct comedi_device *dev,
err |= -EINVAL;
}
break;
-   default:
-   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
-   break;
}
 
if (cmd-scan_begin_src == TRIG_TIMER)
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/26] staging: comedi: dt282x: fix the ao cmd-start_arg use for TRIG_INT

2014-04-17 Thread H Hartley Sweeten
This driver only supports a cmd-start_src of TRIG_INT for ao commands. The
cmd-start_arg is trivially validated to be 0. For TRIG_INT source, the
cmd-start_arg is actually the valid trig_num that is passed to the async
(*inttrig) callback.

Refactor the (*inttrig) function so that the cmd-start_arg is used to check
the trig_num instead of the open coded value.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/dt282x.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/dt282x.c 
b/drivers/staging/comedi/drivers/dt282x.c
index b1154f0..474f52d 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -878,12 +878,14 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev,
 }
 
 static int dt282x_ao_inttrig(struct comedi_device *dev,
-struct comedi_subdevice *s, unsigned int x)
+struct comedi_subdevice *s,
+unsigned int trig_num)
 {
struct dt282x_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
int size;
 
-   if (x != 0)
+   if (trig_num != cmd-start_src)
return -EINVAL;
 
size = cfc_read_array_from_buffer(s, devpriv-dma[0].buf,
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 19/26] staging: comedi: ni_labpc: clarify the cmd-start_arg validation

2014-04-17 Thread H Hartley Sweeten
This driver supports cmd-start_src sources of TRIG_NOW and TRIG_EXT.
Refactor the (*do_cmdtest) to clarify the trivial validation of the
cmd-start_arg.

This also fixes a bug, the cmd-start_src has the trigger not the
cmd-start_arg.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_labpc.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/ni_labpc.c 
b/drivers/staging/comedi/drivers/ni_labpc.c
index f80ca32..fc9d314 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -649,8 +649,14 @@ static int labpc_ai_cmdtest(struct comedi_device *dev,
 
/* Step 3: check if arguments are trivially valid */
 
-   if (cmd-start_arg == TRIG_NOW)
+   switch (cmd-start_src) {
+   case TRIG_NOW:
err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+   break;
+   case TRIG_EXT:
+   /* start_arg value is ignored */
+   break;
+   }
 
if (!cmd-chanlist_len)
err |= -EINVAL;
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 24/26] staging: comedi: usbduxfast: fix the cmd-start_arg validation and use

2014-04-17 Thread H Hartley Sweeten
This driver supports cmd-start_src values of TRIG_NOW, TRIG_EXT, and
TRIG_INT. Currently the cmd-start_arg is only validated for TRIG_NOW.

For TRIG_EXT sources, the cmd-start_src is driver specific. For a
TRIG_INT source, the cmd-start_arg is actually the valid trig_num
that is used by the async (*inttrig) callback.

The cmd-start_arg is currently not use in the driver. Just trivially
validate it to be 0 for all cmd-start_src values.

Refactor the (*inttrig) function so that the cmd-start_arg is used
to check the trig_num instead of the open coded value.

For aesthetics, remove some unnecessary comments in the (*do_cmd)
function.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/usbduxfast.c | 21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxfast.c 
b/drivers/staging/comedi/drivers/usbduxfast.c
index d6fae11..a4d7bfb 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/staging/comedi/drivers/usbduxfast.c
@@ -398,8 +398,7 @@ static int usbduxfast_ai_cmdtest(struct comedi_device *dev,
 
/* Step 3: check if arguments are trivially valid */
 
-   if (cmd-start_src == TRIG_NOW)
-   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
 
if (!cmd-chanlist_len)
err |= -EINVAL;
@@ -451,21 +450,20 @@ static int usbduxfast_ai_cmdtest(struct comedi_device 
*dev,
 
 static int usbduxfast_ai_inttrig(struct comedi_device *dev,
 struct comedi_subdevice *s,
-unsigned int trignum)
+unsigned int trig_num)
 {
struct usbduxfast_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
int ret;
 
if (!devpriv)
return -EFAULT;
 
+   if (trig_num != cmd-start_arg)
+   return -EINVAL;
+
down(devpriv-sem);
 
-   if (trignum != 0) {
-   dev_err(dev-class_dev, invalid trignum\n);
-   up(devpriv-sem);
-   return -EINVAL;
-   }
if (!devpriv-ai_cmd_running) {
devpriv-ai_cmd_running = 1;
ret = usbduxfast_submit_urb(dev);
@@ -837,12 +835,7 @@ static int usbduxfast_ai_cmd(struct comedi_device *dev,
return ret;
}
s-async-inttrig = NULL;
-   } else {
-   /*
-* TRIG_INT
-* don't enable the acquision operation
-* wait for an internal signal
-*/
+   } else {/* TRIG_INT */
s-async-inttrig = usbduxfast_ai_inttrig;
}
up(devpriv-sem);
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/26] staging: comedi: amplc_pci230: fix the ai/ao cmd-start_arg use for TRIG_INT

2014-04-17 Thread H Hartley Sweeten
This driver trivially validates the cmd-start_arg for all cmd-start_src values
to be 0. For TRIG_INT source, the cmd-start_arg is actually the valid trig_num
that is passed to the async (*inttrig) callback.

Refactor the (*inttrig) functions so that the cmd-start_arg is used to check 
the
trig_num instead of the open coded values.

For aesthetics, refactor the ai (*do_cmd) to remove some unnecessary {}.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/amplc_pci230.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c 
b/drivers/staging/comedi/drivers/amplc_pci230.c
index 7149f47..d7ffd18 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -1427,7 +1427,9 @@ static int pci230_ao_inttrig_start(struct comedi_device 
*dev,
   struct comedi_subdevice *s,
   unsigned int trig_num)
 {
-   if (trig_num != 0)
+   struct comedi_cmd *cmd = s-async-cmd;
+
+   if (trig_num != cmd-start_src)
return -EINVAL;
 
s-async-inttrig = NULL;
@@ -2146,7 +2148,9 @@ static int pci230_ai_inttrig_start(struct comedi_device 
*dev,
   struct comedi_subdevice *s,
   unsigned int trig_num)
 {
-   if (trig_num != 0)
+   struct comedi_cmd *cmd = s-async-cmd;
+
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
s-async-inttrig = NULL;
@@ -2432,12 +2436,10 @@ static int pci230_ai_cmd(struct comedi_device *dev, 
struct comedi_subdevice *s)
}
}
 
-   if (cmd-start_src == TRIG_INT) {
+   if (cmd-start_src == TRIG_INT)
s-async-inttrig = pci230_ai_inttrig_start;
-   } else {
-   /* TRIG_NOW */
+   else/* TRIG_NOW */
pci230_ai_start(dev, s);
-   }
 
return 0;
 }
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/26] staging: comedi: gsc_hpdi: validate the cmd-start_arg

2014-04-17 Thread H Hartley Sweeten
The cmd-start_arg should be trivially validated in Step 3 of the
(*do_cmdtest) functions. Add the necessary code.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/gsc_hpdi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c 
b/drivers/staging/comedi/drivers/gsc_hpdi.c
index bae4e97..22333c1 100644
--- a/drivers/staging/comedi/drivers/gsc_hpdi.c
+++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
@@ -410,6 +410,8 @@ static int gsc_hpdi_cmd_test(struct comedi_device *dev,
 
/* Step 3: check if arguments are trivially valid */
 
+   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+
if (!cmd-chanlist_len || !cmd-chanlist) {
cmd-chanlist_len = 32;
err |= -EINVAL;
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/26] staging: comedi: hwdrv_apci3200: properly validata the ai cmd-start_arg

2014-04-17 Thread H Hartley Sweeten
The async command 'arguments' should be trivially validated in Step 3 of
the (*do_cmdtest) not Step 2b. Move the validataion in this driver to the
proper place.

This driver supports two cmd-start_src values, TRIG_NOW and TRIG_EXT.
TRIG_NOW sources should always have an arg of 0. The arg for TRIG_EXT
sources is driver specific.

Properly validate the cmd-start_arg based on the cmd-start_src. Remove
the noise when the arg is invalid and modify the cmd-start_arg so that
a valid value is returned to the user.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 .../comedi/drivers/addi-data/hwdrv_apci3200.c  | 38 +-
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
index 76a6682..9b8851c 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
@@ -2221,12 +2221,11 @@ static int apci3200_ai_cmdtest(struct comedi_device 
*dev,
unsigned int ui_ConvertTimeBase = 0;
unsigned int ui_DelayTime = 0;
unsigned int ui_DelayTimeBase = 0;
-   int i_Triggermode = 0;
-   int i_TriggerEdge = 0;
int i_NbrOfChannel = 0;
int i_Cpt = 0;
double d_ConversionTimeForAllChannels = 0.0;
double d_SCANTimeNewUnit = 0.0;
+   unsigned int arg;
 
/* Step 1 : check if triggers are trivially valid */
 
@@ -2253,19 +2252,6 @@ static int apci3200_ai_cmdtest(struct comedi_device *dev,
 
/* Step 2b : and mutually compatible */
 
-   if (cmd-start_src == TRIG_EXT) {
-   i_TriggerEdge = cmd-start_arg  0x;
-   i_Triggermode = cmd-start_arg  16;
-   if (i_TriggerEdge  1 || i_TriggerEdge  3) {
-   err++;
-   printk(\nThe trigger edge selection is in error\n);
-   }
-   if (i_Triggermode != 2) {
-   err++;
-   printk(\nThe trigger mode selection is in error\n);
-   }
-   }
-
if (err) {
apci3200_reset(dev);
return 2;
@@ -2273,6 +2259,28 @@ static int apci3200_ai_cmdtest(struct comedi_device *dev,
 
/* Step 3: check if arguments are trivially valid */
 
+   switch (cmd-start_src) {
+   case TRIG_NOW:
+   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+   break;
+   case TRIG_EXT:
+   /* validate the trigger edge selection */
+   arg = cmd-start_arg  0x;
+   if (arg  1 || arg  3) {
+   cmd-start_arg = ~0x;
+   cmd-start_arg |= 1;
+   err |= -EINVAL;
+   }
+   /* validate the trigger mode selection */
+   arg = cmd-start_arg  16;
+   if (arg != 2) {
+   cmd-start_arg = ~(0x  16);
+   cmd-start_arg |= (2  16);
+   err |= -EINVAL;
+   }
+   break;
+   }
+
err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, cmd-chanlist_len);
 
/* i_FirstChannel=cmd-chanlist[0]; */
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/26] staging: comedi: ni_tiocmd: clarify the cmd-start_arg validation and use

2014-04-17 Thread H Hartley Sweeten
This driver supportes cmd-start_src sources of TRIG_NOW, TRIG_INT, TRIG_OTHER,
and TRIG_EXT. Refactor the (*do_cmdtest) to clarify the trivial validation of
the cmd-start_arg. For a TRIG_INT source, the cmd-start_arg is actually the
valid trig_num that is passed to the async (*inttrig) callback.

Refactor the (*inttrig) function so that the cmd-start_arg is used to check
the trig_num instead of the open coded value.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_tiocmd.c | 18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c 
b/drivers/staging/comedi/drivers/ni_tiocmd.c
index 7d64f88..b9d23db 100644
--- a/drivers/staging/comedi/drivers/ni_tiocmd.c
+++ b/drivers/staging/comedi/drivers/ni_tiocmd.c
@@ -89,14 +89,16 @@ static void ni_tio_configure_dma(struct ni_gpct *counter, 
short enable,
 
 static int ni_tio_input_inttrig(struct comedi_device *dev,
struct comedi_subdevice *s,
-   unsigned int trignum)
+   unsigned int trig_num)
 {
+   struct ni_gpct *counter = s-private;
+   struct comedi_cmd *cmd = s-async-cmd;
unsigned long flags;
int retval = 0;
-   struct ni_gpct *counter = s-private;
 
BUG_ON(counter == NULL);
-   if (trignum != 0)
+
+   if (trig_num != cmd-start_src)
return -EINVAL;
 
spin_lock_irqsave(counter-lock, flags);
@@ -271,8 +273,16 @@ int ni_tio_cmdtest(struct comedi_device *dev,
 
/* Step 3: check if arguments are trivially valid */
 
-   if (cmd-start_src != TRIG_EXT)
+   switch (cmd-start_src) {
+   case TRIG_NOW:
+   case TRIG_INT:
+   case TRIG_OTHER:
err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+   break;
+   case TRIG_EXT:
+   /* start_arg is the start_trigger passed to ni_tio_arm() */
+   break;
+   }
 
if (cmd-scan_begin_src != TRIG_EXT)
err |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, 0);
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 26/26] staging: comedi: ni_mio_common: clarify the cmd-start_arg validation and use

2014-04-17 Thread H Hartley Sweeten
Clarify the cmd-start_arg validation in Step 3 of the (*do_cmdtest)
functions.

For a TRIG_INT source, the cmd-start_arg is actually the valid
trig_num that is used by the async (*inttrig) callbacks.

Refactor the (*inttrig) functions so that the cmd-start_arg is used
to check the trig_num instead of the open coded values.

For aesthetics, refactor the (*do_cmd) functions to use if/else instead
of the switch to handle the cmd-start_src.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 74 +++---
 1 file changed, 42 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 2e26622..087b533 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -2080,7 +2080,7 @@ static int ni_ai_cmdtest(struct comedi_device *dev, 
struct comedi_subdevice *s,
const struct ni_board_struct *board = comedi_board(dev);
struct ni_private *devpriv = dev-private;
int err = 0;
-   int tmp;
+   unsigned int tmp;
unsigned int sources;
 
/* Step 1 : check if triggers are trivially valid */
@@ -2119,17 +2119,19 @@ static int ni_ai_cmdtest(struct comedi_device *dev, 
struct comedi_subdevice *s,
 
/* Step 3: check if arguments are trivially valid */
 
-   if (cmd-start_src == TRIG_EXT) {
-   /* external trigger */
-   unsigned int tmp = CR_CHAN(cmd-start_arg);
+   switch (cmd-start_src) {
+   case TRIG_NOW:
+   case TRIG_INT:
+   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+   break;
+   case TRIG_EXT:
+   tmp = CR_CHAN(cmd-start_arg);
 
if (tmp  16)
tmp = 16;
tmp |= (cmd-start_arg  (CR_INVERT | CR_EDGE));
err |= cfc_check_trigger_arg_is(cmd-start_arg, tmp);
-   } else {
-   /* true for both TRIG_NOW and TRIG_INT */
-   err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
+   break;
}
 
if (cmd-scan_begin_src == TRIG_TIMER) {
@@ -2510,30 +2512,28 @@ static int ni_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
}
 #endif
 
-   switch (cmd-start_src) {
-   case TRIG_NOW:
+   if (cmd-start_src == TRIG_NOW) {
/* AI_START1_Pulse */
devpriv-stc_writew(dev, AI_START1_Pulse | devpriv-ai_cmd2,
AI_Command_2_Register);
s-async-inttrig = NULL;
-   break;
-   case TRIG_EXT:
+   } else if (cmd-start_src == TRIG_EXT) {
s-async-inttrig = NULL;
-   break;
-   case TRIG_INT:
-   s-async-inttrig = ni_ai_inttrig;
-   break;
+   } else {/* TRIG_INT */
+   s-async-inttrig = ni_ai_inttrig;
}
 
return 0;
 }
 
-static int ni_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
-unsigned int trignum)
+static int ni_ai_inttrig(struct comedi_device *dev,
+struct comedi_subdevice *s,
+unsigned int trig_num)
 {
struct ni_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
 
-   if (trignum != 0)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
devpriv-stc_writew(dev, AI_START1_Pulse | devpriv-ai_cmd2,
@@ -2946,17 +2946,19 @@ static int ni_ao_insn_config(struct comedi_device *dev,
return -EINVAL;
 }
 
-static int ni_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s,
-unsigned int trignum)
+static int ni_ao_inttrig(struct comedi_device *dev,
+struct comedi_subdevice *s,
+unsigned int trig_num)
 {
const struct ni_board_struct *board __maybe_unused = comedi_board(dev);
struct ni_private *devpriv = dev-private;
+   struct comedi_cmd *cmd = s-async-cmd;
int ret;
int interrupt_b_bits;
int i;
static const int timeout = 1000;
 
-   if (trignum != 0)
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
/* Null trig at beginning prevent ao start trigger from executing more 
than
@@ -3217,7 +3219,7 @@ static int ni_ao_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
AO_BC_TC_Interrupt_Enable, 1);
}
 
-   s-async-inttrig = ni_ao_inttrig;
+   s-async-inttrig = ni_ao_inttrig;
 
return 0;
 }
@@ -3228,7 +3230,7 @@ static int ni_ao_cmdtest(struct comedi_device *dev, 
struct comedi_subdevice *s,
const struct ni_board_struct *board = comedi_board(dev);
struct ni_private 

[PATCH 02/26] staging: comedi: drivers: properly validate cmd-scan_end_arg

2014-04-17 Thread H Hartley Sweeten
When the async command 'scan_end_src' is TRIG_COUNT the 'scan_end_arg'
is the cmd-chanlist_len. Fix a couple open-coded drivers. Add the
check to the drivers that do not validate this command argument.

The core validates that the cmd-chanlist_len is = s-len_chanlist.
During the post config after the attach the core also make sure that
the s-len_chanlist is initialized. For clarity, initialize the
s-len_chanlist in a couple drivers that are relying on the core to
initialize it to '1'.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/8255.c | 3 ++-
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 1 +
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c | 5 +
 drivers/staging/comedi/drivers/addi_apci_1032.c   | 3 ++-
 drivers/staging/comedi/drivers/amplc_pc236.c  | 3 ++-
 drivers/staging/comedi/drivers/comedi_parport.c   | 3 ++-
 drivers/staging/comedi/drivers/dt282x.c   | 2 +-
 drivers/staging/comedi/drivers/ni_6527.c  | 3 ++-
 drivers/staging/comedi/drivers/ni_65xx.c  | 3 ++-
 drivers/staging/comedi/drivers/pcl726.c   | 3 ++-
 drivers/staging/comedi/drivers/rtd520.c   | 2 ++
 11 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/comedi/drivers/8255.c 
b/drivers/staging/comedi/drivers/8255.c
index 48817f0..1d53e24 100644
--- a/drivers/staging/comedi/drivers/8255.c
+++ b/drivers/staging/comedi/drivers/8255.c
@@ -231,7 +231,7 @@ static int subdev_8255_cmdtest(struct comedi_device *dev,
err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
err |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, 0);
err |= cfc_check_trigger_arg_is(cmd-convert_arg, 0);
-   err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, 1);
+   err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, cmd-chanlist_len);
err |= cfc_check_trigger_arg_is(cmd-stop_arg, 0);
 
if (err)
@@ -298,6 +298,7 @@ int subdev_8255_init_irq(struct comedi_device *dev, struct 
comedi_subdevice *s,
if (ret)
return ret;
 
+   s-len_chanlist = 1;
s-do_cmdtest   = subdev_8255_cmdtest;
s-do_cmd   = subdev_8255_cmd;
s-cancel   = subdev_8255_cancel;
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 66c24e4..7ead23e 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -778,6 +778,7 @@ static int apci3120_ai_cmdtest(struct comedi_device *dev,
}
 
err |= cfc_check_trigger_arg_min(cmd-chanlist_len, 1);
+   err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, cmd-chanlist_len);
 
if (cmd-stop_src == TRIG_COUNT)
err |= cfc_check_trigger_arg_min(cmd-stop_arg, 1);
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
index 0536d83..76a6682 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
@@ -2270,6 +2270,11 @@ static int apci3200_ai_cmdtest(struct comedi_device *dev,
apci3200_reset(dev);
return 2;
}
+
+   /* Step 3: check if arguments are trivially valid */
+
+   err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, cmd-chanlist_len);
+
/* i_FirstChannel=cmd-chanlist[0]; */
s_BoardInfos[dev-minor].i_FirstChannel = cmd-chanlist[0];
/* i_LastChannel=cmd-chanlist[1]; */
diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c 
b/drivers/staging/comedi/drivers/addi_apci_1032.c
index d6a5424..c242afc 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1032.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1032.c
@@ -198,7 +198,7 @@ static int apci1032_cos_cmdtest(struct comedi_device *dev,
err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
err |= cfc_check_trigger_arg_is(cmd-scan_begin_arg, 0);
err |= cfc_check_trigger_arg_is(cmd-convert_arg, 0);
-   err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, 1);
+   err |= cfc_check_trigger_arg_is(cmd-scan_end_arg, cmd-chanlist_len);
err |= cfc_check_trigger_arg_is(cmd-stop_arg, 0);
 
if (err)
@@ -332,6 +332,7 @@ static int apci1032_auto_attach(struct comedi_device *dev,
s-range_table  = range_digital;
s-insn_config  = apci1032_cos_insn_config;
s-insn_bits= apci1032_cos_insn_bits;
+   s-len_chanlist = 1;
s-do_cmdtest   = apci1032_cos_cmdtest;
s-do_cmd   = apci1032_cos_cmd;
s-cancel   = apci1032_cos_cancel;
diff --git 

[PATCH 25/26] staging: comedi: usbdux: fix the cmd-start_arg use

2014-04-17 Thread H Hartley Sweeten
For all cmd-start_src values this driver trivially validates that the
cmd-start_arg is 0.

For a TRIG_INT source, the cmd-start_arg is actually the valid trig_num
that is used by the async (*inttrig) callback.

Refactor the (*inttrig) functions so that the cmd-start_arg is used to
check the trig_num instead of the open coded values.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/usbdux.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index b59af03..4002f49 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -692,15 +692,16 @@ static int receive_dux_commands(struct comedi_device 
*dev, unsigned int command)
 
 static int usbdux_ai_inttrig(struct comedi_device *dev,
 struct comedi_subdevice *s,
-unsigned int trignum)
+unsigned int trig_num)
 {
struct usbdux_private *devpriv = dev-private;
-   int ret = -EINVAL;
+   struct comedi_cmd *cmd = s-async-cmd;
+   int ret;
 
-   down(devpriv-sem);
+   if (trig_num != cmd-start_arg)
+   return -EINVAL;
 
-   if (trignum != 0)
-   goto ai_trig_exit;
+   down(devpriv-sem);
 
if (!devpriv-ai_cmd_running) {
devpriv-ai_cmd_running = 1;
@@ -913,15 +914,16 @@ ao_write_exit:
 
 static int usbdux_ao_inttrig(struct comedi_device *dev,
 struct comedi_subdevice *s,
-unsigned int trignum)
+unsigned int trig_num)
 {
struct usbdux_private *devpriv = dev-private;
-   int ret = -EINVAL;
+   struct comedi_cmd *cmd = s-async-cmd;
+   int ret;
 
-   down(devpriv-sem);
+   if (trig_num != cmd-start_arg)
+   return -EINVAL;
 
-   if (trignum != 0)
-   goto ao_trig_exit;
+   down(devpriv-sem);
 
if (!devpriv-ao_cmd_running) {
devpriv-ao_cmd_running = 1;
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 22/26] staging: comedi: s626: clarify the cmd-start_arg validation and use

2014-04-17 Thread H Hartley Sweeten
This driver supports a cmd-start_src of TRIG_NOW, TRIG_INT or TRIG_EXT.

Clarify the cmd-start_arg validation in Step 3 of the (*do_cmdtest).

For a TRIG_INT source, the cmd-start_arg is actually the valid
trig_num that is used by the async (*inttrig) callback.

Refactor the (*inttrig) function so that the cmd-start_arg is used
to check the trig_num instead of the open coded value.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/s626.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c 
b/drivers/staging/comedi/drivers/s626.c
index 6da43de..647b9e5 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -2076,9 +2076,12 @@ static int s626_ai_load_polllist(uint8_t *ppl, struct 
comedi_cmd *cmd)
 }
 
 static int s626_ai_inttrig(struct comedi_device *dev,
-  struct comedi_subdevice *s, unsigned int trignum)
+  struct comedi_subdevice *s,
+  unsigned int trig_num)
 {
-   if (trignum != 0)
+   struct comedi_cmd *cmd = s-async-cmd;
+
+   if (trig_num != cmd-start_arg)
return -EINVAL;
 
/* Start executing the RPS program */
@@ -2314,12 +2317,18 @@ static int s626_ai_cmdtest(struct comedi_device *dev,
if (err)
return 2;
 
-   /* step 3: make sure arguments are trivially compatible */
+   /* Step 3: check if arguments are trivially valid */
 
-   if (cmd-start_src != TRIG_EXT)
+   switch (cmd-start_src) {
+   case TRIG_NOW:
+   case TRIG_INT:
err |= cfc_check_trigger_arg_is(cmd-start_arg, 0);
-   if (cmd-start_src == TRIG_EXT)
+   break;
+   case TRIG_EXT:
err |= cfc_check_trigger_arg_max(cmd-start_arg, 39);
+   break;
+   }
+
if (cmd-scan_begin_src == TRIG_EXT)
err |= cfc_check_trigger_arg_max(cmd-scan_begin_arg, 39);
if (cmd-convert_src == TRIG_EXT)
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/26] staging: comedi: addi_apci_3xxx: fix ai subdevice 'len_chanlist'

2014-04-17 Thread H Hartley Sweeten
Due to a driver limitation, the (*do_cmdtest) for the analog input subdevice
overrides the cmd-chanlist_len to force single channel chanlists. But, the
cmd-scan_end_arg was already validated before this happens. Instead of
fixing the (*do_cmdtest) just set the subdevice len_chanlist to 1 to limit
the chanlist size. Move the comment also.

Signed-off-by: H Hartley Sweeten hswee...@visionengravers.com
Cc: Ian Abbott abbo...@mev.co.uk
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
---
 drivers/staging/comedi/drivers/addi_apci_3xxx.c | 40 -
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c 
b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
index 6dc11c4..64c37b6 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
@@ -573,26 +573,6 @@ static int apci3xxx_ai_cmdtest(struct comedi_device *dev,
 
/* step 4: fix up any arguments */
 
-   /*
-* FIXME: The hardware supports multiple scan modes but the original
-* addi-data driver only supported reading a single channel with
-* interrupts. Need a proper datasheet to fix this.
-*
-* The following scan modes are supported by the hardware:
-* 1) Single software scan
-* 2) Single hardware triggered scan
-* 3) Continuous software scan
-* 4) Continuous software scan with timer delay
-* 5) Continuous hardware triggered scan
-* 6) Continuous hardware triggered scan with timer delay
-*
-* For now, limit the chanlist to a single channel.
-*/
-   if (cmd-chanlist_len  1) {
-   cmd-chanlist_len = 1;
-   err |= -EINVAL;
-   }
-
tmp = cmd-convert_arg;
err |= apci3xxx_ai_ns_to_timer(dev, cmd-convert_arg,
   cmd-flags  TRIG_ROUND_MASK);
@@ -842,12 +822,30 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
s-subdev_flags = SDF_READABLE | board-ai_subdev_flags;
s-n_chan   = board-ai_n_chan;
s-maxdata  = board-ai_maxdata;
-   s-len_chanlist = s-n_chan;
s-range_table  = apci3xxx_ai_range;
s-insn_read= apci3xxx_ai_insn_read;
if (dev-irq) {
+   /*
+* FIXME: The hardware supports multiple scan modes
+* but the original addi-data driver only supported
+* reading a single channel with interrupts. Need a
+* proper datasheet to fix this.
+*
+* The following scan modes are supported by the
+* hardware:
+*   1) Single software scan
+*   2) Single hardware triggered scan
+*   3) Continuous software scan
+*   4) Continuous software scan with timer delay
+*   5) Continuous hardware triggered scan
+*   6) Continuous hardware triggered scan with timer
+*  delay
+*
+* For now, limit the chanlist to a single channel.
+*/
dev-read_subdev = s;
s-subdev_flags |= SDF_CMD_READ;
+   s-len_chanlist = 1;
s-do_cmdtest   = apci3xxx_ai_cmdtest;
s-do_cmd   = apci3xxx_ai_cmd;
s-cancel   = apci3xxx_ai_cancel;
-- 
1.8.5.2

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH net-next,v4] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-04-17 Thread Haiyang Zhang


 -Original Message-
 From: David Miller [mailto:da...@davemloft.net]
 Sent: Monday, April 7, 2014 2:43 PM
 To: Haiyang Zhang
 Cc: net...@vger.kernel.org; KY Srinivasan; o...@aepfle.de;
 jasow...@redhat.com; linux-ker...@vger.kernel.org; driverdev-
 de...@linuxdriverproject.org
 Subject: Re: [PATCH net-next,v4] hyperv: Add support for virtual Receive Side
 Scaling (vRSS)
 
 
 The net-next tree is not open yet, I will announce when it is and you can 
 submit
 net-next targetted patches.

Dave,

Is the net-next tree open now? 
(I haven't seen your announcement, but I saw some patches for net-next are 
under review.)

Thanks,
- Haiyang
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next,v4] hyperv: Add support for virtual Receive Side Scaling (vRSS)

2014-04-17 Thread David Miller
From: Haiyang Zhang haiya...@microsoft.com
Date: Thu, 17 Apr 2014 17:25:31 +

 Is the net-next tree open now? 

No, it is not.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [staging:staging-next 133/193] drivers/staging/rtl8723au/core/rtw_mlme_ext.c:1236 OnAssocReq23a() error: we previously assumed 'p' could be null (see line 1234)

2014-04-17 Thread Jes Sorensen
Dan Carpenter dan.carpen...@oracle.com writes:
 On Thu, Apr 17, 2014 at 11:50:13AM +0200, Jes Sorensen wrote:
  Old smatch warnings:
  drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4362
  collect_bss_info23a() error: __builtin_memcpy() 'bssid-IEs' too small
  (768 vs u32max)
  drivers/staging/rtl8723au/core/rtw_mlme_ext.c:4860 process_80211d()
  error: testing array offset 'i' after use.
 
 We already have a check in palce here - do I need to make the
 if (length  MAX_IE_SZ) check for length  0 to make this warning go
 away?

 Oh.  Wait.  I responded to the wrong thing.

 Yeah.  You could check for negatives or make length unsigned or you
 could check skb-len to make sure it wasn't too short.  Any of those
 would work.

I checked, and given skb-len is unsigned int, it seems reasonable to
default to unsigned int for variables reading skb-len.

I'll keep this in mind when fixing it up.

Thanks again.

Jes
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH V4] staging: cxt1e1: replace OS_kmalloc/OS_kfree with kzalloc/kfree

2014-04-17 Thread Daeseok Youn
Replace OS_kmalloc/OS_kfree with kzalloc/kfree.
And also some allocation doesn't need to use GFP_DMA
so just use GFP_KERNEL.

c4_new() function is never called, remove it.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
V4: update patch description, OS_kmalloc should be replaced with
kzalloc for zeroed out the allocated data.
V3: replace kmalloc with kzalloc.
V2: fix subject and comment correctly.

It has some coding style issue. If this patch is merged,
I fix this issue with another patch.

 drivers/staging/cxt1e1/hwprobe.c |2 +-
 drivers/staging/cxt1e1/linux.c   |   21 +--
 drivers/staging/cxt1e1/musycc.c  |   12 ---
 drivers/staging/cxt1e1/pmcc4_drv.c   |   47 +-
 drivers/staging/cxt1e1/sbecom_inline_linux.h |   23 +
 drivers/staging/cxt1e1/sbecrc.c  |5 ++-
 drivers/staging/cxt1e1/sbeproc.c |2 +-
 7 files changed, 32 insertions(+), 80 deletions(-)

diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c
index 9b4198b..6e207f5 100644
--- a/drivers/staging/cxt1e1/hwprobe.c
+++ b/drivers/staging/cxt1e1/hwprobe.c
@@ -205,7 +205,7 @@ cleanup_devs(void)
 #ifdef CONFIG_SBE_PMCC4_NCOMM
free_irq(hi-pdev[1]-irq, hi-ndev);
 #endif
-   OS_kfree(hi-ndev);
+   kfree(hi-ndev);
}
 }
 
diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c
index b02f5ade..4b4609d 100644
--- a/drivers/staging/cxt1e1/linux.c
+++ b/drivers/staging/cxt1e1/linux.c
@@ -60,7 +60,6 @@ status_tc4_chan_work_init(mpi_t *, mch_t *);
 voidmusycc_wq_chan_restart(void *);
 status_t __init c4_init(ci_t *, u_char *, u_char *);
 status_t __init c4_init2(ci_t *);
-ci_t   *__init c4_new(void *);
 int __init  c4hw_attach_all(void);
 void __init hdw_sn_get(hdw_info_t *, int);
 
@@ -418,7 +417,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
struct c4_priv *priv;
 
/* allocate then fill in private data structure */
-   priv = OS_kmalloc(sizeof(struct c4_priv));
+   priv = kzalloc(sizeof(struct c4_priv), GFP_KERNEL);
if (!priv) {
pr_warning(%s: no memory for net_device !\n,
   ci-devname);
@@ -428,7 +427,7 @@ create_chan(struct net_device *ndev, ci_t *ci,
if (!dev) {
pr_warning(%s: no memory for hdlc_device !\n,
   ci-devname);
-   OS_kfree(priv);
+   kfree(priv);
return NULL;
}
priv-ci = ci;
@@ -972,8 +971,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
 
if (register_netdev(ndev) ||
(c4_init(ci, (u_char *) f0, (u_char *) f1) != 
SBE_DRVR_SUCCESS)) {
-   OS_kfree(netdev_priv(ndev));
-   OS_kfree(ndev);
+   kfree(netdev_priv(ndev));
+   kfree(ndev);
error_flag = -ENODEV;
return NULL;
}
@@ -998,8 +997,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
pr_warning(%s: MUSYCC could not get irq: %d\n,
   ndev-name, irq0);
unregister_netdev(ndev);
-   OS_kfree(netdev_priv(ndev));
-   OS_kfree(ndev);
+   kfree(netdev_priv(ndev));
+   kfree(ndev);
error_flag = -EIO;
return NULL;
}
@@ -1008,8 +1007,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
pr_warning(%s: EBUS could not get irq: %d\n, hi-devname, 
irq1);
unregister_netdev(ndev);
free_irq(irq0, ndev);
-   OS_kfree(netdev_priv(ndev));
-   OS_kfree(ndev);
+   kfree(netdev_priv(ndev));
+   kfree(ndev);
error_flag = -EIO;
return NULL;
}
@@ -1068,8 +1067,8 @@ c4_add_dev(hdw_info_t *hi, int brdno, unsigned long f0, 
unsigned long f1,
unregister_netdev(ndev);
free_irq(irq1, ndev);
free_irq(irq0, ndev);
-   OS_kfree(netdev_priv(ndev));
-   OS_kfree(ndev);
+   kfree(netdev_priv(ndev));
+   kfree(ndev);
/* failure, error_flag is set */
return NULL;
}
diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c
index 7b4f6f2..872cdae 100644
--- a/drivers/staging/cxt1e1/musycc.c
+++ b/drivers/staging/cxt1e1/musycc.c
@@ -744,7 +744,8 @@ musycc_init(ci_t *ci)
 
 #define INT_QUEUE_BOUNDARY  4
 
-regaddr = OS_kmalloc((INT_QUEUE_SIZE + 1) * sizeof(u_int32_t));
+   regaddr = kzalloc((INT_QUEUE_SIZE + 1) * sizeof(u_int32_t),
+ GFP_KERNEL |