Re: [PATCH] staging: android: logger: fix kuid/uid in logger_entry

2014-10-30 Thread Arnd Bergmann
On Thursday 30 October 2014 10:23:31 Xiong Zhou wrote:
> From: Xiong Zhou 
> 
> struct logger_entry can be returned to userspace via ioctl,
> so it is wrong to have a kuid_t member, fixing it to uid_t.
> This was introduced by commit bd471258f2, to pass uidguid
> type checks : UIDGID_STRICT_TYPE_CHECKS, which has been
> removed from kernel in commit 261000a56b6.
> 
> Fixes: bd471258f2 (logger: use kuid_t instead of uid_t)
> Signed-off-by: Xiong Zhou 

Sorry, but this isn't good.

You had an earlier patch that introduced a bug by hiding a warning,
and now you send a new patch to hide the bug better instead of
fixing it?

> diff --git a/drivers/staging/android/logger.c 
> b/drivers/staging/android/logger.c
> index 28b93d3..fb06bf2 100644
> --- a/drivers/staging/android/logger.c
> +++ b/drivers/staging/android/logger.c
> @@ -252,7 +252,7 @@ static size_t get_next_entry_by_uid(struct logger_log 
> *log,
> 
> entry = get_entry_header(log, off, &scratch);
> 
> -   if (uid_eq(entry->euid, euid))
> +   if (entry->euid == __kuid_val(euid))
> return off;
> 
> next_len = sizeof(struct logger_entry) + entry->len;

The code above was correct, you are just breaking it more.

> @@ -430,7 +430,7 @@ static ssize_t logger_write_iter(struct kiocb *iocb, 
> struct iov_iter *from)
> header.tid = current->pid;
> header.sec = now.tv_sec;
> header.nsec = now.tv_nsec;
> -   header.euid = current_euid();
> +   header.euid = __kuid_val(current_euid());
> header.len = count;
> header.hdr_size = sizeof(struct logger_entry);
> 

This writes to the internal data structure, so here you should still use
kuid_t. The problem is that you are later leaking this to user space,
so a user in one container can read entries from a user with the same
uid in another container, and that a process calling read() with the
r_all bit set will get entries with uids from all containers, using
the kernel-internal uid values instead of the ones valid for the current
container.

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


Re: [PATCH] staging:rtl8723au: core: Fix error reported by checkpatch.

2014-10-30 Thread Jes Sorensen
Joe Perches  writes:
> On Mon, 2014-10-27 at 09:43 +0100, Jes Sorensen wrote:
>> Sanjeev Sharma  writes:
>> > This is a patch to the rtw_cmd.c file that fixes
>> > Error reported by checkpatch.
> []
>> > diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c
>> > b/drivers/staging/rtl8723au/core/rtw_cmd.c
> []
>> > @@ -957,7 +957,7 @@ static void traffic_status_watchdog(struct rtw_adapter 
>> > *padapter)
>> >/*  check traffic for  powersaving. */
>> >if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod +
>> >  pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
>> > -  pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod >2)
>> > +  pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 
>> > 2)
>> >bEnterPS = false;
>> >else
>> >bEnterPS = true;
>> 
>> This makes the line longer than 80 characters, that is worse than the
>> 'problem' you are fixing.
>
> The code already has dozens of long lines already.
>
> This is generally a problem because the variable names
> are pretty long so strict 80 column adherence generally
> isn't possible.

It does, but that is not a reason to add more. I have generally tried to
trim it down when I cleaned up pieces of it.

Jes


> A possible way to shorten these relatively long variable
> name/line lengths is to use a temporary for
>
>   pmlmeprv->LinkDetectInfo
>
>   struct rt_link_detect *ldi = &pmlmeprv->LinkDetectInfo;
>
> so:
>
>  drivers/staging/rtl8723au/core/rtw_cmd.c | 46 
> 
>  1 file changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c 
> b/drivers/staging/rtl8723au/core/rtw_cmd.c
> index d2d7edf..1b24945 100644
> --- a/drivers/staging/rtl8723au/core/rtw_cmd.c
> +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c
> @@ -922,34 +922,33 @@ static void traffic_status_watchdog(struct rtw_adapter 
> *padapter)
>   u8 bHigherBusyTxTraffic = false;
>   struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
>   int BusyThreshold = 100;
> + struct rt_link_detect *ldi = &pmlmepriv->LinkDetectInfo;
> +
>   /*  */
>   /*  Determine if our traffic is busy now */
>   /*  */
>   if (check_fwstate(pmlmepriv, _FW_LINKED)) {
>   if (rtl8723a_BT_coexist(padapter))
>   BusyThreshold = 50;
> - else if (pmlmepriv->LinkDetectInfo.bBusyTraffic)
> + else if (ldi->bBusyTraffic)
>   BusyThreshold = 75;
>   /*  if we raise bBusyTraffic in last watchdog, using
>   lower threshold. */
> - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > BusyThreshold ||
> - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > BusyThreshold) {
> + if (ldi->NumRxOkInPeriod > BusyThreshold ||
> + ldi->NumTxOkInPeriod > BusyThreshold) {
>   bBusyTraffic = true;
>  
> - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod >
> - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod)
> + if (ldi->NumRxOkInPeriod > ldi->NumTxOkInPeriod)
>   bRxBusyTraffic = true;
>   else
>   bTxBusyTraffic = true;
>   }
>  
>   /*  Higher Tx/Rx data. */
> - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 4000 ||
> - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 4000) {
> + if (ldi->NumRxOkInPeriod > 4000 ||
> + ldi->NumTxOkInPeriod > 4000) {
>   bHigherBusyTraffic = true;
> -
> - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod >
> - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod)
> + if (ldi->NumRxOkInPeriod > ldi->NumTxOkInPeriod)
>   bHigherBusyRxTraffic = true;
>   else
>   bHigherBusyTxTraffic = true;
> @@ -958,9 +957,9 @@ static void traffic_status_watchdog(struct rtw_adapter 
> *padapter)
>   if (!rtl8723a_BT_coexist(padapter) ||
>   !rtl8723a_BT_using_antenna_1(padapter)) {
>   /*  check traffic for  powersaving. */
> - if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod +
> -   pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
> - pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod >2)
> + if (((ldi->NumRxUnicastOkInPeriod +
> +   ldi->NumTxOkInPeriod) > 8) ||
> + ldi->NumRxUnicastOkInPeriod > 2)
>   bEnterPS = false;
>   else
>   bEnterPS = true;
> @@ -971,18 +970,19 @@ static void traffic_statu

Notification

2014-10-30 Thread G-Notice
Please find attached your award notification document.
GPA TEAM


Notice2014.pdf
Description: Adobe PDF document
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: comedi: comedi_test: fix timer lock-up

2014-10-30 Thread Ian Abbott
Commit 240512474424 ("staging: comedi: comedi_test: use
comedi_handle_events()") resulted in the timer routine
`waveform_ai_interrupt()` calling `comedi_handle_events()` instead of
`comedi_events()`.  That had the advantage of automatically stopping the
acquisition on overflow/error/end-of-acquisition conditions (by calling
the comedi subdevice's "cancel" handler), but currently results in the
timer routine locking when one of those conditions occur.  This is
because the "cancel" handler `waveform_ai_cancel()` calls
`del_timer_sync()`.

Fix it by adding a bit to the device private data that indicates whether
the acquisition is active or not, and changing the "cancel" handler to
use `del_timer()` instead of `del_timer_sync()`.  The bit is set when
starting the acquisition, cleared when ending the acquisition (in the
"cancel" handler), and tested in the timer routine, which will do
nothing if the acquisition is inactive.  Also, make sure any scheduled
timeout event gets cancelled when the low-level device gets "detached"
from the comedi core by calling `del_timer_sync()` in the "detach"
handler `waveform_detach()`.

Fixes: 240512474424 ("staging: comedi: comedi_test: use comedi_handle_events()")
Signed-off-by: Ian Abbott 
---
v2: rebased after commit dd28153b2a8ca
Greg, this fix is for "linux-next" and "staging-next".
---
 drivers/staging/comedi/drivers/comedi_test.c | 21 +++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 4d4358c..e1a11c4 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -56,6 +56,10 @@ zero volts).
 
 #define N_CHANS 8
 
+enum waveform_state_bits {
+   WAVEFORM_AI_RUNNING = 0
+};
+
 /* Data unique to this driver */
 struct waveform_private {
struct timer_list timer;
@@ -65,6 +69,7 @@ struct waveform_private {
unsigned long usec_current; /* current time (mod waveform period) */
unsigned long usec_remainder;   /* usec since last scan */
unsigned long ai_count; /* number of conversions remaining */
+   unsigned long state_bits;
unsigned int scan_period;   /* scan period in usec */
unsigned int convert_period;/* conversion period in usec */
unsigned int ao_loopbacks[N_CHANS];
@@ -175,6 +180,10 @@ static void waveform_ai_interrupt(unsigned long arg)
ktime_t now;
bool stopping = false;
 
+   /* check command is still active */
+   if (!test_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits))
+   return;
+
now = ktime_get();
 
elapsed_time = ktime_to_us(ktime_sub(now, devpriv->last));
@@ -322,6 +331,10 @@ static int waveform_ai_cmd(struct comedi_device *dev,
devpriv->usec_remainder = 0;
 
devpriv->timer.expires = jiffies + 1;
+   /* mark command as active */
+   smp_mb__before_atomic();
+   set_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);
+   smp_mb__after_atomic();
add_timer(&devpriv->timer);
return 0;
 }
@@ -331,7 +344,11 @@ static int waveform_ai_cancel(struct comedi_device *dev,
 {
struct waveform_private *devpriv = dev->private;
 
-   del_timer_sync(&devpriv->timer);
+   /* mark command as no longer active */
+   clear_bit(WAVEFORM_AI_RUNNING, &devpriv->state_bits);
+   smp_mb__after_atomic();
+   /* cannot call del_timer_sync() as may be called from timer routine */
+   del_timer(&devpriv->timer);
return 0;
 }
 
@@ -433,7 +450,7 @@ static void waveform_detach(struct comedi_device *dev)
struct waveform_private *devpriv = dev->private;
 
if (devpriv)
-   waveform_ai_cancel(dev, dev->read_subdev);
+   del_timer_sync(&devpriv->timer);
 }
 
 static struct comedi_driver waveform_driver = {
-- 
2.1.1

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


Re: [PATCH - resend] checkpatch: Remove unnecessary + after {8,8}

2014-10-30 Thread Borislav Petkov
Hey Andrew,

can we get this one applied already - I'm seeing this warning at least
since before my summer vacation started! :-P

Thanks.

On Mon, Sep 01, 2014 at 09:55:06AM -0700, Joe Perches wrote:
> There's a useless "+" use that needs to be removed as perl 5.20
> emits a "Useless use of greediness modifier '+'" message each
> time it's hit.
> 
> Reported-by: Greg KH 
> Signed-off-by: Joe Perches 
> ---
> 
> Resending, maybe Andrew's all-seeing eye blinked...
> 
> On Fri, 2014-07-11 at 19:05 -0700, Greg KH wrote:
> > Ok, with linux-next I get the same thing:
> 
> Thanks Greg.
> 
>  scripts/checkpatch.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index d5ac001..370a974 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2376,7 +2376,7 @@ sub process {
>   "please, no space before tabs\n" . $herevet) &&
>   $fix) {
>   while ($fixed[$fixlinenr] =~
> -s/(^\+.*) {8,8}+\t/$1\t\t/) {}
> +s/(^\+.*) {8,8}\t/$1\t\t/) {}
>   while ($fixed[$fixlinenr] =~
>  s/(^\+.*) +\t/$1\t/) {}
>   }
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH - resend] checkpatch: Remove unnecessary + after {8,8}

2014-10-30 Thread Borislav Petkov
On Thu, Oct 30, 2014 at 12:12:04PM +0100, Borislav Petkov wrote:
> Hey Andrew,
> 
> can we get this one applied already - I'm seeing this warning at least
> since before my summer vacation started! :-P

Oh ok, so it did go in after 3.17 but when using checkpatch on a 3.17
tree, it fires of course. Maybe the first checkpatch fix to tag for
stable?

:-)

-- 
Regards/Gruss,
Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/7] staging: comedi: enforce data transfer direction

2014-10-30 Thread Ian Abbott
Most comedi subdevices that support asynchronous data acquisition
commands only support data transfer in a single direction, as indicated
by the `SDF_CMD_READ` and `SDF_CMD_WRITE` subdevice flags.  A few allow
data transfer in either direction, but only a single direction at a
time, as indicated by the `CMDF_WRITE` command flag in the `flags`
member of the `struct comedi_cmd` from user-space used to set up the
asynchronous command.  The `CMDF_WRITE` flag isn't commonly set for
"write" commands if that is the only direction the subdevice supports.

Since it would be useful for comedi to have a clear indication of which
data transfer direction is being used, patch 1 forces the `CMDF_WRITE`
command flag to the correct state if only one direction is supported.
The flag can then be checked by comedi in the subdevice's local copy of
the current command (in `s->async->cmd`) to determine the data transfer
direction unambiguously.

Patch 2 stops the "me4000" driver clobbering the command flags.

Patch 3 removes some now redundant modification of the `CMDF_WRITE` flag
in "ni_mio_common.c" (used by the "ni_pcimio", "ni_atmio" and
"ni_mio_cs" drivers).

Patches 4 and 5 disallow the read() and write() file operations if the
subdevice has been set up with a command in the "write" or "read" data
transfer direction respectively.

Patch 6 changes the readable/writeable checks for the poll() file
operation.  It already considers the file readable/writeable if
read()/write() would fail with an error, so change it to check for
"wrong direction" as one of the possible failures.

Patch 7 makes the direction test in the handling of the `COMEDI_BUFINFO`
ioctl (used to update buffer positions for mmapped buffers) less
ambiguous.  The current test used the `SDF_CMD_READ` and `SDF_CMD_WRITE`
subdevice flags to check the direction, which is ambiguous if both flags
are set.  Update it to use the `CMDF_WRITE` command flag instead.

1) staging: comedi: maybe force CMDF_WRITE command flag
2) staging: comedi: me4000: don't clobber command flags
3) staging: comedi: ni_mio_common: don't change CMDF_WRITE flag
4) staging: comedi: don't allow read() on async command set up for "write"
5) staging: comedi: don't allow write() on async command set up for "read"
6) staging: comedi: check command direction in poll() file operation
7) staging: comedi: check actual data direction for COMEDI_BUFINFO ioctl

 drivers/staging/comedi/comedi_fops.c   | 37 --
 drivers/staging/comedi/drivers/me4000.c|  3 ---
 drivers/staging/comedi/drivers/ni_mio_common.c |  6 -
 3 files changed, 35 insertions(+), 11 deletions(-)
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/7] staging: comedi: ni_mio_common: don't change CMDF_WRITE flag

2014-10-30 Thread Ian Abbott
There is no need for `ni_ai_cmdtest()` or `ni_ao_cmdtest()` to set the
`CMDF_WRITE` flag to the correct state as it has already been done by
the core comedi module.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 785ad70..852b645 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -2251,9 +2251,6 @@ static int ni_ai_cmdtest(struct comedi_device *dev, 
struct comedi_subdevice *s,
 
/* Step 1 : check if triggers are trivially valid */
 
-   if ((cmd->flags & CMDF_WRITE))
-   cmd->flags &= ~CMDF_WRITE;
-
err |= cfc_check_trigger_src(&cmd->start_src,
TRIG_NOW | TRIG_INT | TRIG_EXT);
err |= cfc_check_trigger_src(&cmd->scan_begin_src,
@@ -3286,9 +3283,6 @@ static int ni_ao_cmdtest(struct comedi_device *dev, 
struct comedi_subdevice *s,
 
/* Step 1 : check if triggers are trivially valid */
 
-   if ((cmd->flags & CMDF_WRITE) == 0)
-   cmd->flags |= CMDF_WRITE;
-
err |= cfc_check_trigger_src(&cmd->start_src, TRIG_INT | TRIG_EXT);
err |= cfc_check_trigger_src(&cmd->scan_begin_src,
TRIG_TIMER | TRIG_EXT);
-- 
2.1.1

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


[PATCH 4/7] staging: comedi: don't allow read() on async command set up for "write"

2014-10-30 Thread Ian Abbott
If a Comedi asynchronous command has been set up for data transfer in
the "write" direction on the current "read" subdevice (for those
subdevices that support both directions), don't allow the "read" file
operation as that would mess with the data in the comedi data buffer
that is read by the low-level comedi hardware driver.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index fef68da..6805ec9 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2210,6 +2210,10 @@ static ssize_t comedi_read(struct file *file, char 
__user *buf, size_t nbytes,
retval = -EACCES;
goto out;
}
+   if (async->cmd.flags & CMDF_WRITE) {
+   retval = -EINVAL;
+   goto out;
+   }
 
add_wait_queue(&async->wait_head, &wait);
while (nbytes > 0 && !retval) {
@@ -2249,6 +2253,10 @@ static ssize_t comedi_read(struct file *file, char 
__user *buf, size_t nbytes,
retval = -EACCES;
break;
}
+   if (async->cmd.flags & CMDF_WRITE) {
+   retval = -EINVAL;
+   break;
+   }
continue;
}
m = copy_to_user(buf, async->prealloc_buf +
-- 
2.1.1

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


[PATCH 6/7] staging: comedi: check command direction in poll() file operation

2014-10-30 Thread Ian Abbott
`comedi_poll()` handles the poll() file operation for comedi devices.

If no asynchronous command has been set up on the current "read"
subdevice, it sets the `POLLIN` and `POLLRDNORM` bits in the return
value to indicate that the read() file operation would not block as it
would return an error.  Add a check so it also does that if the
asynchronous command has been set up in the "write" direction as that
also causes the read() file operation to return an error.

Similarly, if no asynchronous command has need set up on the current
"write" subdevice, it sets the `POLLOUT` and `POLLWRNORM` bits in the
return value to indicate that the write() file operation would not block
as it would return an error.  Add a check so it also does that if the
asynchronous command has been set up in the "read" direction as that
also causes the write() file operation to return an error.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index 6328965..d55f709 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2017,6 +2017,7 @@ static unsigned int comedi_poll(struct file *file, 
poll_table *wait)
if (s && s->async) {
poll_wait(file, &s->async->wait_head, wait);
if (!s->busy || !comedi_is_subdevice_running(s) ||
+   (s->async->cmd.flags & CMDF_WRITE) ||
comedi_buf_read_n_available(s) > 0)
mask |= POLLIN | POLLRDNORM;
}
@@ -2028,6 +2029,7 @@ static unsigned int comedi_poll(struct file *file, 
poll_table *wait)
poll_wait(file, &s->async->wait_head, wait);
comedi_buf_write_alloc(s, s->async->prealloc_bufsz);
if (!s->busy || !comedi_is_subdevice_running(s) ||
+   !(s->async->cmd.flags & CMDF_WRITE) ||
comedi_buf_write_n_allocated(s) >= bps)
mask |= POLLOUT | POLLWRNORM;
}
-- 
2.1.1

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


[PATCH 5/7] staging: comedi: don't allow write() on async command set up for "read"

2014-10-30 Thread Ian Abbott
If a Comedi asynchronous command has been set up for data transfer in
the "read" direction on the current "write" subdevice (for those
subdevices that support both directions), don't allow the "write" file
operation as that would mess with the data in the comedi data buffer
that is written by the low-level comedi hardware driver.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index 6805ec9..6328965 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2075,6 +2075,10 @@ static ssize_t comedi_write(struct file *file, const 
char __user *buf,
retval = -EACCES;
goto out;
}
+   if (!(async->cmd.flags & CMDF_WRITE)) {
+   retval = -EINVAL;
+   goto out;
+   }
 
add_wait_queue(&async->wait_head, &wait);
on_wait_queue = true;
@@ -2146,6 +2150,10 @@ static ssize_t comedi_write(struct file *file, const 
char __user *buf,
retval = -EACCES;
break;
}
+   if (!(async->cmd.flags & CMDF_WRITE)) {
+   retval = -EINVAL;
+   break;
+   }
continue;
}
 
-- 
2.1.1

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


[PATCH 1/7] staging: comedi: maybe force CMDF_WRITE command flag

2014-10-30 Thread Ian Abbott
Most comedi subdevices that support asynchronous commands only support
data transfer in either the "read" or "write" direction, as indicated by
the `SDF_CMD_READ` and `SDF_CMD_WRITE` subdevice flags, although a few
support both directions on the same subdevice (though not
simultaneously).  The `struct comedi_cmd` structure passed via ioctl
call to set up the command contains a `CMDF_WRITE` flag that can be used
to choose the direction if the subdevice supports both directions, but
the flag is optional if the subdevice only supports data transfer in one
direction.

If the subdevice only supports asynchronous data transfer in a sing
direction, set the `CMDF_WRITE` flag to the correct state so that Comedi
can make use of it later.  In the case of the `COMEDI_CMDTEST` ioctl,
the updated flag will be written back to the `struct comedi_cmd` in
user-space.  In the case of the `COMEDI_CMD` ioctl, the flag only gets
written back if an error is detected while testing the command, or if
the `CMDF_BOGUS` command flag is set.  Since `__comedi_get_user_cmd()`
is called for both ioctls, that's a good place to set the flag.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index 224af2b..fef68da 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1451,6 +1451,21 @@ static int __comedi_get_user_cmd(struct comedi_device 
*dev,
return -EINVAL;
}
 
+   /*
+* Set the CMDF_WRITE flag to the correct state if the subdevice
+* supports only "read" commands or only "write" commands.
+*/
+   switch (s->subdev_flags & (SDF_CMD_READ | SDF_CMD_WRITE)) {
+   case SDF_CMD_READ:
+   cmd->flags &= ~CMDF_WRITE;
+   break;
+   case SDF_CMD_WRITE:
+   cmd->flags |= CMDF_WRITE;
+   break;
+   default:
+   break;
+   }
+
return 0;
 }
 
-- 
2.1.1

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


[PATCH 2/7] staging: comedi: me4000: don't clobber command flags

2014-10-30 Thread Ian Abbott
The low-level Comedi drivers shouldn't change the `flags` member of
`struct comedi_cmd` as the Comedi core also uses some of those flags.
They should just ignore the flags they don't understand.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/drivers/me4000.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 6516ac0..6e73e6e 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -848,9 +848,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
unsigned int scan_ticks;
int err = 0;
 
-   /* Only rounding flags are implemented */
-   cmd->flags &= CMDF_ROUND_NEAREST | CMDF_ROUND_UP | CMDF_ROUND_DOWN;
-
/* Round the timer arguments */
ai_round_cmd_args(dev, s, cmd, &init_ticks, &scan_ticks, &chan_ticks);
 
-- 
2.1.1

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


[PATCH 7/7] staging: comedi: check actual data direction for COMEDI_BUFINFO ioctl

2014-10-30 Thread Ian Abbott
`do_bufinfo_ioctl()` handled the `COMEDI_BUFINFO` ioctl.  It is supposed
to update the read or write positions in the buffer depending on the
direction of data transfer set up by the asynchronous command.
Currently it checks the `SDF_CMD_READ` and `SDF_CMD_WRITE` subdevice
flags.  That's fine for most subdevices - the ones that only support one
direction, but is incorrect for those subdevices that allow the command
to be set up in either direction.  Since we now set the `CMDF_WRITE`
flag according to the data transfer direction of the current command
running on the subdevice, check that flag instead.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/comedi_fops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c 
b/drivers/staging/comedi/comedi_fops.c
index d55f709..57ad6cd 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -991,7 +991,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
if (s->busy != file)
return -EACCES;
 
-   if (bi.bytes_read && (s->subdev_flags & SDF_CMD_READ)) {
+   if (bi.bytes_read && !(async->cmd.flags & CMDF_WRITE)) {
bi.bytes_read = comedi_buf_read_alloc(s, bi.bytes_read);
comedi_buf_read_free(s, bi.bytes_read);
 
@@ -1001,7 +1001,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev,
}
}
 
-   if (bi.bytes_written && (s->subdev_flags & SDF_CMD_WRITE)) {
+   if (bi.bytes_written && (async->cmd.flags & CMDF_WRITE)) {
bi.bytes_written =
comedi_buf_write_alloc(s, bi.bytes_written);
comedi_buf_write_free(s, bi.bytes_written);
-- 
2.1.1

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


Re: [PATCH v3 1/1] staging: skein: Removes skein_debug include

2014-10-30 Thread Jason Cooper
On Wed, Oct 29, 2014 at 07:12:08PM -0500, Eric Rost wrote:
> Removes skein_debug.h include since skein_debug.h is nonexistent.
> Removes unneeded debug empty macro defines and their uses.
> 
> Signed-off-by: Eric Rost 
> ---
>  drivers/staging/skein/skein_base.c  | 18 -
>  drivers/staging/skein/skein_base.h  | 17 -
>  drivers/staging/skein/skein_block.c | 51 
> +
>  3 files changed, 1 insertion(+), 85 deletions(-)

Well done, Eric.

Reviewed-by: Jason Cooper 

thx,

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


Re: [PATCH] staging:rtl8723au: core: Fix error reported by checkpatch.

2014-10-30 Thread Jes Sorensen
"Sharma, Sanjeev"  writes:
> -Original Message-
> From: Jes Sorensen [mailto:jes.soren...@redhat.com] 
> Sent: Monday, October 27, 2014 2:13 PM
> To: Sharma, Sanjeev
> Cc: larry.fin...@lwfinger.net; gre...@linuxfoundation.org;
> linux-wirel...@vger.kernel.org; de...@driverdev.osuosl.org;
> linux-ker...@vger.kernel.org
> Subject: Re: [PATCH] staging:rtl8723au: core: Fix error reported by 
> checkpatch.
>
> Sanjeev Sharma  writes:
>> This is a patch to the rtw_cmd.c file that fixes Error reported by 
>> checkpatch.
>>
>> Signed-off-by: Sanjeev Sharma 
>> ---
>>  drivers/staging/rtl8723au/core/rtw_cmd.c | 83 
>> +++-
>>  1 file changed, 40 insertions(+), 43 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c 
>> b/drivers/staging/rtl8723au/core/rtw_cmd.c
>> index 4eaa502..c1f6254 100644
>> --- a/drivers/staging/rtl8723au/core/rtw_cmd.c
>> +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c
>> @@ -957,7 +957,7 @@ static void traffic_status_watchdog(struct rtw_adapter 
>> *padapter)
>>  /*  check traffic for  powersaving. */
>>  if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod +
>>pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
>> -pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod >2)
>> +pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 
>> 2)
>>  bEnterPS = false;
>>  else
>>  bEnterPS = true;
>
> This makes the line longer than 80 characters, that is worse than the 
> 'problem' you are fixing.
>
> Jes
>
> Hello jes,
>
> How it can be worse because checkpatch treating this as an Error and
> line longer than 80 character is warning reported by checkpatch and I
> could see that in entire staging directory, 
> every maintainer most of the time ignore the 80 column limit and give
> priority to Error. 
>
> Please let me know your comment .
>
> Sanjeev Sharma 

checkpatch has it's ideas, doesn't mean it's blindly right at all
times. In this particular case it keeps the code more readable to keep
it below 80 characters than it does to add those two blanks and make the
line longer.

I agree the long variable names are nasty, and it doesn't help they were
done in StUdLyCaPs. If you want to attack it from that front, please go
ahead.

However, on formatting, please respond with proper email using proper
quoting when replying.

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


Re: [PATCH] staging:rtl8723au: core: Fix error reported by checkpatch.

2014-10-30 Thread Jes Sorensen
"Sharma, Sanjeev"  writes:
> -Original Message-
> From: Joe Perches [mailto:j...@perches.com] 
> Sent: Monday, October 27, 2014 8:23 PM
> To: Jes Sorensen
> Cc: Sharma, Sanjeev; larry.fin...@lwfinger.net;
> gre...@linuxfoundation.org; linux-wirel...@vger.kernel.org;
> de...@driverdev.osuosl.org; linux-ker...@vger.kernel.org
> Subject: Re: [PATCH] staging:rtl8723au: core: Fix error reported by 
> checkpatch.
>
> On Mon, 2014-10-27 at 09:43 +0100, Jes Sorensen wrote:
>> Sanjeev Sharma  writes:
>> > This is a patch to the rtw_cmd.c file that fixes Error reported by 
>> > checkpatch.
> []
>> > diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c 
>> > b/drivers/staging/rtl8723au/core/rtw_cmd.c
> []
>> > @@ -957,7 +957,7 @@ static void traffic_status_watchdog(struct rtw_adapter 
>> > *padapter)
>> >/*  check traffic for  powersaving. */
>> >if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod +
>> >  pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
>> > -  pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod >2)
>> > +  pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 
>> > 2)
>> >bEnterPS = false;
>> >else
>> >bEnterPS = true;
>> 
>> This makes the line longer than 80 characters, that is worse than the 
>> 'problem' you are fixing.
>
> The code already has dozens of long lines already.
>
> This is generally a problem because the variable names are pretty long so 
> strict 80 column adherence generally isn't possible.
>
> A possible way to shorten these relatively long variable name/line lengths is 
> to use a temporary for
>
>   pmlmeprv->LinkDetectInfo
>
>   struct rt_link_detect *ldi = &pmlmeprv->LinkDetectInfo;
>
> so:
>
> I am agree on this approach but Let's wait for Jes opinion on it.
>
> Sanjeev Sharma
>
>  drivers/staging/rtl8723au/core/rtw_cmd.c | 46 
> 
>  1 file changed, 23 insertions(+), 23 deletions(-)

This is fine with me.

Jes

>
> diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c 
> b/drivers/staging/rtl8723au/core/rtw_cmd.c
> index d2d7edf..1b24945 100644
> --- a/drivers/staging/rtl8723au/core/rtw_cmd.c
> +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c
> @@ -922,34 +922,33 @@ static void traffic_status_watchdog(struct rtw_adapter 
> *padapter)
>   u8 bHigherBusyTxTraffic = false;
>   struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
>   int BusyThreshold = 100;
> + struct rt_link_detect *ldi = &pmlmepriv->LinkDetectInfo;
> +
>   /*  */
>   /*  Determine if our traffic is busy now */
>   /*  */
>   if (check_fwstate(pmlmepriv, _FW_LINKED)) {
>   if (rtl8723a_BT_coexist(padapter))
>   BusyThreshold = 50;
> - else if (pmlmepriv->LinkDetectInfo.bBusyTraffic)
> + else if (ldi->bBusyTraffic)
>   BusyThreshold = 75;
>   /*  if we raise bBusyTraffic in last watchdog, using
>   lower threshold. */
> - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > BusyThreshold ||
> - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > BusyThreshold) {
> + if (ldi->NumRxOkInPeriod > BusyThreshold ||
> + ldi->NumTxOkInPeriod > BusyThreshold) {
>   bBusyTraffic = true;
>  
> - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod >
> - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod)
> + if (ldi->NumRxOkInPeriod > ldi->NumTxOkInPeriod)
>   bRxBusyTraffic = true;
>   else
>   bTxBusyTraffic = true;
>   }
>  
>   /*  Higher Tx/Rx data. */
> - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 4000 ||
> - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 4000) {
> + if (ldi->NumRxOkInPeriod > 4000 ||
> + ldi->NumTxOkInPeriod > 4000) {
>   bHigherBusyTraffic = true;
> -
> - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod >
> - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod)
> + if (ldi->NumRxOkInPeriod > ldi->NumTxOkInPeriod)
>   bHigherBusyRxTraffic = true;
>   else
>   bHigherBusyTxTraffic = true;
> @@ -958,9 +957,9 @@ static void traffic_status_watchdog(struct rtw_adapter 
> *padapter)
>   if (!rtl8723a_BT_coexist(padapter) ||
>   !rtl8723a_BT_using_antenna_1(padapter)) {
>   /*  check traffic for  powersaving. */
> - if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod +
> -   pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
> - pmlmepriv->Lin

RE: [PATCH 4/7] staging: comedi: don't allow read() on async command set up for "write"

2014-10-30 Thread Hartley Sweeten
On Thursday, October 30, 2014 5:42 AM, Ian Abbott wrote:
> If a Comedi asynchronous command has been set up for data transfer in
> the "write" direction on the current "read" subdevice (for those
> subdevices that support both directions), don't allow the "read" file
> operation as that would mess with the data in the comedi data buffer
> that is read by the low-level comedi hardware driver.
>
> Signed-off-by: Ian Abbott 
> ---
>  drivers/staging/comedi/comedi_fops.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/staging/comedi/comedi_fops.c 
> b/drivers/staging/comedi/comedi_fops.c
> index fef68da..6805ec9 100644
> --- a/drivers/staging/comedi/comedi_fops.c
> +++ b/drivers/staging/comedi/comedi_fops.c
> @@ -2210,6 +2210,10 @@ static ssize_t comedi_read(struct file *file, char 
> __user *buf, size_t nbytes,
>   retval = -EACCES;
>   goto out;
>   }
> + if (async->cmd.flags & CMDF_WRITE) {
> + retval = -EINVAL;
> + goto out;
> + }
>  
>   add_wait_queue(&async->wait_head, &wait);
>   while (nbytes > 0 && !retval) {
> @@ -2249,6 +2253,10 @@ static ssize_t comedi_read(struct file *file, char 
> __user *buf, size_t nbytes,
>   retval = -EACCES;
>   break;
>   }
> + if (async->cmd.flags & CMDF_WRITE) {
> + retval = -EINVAL;
> + break;
> + }

Is this second test really needed in the while() loop?

For that matter, are the s->busy tests needed in the while() loop?

>   continue;
 >  }
 >  m = copy_to_user(buf, async->prealloc_buf +

Regards,
Hartley

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


RE: [PATCH 5/7] staging: comedi: don't allow write() on async command set up for "read"

2014-10-30 Thread Hartley Sweeten
On Thursday, October 30, 2014 5:43 AM, Ian Abbott wrote:
> If a Comedi asynchronous command has been set up for data transfer in
> the "read" direction on the current "write" subdevice (for those
> subdevices that support both directions), don't allow the "write" file
> operation as that would mess with the data in the comedi data buffer
> that is written by the low-level comedi hardware driver.
>
> Signed-off-by: Ian Abbott 
> ---
>  drivers/staging/comedi/comedi_fops.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/staging/comedi/comedi_fops.c 
> b/drivers/staging/comedi/comedi_fops.c
> index 6805ec9..6328965 100644
> --- a/drivers/staging/comedi/comedi_fops.c
> +++ b/drivers/staging/comedi/comedi_fops.c
> @@ -2075,6 +2075,10 @@ static ssize_t comedi_write(struct file *file, const 
> char __user *buf,
>   retval = -EACCES;
>   goto out;
>   }
> + if (!(async->cmd.flags & CMDF_WRITE)) {
> + retval = -EINVAL;
> + goto out;
> + }
>  
>   add_wait_queue(&async->wait_head, &wait);
>   on_wait_queue = true;
> @@ -2146,6 +2150,10 @@ static ssize_t comedi_write(struct file *file, const 
> char __user *buf,
>   retval = -EACCES;
>   break;
>   }
> + if (!(async->cmd.flags & CMDF_WRITE)) {
> + retval = -EINVAL;
> + break;
> + }

Same question as with PATCH 4/7.

Is this test needed in the while () loop. Also, are the s->busy tests needed 
here?

>   continue;
>   }

Regards,
Hartley

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


[PATCH] staging: comedi: comedi_buf: make comedi_buf_write_samples() add samples that fit

2014-10-30 Thread H Hartley Sweeten
This function currently fails if the number of samples to add would
overflow the async buffer. Modify it to add the samples that fit so
at least some of the sample data is returned to the user.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/comedi_buf.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index 6dd87cb..b43424d 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -484,12 +484,16 @@ unsigned int comedi_buf_write_samples(struct 
comedi_subdevice *s,
unsigned int max_samples;
unsigned int nbytes;
 
-   /* make sure there is enought room in the buffer for all the samples */
+   /*
+* Make sure there is enough room in the buffer for all the samples.
+* If not, clamp the nsamples to the number that will fit, flag the
+* buffer overrun and add the samples that fit.
+*/
max_samples = comedi_buf_write_n_available(s) / bytes_per_sample(s);
if (nsamples > max_samples) {
dev_warn(s->device->class_dev, "buffer overrun\n");
s->async->events |= COMEDI_CB_OVERFLOW;
-   return 0;
+   nsamples = max_samples;
}
 
if (nsamples == 0)
-- 
2.0.3

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


[PATCH 2/3] staging: comedi: drivers: remove inappropriate SDF_* flags from subdevices

2014-10-30 Thread H Hartley Sweeten
The SDF_GROUND, SDF_COMMON, SDF_DIFF, and SDF_OTHER flags are only useful
with the analog input and output subdevices.

Remove these flags from the other subdevice types in the comedi drivers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi_apci_1500.c | 6 +++---
 drivers/staging/comedi/drivers/addi_apci_3501.c | 2 +-
 drivers/staging/comedi/drivers/adv_pci1710.c| 4 ++--
 drivers/staging/comedi/drivers/adv_pci_dio.c| 8 
 drivers/staging/comedi/drivers/dyna_pci10xx.c   | 4 ++--
 drivers/staging/comedi/drivers/icp_multi.c  | 2 +-
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c 
b/drivers/staging/comedi/drivers/addi_apci_1500.c
index d43129c..30b132c 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1500.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1500.c
@@ -54,7 +54,7 @@ static int apci1500_auto_attach(struct comedi_device *dev,
/*  Allocate and Initialise DI Subdevice Structures */
s = &dev->subdevices[0];
s->type = COMEDI_SUBD_DI;
-   s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
+   s->subdev_flags = SDF_READABLE;
s->n_chan = 16;
s->maxdata = 1;
s->range_table = &range_digital;
@@ -66,7 +66,7 @@ static int apci1500_auto_attach(struct comedi_device *dev,
/*  Allocate and Initialise DO Subdevice Structures */
s = &dev->subdevices[1];
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
+   s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
s->n_chan = 16;
s->maxdata = 1;
s->range_table = &range_digital;
@@ -77,7 +77,7 @@ static int apci1500_auto_attach(struct comedi_device *dev,
/*  Allocate and Initialise Timer Subdevice Structures */
s = &dev->subdevices[2];
s->type = COMEDI_SUBD_TIMER;
-   s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan = 1;
s->maxdata = 0;
s->len_chanlist = 1;
diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c 
b/drivers/staging/comedi/drivers/addi_apci_3501.c
index 992ac8d..7924523 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3501.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3501.c
@@ -392,7 +392,7 @@ static int apci3501_auto_attach(struct comedi_device *dev,
/* Initialize the timer/watchdog subdevice */
s = &dev->subdevices[3];
s->type = COMEDI_SUBD_TIMER;
-   s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan = 1;
s->maxdata = 0;
s->len_chanlist = 1;
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c 
b/drivers/staging/comedi/drivers/adv_pci1710.c
index c5422f3..e05f4b5 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -1210,7 +1210,7 @@ static int pci1710_auto_attach(struct comedi_device *dev,
if (this_board->n_dichan) {
s = &dev->subdevices[subdev];
s->type = COMEDI_SUBD_DI;
-   s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
+   s->subdev_flags = SDF_READABLE;
s->n_chan = this_board->n_dichan;
s->maxdata = 1;
s->len_chanlist = this_board->n_dichan;
@@ -1222,7 +1222,7 @@ static int pci1710_auto_attach(struct comedi_device *dev,
if (this_board->n_dochan) {
s = &dev->subdevices[subdev];
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan = this_board->n_dochan;
s->maxdata = 1;
s->len_chanlist = this_board->n_dochan;
diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c 
b/drivers/staging/comedi/drivers/adv_pci_dio.c
index f2e2d7e..09609d6 100644
--- a/drivers/staging/comedi/drivers/adv_pci_dio.c
+++ b/drivers/staging/comedi/drivers/adv_pci_dio.c
@@ -930,7 +930,7 @@ static int pci1760_attach(struct comedi_device *dev)
 
s = &dev->subdevices[0];
s->type = COMEDI_SUBD_DI;
-   s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
+   s->subdev_flags = SDF_READABLE;
s->n_chan = 8;
s->maxdata = 1;
s->len_chanlist = 8;
@@ -939,7 +939,7 @@ static int pci1760_attach(struct comedi_device *dev)
 
s = &dev->subdevices[1];
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan = 8;
s->maxdata = 1;
s->len_chanlist = 8;
@@ -978,7 +978,7 @@ static int pci_dio_add_di(struct comedi_device *dev,
const struct dio_boardtype *this_board = dev->board_ptr;
 
s->type = 

[PATCH 0/3] staging: comedi: drivers: tidy up the subdev_flags

2014-10-30 Thread H Hartley Sweeten
For consistency in the comedi drivers:
  1) Replace all SDF_WRITEABLE uses with SDF_WRITABLE
  2) Remove the analog reference flags from the non-analog subdevices
  3) Remove the unnecessary SDF_READABLE flag from the digital output subdevices

H Hartley Sweeten (3):
  staging: comedi: drivers: replace SDF_WRITEABLE with SDF_WRITABLE
  staging: comedi: drivers: remove inappropriate SDF_* flags from subdevices
  staging: comedi: drivers: digital output subdevices do not need SDF_READABLE

 drivers/staging/comedi/drivers/addi_apci_1500.c  | 7 +++
 drivers/staging/comedi/drivers/addi_apci_1516.c  | 2 +-
 drivers/staging/comedi/drivers/addi_apci_1564.c  | 4 ++--
 drivers/staging/comedi/drivers/addi_apci_16xx.c  | 2 +-
 drivers/staging/comedi/drivers/addi_apci_2032.c  | 2 +-
 drivers/staging/comedi/drivers/addi_apci_2200.c  | 2 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c  | 6 +++---
 drivers/staging/comedi/drivers/addi_apci_3501.c  | 6 +++---
 drivers/staging/comedi/drivers/addi_apci_3xxx.c  | 6 +++---
 drivers/staging/comedi/drivers/addi_watchdog.c   | 2 +-
 drivers/staging/comedi/drivers/adl_pci9111.c | 2 +-
 drivers/staging/comedi/drivers/adv_pci1710.c | 4 ++--
 drivers/staging/comedi/drivers/adv_pci1723.c | 2 +-
 drivers/staging/comedi/drivers/adv_pci_dio.c | 8 
 drivers/staging/comedi/drivers/amplc_pc263.c | 2 +-
 drivers/staging/comedi/drivers/amplc_pci263.c| 2 +-
 drivers/staging/comedi/drivers/c6xdigio.c| 2 +-
 drivers/staging/comedi/drivers/cb_pcidas64.c | 2 +-
 drivers/staging/comedi/drivers/comedi_test.c | 2 +-
 drivers/staging/comedi/drivers/das08.c   | 2 +-
 drivers/staging/comedi/drivers/das16m1.c | 2 +-
 drivers/staging/comedi/drivers/das1800.c | 2 +-
 drivers/staging/comedi/drivers/das6402.c | 4 ++--
 drivers/staging/comedi/drivers/das800.c  | 2 +-
 drivers/staging/comedi/drivers/dt9812.c  | 4 ++--
 drivers/staging/comedi/drivers/dyna_pci10xx.c| 4 ++--
 drivers/staging/comedi/drivers/gsc_hpdi.c| 2 +-
 drivers/staging/comedi/drivers/icp_multi.c   | 4 ++--
 drivers/staging/comedi/drivers/me4000.c  | 2 +-
 drivers/staging/comedi/drivers/me_daq.c  | 4 ++--
 drivers/staging/comedi/drivers/ni_usb6501.c  | 2 +-
 drivers/staging/comedi/drivers/quatech_daqp_cs.c | 4 ++--
 drivers/staging/comedi/drivers/serial2002.c  | 4 ++--
 drivers/staging/comedi/drivers/vmk80xx.c | 8 
 34 files changed, 57 insertions(+), 58 deletions(-)

-- 
2.0.3

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


[PATCH 1/3] staging: comedi: drivers: replace SDF_WRITEABLE with SDF_WRITABLE

2014-10-30 Thread H Hartley Sweeten
As indicated in the comedi.h uapi header, SDF_WRITEABLE was a spelling
error in the API, SDF_WRITABLE is prefered.

For aesthetics, replace all the SDF_WRITEABLE uses with SDF_WRITABLE.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi_apci_1500.c  | 5 ++---
 drivers/staging/comedi/drivers/addi_apci_1516.c  | 2 +-
 drivers/staging/comedi/drivers/addi_apci_1564.c  | 4 ++--
 drivers/staging/comedi/drivers/addi_apci_16xx.c  | 2 +-
 drivers/staging/comedi/drivers/addi_apci_2032.c  | 2 +-
 drivers/staging/comedi/drivers/addi_apci_2200.c  | 2 +-
 drivers/staging/comedi/drivers/addi_apci_3120.c  | 6 +++---
 drivers/staging/comedi/drivers/addi_apci_3501.c  | 6 +++---
 drivers/staging/comedi/drivers/addi_apci_3xxx.c  | 6 +++---
 drivers/staging/comedi/drivers/addi_watchdog.c   | 2 +-
 drivers/staging/comedi/drivers/adv_pci1723.c | 2 +-
 drivers/staging/comedi/drivers/c6xdigio.c| 2 +-
 drivers/staging/comedi/drivers/comedi_test.c | 2 +-
 drivers/staging/comedi/drivers/das6402.c | 4 ++--
 drivers/staging/comedi/drivers/dt9812.c  | 4 ++--
 drivers/staging/comedi/drivers/gsc_hpdi.c| 2 +-
 drivers/staging/comedi/drivers/me4000.c  | 2 +-
 drivers/staging/comedi/drivers/me_daq.c  | 4 ++--
 drivers/staging/comedi/drivers/ni_usb6501.c  | 2 +-
 drivers/staging/comedi/drivers/quatech_daqp_cs.c | 4 ++--
 drivers/staging/comedi/drivers/serial2002.c  | 4 ++--
 drivers/staging/comedi/drivers/vmk80xx.c | 8 
 22 files changed, 38 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c 
b/drivers/staging/comedi/drivers/addi_apci_1500.c
index de8d74f..d43129c 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1500.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1500.c
@@ -66,8 +66,7 @@ static int apci1500_auto_attach(struct comedi_device *dev,
/*  Allocate and Initialise DO Subdevice Structures */
s = &dev->subdevices[1];
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags =
-   SDF_READABLE | SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+   s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 16;
s->maxdata = 1;
s->range_table = &range_digital;
@@ -78,7 +77,7 @@ static int apci1500_auto_attach(struct comedi_device *dev,
/*  Allocate and Initialise Timer Subdevice Structures */
s = &dev->subdevices[2];
s->type = COMEDI_SUBD_TIMER;
-   s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON;
+   s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
s->n_chan = 1;
s->maxdata = 0;
s->len_chanlist = 1;
diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c 
b/drivers/staging/comedi/drivers/addi_apci_1516.c
index 55d00fd..d841041 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1516.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1516.c
@@ -163,7 +163,7 @@ static int apci1516_auto_attach(struct comedi_device *dev,
s = &dev->subdevices[1];
if (this_board->do_nchan) {
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_WRITEABLE;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan   = this_board->do_nchan;
s->maxdata  = 1;
s->range_table  = &range_digital;
diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c 
b/drivers/staging/comedi/drivers/addi_apci_1564.c
index c328230..aa908a4 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1564.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1564.c
@@ -403,7 +403,7 @@ static int apci1564_auto_attach(struct comedi_device *dev,
/*  Allocate and Initialise DO Subdevice Structures */
s = &dev->subdevices[1];
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_WRITEABLE;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan   = 32;
s->maxdata  = 1;
s->range_table  = &range_digital;
@@ -431,7 +431,7 @@ static int apci1564_auto_attach(struct comedi_device *dev,
/*  Allocate and Initialise Timer Subdevice Structures */
s = &dev->subdevices[3];
s->type = COMEDI_SUBD_TIMER;
-   s->subdev_flags = SDF_WRITEABLE;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan   = 3;
s->maxdata  = 0;
s->range_table  = &range_digital;
diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c 
b/drivers/staging/comedi/drivers/addi_apci_16xx.c
index 4162e2d..a1248da 100644
--- a/drivers/staging/comedi/drivers/addi_apci_16xx.c
+++ b/drivers/staging/comedi/drivers/addi_apci_16xx.c
@@ -140,7 +140,7 @@ static int apci16xx_auto_attach(struct comedi_device *dev,
for (i = 0; i < n_subdevs; i++) {
s = &dev->subdevices[i];
s->type = COMEDI_SUBD_DIO;
-   s->subdev_flags = SDF_WRIT

[PATCH 3/3] staging: comedi: drivers: digital output subdevices do not need SDF_READABLE

2014-10-30 Thread H Hartley Sweeten
The SDF_READABLE flag is not necessary for digital output subdevices. For
consistency, remove this flag from the comedi drivers that set it.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/adl_pci9111.c  | 2 +-
 drivers/staging/comedi/drivers/amplc_pc263.c  | 2 +-
 drivers/staging/comedi/drivers/amplc_pci263.c | 2 +-
 drivers/staging/comedi/drivers/cb_pcidas64.c  | 2 +-
 drivers/staging/comedi/drivers/das08.c| 2 +-
 drivers/staging/comedi/drivers/das16m1.c  | 2 +-
 drivers/staging/comedi/drivers/das1800.c  | 2 +-
 drivers/staging/comedi/drivers/das800.c   | 2 +-
 drivers/staging/comedi/drivers/icp_multi.c| 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c 
b/drivers/staging/comedi/drivers/adl_pci9111.c
index 18f5f7f..1fd082b 100644
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/staging/comedi/drivers/adl_pci9111.c
@@ -767,7 +767,7 @@ static int pci9111_auto_attach(struct comedi_device *dev,
 
s = &dev->subdevices[3];
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan   = 16;
s->maxdata  = 1;
s->range_table  = &range_digital;
diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c 
b/drivers/staging/comedi/drivers/amplc_pc263.c
index f8e551d..b1946ce 100644
--- a/drivers/staging/comedi/drivers/amplc_pc263.c
+++ b/drivers/staging/comedi/drivers/amplc_pc263.c
@@ -83,7 +83,7 @@ static int pc263_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
s = &dev->subdevices[0];
/* digital output subdevice */
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan = 16;
s->maxdata = 1;
s->range_table = &range_digital;
diff --git a/drivers/staging/comedi/drivers/amplc_pci263.c 
b/drivers/staging/comedi/drivers/amplc_pci263.c
index 2259bee..0d2224b 100644
--- a/drivers/staging/comedi/drivers/amplc_pci263.c
+++ b/drivers/staging/comedi/drivers/amplc_pci263.c
@@ -71,7 +71,7 @@ static int pci263_auto_attach(struct comedi_device *dev,
s = &dev->subdevices[0];
/* digital output subdevice */
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan = 16;
s->maxdata = 1;
s->range_table = &range_digital;
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c 
b/drivers/staging/comedi/drivers/cb_pcidas64.c
index 9196680..c8515d7 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -3868,7 +3868,7 @@ static int setup_subdevices(struct comedi_device *dev)
if (thisboard->layout == LAYOUT_64XX) {
s = &dev->subdevices[3];
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 1;
s->range_table = &range_digital;
diff --git a/drivers/staging/comedi/drivers/das08.c 
b/drivers/staging/comedi/drivers/das08.c
index bdb671a..cdf71f9 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -507,7 +507,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned 
long iobase)
/* do */
if (thisboard->do_nchan) {
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan = thisboard->do_nchan;
s->maxdata = 1;
s->range_table = &range_digital;
diff --git a/drivers/staging/comedi/drivers/das16m1.c 
b/drivers/staging/comedi/drivers/das16m1.c
index 54ccffc..80f41b7 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -597,7 +597,7 @@ static int das16m1_attach(struct comedi_device *dev,
s = &dev->subdevices[2];
/* do */
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan = 4;
s->maxdata = 1;
s->range_table = &range_digital;
diff --git a/drivers/staging/comedi/drivers/das1800.c 
b/drivers/staging/comedi/drivers/das1800.c
index 246a186..bf8bfcf 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -1513,7 +1513,7 @@ static int das1800_attach(struct comedi_device *dev,
/* do */
s = &dev->subdevices[3];
s->type = COMEDI_SUBD_DO;
-   s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
+   s->subdev_flags = SDF_WRITABLE;
s->n_chan = thisboard->do_n_chan;
s->maxdata = 1;
   

[PATCH] staging: comedi: drivers do not need to reset the async->cur_chan

2014-10-30 Thread H Hartley Sweeten
The comedi core calls comedi_buf_reset() before starting an async command
(*do_cmd) and after returning a subdevice to an idle state (*cancel).

The drivers do not need to reset the async->cur_chan in those functions.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 --
 drivers/staging/comedi/drivers/adl_pci9118.c  | 2 --
 drivers/staging/comedi/drivers/adv_pci1710.c  | 2 --
 drivers/staging/comedi/drivers/ni_atmio16d.c  | 1 -
 drivers/staging/comedi/drivers/pcl812.c   | 1 -
 drivers/staging/comedi/drivers/pcl816.c   | 1 -
 drivers/staging/comedi/drivers/usbdux.c   | 6 --
 drivers/staging/comedi/drivers/usbduxfast.c   | 2 --
 drivers/staging/comedi/drivers/usbduxsigma.c  | 5 -
 9 files changed, 22 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 975ee5f..6b65ce6 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -629,7 +629,6 @@ static int apci3120_cancel(struct comedi_device *dev,
inb(dev->iobase + APCI3120_RESET_FIFO);
inw(dev->iobase + APCI3120_RD_STATUS);
devpriv->ui_AiActualScan = 0;
-   s->async->cur_chan = 0;
devpriv->ui_DmaActualBuffer = 0;
 
devpriv->ai_running = 0;
@@ -758,7 +757,6 @@ static int apci3120_cyclic_ai(int mode,
/* END JK 07.05.04: Comparison between WIN32 and Linux driver */
 
devpriv->ui_AiActualScan = 0;
-   s->async->cur_chan = 0;
devpriv->ui_DmaActualBuffer = 0;
 
/* value for timer2  minus -2 has to be done */
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index cb2c485..83c3813 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -575,7 +575,6 @@ static int pci9118_ai_cancel(struct comedi_device *dev,
 
devpriv->ai_act_scan = 0;
devpriv->ai_act_dmapos = 0;
-   s->async->cur_chan = 0;
s->async->inttrig = NULL;
devpriv->ai_neverending = 0;
devpriv->dma_actbuf = 0;
@@ -1120,7 +1119,6 @@ static int pci9118_ai_cmd(struct comedi_device *dev, 
struct comedi_subdevice *s)
 
devpriv->ai_act_scan = 0;
devpriv->ai_act_dmapos = 0;
-   s->async->cur_chan = 0;
 
if (devpriv->usedma) {
Compute_and_setup_dma(dev, s);
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c 
b/drivers/staging/comedi/drivers/adv_pci1710.c
index e05f4b5..075df1c 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -731,7 +731,6 @@ static int pci171x_ai_cancel(struct comedi_device *dev,
}
 
devpriv->ai_act_scan = 0;
-   s->async->cur_chan = 0;
 
return 0;
 }
@@ -931,7 +930,6 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
outb(0, dev->iobase + PCI171x_CLRINT);
 
devpriv->ai_act_scan = 0;
-   s->async->cur_chan = 0;
 
devpriv->CntrlReg &= Control_CNT0;
if ((cmd->flags & CMDF_WAKE_EOS) == 0)
diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c 
b/drivers/staging/comedi/drivers/ni_atmio16d.c
index 2bac693..d0ac49e 100644
--- a/drivers/staging/comedi/drivers/ni_atmio16d.c
+++ b/drivers/staging/comedi/drivers/ni_atmio16d.c
@@ -300,7 +300,6 @@ static int atmio16d_ai_cmd(struct comedi_device *dev,
 * It is still uber-experimental */
 
reset_counters(dev);
-   s->async->cur_chan = 0;
 
/* check if scanning multiple channels */
if (cmd->chanlist_len < 2) {
diff --git a/drivers/staging/comedi/drivers/pcl812.c 
b/drivers/staging/comedi/drivers/pcl812.c
index eef6462..1088607 100644
--- a/drivers/staging/comedi/drivers/pcl812.c
+++ b/drivers/staging/comedi/drivers/pcl812.c
@@ -809,7 +809,6 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
 
devpriv->ai_act_scan = 0;
devpriv->ai_poll_ptr = 0;
-   s->async->cur_chan = 0;
 
/*  don't we want wake up every scan? */
if (cmd->flags & CMDF_WAKE_EOS) {
diff --git a/drivers/staging/comedi/drivers/pcl816.c 
b/drivers/staging/comedi/drivers/pcl816.c
index a471c3d..053eed0 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -509,7 +509,6 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct 
comedi_subdevice *s)
udelay(1);
 
devpriv->ai_act_scan = 0;
-   s->async->cur_chan = 0;
devpriv->ai_cmd_running = 1;
devpriv->ai_poll_ptr = 0;
devpriv->ai_cmd_canceled = 0;
diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/us

[PATCH 0/2] staging: comedi: rtd520: fix analog input munging

2014-10-30 Thread H Hartley Sweeten
Bipolar analog input samples need to be munged from two's-complement format
to the unsigned offset format that comedi expects. Currently this driver
uses a bitmap in the private data to determine if the sample being acquired
is bipolar.

The comedi_async 'cur_chan' is used to test the bit in the bitmap in the
ai_read_n() function. The 'cur_chan' is never incremented so all the bit
tests are using the first channel in the chanlist. Patch 1 fixes this.

Patch 2 removes the bitmap and uses the comedi_is_bipolar() helper to
determine if the sample needs to be munged.

H Hartley Sweeten (2):
  staging: comedi: rtd520: fix ai_read_n() async->cur_chan use
  staging: comedi: rtd520: remove private data 'chan_is_bipolar' member

 drivers/staging/comedi/drivers/rtd520.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

-- 
2.0.3

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


[PATCH 1/2] staging: comedi: rtd520: fix ai_read_n() async->cur_chan use

2014-10-30 Thread H Hartley Sweeten
This functions uses the async->cur_chan to determine if the current channel
is using a bipolar range and the sample needs to be munged. The cur_chan is
never incremented so all the samples are munged based on the fist channel
in the cmd->chanlist.

Bump the cur_chan after writing each sample. This fixes the code so that
the munging will be done correctly.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/rtd520.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/rtd520.c 
b/drivers/staging/comedi/drivers/rtd520.c
index 888238e..8e87655 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -606,6 +606,8 @@ static int ai_read_n(struct comedi_device *dev, struct 
comedi_subdevice *s,
 int count)
 {
struct rtd_private *devpriv = dev->private;
+   struct comedi_async *async = s->async;
+   struct comedi_cmd *cmd = &async->cmd;
int ii;
 
for (ii = 0; ii < count; ii++) {
@@ -618,7 +620,7 @@ static int ai_read_n(struct comedi_device *dev, struct 
comedi_subdevice *s,
 
d = readw(devpriv->las1 + LAS1_ADC_FIFO);
d = d >> 3; /* low 3 bits are marker lines */
-   if (test_bit(s->async->cur_chan, devpriv->chan_is_bipolar))
+   if (test_bit(async->cur_chan, devpriv->chan_is_bipolar))
/* convert to comedi unsigned data */
d = comedi_offset_munge(s, d);
d &= s->maxdata;
@@ -626,6 +628,9 @@ static int ai_read_n(struct comedi_device *dev, struct 
comedi_subdevice *s,
if (!comedi_buf_write_samples(s, &d, 1))
return -1;
 
+   async->cur_chan++;
+   async->cur_chan %= cmd->chanlist_len;
+
if (devpriv->ai_count > 0)  /* < 0, means read forever */
devpriv->ai_count--;
}
-- 
2.0.3

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


[PATCH 2/2] staging: comedi: rtd520: remove private data 'chan_is_bipolar' member

2014-10-30 Thread H Hartley Sweeten
Currently this driver uses a bitmap in the private data to keep track of
the unipolar/bipolar range for each channel. This is needed to determine
if the data needs to be munged for bipolar samples.

Remove this member from the private data and use the comedi core helper
function comedi_range_is_bipolar() to determine if the data needs to be
munged.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/rtd520.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/rtd520.c 
b/drivers/staging/comedi/drivers/rtd520.c
index 8e87655..19596756 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -379,7 +379,6 @@ struct rtd_private {
long ai_count;  /* total transfer size (samples) */
int xfer_count; /* # to transfer data. 0->1/2FIFO */
int flags;  /* flag event modes */
-   DECLARE_BITMAP(chan_is_bipolar, RTD_MAX_CHANLIST);
unsigned fifosz;
 };
 
@@ -438,7 +437,6 @@ static unsigned short rtd_convert_chan_gain(struct 
comedi_device *dev,
unsigned int chanspec, int index)
 {
const struct rtd_boardinfo *board = dev->board_ptr;
-   struct rtd_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(chanspec);
unsigned int range = CR_RANGE(chanspec);
unsigned int aref = CR_AREF(chanspec);
@@ -451,17 +449,14 @@ static unsigned short rtd_convert_chan_gain(struct 
comedi_device *dev,
/* +-5 range */
r |= 0x000;
r |= (range & 0x7) << 4;
-   __set_bit(index, devpriv->chan_is_bipolar);
} else if (range < board->range_uni10) {
/* +-10 range */
r |= 0x100;
r |= ((range - board->range_bip10) & 0x7) << 4;
-   __set_bit(index, devpriv->chan_is_bipolar);
} else {
/* +10 range */
r |= 0x200;
r |= ((range - board->range_uni10) & 0x7) << 4;
-   __clear_bit(index, devpriv->chan_is_bipolar);
}
 
switch (aref) {
@@ -561,6 +556,7 @@ static int rtd_ai_rinsn(struct comedi_device *dev,
unsigned int *data)
 {
struct rtd_private *devpriv = dev->private;
+   unsigned int range = CR_RANGE(insn->chanspec);
int ret;
int n;
 
@@ -586,9 +582,11 @@ static int rtd_ai_rinsn(struct comedi_device *dev,
/* read data */
d = readw(devpriv->las1 + LAS1_ADC_FIFO);
d = d >> 3; /* low 3 bits are marker lines */
-   if (test_bit(0, devpriv->chan_is_bipolar))
-   /* convert to comedi unsigned data */
+
+   /* convert bipolar data to comedi unsigned data */
+   if (comedi_range_is_bipolar(s, range))
d = comedi_offset_munge(s, d);
+
data[n] = d & s->maxdata;
}
 
@@ -611,6 +609,7 @@ static int ai_read_n(struct comedi_device *dev, struct 
comedi_subdevice *s,
int ii;
 
for (ii = 0; ii < count; ii++) {
+   unsigned int range = CR_RANGE(cmd->chanlist[async->cur_chan]);
unsigned short d;
 
if (0 == devpriv->ai_count) {   /* done */
@@ -620,8 +619,9 @@ static int ai_read_n(struct comedi_device *dev, struct 
comedi_subdevice *s,
 
d = readw(devpriv->las1 + LAS1_ADC_FIFO);
d = d >> 3; /* low 3 bits are marker lines */
-   if (test_bit(async->cur_chan, devpriv->chan_is_bipolar))
-   /* convert to comedi unsigned data */
+
+   /* convert bipolar data to comedi unsigned data */
+   if (comedi_range_is_bipolar(s, range))
d = comedi_offset_munge(s, d);
d &= s->maxdata;
 
-- 
2.0.3

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


[PATCH 3/3] staging: comedi: amplc_pci230: remove private data 'ai_scan_pos'

2014-10-30 Thread H Hartley Sweeten
This member of the private data is replicating what the comedi_async
'cur_chan' member is used for. Use that instead and remove the private
data member.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/amplc_pci230.c | 15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c 
b/drivers/staging/comedi/drivers/amplc_pci230.c
index 44c967f..58ec3c2 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -491,7 +491,6 @@ struct pci230_private {
spinlock_t ao_stop_spinlock;/* Spin lock for stopping AO command */
unsigned long daqio;/* PCI230's DAQ I/O space */
unsigned int ai_scan_count; /* Number of AI scans remaining */
-   unsigned int ai_scan_pos;   /* Current position within AI scan */
unsigned int ao_scan_count; /* Number of AO scans remaining.  */
int intr_cpuid; /* ID of CPU running ISR */
unsigned short hwver;   /* Hardware version (for '+' models) */
@@ -1748,13 +1747,13 @@ static void pci230_ai_update_fifo_trigger_level(struct 
comedi_device *dev,
unsigned short adccon;
 
if (cmd->flags & CMDF_WAKE_EOS)
-   wake = scanlen - devpriv->ai_scan_pos;
+   wake = scanlen - s->async->cur_chan;
else if (cmd->stop_src != TRIG_COUNT ||
 devpriv->ai_scan_count >= PCI230_ADC_FIFOLEVEL_HALFFULL ||
 scanlen >= PCI230_ADC_FIFOLEVEL_HALFFULL)
wake = PCI230_ADC_FIFOLEVEL_HALFFULL;
else
-   wake = devpriv->ai_scan_count * scanlen - devpriv->ai_scan_pos;
+   wake = devpriv->ai_scan_count * scanlen - s->async->cur_chan;
if (wake >= PCI230_ADC_FIFOLEVEL_HALFFULL) {
triglev = PCI230_ADC_INT_FIFO_HALF;
} else if (wake > 1 && devpriv->hwver > 0) {
@@ -2064,7 +2063,7 @@ static void pci230_handle_ai(struct comedi_device *dev,
   scanlen > PCI230_ADC_FIFOLEVEL_HALFFULL) {
todo = PCI230_ADC_FIFOLEVEL_HALFFULL;
} else {
-   todo = devpriv->ai_scan_count * scanlen - devpriv->ai_scan_pos;
+   todo = devpriv->ai_scan_count * scanlen - async->cur_chan;
if (todo > PCI230_ADC_FIFOLEVEL_HALFFULL)
todo = PCI230_ADC_FIFOLEVEL_HALFFULL;
}
@@ -2105,13 +2104,8 @@ static void pci230_handle_ai(struct comedi_device *dev,
comedi_buf_write_samples(s, &val, 1);
 
fifoamount--;
-   devpriv->ai_scan_pos++;
-   if (devpriv->ai_scan_pos == scanlen) {
-   /* End of scan. */
-   devpriv->ai_scan_pos = 0;
+   if (async->events & COMEDI_CB_EOS)
devpriv->ai_scan_count--;
-   async->events |= COMEDI_CB_EOS;
-   }
}
if (cmd->stop_src == TRIG_COUNT && devpriv->ai_scan_count == 0) {
/* End of acquisition. */
@@ -2158,7 +2152,6 @@ static int pci230_ai_cmd(struct comedi_device *dev, 
struct comedi_subdevice *s)
return -EBUSY;
 
devpriv->ai_scan_count = cmd->stop_arg;
-   devpriv->ai_scan_pos = 0;   /* Position within scan. */
 
/*
 * Steps:
-- 
2.0.3

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


[PATCH 0/3] staging: comedi: make core track comedi_async 'cur_chan'

2014-10-30 Thread H Hartley Sweeten
Move the tracking of the comedi_async 'cur_chan' into the core.

H Hartley Sweeten (3):
  staging: comedi: ni_mio_common: remove unused variable in ni_ao_fifo_load()
  staging: comedi: drivers: move comedi_async 'cur_chan' tracking into the core
  staging: comedi: amplc_pci230: remove private data 'ai_scan_pos'

 drivers/staging/comedi/drivers.c  |  7 +++
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c |  2 --
 drivers/staging/comedi/drivers/adl_pci9118.c  |  8 ++--
 drivers/staging/comedi/drivers/adv_pci1710.c  | 13 ++---
 drivers/staging/comedi/drivers/amplc_pci230.c | 15 ---
 drivers/staging/comedi/drivers/ni_mio_common.c| 11 ---
 drivers/staging/comedi/drivers/pcl812.c   | 13 -
 drivers/staging/comedi/drivers/pcl816.c   |  6 +-
 drivers/staging/comedi/drivers/pcl818.c   |  6 +-
 drivers/staging/comedi/drivers/rtd520.c   |  3 ---
 10 files changed, 21 insertions(+), 63 deletions(-)

-- 
2.0.3

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


[PATCH 2/3] staging: comedi: drivers: move comedi_async 'cur_chan' tracking into the core

2014-10-30 Thread H Hartley Sweeten
The commedi_async 'cur_chan' member is used to track the current position
in the chanlist for a scan. Currently only a couple comedi drivers use
this member.

For aeshtetics, move the 'cur_chan' tracking into the core for non-SDF_PACKED
subdevices. The 'cur_chan' will be updated after reading or writing samples
to the async buffer by comedi_inc_scan_progress(). All non-SDF_PACKED subdevices
will then automatiaclly track the 'cur_chan'.

Some of the drivers and were using the 'cur_chan' overflow to detect the
end of scan, comedi_inc_scan_progress() detects the end of scan and sets
the COMEDI_CB_EOS event. Those drivers just need to detect the event.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers.c  |  7 +++
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c |  2 --
 drivers/staging/comedi/drivers/adl_pci9118.c  |  8 ++--
 drivers/staging/comedi/drivers/adv_pci1710.c  | 13 ++---
 drivers/staging/comedi/drivers/ni_mio_common.c|  8 
 drivers/staging/comedi/drivers/pcl812.c   | 13 -
 drivers/staging/comedi/drivers/pcl816.c   |  6 +-
 drivers/staging/comedi/drivers/pcl818.c   |  6 +-
 drivers/staging/comedi/drivers/rtd520.c   |  3 ---
 9 files changed, 17 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index ff2df85..9c55dc7 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -341,8 +341,15 @@ void comedi_inc_scan_progress(struct comedi_subdevice *s,
  unsigned int num_bytes)
 {
struct comedi_async *async = s->async;
+   struct comedi_cmd *cmd = &async->cmd;
unsigned int scan_length = comedi_bytes_per_scan(s);
 
+   /* track the 'cur_chan' for non-SDF_PACKED subdevices */
+   if (!(s->subdev_flags & SDF_PACKED)) {
+   async->cur_chan += comedi_bytes_to_samples(s, num_bytes);
+   async->cur_chan %= cmd->chanlist_len;
+   }
+
async->scan_progress += num_bytes;
if (async->scan_progress >= scan_length) {
async->scan_progress %= scan_length;
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 6b65ce6..facd2c4 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1167,8 +1167,6 @@ static void v_APCI3120_InterruptDmaMoveBlock16bit(struct 
comedi_device *dev,
 
devpriv->ui_AiActualScan +=
(s->async->cur_chan + num_samples) / cmd->scan_end_arg;
-   s->async->cur_chan += num_samples;
-   s->async->cur_chan %= cmd->scan_end_arg;
 
comedi_buf_write_samples(s, dma_buffer, num_samples);
 }
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index 83c3813..4060973 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -483,8 +483,6 @@ static void move_block_from_dma(struct comedi_device *dev,
num_samples = defragment_dma_buffer(dev, s, dma_buffer, num_samples);
devpriv->ai_act_scan +=
(s->async->cur_chan + num_samples) / cmd->scan_end_arg;
-   s->async->cur_chan += num_samples;
-   s->async->cur_chan %= cmd->scan_end_arg;
 
comedi_buf_write_samples(s, dma_buffer, num_samples);
 }
@@ -612,10 +610,8 @@ static void interrupt_pci9118_ai_onesample(struct 
comedi_device *dev,
sampl = inl(dev->iobase + PCI9118_AI_FIFO_REG);
 
comedi_buf_write_samples(s, &sampl, 1);
-   s->async->cur_chan++;
-   if (s->async->cur_chan >= cmd->scan_end_arg) {
-   /* one scan done */
-   s->async->cur_chan %= cmd->scan_end_arg;
+
+   if (s->async->events & COMEDI_CB_EOS) {
devpriv->ai_act_scan++;
if (!devpriv->ai_neverending) {
/* all data sampled? */
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c 
b/drivers/staging/comedi/drivers/adv_pci1710.c
index 075df1c..b7083eb 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -772,12 +772,7 @@ static void pci1710_handle_every_sample(struct 
comedi_device *dev,
val &= s->maxdata;
comedi_buf_write_samples(s, &val, 1);
 
-   s->async->cur_chan++;
-   if (s->async->cur_chan >= cmd->chanlist_len)
-   s->async->cur_chan = 0;
-
-
-   if (s->async->cur_chan == 0) {  /*  one scan done */
+   if (s->async->events & COMEDI_CB_EOS) {
devpriv->ai_act_scan++;
  

[PATCH 1/3] staging: comedi: ni_mio_common: remove unused variable in ni_ao_fifo_load()

2014-10-30 Thread H Hartley Sweeten
The local variable 'range' is set but never used. Remove it.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/ni_mio_common.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index fd61d24..32236ef 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1131,14 +1131,11 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
int i;
unsigned short d;
u32 packed_data;
-   int range;
 
chan = async->cur_chan;
for (i = 0; i < n; i++) {
comedi_buf_read_samples(s, &d, 1);
 
-   range = CR_RANGE(cmd->chanlist[chan]);
-
if (devpriv->is_6xxx) {
packed_data = d & 0x;
/* 6711 only has 16 bit wide ao fifo */
-- 
2.0.3

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


[PATCH net-next] hyperv: Add IPv6 into the hash computation for vRSS

2014-10-30 Thread Haiyang Zhang
This will allow the workload spreading via vRSS for IPv6.

Signed-off-by: Haiyang Zhang 
Reviewed-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/netvsc_drv.c   |4 +++-
 drivers/net/hyperv/rndis_filter.c |3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 78ec33f..3295e4e 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -193,7 +193,9 @@ static bool netvsc_set_hash(u32 *hash, struct sk_buff *skb)
struct flow_keys flow;
int data_len;
 
-   if (!skb_flow_dissect(skb, &flow) || flow.n_proto != htons(ETH_P_IP))
+   if (!skb_flow_dissect(skb, &flow) ||
+   !(flow.n_proto == htons(ETH_P_IP) ||
+ flow.n_proto == htons(ETH_P_IPV6)))
return false;
 
if (flow.ip_proto == IPPROTO_TCP)
diff --git a/drivers/net/hyperv/rndis_filter.c 
b/drivers/net/hyperv/rndis_filter.c
index 2b86f0b..ccce6f2 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -728,7 +728,8 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev, 
int num_queue)
rssp->hdr.size = sizeof(struct ndis_recv_scale_param);
rssp->flag = 0;
rssp->hashinfo = NDIS_HASH_FUNC_TOEPLITZ | NDIS_HASH_IPV4 |
-NDIS_HASH_TCP_IPV4;
+NDIS_HASH_TCP_IPV4 | NDIS_HASH_IPV6 |
+NDIS_HASH_TCP_IPV6;
rssp->indirect_tabsize = 4*ITAB_NUM;
rssp->indirect_taboffset = sizeof(struct ndis_recv_scale_param);
rssp->hashkey_size = HASH_KEYLEN;
-- 
1.7.1

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


[PATCH 7/9] staging: unisys: virtpci: Use a single blank line to separate code blocks

2014-10-30 Thread Bryan Thompson
Remove one blank line of two between function variable declaration and 
implementation in
virt_pci_mod_init().

Signed-off-by: Bryan Thompson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virtpci/virtpci.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/unisys/virtpci/virtpci.c 
b/drivers/staging/unisys/virtpci/virtpci.c
index 07d1966..f13daab 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -1502,7 +1502,6 @@ static int __init virtpci_mod_init(void)
 {
int ret;
 
-
if (!unisys_spar_platform)
return -ENODEV;
 
-- 
1.7.9.5

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


[PATCH 8/9] staging: unisys: virtpci: Fix alignment issues

2014-10-30 Thread Bryan Thompson
Use the appropriate whitespace alignment for multiline statements in virtpci.c

Signed-off-by: Bryan Thompson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virtpci/virtpci.c |   28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/unisys/virtpci/virtpci.c 
b/drivers/staging/unisys/virtpci/virtpci.c
index f13daab..928f0fd 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -110,7 +110,7 @@ static int virtpci_device_probe(struct device *dev);
 static int virtpci_device_remove(struct device *dev);
 
 static ssize_t info_debugfs_read(struct file *file, char __user *buf,
- size_t len, loff_t *offset);
+size_t len, loff_t *offset);
 
 static const struct file_operations debugfs_info_fops = {
.read = info_debugfs_read,
@@ -392,9 +392,9 @@ add_vnic(struct add_virt_guestpart *addparams)
GET_BUS_DEV(addparams->bus_no);
 
LOGINF("Adding vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x rcvbufs:%d 
mtu:%d chanptr:%p%pUL\n",
-net.mac_addr[0], net.mac_addr[1], net.mac_addr[2], net.mac_addr[3],
-net.mac_addr[4], net.mac_addr[5], net.num_rcv_bufs, net.mtu,
-addparams->chanptr, &net.zone_uuid);
+  net.mac_addr[0], net.mac_addr[1], net.mac_addr[2],
+  net.mac_addr[3], net.mac_addr[4], net.mac_addr[5],
+  net.num_rcv_bufs, net.mtu, addparams->chanptr, &net.zone_uuid);
i = virtpci_device_add(vbus, VIRTNIC_TYPE, addparams, NULL, &net);
if (i) {
LOGINF("Added vnic macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -624,7 +624,7 @@ static int delete_all_virt(enum virtpci_dev_type devtype,
 
if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) {
LOGERR(" FAILED to delete all devices; devtype:%d not 
vhba:%d or vnic:%d\n",
-devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
+  devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
return 0;
}
 
@@ -694,7 +694,7 @@ virtpci_match_device(const struct pci_device_id *ids,
 {
while (ids->vendor || ids->subvendor || ids->class_mask) {
DBGINF("ids->vendor:%x dev->vendor:%x ids->device:%x 
dev->device:%x\n",
-ids->vendor, dev->vendor, ids->device, dev->device);
+  ids->vendor, dev->vendor, ids->device, dev->device);
 
if ((ids->vendor == dev->vendor) &&
(ids->device == dev->device))
@@ -793,9 +793,9 @@ static void fix_vbus_devInfo(struct device *dev, int devNo, 
int devType,
break;
}
bus_device_info_init(&devInfo, stype,
-  virtpcidrv->name,
-  virtpcidrv->version,
-  virtpcidrv->vertag);
+virtpcidrv->name,
+virtpcidrv->version,
+virtpcidrv->vertag);
write_vbus_devInfo(pChan, &devInfo, devNo);
 
/* Re-write bus+chipset info, because it is possible that this
@@ -916,7 +916,7 @@ static int virtpci_device_add(struct device *parentbus, int 
devtype,
 
if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) {
LOGERR(" FAILED to add device; devtype:%d not vhba:%d or 
vnic:%d\n",
-devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
+  devtype, VIRTHBA_TYPE, VIRTNIC_TYPE);
POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, devtype,
 POSTCODE_SEVERITY_ERR);
return 0;
@@ -1427,7 +1427,7 @@ static int print_vbus(struct device *vbus, void *data)
 }
 
 static ssize_t info_debugfs_read(struct file *file, char __user *buf,
- size_t len, loff_t *offset)
+size_t len, loff_t *offset)
 {
ssize_t bytes_read = 0;
int str_pos = 0;
@@ -1519,7 +1519,7 @@ static int __init virtpci_mod_init(void)
}
DBGINF("bus_register successful\n");
bus_device_info_init(&Bus_DriverInfo, "clientbus", "virtpci",
-  VERSION, NULL);
+VERSION, NULL);
 
/* create a root bus used to parent all the virtpci buses. */
ret = device_register(&virtpci_rootbus_device);
@@ -1542,11 +1542,11 @@ static int __init virtpci_mod_init(void)
}
 
LOGINF("successfully registered virtpci_ctrlchan_func (0x%p) as 
callback.\n",
-(void *)&virtpci_ctrlchan_func);
+  (void *)&virtpci_ctrlchan_func);
/* create debugfs directory and info file inside. */
virtpci_debugfs_dir = debugfs_create_dir("virtpci", NULL);
debugfs_create_file("info", S_IRUSR, virtpci_debugfs_dir,
-   NULL, &debugfs_info_fops);
+   NULL, &debugfs_inf

[PATCH 1/9] staging: unisys: virtpci: Add a blank line after the definition of driver_private

2014-10-30 Thread Bryan Thompson
Insert a blank line between the definition of the driver_private structure and 
the next statement.

Signed-off-by: Bryan Thompson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virtpci/virtpci.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/unisys/virtpci/virtpci.c 
b/drivers/staging/unisys/virtpci/virtpci.c
index 52ec69f..1f72103 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -50,6 +50,7 @@ struct driver_private {
struct module_kobject *mkobj;
struct device_driver *driver;
 };
+
 #define to_driver(obj) container_of(obj, struct driver_private, kobj)
 
 /* bus_id went away in 2.6.30 - the size was 20 bytes, so we'll define
-- 
1.7.9.5

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


[PATCH 4/9] staging: unisys: virtpci: Allocate memory using the size of the variable

2014-10-30 Thread Bryan Thompson
Change two instances of using the sizeof a structure to the size of a specific 
variable when
allocating memory in virtpci.c

Signed-off-by: Bryan Thompson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virtpci/virtpci.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/virtpci/virtpci.c 
b/drivers/staging/unisys/virtpci/virtpci.c
index 560639a..3cfa767 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -256,7 +256,7 @@ static int add_vbus(struct add_vbus_guestpart *addparams)
int ret;
struct device *vbus;
 
-   vbus = kzalloc(sizeof(struct device), GFP_ATOMIC);
+   vbus = kzalloc(sizeof(*vbus), GFP_ATOMIC);
 
POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
if (!vbus)
@@ -922,7 +922,7 @@ static int virtpci_device_add(struct device *parentbus, int 
devtype,
}
 
/* add a Virtual Device */
-   virtpcidev = kzalloc(sizeof(struct virtpci_dev), GFP_ATOMIC);
+   virtpcidev = kzalloc(sizeof(*virtpcidev), GFP_ATOMIC);
if (virtpcidev == NULL) {
LOGERR("can't add device - malloc FALLED\n");
POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
-- 
1.7.9.5

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


[PATCH 5/9] staging: unisys: virtpci: Place logical continuation at the end of a line

2014-10-30 Thread Bryan Thompson
Move the && logical continuation from the start of the second line of an if 
statement
to the end of the first line.

Signed-off-by: Bryan Thompson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virtpci/virtpci.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/virtpci/virtpci.c 
b/drivers/staging/unisys/virtpci/virtpci.c
index 3cfa767..baf12e5 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -696,8 +696,8 @@ virtpci_match_device(const struct pci_device_id *ids,
DBGINF("ids->vendor:%x dev->vendor:%x ids->device:%x 
dev->device:%x\n",
 ids->vendor, dev->vendor, ids->device, dev->device);
 
-   if ((ids->vendor == dev->vendor)
-   && (ids->device == dev->device))
+   if ((ids->vendor == dev->vendor) &&
+   (ids->device == dev->device))
return ids;
 
ids++;
-- 
1.7.9.5

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


[PATCH 9/9] staging: unisys: virtpci: Adjust lines to contain a maximum of 80 characters

2014-10-30 Thread Bryan Thompson
Update delete_all_virt function definition to two lines so each line is less 
than 80
characters long.

Move comments on virtpci_device_add function parameters to a header block to 
contain
each line to 80 characters.

Signed-off-by: Bryan Thompson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virtpci/virtpci.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/virtpci/virtpci.c 
b/drivers/staging/unisys/virtpci/virtpci.c
index 928f0fd..b6c3130 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -897,10 +897,13 @@ static void virtpci_bus_release(struct device *dev)
 /* Adapter functions */
 /*/
 
+/* scsi is expected to be NULL for VNIC add
+ * net is expected to be NULL for VHBA add
+ */
 static int virtpci_device_add(struct device *parentbus, int devtype,
  struct add_virt_guestpart *addparams,
- struct scsi_adap_info *scsi, /* NULL for VNIC add 
*/
- struct net_adap_info *net /* NULL for VHBA add */)
+ struct scsi_adap_info *scsi,
+ struct net_adap_info *net)
 {
struct virtpci_dev *virtpcidev = NULL;
struct virtpci_dev *tmpvpcidev = NULL, *prev;
-- 
1.7.9.5

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


[PATCH 2/9] staging: unisys: virtpci: Remove extraneous blank lines

2014-10-30 Thread Bryan Thompson
Removed unnecessary blank lines from virtpci.c

Signed-off-by: Bryan Thompson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virtpci/virtpci.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/unisys/virtpci/virtpci.c 
b/drivers/staging/unisys/virtpci/virtpci.c
index 1f72103..7b00cef 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -177,7 +177,6 @@ int WAIT_FOR_IO_CHANNEL(struct spar_io_channel_protocol 
__iomem  *chanptr)
int count = 120;
 
while (count > 0) {
-
if (SPAR_CHANNEL_SERVER_READY(&chanptr->channel_header))
return 1;
UIS_THREAD_WAIT_SEC(1);
@@ -348,7 +347,6 @@ static int add_vhba(struct add_virt_guestpart *addparams)
 POSTCODE_SEVERITY_INFO);
}
return i;
-
 }
 
 /* for CHANSOCK macaddr is AUTO-GENERATED; for normal channels,
@@ -1566,7 +1564,6 @@ static void __exit virtpci_mod_exit(void)
bus_unregister(&virtpci_bus_type);
debugfs_remove_recursive(virtpci_debugfs_dir);
LOGINF("Leaving\n");
-
 }
 
 module_init(virtpci_mod_init);
-- 
1.7.9.5

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


[PATCH 6/9] staging: unisys: virtpci: Add braces to if/else statements

2014-10-30 Thread Bryan Thompson
Update if/else blocks with braces on both the if and the else blocks in 
virtpci.c.

Signed-off-by: Bryan Thompson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virtpci/virtpci.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/unisys/virtpci/virtpci.c 
b/drivers/staging/unisys/virtpci/virtpci.c
index baf12e5..07d1966 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -847,8 +847,9 @@ static int virtpci_device_probe(struct device *dev)
virtpcidev->mydriver = virtpcidrv;
POSTCODE_LINUX_2(VPCI_PROBE_EXIT_PC,
 POSTCODE_SEVERITY_INFO);
-   } else
+   } else {
put_device(dev);
+   }
}
POSTCODE_LINUX_2(VPCI_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
return error;   /* -ENODEV for probe failure */
@@ -992,9 +993,9 @@ static int virtpci_device_add(struct device *parentbus, int 
devtype,
}
 
/* add it at the head */
-   if (!VpcidevListHead)
+   if (!VpcidevListHead) {
VpcidevListHead = virtpcidev;
-   else {
+   } else {
/* insert virtpcidev at the head of our linked list of
 * vpcidevs
 */
-- 
1.7.9.5

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


[PATCH 0/9] Cleanup in virtpci.c

2014-10-30 Thread Bryan Thompson
This series of patches cleans up some simple checkpatch.pl findings in virtpci.c

Bryan Thompson (9):
  staging: unisys: virtpci: Add a blank line after the definition of
driver_private
  staging: unisys: virtpci: Remove extraneous blank lines
  staging: unisys: virtpci: Remove space between cast and variable
  staging: unisys: virtpci: Allocate memory using the size of the
variable
  staging: unisys: virtpci: Place logical continuation at the end of a
line
  staging: unisys: virtpci: Add braces to if/else statements
  staging: unisys: virtpci: Use a single blank line to separate code
blocks
  staging: unisys: virtpci: Fix alignment issues
  staging: unisys: virtpci: Adjust lines to contain a maximum of 80
characters

 drivers/staging/unisys/virtpci/virtpci.c |   81 +++---
 1 file changed, 41 insertions(+), 40 deletions(-)

-- 
1.7.9.5

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


[PATCH 3/9] staging: unisys: virtpci: Remove space between cast and variable

2014-10-30 Thread Bryan Thompson
Remove the whitespace between a cast and a variable in virtpci.c.

Signed-off-by: Bryan Thompson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virtpci/virtpci.c |   28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/unisys/virtpci/virtpci.c 
b/drivers/staging/unisys/virtpci/virtpci.c
index 7b00cef..560639a 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -200,7 +200,7 @@ static int write_vbus_chpInfo(struct 
spar_vbus_channel_protocol *chan,
LOGERR("vbus channel not used, because chp_info_offset == 0");
return -1;
}
-   memcpy(((u8 *) (chan)) + off, info, sizeof(*info));
+   memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
return 0;
 }
 
@@ -219,7 +219,7 @@ static int write_vbus_busInfo(struct 
spar_vbus_channel_protocol *chan,
LOGERR("vbus channel not used, because bus_info_offset == 0");
return -1;
}
-   memcpy(((u8 *) (chan)) + off, info, sizeof(*info));
+   memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
return 0;
 }
 
@@ -244,7 +244,7 @@ write_vbus_devInfo(struct spar_vbus_channel_protocol *chan,
LOGERR("vbus channel not used, because dev_info_offset == 0");
return -1;
}
-   memcpy(((u8 *) (chan)) + off, info, sizeof(*info));
+   memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
return 0;
 }
 
@@ -325,7 +325,7 @@ static int add_vhba(struct add_virt_guestpart *addparams)
 
POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
if (!WAIT_FOR_IO_CHANNEL
-   ((struct spar_io_channel_protocol __iomem *) addparams->chanptr)) {
+   ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) {
LOGERR("Timed out.  Channel not ready\n");
POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
return 0;
@@ -355,16 +355,16 @@ static int add_vhba(struct add_virt_guestpart *addparams)
 #define GET_NETADAPINFO_FROM_CHANPTR(chanptr) {
\
memcpy_fromio(net.mac_addr, \
   ((struct spar_io_channel_protocol __iomem *) \
-   chanptr)->vnic.macaddr, \
+  chanptr)->vnic.macaddr,  \
   MAX_MACADDR_LEN);\
net.num_rcv_bufs =  \
readl(&((struct spar_io_channel_protocol __iomem *)\
-   chanptr)->vnic.num_rcv_bufs);   \
+ chanptr)->vnic.num_rcv_bufs); \
net.mtu = readl(&((struct spar_io_channel_protocol __iomem *) \
- chanptr)->vnic.mtu);  \
+   chanptr)->vnic.mtu);\
memcpy_fromio(&net.zone_uuid, \
  &((struct spar_io_channel_protocol __iomem *)\
-   chanptr)->vnic.zone_uuid,   \
+ chanptr)->vnic.zone_uuid, \
  sizeof(uuid_le)); \
 }
 
@@ -381,7 +381,7 @@ add_vnic(struct add_virt_guestpart *addparams)
 
POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
if (!WAIT_FOR_IO_CHANNEL
-   ((struct spar_io_channel_protocol __iomem *) addparams->chanptr)) {
+   ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) {
LOGERR("Timed out, channel not ready\n");
POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
return 0;
@@ -431,7 +431,7 @@ delete_vbus_device(struct device *vbus, void *data)
int checkforroot = (data != NULL);
struct device *pDev = &virtpci_rootbus_device;
 
-   if ((checkforroot) && match_busid(vbus, (void *) BUS_ID(pDev))) {
+   if ((checkforroot) && match_busid(vbus, (void *)BUS_ID(pDev))) {
/* skip it - don't delete root bus */
LOGINF("skipping root bus\n");
return 0;   /* pretend no error */
@@ -606,7 +606,7 @@ static void delete_all(void)
 
/* now delete each vbus */
if (bus_for_each_dev
-   (&virtpci_bus_type, NULL, (void *) 1, delete_vbus_device))
+   (&virtpci_bus_type, NULL, (void *)1, delete_vbus_device))
LOGERR("delete of all vbus failed\n");
 }
 
@@ -1447,7 +1447,7 @@ static ssize_t info_debugfs_read(struct file *file, char 
__user *buf,
printparam.buf = vbuf;
printparam.len = &len;
if (bus_for_each_dev(&virtpci_bus_type, NULL,
-(void *) &printparam, print_vbus))

Re: [PATCH 4/7] staging: comedi: don't allow read() on async command set up for "write"

2014-10-30 Thread Ian Abbott

On 30/10/14 18:05, Hartley Sweeten wrote:

On Thursday, October 30, 2014 5:42 AM, Ian Abbott wrote:

[snip]

add_wait_queue(&async->wait_head, &wait);
while (nbytes > 0 && !retval) {
@@ -2249,6 +2253,10 @@ static ssize_t comedi_read(struct file *file, char 
__user *buf, size_t nbytes,
retval = -EACCES;
break;
}
+   if (async->cmd.flags & CMDF_WRITE) {
+   retval = -EINVAL;
+   break;
+   }


Is this second test really needed in the while() loop?

For that matter, are the s->busy tests needed in the while() loop?


To answer your second question, some other thread using the same file 
object might have cancelled the asynchronous command, causing the 
current thread to see that the command is no longer active when it wakes up.


To answer your first question, that other thread might have managed to 
set up another asynchronous command in before we wake up, and it might 
have been set up as a "write" command (if the subdevice supports 
commands in both directions).  This doesn't detect the case when the 
other thread has managed to set up another "read" command, but since the 
current read() call hasn't read any data yet, we can just pretend we 
didn't know about the original command and read data from the new 
command instead.  (After all, the calling thread can't prove the read() 
started before the first command was cancelled, so we can just pretend 
it didn't.)


--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 5/7] staging: comedi: don't allow write() on async command set up for "read"

2014-10-30 Thread Ian Abbott

On 30/10/14 18:07, Hartley Sweeten wrote:

On Thursday, October 30, 2014 5:43 AM, Ian Abbott wrote:

[snip]

add_wait_queue(&async->wait_head, &wait);
on_wait_queue = true;
@@ -2146,6 +2150,10 @@ static ssize_t comedi_write(struct file *file, const 
char __user *buf,
retval = -EACCES;
break;
}
+   if (!(async->cmd.flags & CMDF_WRITE)) {
+   retval = -EINVAL;
+   break;
+   }


Same question as with PATCH 4/7.

Is this test needed in the while () loop. Also, are the s->busy tests needed 
here?


Yes, for similar reasons.

--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: comedi: comedi_test: fix timer lock-up

2014-10-30 Thread Greg Kroah-Hartman
On Thu, Oct 30, 2014 at 10:03:53AM +, Ian Abbott wrote:
> Commit 240512474424 ("staging: comedi: comedi_test: use
> comedi_handle_events()") resulted in the timer routine
> `waveform_ai_interrupt()` calling `comedi_handle_events()` instead of
> `comedi_events()`.  That had the advantage of automatically stopping the
> acquisition on overflow/error/end-of-acquisition conditions (by calling
> the comedi subdevice's "cancel" handler), but currently results in the
> timer routine locking when one of those conditions occur.  This is
> because the "cancel" handler `waveform_ai_cancel()` calls
> `del_timer_sync()`.
> 
> Fix it by adding a bit to the device private data that indicates whether
> the acquisition is active or not, and changing the "cancel" handler to
> use `del_timer()` instead of `del_timer_sync()`.  The bit is set when
> starting the acquisition, cleared when ending the acquisition (in the
> "cancel" handler), and tested in the timer routine, which will do
> nothing if the acquisition is inactive.  Also, make sure any scheduled
> timeout event gets cancelled when the low-level device gets "detached"
> from the comedi core by calling `del_timer_sync()` in the "detach"
> handler `waveform_detach()`.
> 
> Fixes: 240512474424 ("staging: comedi: comedi_test: use 
> comedi_handle_events()")
> Signed-off-by: Ian Abbott 
> ---
> v2: rebased after commit dd28153b2a8ca
> Greg, this fix is for "linux-next" and "staging-next".

I don't understand, I've already taken this patch, right?  It doesn't
apply to my branch :(

confused,

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


Re: [PATCH V2] staging: dgap: re-arrange functions for removing forward declarations

2014-10-30 Thread Greg KH
On Thu, Oct 30, 2014 at 12:14:00PM +0900, Daeseok Youn wrote:
> Re-arrange the functions for removing forward declarations.
> 
> Tested-by: Mark Hounschell 
> Signed-off-by: Daeseok Youn 
> Tested-by: Mark Hounschell 
> ---
> V2: this patch is rebased on staging-next branch.

Still doesn't apply :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: comedi: comedi_test: fix timer lock-up

2014-10-30 Thread Ian Abbott

On 30/10/14 20:29, Greg Kroah-Hartman wrote:

On Thu, Oct 30, 2014 at 10:03:53AM +, Ian Abbott wrote:

Commit 240512474424 ("staging: comedi: comedi_test: use
comedi_handle_events()") resulted in the timer routine
`waveform_ai_interrupt()` calling `comedi_handle_events()` instead of
`comedi_events()`.  That had the advantage of automatically stopping the
acquisition on overflow/error/end-of-acquisition conditions (by calling
the comedi subdevice's "cancel" handler), but currently results in the
timer routine locking when one of those conditions occur.  This is
because the "cancel" handler `waveform_ai_cancel()` calls
`del_timer_sync()`.

Fix it by adding a bit to the device private data that indicates whether
the acquisition is active or not, and changing the "cancel" handler to
use `del_timer()` instead of `del_timer_sync()`.  The bit is set when
starting the acquisition, cleared when ending the acquisition (in the
"cancel" handler), and tested in the timer routine, which will do
nothing if the acquisition is inactive.  Also, make sure any scheduled
timeout event gets cancelled when the low-level device gets "detached"
from the comedi core by calling `del_timer_sync()` in the "detach"
handler `waveform_detach()`.

Fixes: 240512474424 ("staging: comedi: comedi_test: use comedi_handle_events()")
Signed-off-by: Ian Abbott 
---
v2: rebased after commit dd28153b2a8ca
Greg, this fix is for "linux-next" and "staging-next".


I don't understand, I've already taken this patch, right?  It doesn't
apply to my branch :(


So you have.  Ignore v2 then.  (I got a merge merge conflict when I 
tried it, which is why I sent the rebased version.)


Thanks.

--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 4/7] staging: comedi: don't allow read() on async command set up for "write"

2014-10-30 Thread Hartley Sweeten
On Thursday, October 30, 2014 1:28 PM, Ian Abbott wrote:
> On 30/10/14 18:05, Hartley Sweeten wrote:
>> On Thursday, October 30, 2014 5:42 AM, Ian Abbott wrote:
>  [snip]
>>> add_wait_queue(&async->wait_head, &wait);
>>> while (nbytes > 0 && !retval) {
>>> @@ -2249,6 +2253,10 @@ static ssize_t comedi_read(struct file *file, char 
>>> __user *buf, size_t nbytes,
>>> retval = -EACCES;
>>> break;
>>> }
>>> +   if (async->cmd.flags & CMDF_WRITE) {
>>> +   retval = -EINVAL;
>>> +   break;
>>> +   }
>>
>> Is this second test really needed in the while() loop?
>>
>> For that matter, are the s->busy tests needed in the while() loop?
>
> To answer your second question, some other thread using the same file 
> object might have cancelled the asynchronous command, causing the 
> current thread to see that the command is no longer active when it wakes up.
>
> To answer your first question, that other thread might have managed to 
> set up another asynchronous command in before we wake up, and it might 
> have been set up as a "write" command (if the subdevice supports 
> commands in both directions).  This doesn't detect the case when the 
> other thread has managed to set up another "read" command, but since the 
> current read() call hasn't read any data yet, we can just pretend we 
> didn't know about the original command and read data from the new 
> command instead.  (After all, the calling thread can't prove the read() 
> started before the first command was cancelled, so we can just pretend 
> it didn't.)

But when the command is first started by do_cmd_ioctl() we have this sequence:

if (s->busy)
return -EBUSY;
...
s->busy = file;
ret = s->do_cmd(dev, s);

>From then on the s->busy pointer can only be cleared in do_become_nonbusy()
(by way of a (*cancel)). So another command cannot be started until the current
command is completed.

The user could do a (*do_cmdtest) while a command is running but that does not
effect the read/write of the async buffer.

Hartley


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


Re: [PATCH 4/7] staging: comedi: don't allow read() on async command set up for "write"

2014-10-30 Thread Ian Abbott

On 30/10/14 20:45, Hartley Sweeten wrote:

On Thursday, October 30, 2014 1:28 PM, Ian Abbott wrote:

On 30/10/14 18:05, Hartley Sweeten wrote:

On Thursday, October 30, 2014 5:42 AM, Ian Abbott wrote:

  [snip]

add_wait_queue(&async->wait_head, &wait);
while (nbytes > 0 && !retval) {
@@ -2249,6 +2253,10 @@ static ssize_t comedi_read(struct file *file, char 
__user *buf, size_t nbytes,
retval = -EACCES;
break;
}
+   if (async->cmd.flags & CMDF_WRITE) {
+   retval = -EINVAL;
+   break;
+   }


Is this second test really needed in the while() loop?

For that matter, are the s->busy tests needed in the while() loop?


To answer your second question, some other thread using the same file
object might have cancelled the asynchronous command, causing the
current thread to see that the command is no longer active when it wakes up.

To answer your first question, that other thread might have managed to
set up another asynchronous command in before we wake up, and it might
have been set up as a "write" command (if the subdevice supports
commands in both directions).  This doesn't detect the case when the
other thread has managed to set up another "read" command, but since the
current read() call hasn't read any data yet, we can just pretend we
didn't know about the original command and read data from the new
command instead.  (After all, the calling thread can't prove the read()
started before the first command was cancelled, so we can just pretend
it didn't.)


But when the command is first started by do_cmd_ioctl() we have this sequence:

if (s->busy)
return -EBUSY;
...
s->busy = file;
ret = s->do_cmd(dev, s);

 From then on the s->busy pointer can only be cleared in do_become_nonbusy()
(by way of a (*cancel)). So another command cannot be started until the current
command is completed.


The other thread could do its own read() after it cancelled the command, 
which would clear the busy condition (once it returns 0 to indicate 
end-of-file), so the current thread's read() still needs to check it.


--
-=( Ian Abbott @ MEV Ltd.E-mail:  )=-
-=(  Web: http://www.mev.co.uk/  )=-
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH 0/7] staging: comedi: enforce data transfer direction

2014-10-30 Thread Hartley Sweeten
On Thursday, October 30, 2014 5:42 AM, Ian Abbott wrote:
> Most comedi subdevices that support asynchronous data acquisition
> commands only support data transfer in a single direction, as indicated
> by the `SDF_CMD_READ` and `SDF_CMD_WRITE` subdevice flags.  A few allow
> data transfer in either direction, but only a single direction at a
> time, as indicated by the `CMDF_WRITE` command flag in the `flags`
> member of the `struct comedi_cmd` from user-space used to set up the
> asynchronous command.  The `CMDF_WRITE` flag isn't commonly set for
> "write" commands if that is the only direction the subdevice supports.
>
> Since it would be useful for comedi to have a clear indication of which
> data transfer direction is being used, patch 1 forces the `CMDF_WRITE`
> command flag to the correct state if only one direction is supported.
> The flag can then be checked by comedi in the subdevice's local copy of
> the current command (in `s->async->cmd`) to determine the data transfer
> direction unambiguously.
>
> Patch 2 stops the "me4000" driver clobbering the command flags.
>
> Patch 3 removes some now redundant modification of the `CMDF_WRITE` flag
> in "ni_mio_common.c" (used by the "ni_pcimio", "ni_atmio" and
> "ni_mio_cs" drivers).
>
> Patches 4 and 5 disallow the read() and write() file operations if the
> subdevice has been set up with a command in the "write" or "read" data
> transfer direction respectively.
>
> Patch 6 changes the readable/writeable checks for the poll() file
> operation.  It already considers the file readable/writeable if
> read()/write() would fail with an error, so change it to check for
> "wrong direction" as one of the possible failures.
>
> Patch 7 makes the direction test in the handling of the `COMEDI_BUFINFO`
> ioctl (used to update buffer positions for mmapped buffers) less
> ambiguous.  The current test used the `SDF_CMD_READ` and `SDF_CMD_WRITE`
> subdevice flags to check the direction, which is ambiguous if both flags
> are set.  Update it to use the `CMDF_WRITE` command flag instead.

Reviewed-by: H Hartley Sweeten 

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


Re: [PATCH net-next] hyperv: Add IPv6 into the hash computation for vRSS

2014-10-30 Thread David Miller
From: Haiyang Zhang 
Date: Thu, 30 Oct 2014 14:07:17 -0700

> This will allow the workload spreading via vRSS for IPv6.
> 
> Signed-off-by: Haiyang Zhang 
> Reviewed-by: K. Y. Srinivasan 

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


Re: [PATCH V2] staging: dgap: re-arrange functions for removing forward declarations

2014-10-30 Thread DaeSeok Youn
Hi,

2014-10-31 5:33 GMT+09:00 Greg KH :
> On Thu, Oct 30, 2014 at 12:14:00PM +0900, Daeseok Youn wrote:
>> Re-arrange the functions for removing forward declarations.
>>
>> Tested-by: Mark Hounschell 
>> Signed-off-by: Daeseok Youn 
>> Tested-by: Mark Hounschell 
>> ---
>> V2: this patch is rebased on staging-next branch.
>
> Still doesn't apply :(

You maybe merge this patch to staging-testing branch, right?
I tried to rebase this patch on staging-next but staging-testing had
two patches more from Tapasweni.

I will rebase on staging-testing and send this again.

Thanks.

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


[PATCH] Staging: android: ion: fix typos in comments

2014-10-30 Thread Tristan Lelong
Fix some coding style warnings detected by checkpatch.pl in ion.

Signed-off-by: Tristan Lelong 
---
 drivers/staging/android/ion/ion.c  | 2 +-
 drivers/staging/android/ion/ion.h  | 2 +-
 drivers/staging/android/ion/ion_priv.h | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/android/ion/ion.c 
b/drivers/staging/android/ion/ion.c
index 290d4d2..8724ef8 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -250,7 +250,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap 
*heap,
   our systems the only dma_address space is physical addresses.
   Additionally, we can't afford the overhead of invalidating every
   allocation via dma_map_sg. The implicit contract here is that
-  memory comming from the heaps is ready for dma, ie if it has a
+  memory coming from the heaps is ready for dma, ie if it has a
   cached mapping that mapping has been invalidated */
for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i)
sg_dma_address(sg) = sg_phys(sg);
diff --git a/drivers/staging/android/ion/ion.h 
b/drivers/staging/android/ion/ion.h
index d305bb7..443db84 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -76,7 +76,7 @@ struct ion_platform_data {
  * size
  *
  * Calls memblock reserve to set aside memory for heaps that are
- * located at specific memory addresses or of specfic sizes not
+ * located at specific memory addresses or of specific sizes not
  * managed by the kernel
  */
 void ion_reserve(struct ion_platform_data *data);
diff --git a/drivers/staging/android/ion/ion_priv.h 
b/drivers/staging/android/ion/ion_priv.h
index c8f0175..18a5f93 100644
--- a/drivers/staging/android/ion/ion_priv.h
+++ b/drivers/staging/android/ion/ion_priv.h
@@ -345,7 +345,7 @@ void ion_carveout_free(struct ion_heap *heap, 
ion_phys_addr_t addr,
  * functions for creating and destroying a heap pool -- allows you
  * to keep a pool of pre allocated memory to use from your heap.  Keeping
  * a pool of memory that is ready for dma, ie any cached mapping have been
- * invalidated from the cache, provides a significant peformance benefit on
+ * invalidated from the cache, provides a significant performance benefit on
  * many systems */
 
 /**
@@ -362,7 +362,7 @@ void ion_carveout_free(struct ion_heap *heap, 
ion_phys_addr_t addr,
  *
  * Allows you to keep a pool of pre allocated pages to use from your heap.
  * Keeping a pool of pages that is ready for dma, ie any cached mapping have
- * been invalidated from the cache, provides a significant peformance benefit
+ * been invalidated from the cache, provides a significant performance benefit
  * on many systems
  */
 struct ion_page_pool {
-- 
2.1.1

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