[patch 1/2] staging: lustre: validate size in lustre_posix_acl_xattr_filter()

2014-10-22 Thread Dan Carpenter
This is mostly to silence static checker complaints.

In theory the problem here is that if size is in the 1-3 range then we
don't allocate enough memory for the posix_acl_xattr_header struct and
it results in memory corruption.  But in reality kmalloc() return values
are aligned at sizeof(long) so corrupting this small amount of data is
not harmful.

The "size" variable should be type size_t.  The value of size is checked
in setxattr() so we know it is a number between "0 - XATTR_SIZE_MAX".
There is no need to check for negative sizes.

Signed-off-by: Dan Carpenter 
---
Static checker stuff not tested.

diff --git a/drivers/staging/lustre/lustre/include/lustre_eacl.h 
b/drivers/staging/lustre/lustre/include/lustre_eacl.h
index b94f76a..0f8f76c 100644
--- a/drivers/staging/lustre/lustre/include/lustre_eacl.h
+++ b/drivers/staging/lustre/lustre/include/lustre_eacl.h
@@ -74,7 +74,7 @@ typedef struct {
 extern ext_acl_xattr_header *
 lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size);
 extern int
-lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size,
+lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size,
  posix_acl_xattr_header **out);
 extern void
 lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size);
diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c 
b/drivers/staging/lustre/lustre/obdclass/acl.c
index 2619bfe..9a69f6b 100644
--- a/drivers/staging/lustre/lustre/obdclass/acl.c
+++ b/drivers/staging/lustre/lustre/obdclass/acl.c
@@ -171,17 +171,17 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_2ext);
 /*
  * Filter out the "nobody" entries in the posix ACL.
  */
-int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size,
+int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size,
  posix_acl_xattr_header **out)
 {
int count, i, j, rc = 0;
__u32 id;
posix_acl_xattr_header *new;
 
-   if (unlikely(size < 0))
-   return -EINVAL;
-   else if (!size)
+   if (!size)
return 0;
+   if (size < sizeof(*new))
+   return -EINVAL;
 
OBD_ALLOC(new, size);
if (unlikely(new == NULL))
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[patch 2/2] staging: lustre: validate size in ll_setxattr()

2014-10-22 Thread Dan Carpenter
If size is smaller than the lov_user_md struct then we are reading
beyond the end of the buffer.  I guess this is an information leak or it
could cause an Oops if the memory is not mapped.

Signed-off-by: Dan Carpenter 
---
This was discovered through a code audit.  I'm not terribly familiar
with this code and I haven't tested it.  Please review it carefully.

diff --git a/drivers/staging/lustre/lustre/llite/xattr.c 
b/drivers/staging/lustre/lustre/llite/xattr.c
index 252a619..75abb97 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -223,6 +223,9 @@ int ll_setxattr(struct dentry *dentry, const char *name,
CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), xattr %s\n",
   inode->i_ino, inode->i_generation, inode, name);
 
+   if (size != 0 && size < sizeof(struct lov_user_md))
+   return -EINVAL;
+
ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_SETXATTR, 1);
 
if ((strncmp(name, XATTR_TRUSTED_PREFIX,
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] mfd: rtsx: fix PM suspend for 5227 & 5249

2014-10-22 Thread Micky Ching

Hi Lee,

I am wondering if you have accepted this patch?

Best Regards.
micky.
On 10/11/2014 09:07 AM, Micky Ching wrote:


On 10/10/2014 06:21 PM, Lee Jones wrote:

On Fri, 10 Oct 2014, micky_ch...@realsil.com.cn wrote:


From: Micky Ching 

Fix rts5227&5249 failed send buffer cmd after suspend,
PM_CTRL3 should reset before send any buffer cmd after suspend.
Otherwise, buffer cmd will failed, this will lead resume fail.

Signed-off-by: Micky Ching 
---
  drivers/mfd/Makefile |  2 +-
  drivers/mfd/rts5227.c|  6 ++
  drivers/mfd/rts5249.c|  4 
  drivers/mfd/rtsx_gops.c  | 37 
+

  drivers/mfd/rtsx_pcr.h   |  3 +++
  include/linux/mfd/rtsx_pci.h | 28 
  6 files changed, 79 insertions(+), 1 deletion(-)
  create mode 100644 drivers/mfd/rtsx_gops.c

[...]

+static inline int rtsx_pci_update_cfg_byte(struct rtsx_pcr *pcr, 
int addr,

+u8 mask, u8 append)
+{
+int err;
+u8 val;
+
+err = pci_read_config_byte(pcr->pci, addr, &val);
+if (err < 0)
+return err;
+return pci_write_config_byte(pcr->pci, addr, (val & mask) | 
append);

+}
+

Why is this in here?  Why not put it in the generic ops file?
This function is a good interface, we will use it many times in the 
future.


generic ops file is only used to some operation can be used for 
different chip,

some special chip may replace generic ops by provide their own ops.
So generic ops file is just use to abstract the same code, not for 
good interface.








--
Best Regards,
micky.

Realsil Microelectronics Inc. PCBU swlinux.
Tel:86-512-6258-8966 Ext: 5806

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


[PATCH] staging: rtl8192e: from bus specific dma api to dma api

2014-10-22 Thread Sudip Mukherjee
we should be using DMA API rather than using bus specific DMA API.
converted the occurrence of pci_map_*() to dma_map_*(),
and at the same time used the dma_mapping_error().

Signed-off-by: Sudip Mukherjee 
---
 drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 12 ++--
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c   | 19 ++-
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c 
b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 552d943..d3a3ce2 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -1180,8 +1180,8 @@ void  rtl8192_tx_fill_desc(struct net_device *dev, struct 
tx_desc *pdesc,
   struct cb_desc *cb_desc, struct sk_buff *skb)
 {
struct r8192_priv *priv = rtllib_priv(dev);
-   dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len,
-PCI_DMA_TODEVICE);
+   dma_addr_t mapping = dma_map_single(&priv->pdev->dev, skb->data,
+   skb->len, DMA_TO_DEVICE);
struct tx_fwinfo_8190pci *pTxFwInfo = NULL;
 
pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data;
@@ -1193,7 +1193,7 @@ void  rtl8192_tx_fill_desc(struct net_device *dev, struct 
tx_desc *pdesc,
pTxFwInfo->TxRate,
cb_desc);
 
-   if (pci_dma_mapping_error(priv->pdev, mapping))
+   if (dma_mapping_error(&priv->pdev->dev, mapping))
RT_TRACE(COMP_ERR, "DMA Mapping error\n");
if (cb_desc->bAMPDUEnable) {
pTxFwInfo->AllowAggregation = 1;
@@ -1290,10 +1290,10 @@ void  rtl8192_tx_fill_cmd_desc(struct net_device *dev,
   struct cb_desc *cb_desc, struct sk_buff *skb)
 {
struct r8192_priv *priv = rtllib_priv(dev);
-   dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len,
-PCI_DMA_TODEVICE);
+   dma_addr_t mapping = dma_map_single(&priv->pdev->dev, skb->data,
+   skb->len, PCI_DMA_TODEVICE);
 
-   if (pci_dma_mapping_error(priv->pdev, mapping))
+   if (dma_mapping_error(&priv->pdev->dev, mapping))
RT_TRACE(COMP_ERR, "DMA Mapping error\n");
memset(entry, 0, 12);
entry->LINIP = cb_desc->bLastIniPkt;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c 
b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 5615c80..da8fa29 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -2097,11 +2097,11 @@ static short rtl8192_alloc_rx_desc_ring(struct 
net_device *dev)
skb->dev = dev;
priv->rx_buf[rx_queue_idx][i] = skb;
mapping = (dma_addr_t *)skb->cb;
-   *mapping = pci_map_single(priv->pdev,
+   *mapping = dma_map_single(&priv->pdev->dev,
  skb_tail_pointer_rsl(skb),
  priv->rxbuffersize,
- PCI_DMA_FROMDEVICE);
-   if (pci_dma_mapping_error(priv->pdev, *mapping)) {
+ DMA_FROM_DEVICE);
+   if (dma_mapping_error(&priv->pdev->dev, *mapping)) {
dev_kfree_skb_any(skb);
return -1;
}
@@ -2393,12 +2393,13 @@ static void rtl8192_rx_normal(struct net_device *dev)
 
priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] =
 skb;
-   *((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev,
-   skb_tail_pointer_rsl(skb),
-   priv->rxbuffersize,
-   PCI_DMA_FROMDEVICE);
-   if (pci_dma_mapping_error(priv->pdev,
- *((dma_addr_t *)skb->cb))) {
+   *((dma_addr_t *)skb->cb) =
+   dma_map_single(&priv->pdev->dev,
+  skb_tail_pointer_rsl(skb),
+  priv->rxbuffersize,
+  DMA_FROM_DEVICE);
+   if (dma_mapping_error(&priv->pdev->dev,
+ *((dma_addr_t *)skb->cb))) {
dev_kfree_skb_any(skb);
return;
}
-- 
1.8.1.2

___
devel mailing list
de...

Re: [PATCH v2] mfd: rtsx: fix PM suspend for 5227 & 5249

2014-10-22 Thread Lee Jones
On Fri, 10 Oct 2014, micky_ch...@realsil.com.cn wrote:

> From: Micky Ching 
> 
> Fix rts5227&5249 failed send buffer cmd after suspend,
> PM_CTRL3 should reset before send any buffer cmd after suspend.
> Otherwise, buffer cmd will failed, this will lead resume fail.
> 
> Signed-off-by: Micky Ching 
> ---
>  drivers/mfd/Makefile |  2 +-
>  drivers/mfd/rts5227.c|  6 ++
>  drivers/mfd/rts5249.c|  4 
>  drivers/mfd/rtsx_gops.c  | 37 +
>  drivers/mfd/rtsx_pcr.h   |  3 +++
>  include/linux/mfd/rtsx_pci.h | 28 
>  6 files changed, 79 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/mfd/rtsx_gops.c

Applied, thanks.

> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index f001487..7f45c06 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -13,7 +13,7 @@ obj-$(CONFIG_MFD_CROS_EC)   += cros_ec.o
>  obj-$(CONFIG_MFD_CROS_EC_I2C)+= cros_ec_i2c.o
>  obj-$(CONFIG_MFD_CROS_EC_SPI)+= cros_ec_spi.o
>  
> -rtsx_pci-objs:= rtsx_pcr.o rts5209.o rts5229.o 
> rtl8411.o rts5227.o rts5249.o
> +rtsx_pci-objs:= rtsx_pcr.o rtsx_gops.o rts5209.o 
> rts5229.o rtl8411.o rts5227.o rts5249.o
>  obj-$(CONFIG_MFD_RTSX_PCI)   += rtsx_pci.o
>  obj-$(CONFIG_MFD_RTSX_USB)   += rtsx_usb.o
>  
> diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c
> index 9c8eec8..3240740 100644
> --- a/drivers/mfd/rts5227.c
> +++ b/drivers/mfd/rts5227.c
> @@ -130,6 +130,12 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
>  
>  static int rts5227_optimize_phy(struct rtsx_pcr *pcr)
>  {
> + int err;
> +
> + err = rtsx_gops_pm_reset(pcr);
> + if (err < 0)
> + return err;
> +
>   /* Optimize RX sensitivity */
>   return rtsx_pci_write_phy_register(pcr, 0x00, 0xBA42);
>  }
> diff --git a/drivers/mfd/rts5249.c b/drivers/mfd/rts5249.c
> index 573de7b..cf425cc 100644
> --- a/drivers/mfd/rts5249.c
> +++ b/drivers/mfd/rts5249.c
> @@ -130,6 +130,10 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
>  {
>   int err;
>  
> + err = rtsx_gops_pm_reset(pcr);
> + if (err < 0)
> + return err;
> +
>   err = rtsx_pci_write_phy_register(pcr, PHY_REG_REV,
>   PHY_REG_REV_RESV | PHY_REG_REV_RXIDLE_LATCHED |
>   PHY_REG_REV_P1_EN | PHY_REG_REV_RXIDLE_EN |
> diff --git a/drivers/mfd/rtsx_gops.c b/drivers/mfd/rtsx_gops.c
> new file mode 100644
> index 000..b1a98c6
> --- /dev/null
> +++ b/drivers/mfd/rtsx_gops.c
> @@ -0,0 +1,37 @@
> +/* Driver for Realtek PCI-Express card reader
> + *
> + * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the
> + * Free Software Foundation; either version 2, or (at your option) any
> + * later version.
> + *
> + * This program is distributed in the hope that it will be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see .
> + *
> + * Author:
> + *   Micky Ching 
> + */
> +
> +#include 
> +#include "rtsx_pcr.h"
> +
> +int rtsx_gops_pm_reset(struct rtsx_pcr *pcr)
> +{
> + int err;
> +
> + /* init aspm */
> + rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, 0xFF, 0x00);
> + err = rtsx_pci_update_cfg_byte(pcr, LCTLR, ~LCTLR_ASPM_CTL_MASK, 0x00);
> + if (err < 0)
> + return err;
> +
> + /* reset PM_CTRL3 before send buffer cmd */
> + return rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00);
> +}
> diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
> index 07e4c2e..fe2bbb6 100644
> --- a/drivers/mfd/rtsx_pcr.h
> +++ b/drivers/mfd/rtsx_pcr.h
> @@ -72,4 +72,7 @@ do {
> \
>   pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \
>  } while (0)
>  
> +/* generic operations */
> +int rtsx_gops_pm_reset(struct rtsx_pcr *pcr);
> +
>  #endif
> diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
> index 74346d5..1604dda 100644
> --- a/include/linux/mfd/rtsx_pci.h
> +++ b/include/linux/mfd/rtsx_pci.h
> @@ -707,6 +707,14 @@
>  #define PM_CTRL1 0xFF44
>  #define PM_CTRL2 0xFF45
>  #define PM_CTRL3 0xFF46
> +#define   SDIO_SEND_PME_EN   0x80
> +#define   FORCE_RC_MODE_ON   0x40
> +#define   FORCE_RX50_LINK_ON 0x20
> +#define   D3_DELINK_MODE_EN  0x10
> +#define   USE_PESRTB_CTL_DELINK  0x08
> +#define   DELA

Re: [patch 2/2] staging: lustre: validate size in ll_setxattr()

2014-10-22 Thread Dan Carpenter
On Wed, Oct 22, 2014 at 02:27:08PM +0400, Andrew Perepechko wrote:
> Hi Dan!
> 
> You probably meant putting that check after the followring if-statement,
> since generic extended attributes can have size 1, 2, 3, ...
> 

Ok.

> In that case, size == 0 seems to be the wrong value size for an lov param
> as well.

I don't know about this.  The code is very clear that size == 0 is
acceptable inside the if statement.  Oleg?

regards,
dan carpenter

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


Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()

2014-10-22 Thread Mike Surcouf
I get that NTP can be installed locally.  This is how I regulate time
on my guests.  I agree the admin argument probably doesn't stand up.

The problem is hyperv_clocksource (pluggable time source used by
hyperv guests) is systematically fast in my environment. by around
-250 PPM.
I get away with NTP (just).
However others have had to use tickadj to get hyperv_clocksource close
enough for NTP to work i.e. inside +/-500 PPM. (This IS outside normal
admin tasks)

So if we are going to use NTP as the solution for hyperv guests (which
is a valid one) the systematic drift of hyperv_clocksource in
different environments will need to be addressed.  Maybe this patch
could be modified to tune the tick count on boot before NTP starts and
then leave it alone so NTP can take over.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/9] staging: comedi: addi_apci_1564: additional clean up

2014-10-22 Thread Ian Abbott

On 21/10/14 18:15, Hartley Sweeten wrote:

In addition, in apci1564_interrupt() the dev->iobase (BAR1) is used for:

s->state = inl(dev->iobase + APCI1564_DI_INT_STATUS_REG) & 0x;

But is apci1564_reset() and apci1564_cos_insn_config() that register
is accessed using devpriv->amcc_iobase (BAR0):

inl(devpriv->amcc_iobase + APCI1564_DI_INT_STATUS_REG);

The register should not be accessible from both BARs so BAR1 must be
the real base address for the boards main registers.

dev->iobase (BAR1) is currently used to access the counter register
(other than the one access to APCI1564_DI_INT_STATUS_REG listed
above). The mapping of those registers would overlay the boards main
registers so my guess is they should really use BAR2 as the base address.

I need to dig thru the git history to see if the screw up was
caused by various patches to the driver or if the problem
existed from when it was initially merged.


Looks like commit 860ba36cbeadee9064e2925be11dfb8368b9b25d ("staging: 
comedi: addi_apci_1564: move apci1564_interrupt() into 
addi_apci_1564.c") is the culprit.


--
-=( 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] staging: android: binder: move to the "real" part of the kernel

2014-10-22 Thread Joe Perches
On Tue, 2014-10-21 at 20:10 -0700, Rom Lemarchand wrote:
> On the topic of maintainers for binder: both Arve Hjønnevåg
> (a...@android.com) and Riley Andrews (riandr...@android.com) have
> volunteered to be co-maintainers with Greg.
> 
> We would also like to make kernel-t...@android.com the maintainer of
> the whole android directory.

It's generally better to have people as maintainers than
using nameless email addresses.

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


[PATCH] staging: comedi: Kconfig: fix config COMEDI_ADDI_APCI_3120 dependants

2014-10-22 Thread Ian Abbott
A merge conflict between commits
fbfd9c8a1782f33d7b67294b2a42587063e61c0c ("staging: comedi:
addi_apci_3120: use dma_alloc_coherent()") and
aff5b1f8eb71b64bb613dc64c50b6904e89f79b9 ("staging: comedi: remove
comedi_fc module") left the COMEDI_ADDI_APCI_3120 config option
depending on VIRT_TO_BUS when it no longer needs to do so.  The
dependency was removed by the first commit and accidentally reinstated
by the second commit.  Remove the dependency again.

Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index a8bc2b5..26e228f 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -667,7 +667,6 @@ config COMEDI_ADDI_APCI_2200
 config COMEDI_ADDI_APCI_3120
tristate "ADDI-DATA APCI_3120/3001 support"
depends on HAS_DMA
-   depends on VIRT_TO_BUS
---help---
  Enable support for ADDI-DATA APCI_3120/3001 cards
 
-- 
2.1.1

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


Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()

2014-10-22 Thread Thomas Gleixner
On Wed, 22 Oct 2014, Mike Surcouf wrote:

> I get that NTP can be installed locally.  This is how I regulate time
> on my guests.  I agree the admin argument probably doesn't stand up.
> 
> The problem is hyperv_clocksource (pluggable time source used by
> hyperv guests) is systematically fast in my environment. by around
> -250 PPM.
> I get away with NTP (just).
> However others have had to use tickadj to get hyperv_clocksource close
> enough for NTP to work i.e. inside +/-500 PPM. (This IS outside normal
> admin tasks)
> 
> So if we are going to use NTP as the solution for hyperv guests (which
> is a valid one) the systematic drift of hyperv_clocksource in
> different environments will need to be addressed.  Maybe this patch
> could be modified to tune the tick count on boot before NTP starts and
> then leave it alone so NTP can take over.

How about fixing hyperv_clocksource in the first place?

Thanks,

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


RE: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()

2014-10-22 Thread Thomas Shao

> -Original Message-
> From: linux-kernel-ow...@vger.kernel.org [mailto:linux-kernel-
> ow...@vger.kernel.org] On Behalf Of Thomas Gleixner
> Sent: Wednesday, October 22, 2014 8:42 PM
> To: Mike Surcouf
> Cc: Thomas Shao; Richard Cochran; Jeff Epler; gre...@linuxfoundation.org;
> LKML; de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> jasow...@redhat.com; KY Srinivasan; John Stultz; Richard Cochran
> Subject: Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for
> do_adjtimex()
> 
> On Wed, 22 Oct 2014, Mike Surcouf wrote:
> 
> > I get that NTP can be installed locally.  This is how I regulate time
> > on my guests.  I agree the admin argument probably doesn't stand up.
> >
> > The problem is hyperv_clocksource (pluggable time source used by
> > hyperv guests) is systematically fast in my environment. by around
> > -250 PPM.
> > I get away with NTP (just).
> > However others have had to use tickadj to get hyperv_clocksource close
> > enough for NTP to work i.e. inside +/-500 PPM. (This IS outside normal
> > admin tasks)
> >
> > So if we are going to use NTP as the solution for hyperv guests (which
> > is a valid one) the systematic drift of hyperv_clocksource in
> > different environments will need to be addressed.  Maybe this patch
> > could be modified to tune the tick count on boot before NTP starts and
> > then leave it alone so NTP can take over.
> 
> How about fixing hyperv_clocksource in the first place?
> 

I've tested the hyperv_clocksource in my environment using upstream kernel. 
There is some minor time drift (around 1.5 second one day), it should not be 
that big, and break ntp. 

Mike, can you share me your kernel version and which Linux distro do you use? 

> Thanks,
> 
>   tglx
> 
> --
> 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/
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [patch 2/2] staging: lustre: validate size in ll_setxattr()

2014-10-22 Thread Drokin, Oleg
Hello!

On Oct 22, 2014, at 6:32 AM, Dan Carpenter wrote:
>> In that case, size == 0 seems to be the wrong value size for an lov param
>> as well.
> I don't know about this.  The code is very clear that size == 0 is
> acceptable inside the if statement.  Oleg?

I am not sure what if statement do you mean?
If it's the "if ((strncmp(name, XATTR_TRUSTED_PREFIX," one then size of 0
does seem to be incorrect:

struct lov_user_md *lump = (struct lov_user_md *)value; 
// (I hope this is not a user pointer?)
…
if (lump != NULL && lump->lmm_stripe_offset == 0)
lump->lmm_stripe_offset = -1;
// So, if lump is 0, we are already accessing past allowed range
…
int lum_size = (lump->lmm_magic == LOV_USER_MAGIC_V1) ?
and again…

Bye,
Oleg

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


Re: [patch 2/2] staging: lustre: validate size in ll_setxattr()

2014-10-22 Thread Dan Carpenter
On Wed, Oct 22, 2014 at 01:53:15PM +, Drokin, Oleg wrote:
> Hello!
> 
> On Oct 22, 2014, at 6:32 AM, Dan Carpenter wrote:
> >> In that case, size == 0 seems to be the wrong value size for an lov param
> >> as well.
> > I don't know about this.  The code is very clear that size == 0 is
> > acceptable inside the if statement.  Oleg?
> 
> I am not sure what if statement do you mean?
> If it's the "if ((strncmp(name, XATTR_TRUSTED_PREFIX," one then size of 0
> does seem to be incorrect:
> 
> struct lov_user_md *lump = (struct lov_user_md *)value; 
> // (I hope this is not a user pointer?)

It's not.

> …
> if (lump != NULL && lump->lmm_stripe_offset == 0)
> lump->lmm_stripe_offset = -1;
> // So, if lump is 0, we are already accessing past allowed range

If size is zero then lump is NULL and the existing code is very careful
to test for that and avoid NULL dereferences.  I think that Andrew is
saying at it doesn't make sense for lump to be NULL.

Anyway, let me send a v2 which fixes the bug and leaves lump == NULL as
is.

regards,
dan carpenter

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


Re: [PATCH v2 1/2] timekeeping: add EXPORT_SYMBOL_GPL for do_adjtimex()

2014-10-22 Thread Mike Surcouf
> Mike, can you share me your kernel version and which Linux distro do you use?

2.6.32-504.el6.x86_64 AKA RHEL 6.6
Happened on centos 7 and 6.5 too.
#cat /var/lib/ntp/drift
-248.869
About 20 secs a day (constant)

Its not a new problem I had this in other distros and other kernels.
I would say its environmental but not just my environment.

Confirmed with Olaf on SUSEvariants back in  2012 but never came to anything

see enc email

-
> > KY, can your team have a look at this?
>
> Vijay, have we done time stability test in the recent past. We should
> look at replicating this issue on Distros of interest. Olaf, on sles11
> sp2, were you running NTP and how much was the drift.

sles11sp2: uptime 23:45 hours, its 38 seconds ahead

12.2: uptime 1 day, 5:17 hours, its 47 seconds ahead

ntpd is not running in both guests.

> Also, what was the host in this test.

The host is an uptodate w2k8 r2.

Olaf
---

Thanks

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


[patch 2/2 v2] staging: lustre: validate size in ll_setxattr()

2014-10-22 Thread Dan Carpenter
If size is smaller than the lov_user_md struct then we are reading
beyond the end of the buffer.  I guess this is an information leak or it
could cause an Oops if the memory is not mapped.

Signed-off-by: Dan Carpenter 
---
v2:  Andrew Perepechko pointed out that the check needs to be inside the
if statement.

diff --git a/drivers/staging/lustre/lustre/llite/xattr.c 
b/drivers/staging/lustre/lustre/llite/xattr.c
index 252a619..3ad9796 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -234,6 +234,9 @@ int ll_setxattr(struct dentry *dentry, const char *name,
struct lov_user_md *lump = (struct lov_user_md *)value;
int rc = 0;
 
+   if (size != 0 && size < sizeof(struct lov_user_md))
+   return -EINVAL;
+
/* Attributes that are saved via getxattr will always have
 * the stripe_offset as 0.  Instead, the MDS should be
 * allowed to pick the starting OST index.   b=17846 */
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 12/22] staging: comedi: addi_apci_3120: remove analog output reset

2014-10-22 Thread Ian Abbott

On 20/10/14 19:34, H Hartley Sweeten wrote:

The apci3120_reset() function is called at the end of the (*auto_attach) and
with the (*detach) is called to unload the driver. Part of this function
resets all the analog output channels to 0V.

There are two problems with this.
1) Only the APCI-3120 has analog outputs, the APCI-3001 does not.
2) The DA_READY bit in the status register needs to be checked before each
write to update the analog outputs. It's unknown what the DA_READY bit
does on the APCI-3001 board.

Just remove the analog output reset to avoid any problems.


A minor niggle is that the readback value for a channel won't match the 
voltage until the channel is written.  Maybe the code for writing to the 
channel and setting the readback value could be factored out of the 
insn_write handler and called for each channel during auto_attach 
(ignoring any timeout errors).  This could be done after this patch series.


--
-=( 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 00/22] staging: comedi: addi_apci_3120: additional clean up

2014-10-22 Thread Ian Abbott

On 20/10/14 19:34, H Hartley Sweeten wrote:

More cleanup of the addi_apci_3120 driver.

These apply after:
   [PATCH 00/34] staging: comedi: addi-data: remove "common" code bloat

H Hartley Sweeten (22):
   staging: comedi: addi_apci_3120: DMA requires an interrupt
   staging: comedi: addi_apci_3120: introduce struct apci3120_dmabuf
   staging: comedi: addi_apci_3120: remove unused struct definition
   staging: comedi: addi_apci_3120: remove unipolar range from analog outputs
   staging: comedi: addi_apci_3120: remove private data 'i_IobaseReserved'
   staging: comedi: addi_apci_3120: use correct iobase to write AMCC registers
   staging: comedi: addi_apci_3120: use correct iobase to read board register
   staging: comedi: addi_apci_3120: rename private data 'i_IobaseAddon'
   staging: comedi: addi_apci_3120: rename private data 'i_IobaseAmcc'
   staging: comedi: addi_apci_3120: remove private data 'iobase'
   staging: comedi: addi_apci_3120: prevent deadlock in apci3120_ao_insn_write()
   staging: comedi: addi_apci_3120: remove analog output reset
   staging: comedi: addi_apci_3120: fix apci3120_ao_insn_write()
   staging: comedi: addi_apci_3120: provide analog output 'readback'
   staging: comedi: addi_apci_3120: tidy up analog output subdevice init
   staging: comedi: addi_apci_3120: tidy up digital input subdevice init
   staging: comedi: addi_apci_3120: tidy up digital output subdevice init
   staging: comedi: addi_apci_3120: tidy up analog input subdevice init
   staging: comedi: addi_apci_3120: tidy up timer subdevice init
   staging: comedi: addi_apci_3120: reset the board before hooking up the 
interrupt
   staging: comedi: addi_apci_3120: don't reset board when canceling ai command
   staging: comedi: addi_apci_3120: don't reset board when detaching driver

  .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 469 -
  drivers/staging/comedi/drivers/addi_apci_3120.c| 238 ++-
  2 files changed, 317 insertions(+), 390 deletions(-)



Now that the AO subdevice supports "readback" via the insn_read handler, 
it would be nice to initialize the analog outputs and readback values so 
they match during auto_attach (see my comment on patch 12).  But that 
can be added later.


Reviewed-by: Ian Abbott 

--
-=( 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: skein: Loadable Module Support

2014-10-22 Thread Jason Cooper
Eric,

Awesome!  You must have been reading my TODO list :)

On Tue, Oct 21, 2014 at 09:44:27AM -0500, Eric Rost wrote:
> Adds loadable module support for Skein256, Skein512, and Skein1024 Hash
> Algorithms.

This description is accurate, but incomplete.  You're also integrating
skein into the crypto API.  If you don't mind, could you split this
patch in two?  The first integrating into the crypto API (such that
userspace could call into it), and the second enabling loadable module
support?

More thoughts below.

> Signed-off-by: Eric Rost 
> ---
>  drivers/staging/skein/Kconfig | 12 +
>  drivers/staging/skein/Makefile|  6 +++
>  drivers/staging/skein/skein.c | 11 +++-
>  drivers/staging/skein/skein.h |  6 +++
>  drivers/staging/skein/skein1024_generic.c | 88 
> +++
>  drivers/staging/skein/skein256_generic.c  | 88 
> +++
>  drivers/staging/skein/skein512_generic.c  | 88 
> +++
>  7 files changed, 298 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/staging/skein/skein1024_generic.c
>  create mode 100644 drivers/staging/skein/skein256_generic.c
>  create mode 100644 drivers/staging/skein/skein512_generic.c
> 
> diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
> index b9172bf..e260111 100644
> --- a/drivers/staging/skein/Kconfig
> +++ b/drivers/staging/skein/Kconfig
> @@ -15,6 +15,18 @@ config CRYPTO_SKEIN
> for more information.  This module depends on the threefish block
> cipher module.
>  
> +config CRYPTO_SKEIN_256
> + tristate "Skein256 driver"
> + select CRYPTO_SKEIN
> +
> +config CRYPTO_SKEIN_512
> + tristate "Skein512 driver"
> + select CRYPTO_SKEIN
> +
> +config CRYPTO_SKEIN_1024
> + tristate "Skein1024 driver"
> + select CRYPTO_SKEIN
> +
>  config CRYPTO_THREEFISH
>   bool "Threefish tweakable block cipher"
>   depends on (X86 || UML_X86) && 64BIT && CRYPTO
> diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
> index a14aadd..1be01fe 100644
> --- a/drivers/staging/skein/Makefile
> +++ b/drivers/staging/skein/Makefile
> @@ -5,5 +5,11 @@ obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
>   skein_api.o \
>   skein_block.o
>  
> +obj-$(CONFIG_CRYPTO_SKEIN_256) += skein256_generic.o
> +
> +obj-$(CONFIG_CRYPTO_SKEIN_512) += skein512_generic.o
> +
> +obj-$(CONFIG_CRYPTO_SKEIN_1024) += skein1024_generic.o
> +

This isn't really doing what we want.  You'll have loadable modules, but
the actual code will still be built into the kernel.

>  obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
> threefish_api.o
> diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
> index 8cc8358..2138e22 100644
> --- a/drivers/staging/skein/skein.c
> +++ b/drivers/staging/skein/skein.c
> @@ -11,6 +11,7 @@
>  #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
>  
>  #include/* get the memcpy/memset functions */
> +#include 
>  #include "skein.h" /* get the Skein API definitions   */
>  #include "skein_iv.h"/* get precomputed IVs */
>  #include "skein_block.h"
> @@ -73,6 +74,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t 
> hash_bit_len)
>  
>   return SKEIN_SUCCESS;
>  }
> +EXPORT_SYMBOL(skein_256_init);

Once the above is corrected, these shouldn't be necessary.

>  
>  /**/
>  /* init the context for a MAC and/or tree hash operation */
> @@ -191,7 +193,7 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 
> *msg,
>  
>   return SKEIN_SUCCESS;
>  }
> -
> +EXPORT_SYMBOL(skein_256_update);
>  /**/
>  /* finalize the hash computation and output the result */
>  int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val)
> @@ -240,6 +242,7 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 
> *hash_val)
>   }
>   return SKEIN_SUCCESS;
>  }
> +EXPORT_SYMBOL(skein_256_final);
>  
>  /*/
>  /* 512-bit Skein */
> @@ -303,6 +306,7 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t 
> hash_bit_len)
>  
>   return SKEIN_SUCCESS;
>  }
> +EXPORT_SYMBOL(skein_512_init);
>  
>  /**/
>  /* init the context for a MAC and/or tree hash operation */
> @@ -420,6 +424,7 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 
> *msg,
>  
>   return SKEIN_SUCCESS;
>  }
> +EXPORT_SYMBOL(skein_512_update);
>  
>  /**/
>  /* finalize the hash computation and output the result */
> @@ -469,6 +474,7 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 
> *hash_va

Re: [PATCH 01/18] staging: comedi: comedi_buf: introduce comedi_buf_read_samples()

2014-10-22 Thread Ian Abbott

On 20/10/14 19:52, H Hartley Sweeten wrote:

Introduce a generic method to read samples from the async buffer.

The size of each sample is detected automatically using the bytes_per_sample()
helper. The unsigned long long is used to avoid any possible integer overflow
when calculating the 'nbytes' for all the requested samples. This value is
then clampled to the actual size of the async buffer. The samples are read
from the async buffer using comedi_read_array_from_buffer().

This will allow converting all the comedi drivers to use a common method when
reading data from the async buffer.

Since comedi_read_array_from_buffer() sets the COMEDI_CB_BLOCK event after
reading the data, those events can be removed from the drivers.

In addition, comedi_inc_scan_progress() will automatically detect the end of
scan and set the COMEDI_CB_EOS event. Those events can also be removed from
the drivers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
  drivers/staging/comedi/comedi_buf.c | 23 +++
  drivers/staging/comedi/comedidev.h  |  2 ++
  2 files changed, 25 insertions(+)

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index c60a45ad..03b475a 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -575,3 +575,26 @@ unsigned int comedi_read_array_from_buffer(struct 
comedi_subdevice *s,
return num_bytes;
  }
  EXPORT_SYMBOL_GPL(comedi_read_array_from_buffer);
+
+/**
+ * comedi_buf_read_samples - read sample data from comedi buffer
+ * @s: comedi_subdevice struct
+ * @data: destination
+ * @nsamples: maximum number of samples to read
+ *
+ * Reads up to nsamples from the comedi buffer associated with the subdevice,
+ * marks it as read and updates the acquisition scan progress.
+ *
+ * Returns the amount of data read in bytes.
+ */
+unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
+void *data, unsigned int nsamples)
+{
+   unsigned long long nbytes = nsamples * bytes_per_sample(s);


That doesn't do what you think.  One of the operands of '*' would have 
to be cast to '(unsigned long long)' first.


The other option is to clamp 'nsamples' to 's->async->prealloc_bufsz / 
bytes_per_sample(s)'.  If there was a log2 version of 
bytes_per_sample(), the division could be replaced with a bit-shift (the 
compiler probably isn't clever enough to do that optimization by 
itself).  On a side-note, 'bytes_per_sample()' ought to be renamed to 
'comedi_bytes_per_sample()' at some point.



+
+   if (nbytes > s->async->prealloc_bufsz)
+   nbytes = s->async->prealloc_bufsz;
+
+   return comedi_read_array_from_buffer(s, data, nbytes);
+}
+EXPORT_SYMBOL_GPL(comedi_buf_read_samples);
diff --git a/drivers/staging/comedi/comedidev.h 
b/drivers/staging/comedi/comedidev.h
index fb8ff84..ba4084b 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -453,6 +453,8 @@ unsigned int comedi_write_array_to_buffer(struct 
comedi_subdevice *s,
  unsigned int num_bytes);
  unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s,
   void *data, unsigned int num_bytes);
+unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
+void *data, unsigned int nsamples);

  /* drivers.c - general comedi driver functions */





--
-=( 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: skein: Loadable Module Support

2014-10-22 Thread Eric Rost
On Wed, 2014-10-22 at 11:10 -0400, Jason Cooper wrote:

> 
> If you don't mind, could you split this
> patch in two?  The first integrating into the crypto API (such that
> userspace could call into it), and the second enabling loadable module
> support?
> 

Will do!

> > Signed-off-by: Eric Rost 
> > ---
> >  drivers/staging/skein/Kconfig | 12 +
> >  drivers/staging/skein/Makefile|  6 +++
> >  drivers/staging/skein/skein.c | 11 +++-
> >  drivers/staging/skein/skein.h |  6 +++
> >  drivers/staging/skein/skein1024_generic.c | 88 
> > +++
> >  drivers/staging/skein/skein256_generic.c  | 88 
> > +++
> >  drivers/staging/skein/skein512_generic.c  | 88 
> > +++
> >  7 files changed, 298 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/staging/skein/skein1024_generic.c
> >  create mode 100644 drivers/staging/skein/skein256_generic.c
> >  create mode 100644 drivers/staging/skein/skein512_generic.c
> > 
> > diff --git a/drivers/staging/skein/Kconfig b/drivers/staging/skein/Kconfig
> > index b9172bf..e260111 100644
> > --- a/drivers/staging/skein/Kconfig
> > +++ b/drivers/staging/skein/Kconfig
> > @@ -15,6 +15,18 @@ config CRYPTO_SKEIN
> >   for more information.  This module depends on the threefish block
> >   cipher module.
> >  
> > +config CRYPTO_SKEIN_256
> > +   tristate "Skein256 driver"
> > +   select CRYPTO_SKEIN
> > +
> > +config CRYPTO_SKEIN_512
> > +   tristate "Skein512 driver"
> > +   select CRYPTO_SKEIN
> > +
> > +config CRYPTO_SKEIN_1024
> > +   tristate "Skein1024 driver"
> > +   select CRYPTO_SKEIN
> > +
> >  config CRYPTO_THREEFISH
> > bool "Threefish tweakable block cipher"
> > depends on (X86 || UML_X86) && 64BIT && CRYPTO
> > diff --git a/drivers/staging/skein/Makefile b/drivers/staging/skein/Makefile
> > index a14aadd..1be01fe 100644
> > --- a/drivers/staging/skein/Makefile
> > +++ b/drivers/staging/skein/Makefile
> > @@ -5,5 +5,11 @@ obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
> > skein_api.o \
> > skein_block.o
> >  
> > +obj-$(CONFIG_CRYPTO_SKEIN_256) += skein256_generic.o
> > +
> > +obj-$(CONFIG_CRYPTO_SKEIN_512) += skein512_generic.o
> > +
> > +obj-$(CONFIG_CRYPTO_SKEIN_1024) += skein1024_generic.o
> > +
> 
> This isn't really doing what we want.  You'll have loadable modules, but
> the actual code will still be built into the kernel.
> 
> >  obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
> >   threefish_api.o
> > diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
> > index 8cc8358..2138e22 100644
> > --- a/drivers/staging/skein/skein.c
> > +++ b/drivers/staging/skein/skein.c
> > @@ -11,6 +11,7 @@
> >  #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
> >  
> >  #include/* get the memcpy/memset functions */
> > +#include 
> >  #include "skein.h" /* get the Skein API definitions   */
> >  #include "skein_iv.h"/* get precomputed IVs */
> >  #include "skein_block.h"
> > @@ -73,6 +74,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t 
> > hash_bit_len)
> >  
> > return SKEIN_SUCCESS;
> >  }
> > +EXPORT_SYMBOL(skein_256_init);
> 
> Once the above is corrected, these shouldn't be necessary.
> 
Will give it a whirl, I was having problems with undefined symbols at
linking even when I was building it as one module, but it may have been
something else
> > --- a/drivers/staging/skein/skein.h
> > +++ b/drivers/staging/skein/skein.h
> > @@ -26,8 +26,14 @@
> >  **0: use assert()  to flag errors
> >  **1: return SKEIN_FAIL to flag errors
> >  **
> > +**
> >  
> > ***/
> 
> superfluous whitespace addition?
> 
Remnants of a backed out change... will fix.

> > +
> > +static struct shash_alg alg = {
> > +   .digestsize =   (SKEIN1024_DIGEST_SIZE / 8),
> > +   .init   =   skein1024_init,
> > +   .update =   crypto_skein1024_update,
> 
> why is this function name different from the other two?

It was inherited from the sha1 file I based this off of, I can make them
the same.

> I think it might be best to have two loadable modules.  One for
> threefish, and one for skein.  Adding threefish to the crypto API is a
> bit more difficult than adding skein, as the crypto API doesn't
> currently support tweakable block ciphers.
> 
> To keep things moving, it'd probably be best to do one module for now,
> skein.  Have all the object files for skein and threefish in it, and
> register the three hash algos with the API.
> 
> After that, we can go back and split out threefish into a separate
> module with it's own registration into the crypto API.
> 
> Does that sound sensible?
> 
> thx,
> 
> Jason.

Sounds fine to me, I will build it th

[PATCH] tools: hv: introduce -n/--no-daemon option

2014-10-22 Thread Vitaly Kuznetsov
All tools/hv daemons do mandatory daemon() on startup. However, no pidfile
is created, this make it difficult for an init system to track such daemons.
Modern linux distros use systemd as their init system. It can handle the
daemonizing by itself, however, it requires a daemon to stay in foreground
for that. Some distros already carry distro-specific patch for hv tools
which switches off daemon().

Introduce -n/--no-daemon option for all 3 daemons in hv/tools. Parse options
with getopt() to make this part easily expandable.

Signed-off-by: Vitaly Kuznetsov 
---
 tools/hv/hv_fcopy_daemon.c | 33 +++--
 tools/hv/hv_kvp_daemon.c   | 34 --
 tools/hv/hv_vss_daemon.c   | 33 +++--
 3 files changed, 94 insertions(+), 6 deletions(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index 8f96b3e..f437d73 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int target_fd;
 static char target_fname[W_MAX_PATH];
@@ -126,15 +127,43 @@ static int hv_copy_cancel(void)
 
 }
 
-int main(void)
+void print_usage(char *argv[])
+{
+   fprintf(stderr, "Usage: %s [options]\n"
+   "Options are:\n"
+   "  -n, --no-daemonstay in foreground, don't daemonize\n"
+   "  -h, --help print this help\n", argv[0]);
+}
+
+int main(int argc, char *argv[])
 {
int fd, fcopy_fd, len;
int error;
+   int daemonize = 1, long_index = 0, opt;
int version = FCOPY_CURRENT_VERSION;
char *buffer[4096 * 2];
struct hv_fcopy_hdr *in_msg;
 
-   if (daemon(1, 0)) {
+   static struct option long_options[] = {
+   {"help",no_argument,   0,  'h' },
+   {"no-daemon",   no_argument,   0,  'n' },
+   {0, 0, 0,  0   }
+   };
+
+   while ((opt = getopt_long(argc, argv, "hn", long_options,
+ &long_index)) != -1) {
+   switch (opt) {
+   case 'n':
+   daemonize = 0;
+   break;
+   case 'h':
+   default:
+   print_usage(argv);
+   exit(EXIT_FAILURE);
+   }
+   }
+
+   if (daemonize && daemon(1, 0)) {
syslog(LOG_ERR, "daemon() failed; error: %s", strerror(errno));
exit(EXIT_FAILURE);
}
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 4088b81..22b0764 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * KVP protocol: The user mode component first registers with the
@@ -1417,7 +1418,15 @@ netlink_send(int fd, struct cn_msg *msg)
return sendmsg(fd, &message, 0);
 }
 
-int main(void)
+void print_usage(char *argv[])
+{
+   fprintf(stderr, "Usage: %s [options]\n"
+   "Options are:\n"
+   "  -n, --no-daemonstay in foreground, don't daemonize\n"
+   "  -h, --help print this help\n", argv[0]);
+}
+
+int main(int argc, char *argv[])
 {
int fd, len, nl_group;
int error;
@@ -1435,9 +1444,30 @@ int main(void)
struct hv_kvp_ipaddr_value *kvp_ip_val;
char *kvp_recv_buffer;
size_t kvp_recv_buffer_len;
+   int daemonize = 1, long_index = 0, opt;
+
+   static struct option long_options[] = {
+   {"help",no_argument,   0,  'h' },
+   {"no-daemon",   no_argument,   0,  'n' },
+   {0, 0, 0,  0   }
+   };
+
+   while ((opt = getopt_long(argc, argv, "hn", long_options,
+ &long_index)) != -1) {
+   switch (opt) {
+   case 'n':
+   daemonize = 0;
+   break;
+   case 'h':
+   default:
+   print_usage(argv);
+   exit(EXIT_FAILURE);
+   }
+   }
 
-   if (daemon(1, 0))
+   if (daemonize && daemon(1, 0))
return 1;
+
openlog("KVP", 0, LOG_USER);
syslog(LOG_INFO, "KVP starting; pid is:%d", getpid());
 
diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index 6a213b8..9ae2b6e 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static struct sockaddr_nl addr;
 
@@ -131,7 +132,15 @@ static int netlink_send(int fd, struct cn_msg *msg)
return sendmsg(fd, &message, 0);
 }
 
-int main(void)
+void print_usage(char *argv[])
+{
+   fprintf(stderr, "Usage: %s [options]\n"
+   "Options are:\n"
+   "  -n, --no-daemonstay in foreground, don't daemonize

Re: [PATCH v2] staging: skein: Loadable Module Support

2014-10-22 Thread Jason Cooper
On Wed, Oct 22, 2014 at 10:54:26AM -0500, Eric Rost wrote:
> On Wed, 2014-10-22 at 11:10 -0400, Jason Cooper wrote:
> > At some point, Eric Rost wrote:
...
> > > diff --git a/drivers/staging/skein/Makefile 
> > > b/drivers/staging/skein/Makefile
> > > index a14aadd..1be01fe 100644
> > > --- a/drivers/staging/skein/Makefile
> > > +++ b/drivers/staging/skein/Makefile
> > > @@ -5,5 +5,11 @@ obj-$(CONFIG_CRYPTO_SKEIN) +=   skein.o \
> > >   skein_api.o \
> > >   skein_block.o
> > >  
> > > +obj-$(CONFIG_CRYPTO_SKEIN_256) += skein256_generic.o
> > > +
> > > +obj-$(CONFIG_CRYPTO_SKEIN_512) += skein512_generic.o
> > > +
> > > +obj-$(CONFIG_CRYPTO_SKEIN_1024) += skein1024_generic.o
> > > +
> > 
> > This isn't really doing what we want.  You'll have loadable modules, but
> > the actual code will still be built into the kernel.
> > 
> > >  obj-$(CONFIG_CRYPTO_THREEFISH) += threefish_block.o \
> > > threefish_api.o
> > > diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c
> > > index 8cc8358..2138e22 100644
> > > --- a/drivers/staging/skein/skein.c
> > > +++ b/drivers/staging/skein/skein.c
> > > @@ -11,6 +11,7 @@
> > >  #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
> > >  
> > >  #include/* get the memcpy/memset functions */
> > > +#include 
> > >  #include "skein.h" /* get the Skein API definitions   */
> > >  #include "skein_iv.h"/* get precomputed IVs */
> > >  #include "skein_block.h"
> > > @@ -73,6 +74,7 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t 
> > > hash_bit_len)
> > >  
> > >   return SKEIN_SUCCESS;
> > >  }
> > > +EXPORT_SYMBOL(skein_256_init);
> > 
> > Once the above is corrected, these shouldn't be necessary.
> > 
> Will give it a whirl, I was having problems with undefined symbols at
> linking even when I was building it as one module, but it may have been
> something else

Try just changing CRYPTO_SKEIN to a tri-state, and adding your
skein_generic.o to the obj-$(CONFIG_CRYPTO_SKEIN) list.

You'll probably have to collapse CRYPTO_THREEFISH into CRYPTO_SKEIN for
now.  Let's get the crypto API registration proper first, them we can
focus on the loadable module bit.

thx,

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


Re: [PATCH 09/18] staging: comedi: comedi_buf: make comedi_buf_read_samples() work for single samples

2014-10-22 Thread Ian Abbott

On 20/10/14 19:52, H Hartley Sweeten wrote:

A number of drivers currently use comedi_buf_get() to read single samples
from the the async buffer. This works but the drivers have to handle the
COMEDI_CB_BLOCK and COMEDI_CB_EOS events. Converting those drivers to use
comedi_buf_read_samples() moves the handling of those events into the core.

Add a check to comedi_buf_read_samples() so that the single sample is read
from the buffer only if there is a full sample in the buffer. This allows
comedi_buf_read_samples() to mimic the action of comedi_buf_get() with the
added benifit of handling the events.


Even for more than one sample it would be better if 
comedi_buf_read_samples() only read a whole number of samples from the 
buffer, e.g. by rounding down the value from 
comedi_buf_read_n_available().  Then you wouldn't need to treat single 
samples as a special case.




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

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index 4cf02cb..6b6143b 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -564,6 +564,7 @@ unsigned int comedi_buf_read_samples(struct 
comedi_subdevice *s,
 void *data, unsigned int nsamples)
  {
unsigned long long nbytes = nsamples * bytes_per_sample(s);
+   unsigned int n = comedi_buf_read_n_available(s);

if (nbytes > s->async->prealloc_bufsz)
nbytes = s->async->prealloc_bufsz;
@@ -571,6 +572,10 @@ unsigned int comedi_buf_read_samples(struct 
comedi_subdevice *s,
if (nbytes == 0)
return 0;

+   /* single sample reads must return a full sample */
+   if (nsamples == 1 && n < nbytes)
+   return 0;
+
nbytes = comedi_buf_read_alloc(s, nbytes);
comedi_buf_memcpy_from(s, 0, data, nbytes);
comedi_buf_read_free(s, nbytes);




--
-=( 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] tools: hv: introduce -n/--no-daemon option

2014-10-22 Thread KY Srinivasan


> -Original Message-
> From: Vitaly Kuznetsov [mailto:vkuzn...@redhat.com]
> Sent: Wednesday, October 22, 2014 9:07 AM
> To: KY Srinivasan; Haiyang Zhang; de...@linuxdriverproject.org
> Cc: linux-ker...@vger.kernel.org
> Subject: [PATCH] tools: hv: introduce -n/--no-daemon option
> 
> All tools/hv daemons do mandatory daemon() on startup. However, no
> pidfile is created, this make it difficult for an init system to track such
> daemons.
> Modern linux distros use systemd as their init system. It can handle the
> daemonizing by itself, however, it requires a daemon to stay in foreground
> for that. Some distros already carry distro-specific patch for hv tools which
> switches off daemon().
> 
> Introduce -n/--no-daemon option for all 3 daemons in hv/tools. Parse
> options with getopt() to make this part easily expandable.
> 
> Signed-off-by: Vitaly Kuznetsov 
You may want to include Greg KH in the "to" list.
Signed-off-by:  K. Y. Srinivasan 


> ---
>  tools/hv/hv_fcopy_daemon.c | 33 +++-
> -
>  tools/hv/hv_kvp_daemon.c   | 34
> --
>  tools/hv/hv_vss_daemon.c   | 33 +++--
>  3 files changed, 94 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
> index 8f96b3e..f437d73 100644
> --- a/tools/hv/hv_fcopy_daemon.c
> +++ b/tools/hv/hv_fcopy_daemon.c
> @@ -33,6 +33,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  static int target_fd;
>  static char target_fname[W_MAX_PATH];
> @@ -126,15 +127,43 @@ static int hv_copy_cancel(void)
> 
>  }
> 
> -int main(void)
> +void print_usage(char *argv[])
> +{
> + fprintf(stderr, "Usage: %s [options]\n"
> + "Options are:\n"
> + "  -n, --no-daemonstay in foreground, don't
> daemonize\n"
> + "  -h, --help print this help\n", argv[0]);
> +}
> +
> +int main(int argc, char *argv[])
>  {
>   int fd, fcopy_fd, len;
>   int error;
> + int daemonize = 1, long_index = 0, opt;
>   int version = FCOPY_CURRENT_VERSION;
>   char *buffer[4096 * 2];
>   struct hv_fcopy_hdr *in_msg;
> 
> - if (daemon(1, 0)) {
> + static struct option long_options[] = {
> + {"help",no_argument,   0,  'h' },
> + {"no-daemon",   no_argument,   0,  'n' },
> + {0, 0, 0,  0   }
> + };
> +
> + while ((opt = getopt_long(argc, argv, "hn", long_options,
> +   &long_index)) != -1) {
> + switch (opt) {
> + case 'n':
> + daemonize = 0;
> + break;
> + case 'h':
> + default:
> + print_usage(argv);
> + exit(EXIT_FAILURE);
> + }
> + }
> +
> + if (daemonize && daemon(1, 0)) {
>   syslog(LOG_ERR, "daemon() failed; error: %s",
> strerror(errno));
>   exit(EXIT_FAILURE);
>   }
> diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index
> 4088b81..22b0764 100644
> --- a/tools/hv/hv_kvp_daemon.c
> +++ b/tools/hv/hv_kvp_daemon.c
> @@ -43,6 +43,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  /*
>   * KVP protocol: The user mode component first registers with the @@ -
> 1417,7 +1418,15 @@ netlink_send(int fd, struct cn_msg *msg)
>   return sendmsg(fd, &message, 0);
>  }
> 
> -int main(void)
> +void print_usage(char *argv[])
> +{
> + fprintf(stderr, "Usage: %s [options]\n"
> + "Options are:\n"
> + "  -n, --no-daemonstay in foreground, don't
> daemonize\n"
> + "  -h, --help print this help\n", argv[0]);
> +}
> +
> +int main(int argc, char *argv[])
>  {
>   int fd, len, nl_group;
>   int error;
> @@ -1435,9 +1444,30 @@ int main(void)
>   struct hv_kvp_ipaddr_value *kvp_ip_val;
>   char *kvp_recv_buffer;
>   size_t kvp_recv_buffer_len;
> + int daemonize = 1, long_index = 0, opt;
> +
> + static struct option long_options[] = {
> + {"help",no_argument,   0,  'h' },
> + {"no-daemon",   no_argument,   0,  'n' },
> + {0, 0, 0,  0   }
> + };
> +
> + while ((opt = getopt_long(argc, argv, "hn", long_options,
> +   &long_index)) != -1) {
> + switch (opt) {
> + case 'n':
> + daemonize = 0;
> + break;
> + case 'h':
> + default:
> + print_usage(argv);
> + exit(EXIT_FAILURE);
> + }
> + }
> 
> - if (daemon(1, 0))
> + if (daemonize && daemon(1, 0))
>   return 1;
> +
>   openlog("KVP", 0, LOG_USER);
>   syslog(LOG_INFO, "KVP starting; pid is:%d", getpid());
> 
> diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vs

RE: [PATCH 01/18] staging: comedi: comedi_buf: introduce comedi_buf_read_samples()

2014-10-22 Thread Hartley Sweeten
On Wednesday, October 22, 2014 8:18 AM, Ian Abbott wrote:
> On 20/10/14 19:52, H Hartley Sweeten wrote:
>> Introduce a generic method to read samples from the async buffer.
>>
>> The size of each sample is detected automatically using the 
>> bytes_per_sample()
>> helper. The unsigned long long is used to avoid any possible integer overflow
>> when calculating the 'nbytes' for all the requested samples. This value is
>> then clampled to the actual size of the async buffer. The samples are read
>> from the async buffer using comedi_read_array_from_buffer().
>>
>> This will allow converting all the comedi drivers to use a common method when
>> reading data from the async buffer.
>>
>> Since comedi_read_array_from_buffer() sets the COMEDI_CB_BLOCK event after
>> reading the data, those events can be removed from the drivers.
>>
>> In addition, comedi_inc_scan_progress() will automatically detect the end of
>> scan and set the COMEDI_CB_EOS event. Those events can also be removed from
>> the drivers.
>>
>> Signed-off-by: H Hartley Sweeten 
>> Cc: Ian Abbott 
>> Cc: Greg Kroah-Hartman 
>> ---
>>   drivers/staging/comedi/comedi_buf.c | 23 +++
>>   drivers/staging/comedi/comedidev.h  |  2 ++
>>   2 files changed, 25 insertions(+)
>>
>> diff --git a/drivers/staging/comedi/comedi_buf.c 
>> b/drivers/staging/comedi/comedi_buf.c
>> index c60a45ad..03b475a 100644
>> --- a/drivers/staging/comedi/comedi_buf.c
>> +++ b/drivers/staging/comedi/comedi_buf.c
>> @@ -575,3 +575,26 @@ unsigned int comedi_read_array_from_buffer(struct 
>> comedi_subdevice *s,
>>  return num_bytes;
>>   }
>>   EXPORT_SYMBOL_GPL(comedi_read_array_from_buffer);
>> +
>> +/**
>> + * comedi_buf_read_samples - read sample data from comedi buffer
>> + * @s: comedi_subdevice struct
>> + * @data: destination
>> + * @nsamples: maximum number of samples to read
>> + *
>> + * Reads up to nsamples from the comedi buffer associated with the 
>> subdevice,
>> + * marks it as read and updates the acquisition scan progress.
>> + *
>> + * Returns the amount of data read in bytes.
>> + */
>> +unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
>> + void *data, unsigned int nsamples)
>> +{
>> +unsigned long long nbytes = nsamples * bytes_per_sample(s);
>
> That doesn't do what you think.  One of the operands of '*' would have 
> to be cast to '(unsigned long long)' first.

Yah, I just figured that out yesterday... I need to fix this patch...

> The other option is to clamp 'nsamples' to 's->async->prealloc_bufsz / 
> bytes_per_sample(s)'.  If there was a log2 version of 
> bytes_per_sample(), the division could be replaced with a bit-shift (the 
> compiler probably isn't clever enough to do that optimization by 
> itself).  On a side-note, 'bytes_per_sample()' ought to be renamed to 
> 'comedi_bytes_per_sample()' at some point.

That works and avoids the unsigned long long issue.

It also removes the need for the test below.

>> +
>> +if (nbytes > s->async->prealloc_bufsz)
>> +nbytes = s->async->prealloc_bufsz;
>> +
>> +return comedi_read_array_from_buffer(s, data, nbytes);
>> +}
>> +EXPORT_SYMBOL_GPL(comedi_buf_read_samples);
>> diff --git a/drivers/staging/comedi/comedidev.h 
>> b/drivers/staging/comedi/comedidev.h
>> index fb8ff84..ba4084b 100644
>> --- a/drivers/staging/comedi/comedidev.h
>> +++ b/drivers/staging/comedi/comedidev.h
>> @@ -453,6 +453,8 @@ unsigned int comedi_write_array_to_buffer(struct 
>> comedi_subdevice *s,
>>unsigned int num_bytes);
>>   unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s,
>> void *data, unsigned int num_bytes);
>> +unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
>> + void *data, unsigned int nsamples);
>>
>>   /* drivers.c - general comedi driver functions */
>>
>>

I'll update this and fix patch 09/18 also. I should be able to get
the v2 series out later today.

Thanks,
Hartley

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


[PATCH net] hyperv: Fix the total_data_buflen in send path

2014-10-22 Thread Haiyang Zhang
total_data_buflen is used by netvsc_send() to decide if a packet can be put
into send buffer. It should also include the size of RNDIS message before the
Ethernet frame. Otherwise, a messge with total size bigger than 
send_section_size
may be copied into the send buffer, and cause data corruption.

[Request to include this patch to the Stable branches]

Signed-off-by: Haiyang Zhang 
Reviewed-by: K. Y. Srinivasan 
---
 drivers/net/hyperv/netvsc_drv.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 9e17d1a..78ec33f 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -550,6 +550,7 @@ do_lso:
 do_send:
/* Start filling in the page buffers with the rndis hdr */
rndis_msg->msg_len += rndis_msg_size;
+   packet->total_data_buflen = rndis_msg->msg_len;
packet->page_buf_cnt = init_page_array(rndis_msg, rndis_msg_size,
skb, &packet->page_buf[0]);
 
-- 
1.7.1

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


[PATCH v2] staging: rtl8712: Remove redundant cast

2014-10-22 Thread Rasmus Villemoes
struct firmware::data has type const u8*, as does *ppmappedfw, so the
cast to u8* is unnecessary and slightly confusing.

Signed-off-by: Rasmus Villemoes 
---
 drivers/staging/rtl8712/hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/hal_init.c 
b/drivers/staging/rtl8712/hal_init.c
index 1d6ade0..83f9341 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -86,7 +86,7 @@ static u32 rtl871x_open_fw(struct _adapter *padapter, const 
u8 **ppmappedfw)
(int)padapter->fw->size);
return 0;
}
-   *ppmappedfw = (u8 *)((*praw)->data);
+   *ppmappedfw = (*praw)->data;
return (*praw)->size;
 }
 
-- 
2.0.4

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


[PATCH v2 00/18] staging: comedi: clean up reading data from the async buffer

2014-10-22 Thread H Hartley Sweeten
Currently there are 3 exported methods to read sample data from the async 
buffer.

  1) cfc_read_array_from_buffer() - a wrapper around 
comedi_read_array_from_buffer()
  2) comedi_read_array_from_buffer() - reads multiple samples
  3) comedi_buf_get() - reads a single sample

In addition there are the exported functions comedi_buf_memcpy_{to,from}() that 
are
only used internally to read/write data to/from the async buffer.

Introduce a new generic helper function, comedi_buf_read_samples(), to read 
samples
from the async buffer. Use this function to replace the three "read" methods 
above.

Remove the exports from comedi_buf_memcpy_{to,from}() and tidy them up a bit.

v2: fix patch 01/18 as suggested by Ian Abbott
fix patch 09/18 as suggested by Ian Abbott
  
H Hartley Sweeten (18):
  staging: comedi: comedi_buf: introduce comedi_buf_read_samples()
  staging: comedi: amplc_pci224: use comedi_buf_read_samples()
  staging: comedi: cb_pcidas: introduce cb_pcidas_ao_load_fifo()
  staging: comedi: cb_pcidas: introduce cb_pcidas64_ao_fill_buffer()
  staging: comedi: dt282x: introduce dt282x_ao_setup_dma()
  staging: comedi: comedi_fc.h: remove cfc_read_array_from_buffer()
  staging: comedi: comedi_buf: remove export of comedi_read_array_from_buffer()
  staging: comedi: comedi_buf: absorb comedi_read_array_from_buffer()
  staging: comedi: comedi_buf: make comedi_buf_read_samples() always return 
full samples
  staging: comedi: ni_mio_common: use comedi_buf_read_samples()
  staging: comedi: amplc_pci230: use comedi_buf_read_samples()
  staging: comedi: usbdux: use comedi_buf_read_samples()
  staging: comedi: usbduxsigma: use comedi_buf_read_samples()
  staging: comedi: comedi_buf: remove comedi_buf_get()
  staging: comedi: comedi_buf: dont't export comedi_buf_memcpy_from()
  staging: comedi: comedi_buf: don't export comedi_buf_memcpy_to()
  staging: comedi: comedi_buf: comedi_buf_memcpy_to() remove 'offset' param
  staging: comedi: comedi_buf: comedi_buf_memcpy_from() remove 'offset' param

 drivers/staging/comedi/comedi_buf.c| 70 +--
 drivers/staging/comedi/comedidev.h |  9 +--
 drivers/staging/comedi/drivers/amplc_pci224.c  |  7 +--
 drivers/staging/comedi/drivers/amplc_pci230.c  | 17 +++---
 drivers/staging/comedi/drivers/cb_pcidas.c | 54 +++---
 drivers/staging/comedi/drivers/cb_pcidas64.c   | 79 +++---
 drivers/staging/comedi/drivers/comedi_fc.h |  7 ---
 drivers/staging/comedi/drivers/dt282x.c| 42 +++---
 drivers/staging/comedi/drivers/ni_mio_common.c | 13 +
 drivers/staging/comedi/drivers/usbdux.c|  3 +-
 drivers/staging/comedi/drivers/usbduxsigma.c   |  3 +-
 11 files changed, 135 insertions(+), 169 deletions(-)

-- 
2.0.3

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


[PATCH v2 17/18] staging: comedi: comedi_buf: comedi_buf_memcpy_to() remove 'offset' param

2014-10-22 Thread H Hartley Sweeten
This parameter is always passed as '0'. Remove the unnecessary parameter.

This allows removing the unnecessary check of the write_ptr overflow.

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

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index 0e4727d..c60fa1a 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -443,14 +443,10 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned 
short x)
 EXPORT_SYMBOL_GPL(comedi_buf_put);
 
 static void comedi_buf_memcpy_to(struct comedi_subdevice *s,
-unsigned int offset,
 const void *data, unsigned int num_bytes)
 {
struct comedi_async *async = s->async;
-   unsigned int write_ptr = async->buf_write_ptr + offset;
-
-   if (write_ptr >= async->prealloc_bufsz)
-   write_ptr %= async->prealloc_bufsz;
+   unsigned int write_ptr = async->buf_write_ptr;
 
while (num_bytes) {
unsigned int block_size;
@@ -526,7 +522,7 @@ unsigned int comedi_write_array_to_buffer(struct 
comedi_subdevice *s,
return 0;
}
 
-   comedi_buf_memcpy_to(s, 0, data, num_bytes);
+   comedi_buf_memcpy_to(s, data, num_bytes);
comedi_buf_write_free(s, num_bytes);
comedi_inc_scan_progress(s, num_bytes);
async->events |= COMEDI_CB_BLOCK;
-- 
2.0.3

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


[PATCH v2 13/18] staging: comedi: usbduxsigma: use comedi_buf_read_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_read_samples() to read the analog output samples from
the async buffer. That function will set the COMEDI_CB_BLOCK event
when samples are read from the async buffer.

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index 1d12cc6..de3fb41 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -374,7 +374,7 @@ static void usbduxsigma_ao_handle_urb(struct comedi_device 
*dev,
unsigned int chan = CR_CHAN(cmd->chanlist[i]);
unsigned short val;
 
-   if (!comedi_buf_get(s, &val)) {
+   if (!comedi_buf_read_samples(s, &val, 1)) {
dev_err(dev->class_dev, "buffer underflow\n");
async->events |= COMEDI_CB_OVERFLOW;
return;
@@ -384,7 +384,6 @@ static void usbduxsigma_ao_handle_urb(struct comedi_device 
*dev,
*datap++ = chan;
s->readback[chan] = val;
}
-   async->events |= COMEDI_CB_BLOCK;
}
 
/* if command is still running, resubmit urb */
-- 
2.0.3

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


[PATCH v2 18/18] staging: comedi: comedi_buf: comedi_buf_memcpy_from() remove 'offset' param

2014-10-22 Thread H Hartley Sweeten
This parameter is always passed as '0'. Remove the unnecessary parameter.

This allows removing the unnecessary check of the read_ptr overflow.

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

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index c60fa1a..1f91607 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -466,15 +466,11 @@ static void comedi_buf_memcpy_to(struct comedi_subdevice 
*s,
 }
 
 static void comedi_buf_memcpy_from(struct comedi_subdevice *s,
-  unsigned int offset,
   void *dest, unsigned int nbytes)
 {
void *src;
struct comedi_async *async = s->async;
-   unsigned int read_ptr = async->buf_read_ptr + offset;
-
-   if (read_ptr >= async->prealloc_bufsz)
-   read_ptr %= async->prealloc_bufsz;
+   unsigned int read_ptr = async->buf_read_ptr;
 
while (nbytes) {
unsigned int block_size;
@@ -557,7 +553,7 @@ unsigned int comedi_buf_read_samples(struct 
comedi_subdevice *s,
return 0;
 
nbytes = comedi_buf_read_alloc(s, nsamples * bytes_per_sample(s));
-   comedi_buf_memcpy_from(s, 0, data, nbytes);
+   comedi_buf_memcpy_from(s, data, nbytes);
comedi_buf_read_free(s, nbytes);
comedi_inc_scan_progress(s, nbytes);
s->async->events |= COMEDI_CB_BLOCK;
-- 
2.0.3

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


[PATCH v2 02/18] staging: comedi: amplc_pci224: use comedi_buf_read_samples()

2014-10-22 Thread H Hartley Sweeten
Use the new generic method to read the analog output samples from the async
buffer.

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

diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c 
b/drivers/staging/comedi/drivers/amplc_pci224.c
index 9fcf6f7..342779f 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/staging/comedi/drivers/amplc_pci224.c
@@ -514,14 +514,13 @@ static void pci224_ao_handle_fifo(struct comedi_device 
*dev,
 {
struct pci224_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
-   unsigned int bytes_per_scan = comedi_bytes_per_scan(s);
unsigned int num_scans;
unsigned int room;
unsigned short dacstat;
unsigned int i, n;
 
/* Determine number of scans available in buffer. */
-   num_scans = comedi_buf_read_n_available(s) / bytes_per_scan;
+   num_scans = comedi_buf_read_n_available(s) / comedi_bytes_per_scan(s);
if (cmd->stop_src == TRIG_COUNT) {
/* Fixed number of scans. */
if (num_scans > devpriv->ao_stop_count)
@@ -568,8 +567,8 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev,
 
/* Process scans. */
for (n = 0; n < num_scans; n++) {
-   cfc_read_array_from_buffer(s, &devpriv->ao_scan_vals[0],
-  bytes_per_scan);
+   comedi_buf_read_samples(s, &devpriv->ao_scan_vals[0],
+   cmd->chanlist_len);
for (i = 0; i < cmd->chanlist_len; i++) {
outw(devpriv->ao_scan_vals[devpriv->ao_scan_order[i]],
 dev->iobase + PCI224_DACDATA);
-- 
2.0.3

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


[PATCH v2 03/18] staging: comedi: cb_pcidas: introduce cb_pcidas_ao_load_fifo()

2014-10-22 Thread H Hartley Sweeten
Introduce a helper function to load the analog output FIFO.

This fixes a bug in cb_pcidas_ao_inttrig(). That function was writing
'num_bytes' data values to the FIFO instead of 'num_points'. This results
in twice the number of data values getting written to the FIFO.

Use comedi_buf_read_samples() read the analog output samples from the async
buffer.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c 
b/drivers/staging/comedi/drivers/cb_pcidas.c
index e7ab6bc..a0d462f 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -1134,32 +1134,39 @@ static int cb_pcidas_cancel(struct comedi_device *dev,
return 0;
 }
 
+static void cb_pcidas_ao_load_fifo(struct comedi_device *dev,
+  struct comedi_subdevice *s,
+  unsigned int nsamples)
+{
+   struct cb_pcidas_private *devpriv = dev->private;
+   struct comedi_cmd *cmd = &s->async->cmd;
+   unsigned int nbytes;
+
+   if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < nsamples)
+   nsamples = devpriv->ao_count;
+
+   nbytes = comedi_buf_read_samples(s, devpriv->ao_buffer, nsamples);
+   nsamples = nbytes / bytes_per_sample(s);
+   if (cmd->stop_src == TRIG_COUNT)
+   devpriv->ao_count -= nsamples;
+
+   outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, nsamples);
+}
+
 static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
struct comedi_subdevice *s,
unsigned int trig_num)
 {
const struct cb_pcidas_board *thisboard = dev->board_ptr;
struct cb_pcidas_private *devpriv = dev->private;
-   unsigned int num_bytes, num_points = thisboard->fifo_size;
struct comedi_async *async = s->async;
-   struct comedi_cmd *cmd = &s->async->cmd;
+   struct comedi_cmd *cmd = &async->cmd;
unsigned long flags;
 
if (trig_num != cmd->start_arg)
return -EINVAL;
 
-   /*  load up fifo */
-   if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < num_points)
-   num_points = devpriv->ao_count;
-
-   num_bytes = cfc_read_array_from_buffer(s, devpriv->ao_buffer,
-  num_points * sizeof(short));
-   num_points = num_bytes / sizeof(short);
-
-   if (cmd->stop_src == TRIG_COUNT)
-   devpriv->ao_count -= num_points;
-   /*  write data to board's fifo */
-   outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer, num_bytes);
+   cb_pcidas_ao_load_fifo(dev, s, thisboard->fifo_size);
 
/*  enable dac half-full and empty interrupts */
spin_lock_irqsave(&dev->spinlock, flags);
@@ -1275,8 +1282,6 @@ static void handle_ao_interrupt(struct comedi_device 
*dev, unsigned int status)
struct comedi_subdevice *s = dev->write_subdev;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
-   unsigned int half_fifo = thisboard->fifo_size / 2;
-   unsigned int num_points;
unsigned long flags;
 
if (status & DAEMI) {
@@ -1295,23 +1300,8 @@ static void handle_ao_interrupt(struct comedi_device 
*dev, unsigned int status)
async->events |= COMEDI_CB_EOA;
}
} else if (status & DAHFI) {
-   unsigned int num_bytes;
+   cb_pcidas_ao_load_fifo(dev, s, thisboard->fifo_size / 2);
 
-   /*  figure out how many points we are writing to fifo */
-   num_points = half_fifo;
-   if (cmd->stop_src == TRIG_COUNT &&
-   devpriv->ao_count < num_points)
-   num_points = devpriv->ao_count;
-   num_bytes =
-   cfc_read_array_from_buffer(s, devpriv->ao_buffer,
-  num_points * sizeof(short));
-   num_points = num_bytes / sizeof(short);
-
-   if (cmd->stop_src == TRIG_COUNT)
-   devpriv->ao_count -= num_points;
-   /*  write data to board's fifo */
-   outsw(devpriv->ao_registers + DACDATA, devpriv->ao_buffer,
- num_points);
/*  clear half-full interrupt latch */
spin_lock_irqsave(&dev->spinlock, flags);
outw(devpriv->adc_fifo_bits | DAHFI,
-- 
2.0.3

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


[PATCH v2 12/18] staging: comedi: usbdux: use comedi_buf_read_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_read_samples() to read the analog output samples from
the async buffer. That function will set the COMEDI_CB_BLOCK event
when samples are read from the async buffer.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index eae441f..53f1e21 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -413,7 +413,7 @@ static void usbduxsub_ao_handle_urb(struct comedi_device 
*dev,
unsigned int chan = CR_CHAN(cmd->chanlist[i]);
unsigned short val;
 
-   if (!comedi_buf_get(s, &val)) {
+   if (!comedi_buf_read_samples(s, &val, 1)) {
dev_err(dev->class_dev, "buffer underflow\n");
async->events |= COMEDI_CB_OVERFLOW;
return;
@@ -425,7 +425,6 @@ static void usbduxsub_ao_handle_urb(struct comedi_device 
*dev,
*datap++ = chan << 6;
s->readback[chan] = val;
}
-   async->events |= COMEDI_CB_BLOCK;
}
 
/* if command is still running, resubmit urb for BULK transfer */
-- 
2.0.3

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


[PATCH v2 04/18] staging: comedi: cb_pcidas: introduce cb_pcidas64_ao_fill_buffer()

2014-10-22 Thread H Hartley Sweeten
Introduce a helper function to read the analog output samples from the
async buffer.

This fixes a bug in load_ao_dma_buffer(). That function was decrementing
the 'ao_count' by the number of bytes, not the number of samples, that
were read from the async buffer.

Use comedi_buf_read_samples() to read the analog output samples from
the async buffer.

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

diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c 
b/drivers/staging/comedi/drivers/cb_pcidas64.c
index eafbe9f..06e846f 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -2912,32 +2912,46 @@ static void restart_ao_dma(struct comedi_device *dev)
dma_start_sync(dev, 0);
 }
 
+static unsigned int cb_pcidas64_ao_fill_buffer(struct comedi_device *dev,
+  struct comedi_subdevice *s,
+  unsigned short *dest,
+  unsigned int max_bytes)
+{
+   struct pcidas64_private *devpriv = dev->private;
+   struct comedi_cmd *cmd = &s->async->cmd;
+   unsigned int nsamples = max_bytes / bytes_per_sample(s);
+   unsigned int actual_bytes;
+
+   if (cmd->stop_src == TRIG_COUNT && devpriv->ao_count < nsamples)
+   nsamples = devpriv->ao_count;
+
+   actual_bytes = comedi_buf_read_samples(s, dest, nsamples);
+   nsamples = actual_bytes / bytes_per_sample(s);
+   if (cmd->stop_src == TRIG_COUNT)
+   devpriv->ao_count -= nsamples;
+
+   return nsamples;
+}
+
 static unsigned int load_ao_dma_buffer(struct comedi_device *dev,
   const struct comedi_cmd *cmd)
 {
struct pcidas64_private *devpriv = dev->private;
-   unsigned int num_bytes, buffer_index, prev_buffer_index;
+   struct comedi_subdevice *s = dev->write_subdev;
+   unsigned int buffer_index = devpriv->ao_dma_index;
+   unsigned int prev_buffer_index = prev_ao_dma_index(dev);
+   unsigned int nsamples;
+   unsigned int nbytes;
unsigned int next_bits;
 
-   buffer_index = devpriv->ao_dma_index;
-   prev_buffer_index = prev_ao_dma_index(dev);
-
-   num_bytes = comedi_buf_read_n_available(dev->write_subdev);
-   if (num_bytes > DMA_BUFFER_SIZE)
-   num_bytes = DMA_BUFFER_SIZE;
-   if (cmd->stop_src == TRIG_COUNT && num_bytes > devpriv->ao_count)
-   num_bytes = devpriv->ao_count;
-   num_bytes -= num_bytes % bytes_in_sample;
-
-   if (num_bytes == 0)
+   nsamples = cb_pcidas64_ao_fill_buffer(dev, s,
+ devpriv->ao_buffer[buffer_index],
+ DMA_BUFFER_SIZE);
+   if (nsamples == 0)
return 0;
 
-   num_bytes = cfc_read_array_from_buffer(dev->write_subdev,
-  devpriv->
-  ao_buffer[buffer_index],
-  num_bytes);
-   devpriv->ao_dma_desc[buffer_index].transfer_size =
-   cpu_to_le32(num_bytes);
+   nbytes = nsamples * bytes_per_sample(s);
+   devpriv->ao_dma_desc[buffer_index].transfer_size = cpu_to_le32(nbytes);
/* set end of chain bit so we catch underruns */
next_bits = le32_to_cpu(devpriv->ao_dma_desc[buffer_index].next);
next_bits |= PLX_END_OF_CHAIN_BIT;
@@ -2949,9 +2963,8 @@ static unsigned int load_ao_dma_buffer(struct 
comedi_device *dev,
devpriv->ao_dma_desc[prev_buffer_index].next = cpu_to_le32(next_bits);
 
devpriv->ao_dma_index = (buffer_index + 1) % AO_DMA_RING_COUNT;
-   devpriv->ao_count -= num_bytes;
 
-   return num_bytes;
+   return nbytes;
 }
 
 static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd 
*cmd)
@@ -3191,7 +3204,9 @@ static void set_dac_interval_regs(struct comedi_device 
*dev,
 static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
 {
struct pcidas64_private *devpriv = dev->private;
-   unsigned int num_bytes;
+   struct comedi_subdevice *s = dev->write_subdev;
+   unsigned int nsamples;
+   unsigned int nbytes;
int i;
 
/* clear queue pointer too, since external queue has
@@ -3199,22 +3214,22 @@ static int prep_ao_dma(struct comedi_device *dev, const 
struct comedi_cmd *cmd)
writew(0, devpriv->main_iobase + ADC_QUEUE_CLEAR_REG);
writew(0, devpriv->main_iobase + DAC_BUFFER_CLEAR_REG);
 
-   num_bytes = (DAC_FIFO_SIZE / 2) * bytes_in_sample;
-   if (cmd->stop_src == TRIG_COUNT &&
-   num_bytes / bytes_in_sample > devpriv->ao_count)
-   num_bytes = devpriv->ao_count * byte

[PATCH v2 11/18] staging: comedi: amplc_pci230: use comedi_buf_read_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_read_samples() to read the analog output samples from
the async buffer. That function will set the COMEDI_CB_BLOCK event
when samples are read from the async buffer. In addition, the core
will also handle the end-of-scan detection and set the COMEDI_CB_EOS
event.

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

diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c 
b/drivers/staging/comedi/drivers/amplc_pci230.c
index a3b34d8..f9b952f 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -1075,26 +1075,25 @@ static void pci230_handle_ao_nofifo(struct 
comedi_device *dev,
struct comedi_subdevice *s)
 {
struct pci230_private *devpriv = dev->private;
-   unsigned short data;
-   int i, ret;
struct comedi_async *async = s->async;
struct comedi_cmd *cmd = &async->cmd;
+   unsigned short data;
+   int i;
 
if (cmd->stop_src == TRIG_COUNT && devpriv->ao_scan_count == 0)
return;
+
for (i = 0; i < cmd->chanlist_len; i++) {
unsigned int chan = CR_CHAN(cmd->chanlist[i]);
 
-   /* Read sample from Comedi's circular buffer. */
-   ret = comedi_buf_get(s, &data);
-   if (ret == 0) {
-   s->async->events |= COMEDI_CB_OVERFLOW;
+   if (!comedi_buf_read_samples(s, &data, 1)) {
+   async->events |= COMEDI_CB_OVERFLOW;
return;
}
pci230_ao_write_nofifo(dev, data, chan);
s->readback[chan] = data;
}
-   async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
+
if (cmd->stop_src == TRIG_COUNT) {
devpriv->ao_scan_count--;
if (devpriv->ao_scan_count == 0) {
@@ -1171,12 +1170,12 @@ static bool pci230_handle_ao_fifo(struct comedi_device 
*dev,
unsigned int chan = CR_CHAN(cmd->chanlist[i]);
unsigned short datum;
 
-   comedi_buf_get(s, &datum);
+   comedi_buf_read_samples(s, &datum, 1);
pci230_ao_write_fifo(dev, datum, chan);
s->readback[chan] = datum;
}
}
-   events |= COMEDI_CB_EOS | COMEDI_CB_BLOCK;
+
if (cmd->stop_src == TRIG_COUNT) {
devpriv->ao_scan_count -= num_scans;
if (devpriv->ao_scan_count == 0) {
-- 
2.0.3

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


[PATCH v2 08/18] staging: comedi: comedi_buf: absorb comedi_read_array_from_buffer()

2014-10-22 Thread H Hartley Sweeten
This function is only called by comedi_buf_read_samples(). Absorb it.

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

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index d1303a8..9074da2 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -549,22 +549,6 @@ unsigned int comedi_write_array_to_buffer(struct 
comedi_subdevice *s,
 }
 EXPORT_SYMBOL_GPL(comedi_write_array_to_buffer);
 
-static unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s,
- void *data,
- unsigned int num_bytes)
-{
-   if (num_bytes == 0)
-   return 0;
-
-   num_bytes = comedi_buf_read_alloc(s, num_bytes);
-   comedi_buf_memcpy_from(s, 0, data, num_bytes);
-   comedi_buf_read_free(s, num_bytes);
-   comedi_inc_scan_progress(s, num_bytes);
-   s->async->events |= COMEDI_CB_BLOCK;
-
-   return num_bytes;
-}
-
 /**
  * comedi_buf_read_samples - read sample data from comedi buffer
  * @s: comedi_subdevice struct
@@ -587,7 +571,15 @@ unsigned int comedi_buf_read_samples(struct 
comedi_subdevice *s,
nsamples = max_samples;
 
nbytes = nsamples * bytes_per_sample(s);
+   if (nbytes == 0)
+   return 0;
 
-   return comedi_read_array_from_buffer(s, data, nbytes);
+   nbytes = comedi_buf_read_alloc(s, nbytes);
+   comedi_buf_memcpy_from(s, 0, data, nbytes);
+   comedi_buf_read_free(s, nbytes);
+   comedi_inc_scan_progress(s, nbytes);
+   s->async->events |= COMEDI_CB_BLOCK;
+
+   return nbytes;
 }
 EXPORT_SYMBOL_GPL(comedi_buf_read_samples);
-- 
2.0.3

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


[PATCH v2 01/18] staging: comedi: comedi_buf: introduce comedi_buf_read_samples()

2014-10-22 Thread H Hartley Sweeten
Introduce a generic method to read samples from the async buffer.

The number of requested samples is clampled to the number of samples that
would fill the async buffer. The size of each sample is determined using
the bytes_per_sample() helper. The number of bytes need are then read
from the async buffer using comedi_read_array_from_buffer().

This will allow converting all the comedi drivers to use a common method
to read data from the async buffer.

Since comedi_read_array_from_buffer() sets the COMEDI_CB_BLOCK event after
reading the data, those events can be removed from the drivers.

In addition, comedi_inc_scan_progress() will automatically detect the end of
scan and set the COMEDI_CB_EOS event. Those events can also be removed from
the drivers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/comedi_buf.c | 27 +++
 drivers/staging/comedi/comedidev.h  |  2 ++
 2 files changed, 29 insertions(+)

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index c60a45ad..88a7cae 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -575,3 +575,30 @@ unsigned int comedi_read_array_from_buffer(struct 
comedi_subdevice *s,
return num_bytes;
 }
 EXPORT_SYMBOL_GPL(comedi_read_array_from_buffer);
+
+/**
+ * comedi_buf_read_samples - read sample data from comedi buffer
+ * @s: comedi_subdevice struct
+ * @data: destination
+ * @nsamples: maximum number of samples to read
+ *
+ * Reads up to nsamples from the comedi buffer associated with the subdevice,
+ * marks it as read and updates the acquisition scan progress.
+ *
+ * Returns the amount of data read in bytes.
+ */
+unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
+void *data, unsigned int nsamples)
+{
+   unsigned int max_samples;
+   unsigned int nbytes;
+
+   max_samples = s->async->prealloc_bufsz / bytes_per_sample(s);
+   if (nsamples > max_samples)
+   nsamples = max_samples;
+
+   nbytes = nsamples * bytes_per_sample(s);
+
+   return comedi_read_array_from_buffer(s, data, nbytes);
+}
+EXPORT_SYMBOL_GPL(comedi_buf_read_samples);
diff --git a/drivers/staging/comedi/comedidev.h 
b/drivers/staging/comedi/comedidev.h
index fb8ff84..ba4084b 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -453,6 +453,8 @@ unsigned int comedi_write_array_to_buffer(struct 
comedi_subdevice *s,
  unsigned int num_bytes);
 unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s,
   void *data, unsigned int num_bytes);
+unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
+void *data, unsigned int nsamples);
 
 /* drivers.c - general comedi driver functions */
 
-- 
2.0.3

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


[PATCH v2 14/18] staging: comedi: comedi_buf: remove comedi_buf_get()

2014-10-22 Thread H Hartley Sweeten
This function is no longer used. Remove it.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/comedi_buf.c | 14 --
 drivers/staging/comedi/comedidev.h  |  1 -
 2 files changed, 15 deletions(-)

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index fb2e91a..f7ff420 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -442,20 +442,6 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned 
short x)
 }
 EXPORT_SYMBOL_GPL(comedi_buf_put);
 
-int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x)
-{
-   struct comedi_async *async = s->async;
-   unsigned int n = comedi_buf_read_n_available(s);
-
-   if (n < sizeof(short))
-   return 0;
-   comedi_buf_read_alloc(s, sizeof(short));
-   *x = *(unsigned short *)(async->prealloc_buf + async->buf_read_ptr);
-   comedi_buf_read_free(s, sizeof(short));
-   return 1;
-}
-EXPORT_SYMBOL_GPL(comedi_buf_get);
-
 void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset,
  const void *data, unsigned int num_bytes)
 {
diff --git a/drivers/staging/comedi/comedidev.h 
b/drivers/staging/comedi/comedidev.h
index 766387d..df0209a 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -442,7 +442,6 @@ unsigned int comedi_buf_read_alloc(struct comedi_subdevice 
*s, unsigned int n);
 unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n);
 
 int comedi_buf_put(struct comedi_subdevice *s, unsigned short x);
-int comedi_buf_get(struct comedi_subdevice *s, unsigned short *x);
 
 void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset,
  const void *source, unsigned int num_bytes);
-- 
2.0.3

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


[PATCH v2 15/18] staging: comedi: comedi_buf: dont't export comedi_buf_memcpy_from()

2014-10-22 Thread H Hartley Sweeten
This function is only used internally. Remove the export.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/comedi_buf.c | 6 +++---
 drivers/staging/comedi/comedidev.h  | 3 +--
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index f7ff420..a87b8e6 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -469,8 +469,9 @@ void comedi_buf_memcpy_to(struct comedi_subdevice *s, 
unsigned int offset,
 }
 EXPORT_SYMBOL_GPL(comedi_buf_memcpy_to);
 
-void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset,
-   void *dest, unsigned int nbytes)
+static void comedi_buf_memcpy_from(struct comedi_subdevice *s,
+  unsigned int offset,
+  void *dest, unsigned int nbytes)
 {
void *src;
struct comedi_async *async = s->async;
@@ -495,7 +496,6 @@ void comedi_buf_memcpy_from(struct comedi_subdevice *s, 
unsigned int offset,
read_ptr = 0;
}
 }
-EXPORT_SYMBOL_GPL(comedi_buf_memcpy_from);
 
 /**
  * comedi_write_array_to_buffer - write data to comedi buffer
diff --git a/drivers/staging/comedi/comedidev.h 
b/drivers/staging/comedi/comedidev.h
index df0209a..ce48828 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -445,8 +445,7 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned 
short x);
 
 void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset,
  const void *source, unsigned int num_bytes);
-void comedi_buf_memcpy_from(struct comedi_subdevice *s, unsigned int offset,
-   void *destination, unsigned int num_bytes);
+
 unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s,
  const void *data,
  unsigned int num_bytes);
-- 
2.0.3

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


[PATCH v2 07/18] staging: comedi: comedi_buf: remove export of comedi_read_array_from_buffer()

2014-10-22 Thread H Hartley Sweeten
This function is only used internally. Remove the export.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/comedi_buf.c | 17 +++--
 drivers/staging/comedi/comedidev.h  |  2 --
 2 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index 88a7cae..d1303a8 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -549,19 +549,9 @@ unsigned int comedi_write_array_to_buffer(struct 
comedi_subdevice *s,
 }
 EXPORT_SYMBOL_GPL(comedi_write_array_to_buffer);
 
-/**
- * comedi_read_array_from_buffer - read data from comedi buffer
- * @s: comedi_subdevice struct
- * @data: destination
- * @num_bytes: number of bytes to read
- *
- * Reads up to num_bytes bytes of data from the comedi buffer associated with
- * the subdevice, marks it as read and updates the acquisition scan progress.
- *
- * Returns the amount of data read in bytes.
- */
-unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s,
-  void *data, unsigned int num_bytes)
+static unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s,
+ void *data,
+ unsigned int num_bytes)
 {
if (num_bytes == 0)
return 0;
@@ -574,7 +564,6 @@ unsigned int comedi_read_array_from_buffer(struct 
comedi_subdevice *s,
 
return num_bytes;
 }
-EXPORT_SYMBOL_GPL(comedi_read_array_from_buffer);
 
 /**
  * comedi_buf_read_samples - read sample data from comedi buffer
diff --git a/drivers/staging/comedi/comedidev.h 
b/drivers/staging/comedi/comedidev.h
index ba4084b..766387d 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -451,8 +451,6 @@ void comedi_buf_memcpy_from(struct comedi_subdevice *s, 
unsigned int offset,
 unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s,
  const void *data,
  unsigned int num_bytes);
-unsigned int comedi_read_array_from_buffer(struct comedi_subdevice *s,
-  void *data, unsigned int num_bytes);
 unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
 void *data, unsigned int nsamples);
 
-- 
2.0.3

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


[PATCH v2 16/18] staging: comedi: comedi_buf: don't export comedi_buf_memcpy_to()

2014-10-22 Thread H Hartley Sweeten
This function is only used internally. Remove the export.

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

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index a87b8e6..0e4727d 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -442,8 +442,9 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned 
short x)
 }
 EXPORT_SYMBOL_GPL(comedi_buf_put);
 
-void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset,
- const void *data, unsigned int num_bytes)
+static void comedi_buf_memcpy_to(struct comedi_subdevice *s,
+unsigned int offset,
+const void *data, unsigned int num_bytes)
 {
struct comedi_async *async = s->async;
unsigned int write_ptr = async->buf_write_ptr + offset;
@@ -467,7 +468,6 @@ void comedi_buf_memcpy_to(struct comedi_subdevice *s, 
unsigned int offset,
write_ptr = 0;
}
 }
-EXPORT_SYMBOL_GPL(comedi_buf_memcpy_to);
 
 static void comedi_buf_memcpy_from(struct comedi_subdevice *s,
   unsigned int offset,
diff --git a/drivers/staging/comedi/comedidev.h 
b/drivers/staging/comedi/comedidev.h
index ce48828..9f4f9ef 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -443,9 +443,6 @@ unsigned int comedi_buf_read_free(struct comedi_subdevice 
*s, unsigned int n);
 
 int comedi_buf_put(struct comedi_subdevice *s, unsigned short x);
 
-void comedi_buf_memcpy_to(struct comedi_subdevice *s, unsigned int offset,
- const void *source, unsigned int num_bytes);
-
 unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s,
  const void *data,
  unsigned int num_bytes);
-- 
2.0.3

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


[PATCH v2 09/18] staging: comedi: comedi_buf: make comedi_buf_read_samples() always return full samples

2014-10-22 Thread H Hartley Sweeten
A number of drivers currently use comedi_buf_get() to read single samples
from the the async buffer. This works but the drivers have to handle the
COMEDI_CB_BLOCK and COMEDI_CB_EOS events. Converting those drivers to use
comedi_buf_read_samples() moves the handling of those events into the core.

Modify comedi_buf_read_samples() so that the async buffer is checked for
the number of full samples available. Use that to clamp the number of
samples that will be read. This makes sure that only full samples are
read from the async buffer making comedi_buf_read_samples() mimic the
action of comedi_buf_get() with the added benifit of handling the events.

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

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index 9074da2..fb2e91a 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -566,15 +566,15 @@ unsigned int comedi_buf_read_samples(struct 
comedi_subdevice *s,
unsigned int max_samples;
unsigned int nbytes;
 
-   max_samples = s->async->prealloc_bufsz / bytes_per_sample(s);
+   /* clamp nsamples to the number of full samples available */
+   max_samples = comedi_buf_read_n_available(s) / bytes_per_sample(s);
if (nsamples > max_samples)
nsamples = max_samples;
 
-   nbytes = nsamples * bytes_per_sample(s);
-   if (nbytes == 0)
+   if (nsamples == 0)
return 0;
 
-   nbytes = comedi_buf_read_alloc(s, nbytes);
+   nbytes = comedi_buf_read_alloc(s, nsamples * bytes_per_sample(s));
comedi_buf_memcpy_from(s, 0, data, nbytes);
comedi_buf_read_free(s, nbytes);
comedi_inc_scan_progress(s, nbytes);
-- 
2.0.3

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


[PATCH v2 10/18] staging: comedi: ni_mio_common: use comedi_buf_read_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_read_samples() to get the single samples from the async
buffer. The number of samples in the buffer was validated by the callers
so the error checking can be removed. In addition, the core will set the
COMEDI_CB_BLOCK event so it can also be removed.

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

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index 8ffcd2b..d7f6083 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1134,13 +1134,10 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
unsigned short d;
u32 packed_data;
int range;
-   int err = 1;
 
chan = async->cur_chan;
for (i = 0; i < n; i++) {
-   err &= comedi_buf_get(s, &d);
-   if (err == 0)
-   break;
+   comedi_buf_read_samples(s, &d, 1);
 
range = CR_RANGE(cmd->chanlist[chan]);
 
@@ -1148,9 +1145,7 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
packed_data = d & 0x;
/* 6711 only has 16 bit wide ao fifo */
if (!devpriv->is_6711) {
-   err &= comedi_buf_get(s, &d);
-   if (err == 0)
-   break;
+   comedi_buf_read_samples(s, &d, 1);
chan++;
i++;
packed_data |= (d << 16) & 0x;
@@ -1163,8 +1158,6 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
chan %= cmd->chanlist_len;
}
async->cur_chan = chan;
-   if (err == 0)
-   async->events |= COMEDI_CB_OVERFLOW;
 }
 
 /*
@@ -1201,8 +1194,6 @@ static int ni_ao_fifo_half_empty(struct comedi_device 
*dev,
 
ni_ao_fifo_load(dev, s, n);
 
-   s->async->events |= COMEDI_CB_BLOCK;
-
return 1;
 }
 
-- 
2.0.3

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


[PATCH v2 06/18] staging: comedi: comedi_fc.h: remove cfc_read_array_from_buffer()

2014-10-22 Thread H Hartley Sweeten
This inline function is no longer used. Remove it.

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

diff --git a/drivers/staging/comedi/drivers/comedi_fc.h 
b/drivers/staging/comedi/drivers/comedi_fc.h
index 0f4b360..fed0a54 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.h
+++ b/drivers/staging/comedi/drivers/comedi_fc.h
@@ -42,13 +42,6 @@ static inline unsigned int cfc_write_long_to_buffer(struct 
comedi_subdevice *s,
return comedi_write_array_to_buffer(s, &data, sizeof(data));
 };
 
-static inline unsigned int
-cfc_read_array_from_buffer(struct comedi_subdevice *s, void *data,
-  unsigned int num_bytes)
-{
-   return comedi_read_array_from_buffer(s, data, num_bytes);
-}
-
 /**
  * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source
  * @src: pointer to the trigger source to validate
-- 
2.0.3

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


[PATCH v2 05/18] staging: comedi: dt282x: introduce dt282x_ao_setup_dma()

2014-10-22 Thread H Hartley Sweeten
Introduce a helper function to read the analog output samples from the
async buffer and prep the DMA.

Use comedi_buf_read_samples() to read the analog output samples from
the async buffer.

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

diff --git a/drivers/staging/comedi/drivers/dt282x.c 
b/drivers/staging/comedi/drivers/dt282x.c
index f23d883..88b5610 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -449,13 +449,29 @@ static void dt282x_munge(struct comedi_device *dev,
}
 }
 
+static unsigned int dt282x_ao_setup_dma(struct comedi_device *dev,
+   struct comedi_subdevice *s,
+   int cur_dma)
+{
+   struct dt282x_private *devpriv = dev->private;
+   void *ptr = devpriv->dma[cur_dma].buf;
+   unsigned int nsamples = devpriv->dma_maxsize / bytes_per_sample(s);
+   unsigned int nbytes;
+
+   nbytes = comedi_buf_read_samples(s, ptr, nsamples);
+   if (nbytes)
+   dt282x_prep_ao_dma(dev, cur_dma, nbytes);
+   else
+   dev_err(dev->class_dev, "AO underrun\n");
+
+   return nbytes;
+}
+
 static void dt282x_ao_dma_interrupt(struct comedi_device *dev,
struct comedi_subdevice *s)
 {
struct dt282x_private *devpriv = dev->private;
int cur_dma = devpriv->current_dma_index;
-   void *ptr = devpriv->dma[cur_dma].buf;
-   int size;
 
outw(devpriv->supcsr | DT2821_SUPCSR_CLRDMADNE,
 dev->iobase + DT2821_SUPCSR_REG);
@@ -464,13 +480,8 @@ static void dt282x_ao_dma_interrupt(struct comedi_device 
*dev,
 
devpriv->current_dma_index = 1 - cur_dma;
 
-   size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize);
-   if (size == 0) {
-   dev_err(dev->class_dev, "AO underrun\n");
+   if (!dt282x_ao_setup_dma(dev, s, cur_dma))
s->async->events |= COMEDI_CB_OVERFLOW;
-   } else {
-   dt282x_prep_ao_dma(dev, cur_dma, size);
-   }
 }
 
 static void dt282x_ai_dma_interrupt(struct comedi_device *dev,
@@ -916,26 +927,15 @@ static int dt282x_ao_inttrig(struct comedi_device *dev,
 {
struct dt282x_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
-   int size;
 
if (trig_num != cmd->start_src)
return -EINVAL;
 
-   size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf,
- devpriv->dma_maxsize);
-   if (size == 0) {
-   dev_err(dev->class_dev, "AO underrun\n");
+   if (!dt282x_ao_setup_dma(dev, s, 0))
return -EPIPE;
-   }
-   dt282x_prep_ao_dma(dev, 0, size);
 
-   size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf,
- devpriv->dma_maxsize);
-   if (size == 0) {
-   dev_err(dev->class_dev, "AO underrun\n");
+   if (!dt282x_ao_setup_dma(dev, s, 1))
return -EPIPE;
-   }
-   dt282x_prep_ao_dma(dev, 1, size);
 
outw(devpriv->supcsr | DT2821_SUPCSR_STRIG,
 dev->iobase + DT2821_SUPCSR_REG);
-- 
2.0.3

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


[PATCH 04/10] staging: unisys: fix all logical continuation virthba

2014-10-22 Thread Erik Arfvidson
This patch fixes all logical continuations issues in virthba.c

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virthba/virthba.c | 42 
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index 1f19a98..02c7ac1 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -433,10 +433,10 @@ virthba_ISR(int irq, void *dev_id)
virthbainfo->interrupts_rcvd++;
pChannelHeader = virthbainfo->chinfo.queueinfo->chan;
if (((readq(&pChannelHeader->Features)
- & ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS) != 0)
-   && ((readq(&pChannelHeader->Features) &
-ULTRA_IO_DRIVER_DISABLES_INTS) !=
-   0)) {
+ &ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS) != 0) &
+   ((readq(&pChannelHeader->Features) &
+ ULTRA_IO_DRIVER_DISABLES_INTS) !=
+0)) {
virthbainfo->interrupts_disabled++;
mask = ~ULTRA_CHANNEL_ENABLE_INTS;
rc1 = uisqueue_interlocked_and(virthbainfo->flags_addr, mask);
@@ -810,9 +810,9 @@ virthba_abort_handler(struct scsi_cmnd *scsicmd)
scsidev = scsicmd->device;
for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
 vdisk->next; vdisk = vdisk->next) {
-   if ((scsidev->channel == vdisk->channel)
-   && (scsidev->id == vdisk->id)
-   && (scsidev->lun == vdisk->lun)) {
+   if ((scsidev->channel == vdisk->channel) &&
+   (scsidev->id == vdisk->id) &&
+   (scsidev->lun == vdisk->lun)) {
if (atomic_read(&vdisk->error_count) <
VIRTHBA_ERROR_COUNT) {
atomic_inc(&vdisk->error_count);
@@ -836,9 +836,9 @@ virthba_bus_reset_handler(struct scsi_cmnd *scsicmd)
scsidev = scsicmd->device;
for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
 vdisk->next; vdisk = vdisk->next) {
-   if ((scsidev->channel == vdisk->channel)
-   && (scsidev->id == vdisk->id)
-   && (scsidev->lun == vdisk->lun)) {
+   if ((scsidev->channel == vdisk->channel) &&
+   (scsidev->id == vdisk->id) &&
+   (scsidev->lun == vdisk->lun)) {
if (atomic_read(&vdisk->error_count) <
VIRTHBA_ERROR_COUNT) {
atomic_inc(&vdisk->error_count);
@@ -862,9 +862,9 @@ virthba_device_reset_handler(struct scsi_cmnd *scsicmd)
scsidev = scsicmd->device;
for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
 vdisk->next; vdisk = vdisk->next) {
-   if ((scsidev->channel == vdisk->channel)
-   && (scsidev->id == vdisk->id)
-   && (scsidev->lun == vdisk->lun)) {
+   if ((scsidev->channel == vdisk->channel) &&
+   (scsidev->id == vdisk->id) &&
+   (scsidev->lun == vdisk->lun)) {
if (atomic_read(&vdisk->error_count) <
VIRTHBA_ERROR_COUNT) {
atomic_inc(&vdisk->error_count);
@@ -1133,9 +1133,9 @@ do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct 
scsi_cmnd *scsicmd)
/* Okay see what our error_count is here */
for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
 vdisk->next; vdisk = vdisk->next) {
-   if ((scsidev->channel != vdisk->channel)
-   || (scsidev->id != vdisk->id)
-   || (scsidev->lun != vdisk->lun))
+   if ((scsidev->channel != vdisk->channel) ||
+   (scsidev->id != vdisk->id) ||
+   (scsidev->lun != vdisk->lun))
continue;
 
if (atomic_read(&vdisk->error_count) < VIRTHBA_ERROR_COUNT) {
@@ -1171,8 +1171,8 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct 
scsi_cmnd *scsicmd)
struct virtdisk_info *vdisk;
 
scsidev = scsicmd->device;
-   if ((cmdrsp->scsi.cmnd[0] == INQUIRY)
-   && (cmdrsp->scsi.bufflen >= MIN_INQUIRY_RESULT_LEN)) {
+   if ((cmdrsp->scsi.cmnd[0] == INQUIRY) &&
+   (cmdrsp->scsi.bufflen >= MIN_INQUIRY_RESULT_LEN)) {
if (cmdrsp->scsi.no_disk_result == 0)
return;
 
@@ -1211,9 +1211,9 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct 
scsi_cmnd *scsicmd)
} else {
vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
for ( ; vdisk->next; vdisk = vdisk->next) {
-   if ((scsidev->channel != vdisk->channel)
- 

[PATCH 05/10] staging: unisys: added spinlock comments visorchannel_funcs

2014-10-22 Thread Erik Arfvidson
This patch adds comment documentation to visorchannel_tag struct

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c 
b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
index 01a44c5..48e28e3 100644
--- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
+++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
@@ -34,8 +34,8 @@ struct VISORCHANNEL_Tag {
uuid_le guid;
ulong size;
BOOL needs_lock;
-   spinlock_t insert_lock;
-   spinlock_t remove_lock;
+   spinlock_t insert_lock; /* insert lock for visorchannel queue */
+   spinlock_t remove_lock; /* remove lock for visorchannel queue */
 
struct {
SIGNAL_QUEUE_HEADER req_queue;
-- 
1.9.1

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


[PATCH 03/10] staging: unisys: virthba fix all alingment issues

2014-10-22 Thread Erik Arfvidson
this patch fixes all aligment issues in virthba.c

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virthba/virthba.c | 82 
 1 file changed, 42 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index 35e17ee..1f19a98 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -110,9 +110,10 @@ static int virthba_serverdown(struct virtpci_dev 
*virtpcidev, u32 state);
 static void doDiskAddRemove(struct work_struct *work);
 static void virthba_serverdown_complete(struct work_struct *work);
 static ssize_t info_debugfs_read(struct file *file, char __user *buf,
-   size_t len, loff_t *offset);
+size_t len, loff_t *offset);
 static ssize_t enable_ints_write(struct file *file,
-   const char __user *buffer, size_t count, loff_t *ppos);
+const char __user *buffer, size_t count,
+loff_t *ppos);
 
 /*/
 /* Globals   */
@@ -263,7 +264,7 @@ add_scsipending_entry(struct virthba_info *vhbainfo, char 
cmdtype, void *new)
insert_location = (insert_location + 1) % MAX_PENDING_REQUESTS;
if (insert_location == (int)vhbainfo->nextinsert) {
LOGERR("Queue should be full. insert_location<<%d>>  
Unable to find open slot for pending commands.\n",
-insert_location);
+  insert_location);
spin_unlock_irqrestore(&vhbainfo->privlock, flags);
return -1;
}
@@ -301,13 +302,13 @@ del_scsipending_entry(struct virthba_info *vhbainfo, 
uintptr_t del)
 
if (del >= MAX_PENDING_REQUESTS) {
LOGERR("Invalid queue position <<%lu>> given to delete. 
MAX_PENDING_REQUESTS <<%d>>\n",
-(unsigned long)del, MAX_PENDING_REQUESTS);
+  (unsigned long)del, MAX_PENDING_REQUESTS);
} else {
spin_lock_irqsave(&vhbainfo->privlock, flags);
 
if (vhbainfo->pending[del].sent == NULL)
LOGERR("Deleting already cleared queue entry at 
<<%lu>>.\n",
-(unsigned long)del);
+  (unsigned long)del);
 
sent = vhbainfo->pending[del].sent;
 
@@ -357,8 +358,8 @@ SendDiskAddRemove(struct diskaddremove *dar)
dar->lun);
if (error)
LOGERR("Failed scsi_add_device: 
host_no=%d[chan=%d:id=%d:lun=%d]\n",
-dar->shost->host_no, dar->channel, dar->id,
-dar->lun);
+  dar->shost->host_no, dar->channel, dar->id,
+  dar->lun);
} else
LOGERR("Failed scsi_device_lookup:[chan=%d:id=%d:lun=%d]\n",
   dar->channel, dar->id, dar->lun);
@@ -408,8 +409,8 @@ process_disk_notify(struct Scsi_Host *shost, struct 
uiscmdrsp *cmdrsp)
QUEUE_DISKADDREMOVE(dar);
} else {
LOGERR("kmalloc failed for dar. 
host_no=%d[chan=%d:id=%d:lun=%d]\n",
-shost->host_no, cmdrsp->disknotify.channel,
-cmdrsp->disknotify.id, cmdrsp->disknotify.lun);
+  shost->host_no, cmdrsp->disknotify.channel,
+  cmdrsp->disknotify.id, cmdrsp->disknotify.lun);
}
 }
 
@@ -504,11 +505,11 @@ virthba_probe(struct virtpci_dev *virtpcidev, const 
struct pci_device_id *id)
 * the max-channel value.
 */
LOGINF("virtpcidev->scsi.max.max_channel=%u, max_id=%u, max_lun=%u, 
cmd_per_lun=%u, max_io_size=%u\n",
-(unsigned)virtpcidev->scsi.max.max_channel - 1,
-(unsigned)virtpcidev->scsi.max.max_id,
-(unsigned)virtpcidev->scsi.max.max_lun,
-(unsigned)virtpcidev->scsi.max.cmd_per_lun,
-(unsigned)virtpcidev->scsi.max.max_io_size);
+  (unsigned)virtpcidev->scsi.max.max_channel - 1,
+  (unsigned)virtpcidev->scsi.max.max_id,
+  (unsigned)virtpcidev->scsi.max.max_lun,
+  (unsigned)virtpcidev->scsi.max.cmd_per_lun,
+  (unsigned)virtpcidev->scsi.max.max_io_size);
scsihost->max_channel = (unsigned)virtpcidev->scsi.max.max_channel;
scsihost->max_id = (unsigned)virtpcidev->scsi.max.max_id;
scsihost->max_lun = (unsigned)virtpcidev->scsi.max.max_lun;
@@ -520,12 +521,12 @@ virthba_probe(struct virtpci_dev *virtpcidev, const 
struct pci_device_id *id)
if (scsihost->sg_tablesize > MAX_PHYS_INFO)
scsihost->sg_tablesize = MAX_PHYS_INFO;
LO

[PATCH 01/10] staging: unisys: fix blank lines virthba

2014-10-22 Thread Erik Arfvidson
This patch removes unnecessary blanks lines and adds necessary blank lines in 
virthba.

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virthba/virthba.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index e4130c9..e8868ae2 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -101,7 +101,6 @@ static DEF_SCSI_QCMD(virthba_queue_command)
 #define virthba_queue_command virthba_queue_command_lck
 #endif
 
-
 static int virthba_slave_alloc(struct scsi_device *scsidev);
 static int virthba_slave_configure(struct scsi_device *scsidev);
 static void virthba_slave_destroy(struct scsi_device *scsidev);
@@ -166,6 +165,7 @@ struct virtdisk_info {
atomic_t error_count;
struct virtdisk_info *next;
 };
+
 /* Each Scsi_Host has a host_data area that contains this struct. */
 struct virthba_info {
struct Scsi_Host *scsihost;
@@ -420,7 +420,9 @@ static irqreturn_t
 virthba_ISR(int irq, void *dev_id)
 {
struct virthba_info *virthbainfo = (struct virthba_info *) dev_id;
+
CHANNEL_HEADER __iomem *pChannelHeader;
+
SIGNAL_QUEUE_HEADER __iomem *pqhdr;
u64 mask;
unsigned long long rc1;
@@ -989,7 +991,6 @@ virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
sgl = scsi_sglist(scsicmd);
 
for_each_sg(sgl, sg, scsi_sg_count(scsicmd), i) {
-
cmdrsp->scsi.gpi_list[i].address = sg_phys(sg);
cmdrsp->scsi.gpi_list[i].length = sg->length;
if ((i != 0) && (sg->offset != 0))
@@ -1207,7 +1208,6 @@ do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct 
scsi_cmnd *scsicmd)
bufind += sg[i].length;
}
} else {
-
vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
for ( ; vdisk->next; vdisk = vdisk->next) {
if ((scsidev->channel != vdisk->channel)
@@ -1323,7 +1323,6 @@ drain_queue(struct virthba_info *virthbainfo, struct 
chaninfo *dc,
}
 }
 
-
 /* main function for the thread that waits for scsi commands to arrive
  * in a specified queue
  */
@@ -1657,7 +1656,6 @@ virthba_mod_init(void)
POSTCODE_LINUX_3(VHBA_CREATE_FAILURE_PC, error,
 POSTCODE_SEVERITY_ERR);
} else {
-
/* create the debugfs directories and entries */
virthba_debugfs_dir = debugfs_create_dir("virthba", NULL);
debugfs_create_file("info", S_IRUSR, virthba_debugfs_dir,
@@ -1748,7 +1746,6 @@ virthba_mod_exit(void)
 
debugfs_remove_recursive(virthba_debugfs_dir);
LOGINF("Leaving virthba_mod_exit\n");
-
 }
 
 /* specify function to be run at module insertion time */
-- 
1.9.1

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


[PATCH 02/10] staging: unisys: virthba fix all spaces after cast

2014-10-22 Thread Erik Arfvidson
This patch fixes all spaces after cast for virthba

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/virthba/virthba.c | 130 +++
 1 file changed, 65 insertions(+), 65 deletions(-)

diff --git a/drivers/staging/unisys/virthba/virthba.c 
b/drivers/staging/unisys/virthba/virthba.c
index e8868ae2..35e17ee 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -261,7 +261,7 @@ add_scsipending_entry(struct virthba_info *vhbainfo, char 
cmdtype, void *new)
insert_location = vhbainfo->nextinsert;
while (vhbainfo->pending[insert_location].sent != NULL) {
insert_location = (insert_location + 1) % MAX_PENDING_REQUESTS;
-   if (insert_location == (int) vhbainfo->nextinsert) {
+   if (insert_location == (int)vhbainfo->nextinsert) {
LOGERR("Queue should be full. insert_location<<%d>>  
Unable to find open slot for pending commands.\n",
 insert_location);
spin_unlock_irqrestore(&vhbainfo->privlock, flags);
@@ -290,7 +290,7 @@ add_scsipending_entry_with_wait(struct virthba_info 
*vhbainfo, char cmdtype,
insert_location = add_scsipending_entry(vhbainfo, cmdtype, new);
}
 
-   return (unsigned int) insert_location;
+   return (unsigned int)insert_location;
 }
 
 static void *
@@ -301,13 +301,13 @@ del_scsipending_entry(struct virthba_info *vhbainfo, 
uintptr_t del)
 
if (del >= MAX_PENDING_REQUESTS) {
LOGERR("Invalid queue position <<%lu>> given to delete. 
MAX_PENDING_REQUESTS <<%d>>\n",
-(unsigned long) del, MAX_PENDING_REQUESTS);
+(unsigned long)del, MAX_PENDING_REQUESTS);
} else {
spin_lock_irqsave(&vhbainfo->privlock, flags);
 
if (vhbainfo->pending[del].sent == NULL)
LOGERR("Deleting already cleared queue entry at 
<<%lu>>.\n",
-(unsigned long) del);
+(unsigned long)del);
 
sent = vhbainfo->pending[del].sent;
 
@@ -419,7 +419,7 @@ process_disk_notify(struct Scsi_Host *shost, struct 
uiscmdrsp *cmdrsp)
 static irqreturn_t
 virthba_ISR(int irq, void *dev_id)
 {
-   struct virthba_info *virthbainfo = (struct virthba_info *) dev_id;
+   struct virthba_info *virthbainfo = (struct virthba_info *)dev_id;
 
CHANNEL_HEADER __iomem *pChannelHeader;
 
@@ -445,7 +445,7 @@ virthba_ISR(int irq, void *dev_id)
return IRQ_NONE;
}
pqhdr = (SIGNAL_QUEUE_HEADER __iomem *)
-   ((char __iomem *) pChannelHeader +
+   ((char __iomem *)pChannelHeader +
 readq(&pChannelHeader->oChannelSpace)) + IOCHAN_FROM_IOPART;
writeq(readq(&pqhdr->NumInterruptsReceived) + 1,
   &pqhdr->NumInterruptsReceived);
@@ -504,19 +504,19 @@ virthba_probe(struct virtpci_dev *virtpcidev, const 
struct pci_device_id *id)
 * the max-channel value.
 */
LOGINF("virtpcidev->scsi.max.max_channel=%u, max_id=%u, max_lun=%u, 
cmd_per_lun=%u, max_io_size=%u\n",
-(unsigned) virtpcidev->scsi.max.max_channel - 1,
-(unsigned) virtpcidev->scsi.max.max_id,
-(unsigned) virtpcidev->scsi.max.max_lun,
-(unsigned) virtpcidev->scsi.max.cmd_per_lun,
-(unsigned) virtpcidev->scsi.max.max_io_size);
-   scsihost->max_channel = (unsigned) virtpcidev->scsi.max.max_channel;
-   scsihost->max_id = (unsigned) virtpcidev->scsi.max.max_id;
-   scsihost->max_lun = (unsigned) virtpcidev->scsi.max.max_lun;
-   scsihost->cmd_per_lun = (unsigned) virtpcidev->scsi.max.cmd_per_lun;
+(unsigned)virtpcidev->scsi.max.max_channel - 1,
+(unsigned)virtpcidev->scsi.max.max_id,
+(unsigned)virtpcidev->scsi.max.max_lun,
+(unsigned)virtpcidev->scsi.max.cmd_per_lun,
+(unsigned)virtpcidev->scsi.max.max_io_size);
+   scsihost->max_channel = (unsigned)virtpcidev->scsi.max.max_channel;
+   scsihost->max_id = (unsigned)virtpcidev->scsi.max.max_id;
+   scsihost->max_lun = (unsigned)virtpcidev->scsi.max.max_lun;
+   scsihost->cmd_per_lun = (unsigned)virtpcidev->scsi.max.cmd_per_lun;
scsihost->max_sectors =
-   (unsigned short) (virtpcidev->scsi.max.max_io_size >> 9);
+   (unsigned short)(virtpcidev->scsi.max.max_io_size >> 9);
scsihost->sg_tablesize =
-   (unsigned short) (virtpcidev->scsi.max.max_io_size / PAGE_SIZE);
+   (unsigned short)(virtpcidev->scsi.max.max_io_size / PAGE_SIZE);
if (scsihost->sg_tablesize > MAX_PHYS_INFO)
scsihost->sg_tablesize = MAX_PHYS_INFO;
LOGINF("scsihost->max_channel=%u, max_id=%u, max_lun=%llu, 
cmd_per_lun=%u, max_sectors=%hu, sg_tablesize=%hu\n",
@@ -547,7 +547,7 @

[PATCH 09/10] staging: unisys: remove unnecessary blank line in visorchannel_funcs

2014-10-22 Thread Erik Arfvidson
this patch removes unnecessary blank line in visorchannel_funcs

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c 
b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
index b04d113..7cd5e5b 100644
--- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
+++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
@@ -498,7 +498,6 @@ Away:
 }
 EXPORT_SYMBOL_GPL(visorchannel_signalinsert);
 
-
 int
 visorchannel_signalqueue_slots_avail(VISORCHANNEL *channel, u32 queue)
 {
-- 
1.9.1

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


[PATCH 10/10] staging: unisys: fixed braces check in visorchannel_funcs

2014-10-22 Thread Erik Arfvidson
this patch adds braces to an else statement to remove check in
checkpatch.pl for visorchannel_funcs.c

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c 
b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
index 7cd5e5b..d8d224c 100644
--- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
+++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
@@ -584,8 +584,9 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues,
if (off == 0) {
phdr = &channel->chan_hdr;
seq_puts(seq, "(following data may be stale)\n");
-   } else
+   } else {
return;
+   }
}
nbytes = (ulong)(phdr->Size);
seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes 
(region=0x%lx bytes) ---\n",
-- 
1.9.1

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


[PATCH 07/10] staging: unisys: fixed logical continuation visorchannel_funcs

2014-10-22 Thread Erik Arfvidson
this patch fixes a logical continuation check in visorchannel

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c 
b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
index dbdf1ed..cf1a4d5 100644
--- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
+++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
@@ -382,8 +382,8 @@ safe_sig_queue_validate(pSIGNAL_QUEUE_HEADER psafe_sqh,
pSIGNAL_QUEUE_HEADER punsafe_sqh,
u32 *phead, u32 *ptail)
 {
-   if ((*phead >= psafe_sqh->MaxSignalSlots)
-   || (*ptail >= psafe_sqh->MaxSignalSlots)) {
+   if ((*phead >= psafe_sqh->MaxSignalSlots) ||
+   (*ptail >= psafe_sqh->MaxSignalSlots)) {
/* Choose 0 or max, maybe based on current tail value */
*phead = 0;
*ptail = 0;
-- 
1.9.1

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


[PATCH 08/10] staging: unisys: fixed aligment in visorchannel_funcs

2014-10-22 Thread Erik Arfvidson
this patch fixes aligment for visorchanne_funcs

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
---
 drivers/staging/unisys/visorchannel/visorchannel_funcs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c 
b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
index cf1a4d5..b04d113 100644
--- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
+++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
@@ -393,7 +393,7 @@ safe_sig_queue_validate(pSIGNAL_QUEUE_HEADER psafe_sqh,
punsafe_sqh->Tail = *ptail;
 
ERRDRV("safe_sig_queue_validate: head = 0x%x, tail = 0x%x, 
MaxSlots = 0x%x",
-*phead, *ptail, psafe_sqh->MaxSignalSlots);
+  *phead, *ptail, psafe_sqh->MaxSignalSlots);
return 0;
}
return 1;
-- 
1.9.1

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


Re: [PATCH net] hyperv: Fix the total_data_buflen in send path

2014-10-22 Thread David Miller
From: Haiyang Zhang 
Date: Wed, 22 Oct 2014 13:47:18 -0700

> total_data_buflen is used by netvsc_send() to decide if a packet can be put
> into send buffer. It should also include the size of RNDIS message before the
> Ethernet frame. Otherwise, a messge with total size bigger than 
> send_section_size
> may be copied into the send buffer, and cause data corruption.
> 
> [Request to include this patch to the Stable branches]
> 
> Signed-off-by: Haiyang Zhang 
> Reviewed-by: K. Y. Srinivasan 

Applied and queued up for -stable, thanks.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/10] staging: unisys: remove all unnecessary space after cast visorchannel_funcs

2014-10-22 Thread Erik Arfvidson
This patch removes all unnecessary spaces after cast for visorchannel_funcs

Signed-off-by: Erik Arfvidson 
Signed-off-by: Benjamin Romer 
---
 .../unisys/visorchannel/visorchannel_funcs.c   | 61 +++---
 1 file changed, 31 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c 
b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
index 48e28e3..dbdf1ed 100644
--- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
+++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
@@ -89,7 +89,7 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong 
channelBytes,
}
if (channelBytes == 0)
/* we had better be a CLIENT of this channel */
-   channelBytes = (ulong) p->chan_hdr.Size;
+   channelBytes = (ulong)p->chan_hdr.Size;
if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
/* we had better be a CLIENT of this channel */
guid = p->chan_hdr.Type;
@@ -283,7 +283,7 @@ EXPORT_SYMBOL_GPL(visorchannel_clear);
 void __iomem  *
 visorchannel_get_header(VISORCHANNEL *channel)
 {
-   return (void __iomem *) &(channel->chan_hdr);
+   return (void __iomem *)&channel->chan_hdr;
 }
 EXPORT_SYMBOL_GPL(visorchannel_get_header);
 
@@ -328,7 +328,8 @@ sig_read_header(VISORCHANNEL *channel, u32 queue,
 sig_hdr, sizeof(SIGNAL_QUEUE_HEADER)) < 0) {
ERRDRV("queue=%d SIG_QUEUE_OFFSET=%d",
   queue, (int)SIG_QUEUE_OFFSET(&channel->chan_hdr, queue));
-   ERRDRV("visor_memregion_read of signal queue failed: 
(status=%d)\n", rc);
+   ERRDRV("visor_memregion_read of signal queue failed: 
(status=%d)\n",
+  rc);
goto Away;
}
rc = TRUE;
@@ -513,7 +514,7 @@ visorchannel_signalqueue_slots_avail(VISORCHANNEL *channel, 
u32 queue)
head = head + sig_hdr.MaxSignalSlots;
slots_used = (head - tail);
slots_avail = sig_hdr.MaxSignals - slots_used;
-   return (int) slots_avail;
+   return (int)slots_avail;
 }
 EXPORT_SYMBOL_GPL(visorchannel_signalqueue_slots_avail);
 
@@ -524,7 +525,7 @@ visorchannel_signalqueue_max_slots(VISORCHANNEL *channel, 
u32 queue)
 
if (!sig_read_header(channel, queue, &sig_hdr))
return 0;
-   return (int) sig_hdr.MaxSignals;
+   return (int)sig_hdr.MaxSignals;
 }
 EXPORT_SYMBOL_GPL(visorchannel_signalqueue_max_slots);
 
@@ -532,24 +533,24 @@ static void
 sigqueue_debug(SIGNAL_QUEUE_HEADER *q, int which, struct seq_file *seq)
 {
seq_printf(seq, "Signal Queue #%d\n", which);
-   seq_printf(seq, "   VersionId  = %lu\n", (ulong) q->VersionId);
-   seq_printf(seq, "   Type   = %lu\n", (ulong) q->Type);
+   seq_printf(seq, "   VersionId  = %lu\n", (ulong)q->VersionId);
+   seq_printf(seq, "   Type   = %lu\n", (ulong)q->Type);
seq_printf(seq, "   oSignalBase= %llu\n",
-  (long long) q->oSignalBase);
-   seq_printf(seq, "   SignalSize = %lu\n", (ulong) q->SignalSize);
+  (long long)q->oSignalBase);
+   seq_printf(seq, "   SignalSize = %lu\n", (ulong)q->SignalSize);
seq_printf(seq, "   MaxSignalSlots = %lu\n",
-  (ulong) q->MaxSignalSlots);
-   seq_printf(seq, "   MaxSignals = %lu\n", (ulong) q->MaxSignals);
+  (ulong)q->MaxSignalSlots);
+   seq_printf(seq, "   MaxSignals = %lu\n", (ulong)q->MaxSignals);
seq_printf(seq, "   FeatureFlags   = %-16.16Lx\n",
-  (long long) q->FeatureFlags);
+  (long long)q->FeatureFlags);
seq_printf(seq, "   NumSignalsSent = %llu\n",
-  (long long) q->NumSignalsSent);
+  (long long)q->NumSignalsSent);
seq_printf(seq, "   NumSignalsReceived = %llu\n",
-  (long long) q->NumSignalsReceived);
+  (long long)q->NumSignalsReceived);
seq_printf(seq, "   NumOverflows   = %llu\n",
-  (long long) q->NumOverflows);
-   seq_printf(seq, "   Head   = %lu\n", (ulong) q->Head);
-   seq_printf(seq, "   Tail   = %lu\n", (ulong) q->Tail);
+  (long long)q->NumOverflows);
+   seq_printf(seq, "   Head   = %lu\n", (ulong)q->Head);
+   seq_printf(seq, "   Tail   = %lu\n", (ulong)q->Tail);
 }
 
 void
@@ -587,28 +588,28 @@ visorchannel_debug(VISORCHANNEL *channel, int nQueues,
} else
return;
}
-   nbytes = (ulong) (phdr->Size);
+   nbytes = (ulong)(phdr->Size);
seq_printf(seq, "--- Begin channel @0x%-16.16Lx for 0x%lx bytes 
(region=0x%lx bytes) ---\n",
   addr + off, nbytes, nbytes_region);
seq_printf(seq, "Type= %pU

[PATCH 07/55] staging: comedi: ni_labpc_common: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the
single sample to the async buffer.

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

diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c 
b/drivers/staging/comedi/drivers/ni_labpc_common.c
index 72dc786..6852203 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_common.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_common.c
@@ -818,7 +818,7 @@ static int labpc_drain_fifo(struct comedi_device *dev)
devpriv->count--;
}
data = labpc_read_adc_fifo(dev);
-   cfc_write_to_buffer(dev->read_subdev, data);
+   comedi_buf_write_samples(dev->read_subdev, &data, 1);
devpriv->stat1 = devpriv->read_byte(dev, STAT1_REG);
}
if (i == timeout) {
-- 
2.0.3

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


[PATCH 15/55] staging: comedi: adl_pci9111: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
The number of bytes to add is determined automatically based on the
number of samples and the bytes_per_sample().

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

diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c 
b/drivers/staging/comedi/drivers/adl_pci9111.c
index 076866e..18f5f7f 100644
--- a/drivers/staging/comedi/drivers/adl_pci9111.c
+++ b/drivers/staging/comedi/drivers/adl_pci9111.c
@@ -477,9 +477,8 @@ static void pci9111_handle_fifo_half_full(struct 
comedi_device *dev,
 devpriv->ai_bounce_buffer, samples);
 
if (devpriv->scan_delay < 1) {
-   total = cfc_write_array_to_buffer(s,
- devpriv->ai_bounce_buffer,
- samples * sizeof(short));
+   total = comedi_buf_write_samples(s, devpriv->ai_bounce_buffer,
+samples);
} else {
unsigned int pos = 0;
unsigned int to_read;
@@ -492,9 +491,9 @@ static void pci9111_handle_fifo_half_full(struct 
comedi_device *dev,
if (to_read > samples - pos)
to_read = samples - pos;
 
-   total += cfc_write_array_to_buffer(s,
+   total += comedi_buf_write_samples(s,
devpriv->ai_bounce_buffer + pos,
-   to_read * sizeof(short));
+   to_read);
} else {
to_read = devpriv->chunk_num_samples -
  devpriv->chunk_counter;
-- 
2.0.3

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


[PATCH 04/55] staging: comedi: das800: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the
single sample to the async buffer.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event from the driver.

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

diff --git a/drivers/staging/comedi/drivers/das800.c 
b/drivers/staging/comedi/drivers/das800.c
index e284d20..6013099 100644
--- a/drivers/staging/comedi/drivers/das800.c
+++ b/drivers/staging/comedi/drivers/das800.c
@@ -511,12 +511,11 @@ static irqreturn_t das800_interrupt(int irq, void *d)
 
/* if there are more data points to collect */
if (cmd->stop_src == TRIG_NONE || devpriv->count > 0) {
-   /* write data point to buffer */
-   cfc_write_to_buffer(s, val & s->maxdata);
+   val &= s->maxdata;
+   comedi_buf_write_samples(s, &val, 1);
devpriv->count--;
}
}
-   async->events |= COMEDI_CB_BLOCK;
 
if (fifo_overflow) {
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
-- 
2.0.3

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


[PATCH 01/55] staging: comedi: comedi_buf: introduce comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Introduce a generic method to write samples to the async buffer.

The number of samples is first checked against the number of samples that
would fill the async buffer. The size of each sample is determined using
the bytes_per_sample() helper. If all the samples will fit in the async
buffer they are written to the buffer using comedi_write_array_to_buffer().

This will allow converting all the comedi drivers to use a common method to
write data to the async buffer.

Since comedi_write_array_to_buffer() sets the COMEDI_CB_BLOCK event after
writing the data, those events can be removed from the drivers.

In addition, comedi_inc_scan_progress() will automatically detect the end of
scan and set the COMEDI_CB_EOS event. Those events can also be removed from
the drivers.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/comedi_buf.c | 31 +++
 drivers/staging/comedi/comedidev.h  |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index 1f91607..a41a414 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -528,6 +528,37 @@ unsigned int comedi_write_array_to_buffer(struct 
comedi_subdevice *s,
 EXPORT_SYMBOL_GPL(comedi_write_array_to_buffer);
 
 /**
+ * comedi_buf_write_samples - write sample data to comedi buffer
+ * @s: comedi_subdevice struct
+ * @data: samples
+ * @nsamples: number of samples
+ *
+ * Writes nsamples to the comedi buffer associated with the subdevice, marks
+ * it as written and updates the acquisition scan progress.
+ *
+ * Returns the amount of data written in bytes.
+ */
+unsigned int comedi_buf_write_samples(struct comedi_subdevice *s,
+ const void *data, unsigned int nsamples)
+{
+   unsigned int max_samples;
+   unsigned int nbytes;
+
+   /* make sure there is enought room in the buffer for all the samples */
+   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;
+   }
+
+   nbytes = nsamples * bytes_per_sample(s);
+
+   return comedi_write_array_to_buffer(s, data, nbytes);
+}
+EXPORT_SYMBOL_GPL(comedi_buf_write_samples);
+
+/**
  * comedi_buf_read_samples - read sample data from comedi buffer
  * @s: comedi_subdevice struct
  * @data: destination
diff --git a/drivers/staging/comedi/comedidev.h 
b/drivers/staging/comedi/comedidev.h
index 9f4f9ef..eee4dd4 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -446,6 +446,8 @@ int comedi_buf_put(struct comedi_subdevice *s, unsigned 
short x);
 unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s,
  const void *data,
  unsigned int num_bytes);
+unsigned int comedi_buf_write_samples(struct comedi_subdevice *s,
+ const void *data, unsigned int nsamples);
 unsigned int comedi_buf_read_samples(struct comedi_subdevice *s,
 void *data, unsigned int nsamples);
 
-- 
2.0.3

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


[PATCH 02/55] staging: comedi: comedi_fc.h: remove cfc_write_long_to_buffer()

2014-10-22 Thread H Hartley Sweeten
The inline function is not used. Remove it.

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

diff --git a/drivers/staging/comedi/drivers/comedi_fc.h 
b/drivers/staging/comedi/drivers/comedi_fc.h
index fed0a54..de9331c 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.h
+++ b/drivers/staging/comedi/drivers/comedi_fc.h
@@ -36,12 +36,6 @@ static inline unsigned int cfc_write_to_buffer(struct 
comedi_subdevice *s,
return comedi_write_array_to_buffer(s, &data, sizeof(data));
 };
 
-static inline unsigned int cfc_write_long_to_buffer(struct comedi_subdevice *s,
-   unsigned int data)
-{
-   return comedi_write_array_to_buffer(s, &data, sizeof(data));
-};
-
 /**
  * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source
  * @src: pointer to the trigger source to validate
-- 
2.0.3

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


[PATCH 19/55] staging: comedi: dt282x: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will determining the number of bytes to add based on the
bytes_per_sample().

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

diff --git a/drivers/staging/comedi/drivers/dt282x.c 
b/drivers/staging/comedi/drivers/dt282x.c
index 88b5610..1d9fa37 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -491,6 +491,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device 
*dev,
int cur_dma = devpriv->current_dma_index;
void *ptr = devpriv->dma[cur_dma].buf;
int size = devpriv->dma[cur_dma].size;
+   unsigned int nsamples = size / bytes_per_sample(s);
int ret;
 
outw(devpriv->supcsr | DT2821_SUPCSR_CLRDMADNE,
@@ -501,13 +502,11 @@ static void dt282x_ai_dma_interrupt(struct comedi_device 
*dev,
devpriv->current_dma_index = 1 - cur_dma;
 
dt282x_munge(dev, s, ptr, size);
-   ret = cfc_write_array_to_buffer(s, ptr, size);
-   if (ret != size) {
-   s->async->events |= COMEDI_CB_OVERFLOW;
+   ret = comedi_buf_write_samples(s, ptr, nsamples);
+   if (ret != size)
return;
-   }
 
-   devpriv->nread -= size / 2;
+   devpriv->nread -= nsamples;
if (devpriv->nread < 0) {
dev_info(dev->class_dev, "nread off by one\n");
devpriv->nread = 0;
@@ -566,7 +565,6 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
}
 #if 0
if (adcsr & DT2821_ADCSR_ADDONE) {
-   int ret;
unsigned short data;
 
data = inw(dev->iobase + DT2821_ADDAT_REG);
@@ -574,10 +572,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d)
if (devpriv->ad_2scomp)
data = comedi_offset_munge(s, data);
 
-   ret = comedi_buf_put(s, data);
-
-   if (ret == 0)
-   s->async->events |= COMEDI_CB_OVERFLOW;
+   comedi_buf_write_samples(s, &data, 1);
 
devpriv->nread--;
if (!devpriv->nread) {
-- 
2.0.3

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


[PATCH 10/55] staging: comedi: cb_pcidas: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle single and multi samples writes by determining
the number of bytes to add based on the number of samples and the
bytes_per_sample().

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

diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c 
b/drivers/staging/comedi/drivers/cb_pcidas.c
index a0d462f..53afae093 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -1359,8 +1359,7 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
}
insw(devpriv->adc_fifo + ADCDATA, devpriv->ai_buffer,
 num_samples);
-   cfc_write_array_to_buffer(s, devpriv->ai_buffer,
- num_samples * sizeof(short));
+   comedi_buf_write_samples(s, devpriv->ai_buffer, num_samples);
devpriv->count -= num_samples;
if (cmd->stop_src == TRIG_COUNT && devpriv->count == 0)
async->events |= COMEDI_CB_EOA;
@@ -1372,11 +1371,14 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
/*  else if fifo not empty */
} else if (status & (ADNEI | EOBI)) {
for (i = 0; i < timeout; i++) {
+   unsigned short val;
+
/*  break if fifo is empty */
if ((ADNE & inw(devpriv->control_status +
INT_ADCFIFO)) == 0)
break;
-   cfc_write_to_buffer(s, inw(devpriv->adc_fifo));
+   val = inw(devpriv->adc_fifo);
+   comedi_buf_write_samples(s, &val, 1);
if (cmd->stop_src == TRIG_COUNT &&
--devpriv->count == 0) {
/* end of acquisition */
-- 
2.0.3

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


[PATCH 14/55] staging: comedi: comedi_fc.h: remove cfc_write_to_buffer()

2014-10-22 Thread H Hartley Sweeten
The inline function is no longer used. Remove it.

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

diff --git a/drivers/staging/comedi/drivers/comedi_fc.h 
b/drivers/staging/comedi/drivers/comedi_fc.h
index de9331c..8ecb6bc 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.h
+++ b/drivers/staging/comedi/drivers/comedi_fc.h
@@ -30,12 +30,6 @@ static inline unsigned int cfc_write_array_to_buffer(struct 
comedi_subdevice *s,
return comedi_write_array_to_buffer(s, data, num_bytes);
 }
 
-static inline unsigned int cfc_write_to_buffer(struct comedi_subdevice *s,
-  unsigned short data)
-{
-   return comedi_write_array_to_buffer(s, &data, sizeof(data));
-};
-
 /**
  * cfc_check_trigger_src() - trivially validate a comedi_cmd trigger source
  * @src: pointer to the trigger source to validate
-- 
2.0.3

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


[PATCH 16/55] staging: comedi: hwdrv_apci3120: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle the '* sizeof(foo)' calculation to determine
the number of bytes to add.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 10deb72..4959fc6 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1172,7 +1172,7 @@ static void v_APCI3120_InterruptDmaMoveBlock16bit(struct 
comedi_device *dev,
s->async->cur_chan += num_samples;
s->async->cur_chan %= cmd->scan_end_arg;
 
-   cfc_write_array_to_buffer(s, dma_buffer, num_samples * sizeof(short));
+   comedi_buf_write_samples(s, dma_buffer, num_samples);
 }
 
 /*
-- 
2.0.3

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


[PATCH 03/55] staging: comedi: comedi_test: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the
single sample to the async buffer.

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

diff --git a/drivers/staging/comedi/drivers/comedi_test.c 
b/drivers/staging/comedi/drivers/comedi_test.c
index 8845075..f2d7580 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -204,7 +204,7 @@ static void waveform_ai_interrupt(unsigned long arg)
   devpriv->usec_current +
   i * devpriv->scan_period +
   j * devpriv->convert_period);
-   cfc_write_to_buffer(s, sample);
+   comedi_buf_write_samples(s, &sample, 1);
}
}
 
-- 
2.0.3

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


[PATCH 08/55] staging: comedi: ni_labpc_isadma: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add all
the samples to the async buffer in one operation.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event in the driver.

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

diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c 
b/drivers/staging/comedi/drivers/ni_labpc_isadma.c
index 967202e..6d38605 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c
@@ -91,7 +91,6 @@ void labpc_drain_dma(struct comedi_device *dev)
int status;
unsigned long flags;
unsigned int max_points, num_points, residue, leftover;
-   int i;
 
status = devpriv->stat1;
 
@@ -122,9 +121,7 @@ void labpc_drain_dma(struct comedi_device *dev)
leftover = max_points;
}
 
-   /* write data to comedi buffer */
-   for (i = 0; i < num_points; i++)
-   cfc_write_to_buffer(s, devpriv->dma_buffer[i]);
+   comedi_buf_write_samples(s, devpriv->dma_buffer, num_points);
 
if (cmd->stop_src == TRIG_COUNT)
devpriv->count -= num_points;
@@ -133,8 +130,6 @@ void labpc_drain_dma(struct comedi_device *dev)
set_dma_addr(devpriv->dma_chan, devpriv->dma_addr);
set_dma_count(devpriv->dma_chan, leftover * sample_size);
release_dma_lock(flags);
-
-   async->events |= COMEDI_CB_BLOCK;
 }
 EXPORT_SYMBOL_GPL(labpc_drain_dma);
 
-- 
2.0.3

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


[PATCH 13/55] staging: comedi: ni_mio_common: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle single and multi sample writes by determining
the number of bytes to add based on the bytes_per_sample().

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

diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c 
b/drivers/staging/comedi/drivers/ni_mio_common.c
index d7f6083..37ab22f 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -1228,44 +1228,42 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
 {
struct ni_private *devpriv = dev->private;
struct comedi_async *async = s->async;
+   u32 dl;
+   unsigned short data;
int i;
 
if (devpriv->is_611x) {
-   unsigned short data[2];
-   u32 dl;
-
for (i = 0; i < n / 2; i++) {
dl = ni_readl(dev, ADC_FIFO_Data_611x);
/* This may get the hi/lo data in the wrong order */
-   data[0] = (dl >> 16) & 0x;
-   data[1] = dl & 0x;
-   cfc_write_array_to_buffer(s, data, sizeof(data));
+   data = (dl >> 16) & 0x;
+   comedi_buf_write_samples(s, &data, 1);
+   data = dl & 0x;
+   comedi_buf_write_samples(s, &data, 1);
}
/* Check if there's a single sample stuck in the FIFO */
if (n % 2) {
dl = ni_readl(dev, ADC_FIFO_Data_611x);
-   data[0] = dl & 0x;
-   cfc_write_to_buffer(s, data[0]);
+   data = dl & 0x;
+   comedi_buf_write_samples(s, &data, 1);
}
} else if (devpriv->is_6143) {
-   unsigned short data[2];
-   u32 dl;
-
/*  This just reads the FIFO assuming the data is present, no 
checks on the FIFO status are performed */
for (i = 0; i < n / 2; i++) {
dl = ni_readl(dev, AIFIFO_Data_6143);
 
-   data[0] = (dl >> 16) & 0x;
-   data[1] = dl & 0x;
-   cfc_write_array_to_buffer(s, data, sizeof(data));
+   data = (dl >> 16) & 0x;
+   comedi_buf_write_samples(s, &data, 1);
+   data = dl & 0x;
+   comedi_buf_write_samples(s, &data, 1);
}
if (n % 2) {
/* Assume there is a single sample stuck in the FIFO */
/* Get stranded sample into FIFO */
ni_writel(dev, 0x01, AIFIFO_Control_6143);
dl = ni_readl(dev, AIFIFO_Data_6143);
-   data[0] = (dl >> 16) & 0x;
-   cfc_write_to_buffer(s, data[0]);
+   data = (dl >> 16) & 0x;
+   comedi_buf_write_samples(s, &data, 1);
}
} else {
if (n > sizeof(devpriv->ai_fifo_buffer) /
@@ -1279,9 +1277,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
devpriv->ai_fifo_buffer[i] =
ni_readw(dev, ADC_FIFO_Data_Register);
}
-   cfc_write_array_to_buffer(s, devpriv->ai_fifo_buffer,
- n *
- sizeof(devpriv->ai_fifo_buffer[0]));
+   comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, n);
}
 }
 
@@ -1304,8 +1300,8 @@ static void ni_handle_fifo_dregs(struct comedi_device 
*dev)
 {
struct ni_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
-   unsigned short data[2];
u32 dl;
+   unsigned short data;
unsigned short fifo_empty;
int i;
 
@@ -1315,9 +1311,10 @@ static void ni_handle_fifo_dregs(struct comedi_device 
*dev)
dl = ni_readl(dev, ADC_FIFO_Data_611x);
 
/* This may get the hi/lo data in the wrong order */
-   data[0] = (dl >> 16);
-   data[1] = (dl & 0x);
-   cfc_write_array_to_buffer(s, data, sizeof(data));
+   data = dl >> 16;
+   comedi_buf_write_samples(s, &data, 1);
+   data = dl & 0x;
+   comedi_buf_write_samples(s, &data, 1);
}
} else if (devpriv->is_6143) {
i = 0;
@@ -1325,9 +1322,10 @@ static void ni_handle_fifo_dregs(struct comedi_device 
*dev)
dl = ni_readl(de

[PATCH 09/55] staging: comedi: das1800: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer. That
function will handle single and multi samples writes by determining the number
of bytes to add based on the number of samples and the bytes_per_sample().

Also, remove the unnecessary COMEDI_CB_BLOCK event. comedi_buf_write_samples()
will automatically add that event after adding the samples to the async
buffer.

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

diff --git a/drivers/staging/comedi/drivers/das1800.c 
b/drivers/staging/comedi/drivers/das1800.c
index 7b0b65e..246a186 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -488,8 +488,7 @@ static void das1800_handle_fifo_half_full(struct 
comedi_device *dev,
numPoints = devpriv->count;
insw(dev->iobase + DAS1800_FIFO, devpriv->ai_buf0, numPoints);
munge_data(dev, devpriv->ai_buf0, numPoints);
-   cfc_write_array_to_buffer(s, devpriv->ai_buf0,
- numPoints * sizeof(devpriv->ai_buf0[0]));
+   comedi_buf_write_samples(s, devpriv->ai_buf0, numPoints);
if (cmd->stop_src == TRIG_COUNT)
devpriv->count -= numPoints;
 }
@@ -512,7 +511,7 @@ static void das1800_handle_fifo_not_empty(struct 
comedi_device *dev,
if (!unipolar)
;
dpnt = munge_bipolar_sample(dev, dpnt);
-   cfc_write_to_buffer(s, dpnt);
+   comedi_buf_write_samples(s, &dpnt, 1);
if (cmd->stop_src == TRIG_COUNT)
devpriv->count--;
}
@@ -543,7 +542,7 @@ static void das1800_flush_dma_channel(struct comedi_device 
*dev,
num_samples = devpriv->count;
 
munge_data(dev, buffer, num_samples);
-   cfc_write_array_to_buffer(s, buffer, num_bytes);
+   comedi_buf_write_samples(s, buffer, num_samples);
if (cmd->stop_src == TRIG_COUNT)
devpriv->count -= num_samples;
 }
@@ -649,7 +648,6 @@ static void das1800_ai_handler(struct comedi_device *dev)
das1800_handle_fifo_not_empty(dev, s);
}
 
-   async->events |= COMEDI_CB_BLOCK;
/* if the card's fifo has overflowed */
if (status & OVF) {
/*  clear OVF interrupt bit */
-- 
2.0.3

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


[PATCH 22/55] staging: comedi: usbduxfast: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will determining the number of bytes to add based on the
bytes_per_sample().

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

diff --git a/drivers/staging/comedi/drivers/usbduxfast.c 
b/drivers/staging/comedi/drivers/usbduxfast.c
index 95c2ec7..70ec2f5 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/staging/comedi/drivers/usbduxfast.c
@@ -249,19 +249,17 @@ static void usbduxfast_ai_handle_urb(struct comedi_device 
*dev,
devpriv->ignore--;
} else {
unsigned int nbytes = urb->actual_length;
+   unsigned int nsamples = nbytes / bytes_per_sample(s);
 
if (cmd->stop_src == TRIG_COUNT) {
-   unsigned int nsamples = nbytes / bytes_per_sample(s);
-
if (devpriv->ai_sample_count < nsamples) {
nsamples = devpriv->ai_sample_count;
async->events |= COMEDI_CB_EOA;
}
devpriv->ai_sample_count -= nsamples;
-   nbytes = nsamples * bytes_per_sample(s);
}
 
-   cfc_write_array_to_buffer(s, urb->transfer_buffer, nbytes);
+   comedi_buf_write_samples(s, urb->transfer_buffer, nsamples);
}
 
/* if command is still running, resubmit urb for BULK transfer */
-- 
2.0.3

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


[PATCH 11/55] staging: comedi: adl_pci9118: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
The number of bytes to add is determined automatically based on the
number of samples and the bytes_per_sample().

Change the return type of move_block_from_dma() to void and remove the
unnecessary check of the return value of comedi_buf_write_samples().
The callers don't check the return and it's really not necessary. If
comedi_buf_write_samples() fails to allocate enough space in the async
buffer to add all the samples it sets the COMEDI_CB_OVERFLOW event.
This will cause the async command to (*cancel) when the events are
handled.

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

diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index 7b1720f..cb2c485 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -472,26 +472,21 @@ static unsigned int defragment_dma_buffer(struct 
comedi_device *dev,
return j;
 }
 
-static int move_block_from_dma(struct comedi_device *dev,
-  struct comedi_subdevice *s,
-  unsigned short *dma_buffer,
-  unsigned int num_samples)
+static void move_block_from_dma(struct comedi_device *dev,
+   struct comedi_subdevice *s,
+   unsigned short *dma_buffer,
+   unsigned int num_samples)
 {
struct pci9118_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
-   unsigned int num_bytes;
 
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;
-   num_bytes =
-   cfc_write_array_to_buffer(s, dma_buffer,
- num_samples * sizeof(short));
-   if (num_bytes < num_samples * sizeof(short))
-   return -1;
-   return 0;
+
+   comedi_buf_write_samples(s, dma_buffer, num_samples);
 }
 
 static void pci9118_exttrg_enable(struct comedi_device *dev, bool enable)
@@ -617,7 +612,7 @@ static void interrupt_pci9118_ai_onesample(struct 
comedi_device *dev,
 
sampl = inl(dev->iobase + PCI9118_AI_FIFO_REG);
 
-   cfc_write_to_buffer(s, sampl);
+   comedi_buf_write_samples(s, &sampl, 1);
s->async->cur_chan++;
if (s->async->cur_chan >= cmd->scan_end_arg) {
/* one scan done */
-- 
2.0.3

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


[PATCH 32/55] staging: comedi: dt3000: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

The core will set the COMEDi_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event from the driver.

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

diff --git a/drivers/staging/comedi/drivers/dt3000.c 
b/drivers/staging/comedi/drivers/dt3000.c
index 6544f44..c2058ba 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -315,7 +315,7 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev,
 
for (i = 0; i < count; i++) {
data = readw(dev->mmio + DPR_ADC_buffer + rear);
-   comedi_buf_put(s, data);
+   comedi_buf_write_samples(s, &data, 1);
rear++;
if (rear >= AI_FIFO_DEPTH)
rear = 0;
@@ -351,10 +351,8 @@ static irqreturn_t dt3k_interrupt(int irq, void *d)
 
status = readw(dev->mmio + DPR_Intr_Flag);
 
-   if (status & DT3000_ADFULL) {
+   if (status & DT3000_ADFULL)
dt3k_ai_empty_fifo(dev, s);
-   s->async->events |= COMEDI_CB_BLOCK;
-   }
 
if (status & (DT3000_ADSWERR | DT3000_ADHWERR))
s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
-- 
2.0.3

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


[PATCH 17/55] staging: comedi: das16m1: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
The number of bytes to add is determined automatically based on the
number of samples and the bytes_per_sample().

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

diff --git a/drivers/staging/comedi/drivers/das16m1.c 
b/drivers/staging/comedi/drivers/das16m1.c
index f98bcbe..54ccffc 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -442,8 +442,7 @@ static void das16m1_handler(struct comedi_device *dev, 
unsigned int status)
num_samples = FIFO_SIZE;
insw(dev->iobase, devpriv->ai_buffer, num_samples);
munge_sample_array(devpriv->ai_buffer, num_samples);
-   cfc_write_array_to_buffer(s, devpriv->ai_buffer,
- num_samples * sizeof(short));
+   comedi_buf_write_samples(s, devpriv->ai_buffer, num_samples);
devpriv->adc_count += num_samples;
 
if (cmd->stop_src == TRIG_COUNT) {
-- 
2.0.3

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


[PATCH 30/55] staging: comedi: comedi_parport: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set
by the core. Remove the unnecessary events in the driver.

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

diff --git a/drivers/staging/comedi/drivers/comedi_parport.c 
b/drivers/staging/comedi/drivers/comedi_parport.c
index 0bc3844..3bac903 100644
--- a/drivers/staging/comedi/drivers/comedi_parport.c
+++ b/drivers/staging/comedi/drivers/comedi_parport.c
@@ -225,10 +225,9 @@ static irqreturn_t parport_interrupt(int irq, void *d)
if (!(ctrl & PARPORT_CTRL_IRQ_ENA))
return IRQ_NONE;
 
-   comedi_buf_put(s, 0);
-   s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
-
+   comedi_buf_write_samples(s, &s->state, 1);
comedi_handle_events(dev, s);
+
return IRQ_HANDLED;
 }
 
-- 
2.0.3

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


[PATCH 40/55] staging: comedi: pcl816: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event in the driver.

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

diff --git a/drivers/staging/comedi/drivers/pcl816.c 
b/drivers/staging/comedi/drivers/pcl816.c
index 65cbafb..a471c3d 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -289,8 +289,6 @@ static bool pcl816_ai_next_chan(struct comedi_device *dev,
struct pcl816_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
 
-   s->async->events |= COMEDI_CB_BLOCK;
-
s->async->cur_chan++;
if (s->async->cur_chan >= cmd->chanlist_len) {
s->async->cur_chan = 0;
@@ -313,10 +311,12 @@ static void transfer_from_dma_buf(struct comedi_device 
*dev,
  unsigned short *ptr,
  unsigned int bufptr, unsigned int len)
 {
+   unsigned short val;
int i;
 
for (i = 0; i < len; i++) {
-   comedi_buf_put(s, ptr[bufptr++]);
+   val = ptr[bufptr++];
+   comedi_buf_write_samples(s, &val, 1);
 
if (!pcl816_ai_next_chan(dev, s))
return;
-- 
2.0.3

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


[PATCH 31/55] staging: comedi: dmm32at: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

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

diff --git a/drivers/staging/comedi/drivers/dmm32at.c 
b/drivers/staging/comedi/drivers/dmm32at.c
index 7e69d31..fc2c0db 100644
--- a/drivers/staging/comedi/drivers/dmm32at.c
+++ b/drivers/staging/comedi/drivers/dmm32at.c
@@ -501,7 +501,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d)
 
/* invert sign bit to make range unsigned */
samp = ((msb ^ 0x0080) << 8) + lsb;
-   comedi_buf_put(s, samp);
+   comedi_buf_write_samples(s, &samp, 1);
}
 
if (devpriv->ai_scans_left != 0x) { /* TRIG_COUNT */
-- 
2.0.3

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


[PATCH 20/55] staging: comedi: gsc_hpdi: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle the '* sizeof(foo)' calculation to determine
the number of bytes to add.

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

diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c 
b/drivers/staging/comedi/drivers/gsc_hpdi.c
index e99edaa..58a99e8 100644
--- a/drivers/staging/comedi/drivers/gsc_hpdi.c
+++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
@@ -196,8 +196,8 @@ static void gsc_hpdi_drain_dma(struct comedi_device *dev, 
unsigned int channel)
size = devpriv->dio_count;
devpriv->dio_count -= size;
}
-   cfc_write_array_to_buffer(s, devpriv->desc_dio_buffer[idx],
- size * sizeof(uint32_t));
+   comedi_buf_write_samples(s, devpriv->desc_dio_buffer[idx],
+size);
idx++;
idx %= devpriv->num_dma_descriptors;
start = le32_to_cpu(devpriv->dma_desc[idx].pci_start_addr);
-- 
2.0.3

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


[PATCH 34/55] staging: comedi: ni_6527: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_EOS will automatically be set by the core
with the end-of-scan is detected. Remove the unnecessary event in the
driver.

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

diff --git a/drivers/staging/comedi/drivers/ni_6527.c 
b/drivers/staging/comedi/drivers/ni_6527.c
index b35e1ae..f99847f 100644
--- a/drivers/staging/comedi/drivers/ni_6527.c
+++ b/drivers/staging/comedi/drivers/ni_6527.c
@@ -208,8 +208,7 @@ static irqreturn_t ni6527_interrupt(int irq, void *d)
return IRQ_NONE;
 
if (status & NI6527_STATUS_EDGE) {
-   comedi_buf_put(s, 0);
-   s->async->events |= COMEDI_CB_EOS;
+   comedi_buf_write_samples(s, &s->state, 1);
comedi_handle_events(dev, s);
}
 
-- 
2.0.3

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


[PATCH 18/55] staging: comedi: das16: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will determining the number of bytes to add based on the
bytes_per_sample().

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

diff --git a/drivers/staging/comedi/drivers/das16.c 
b/drivers/staging/comedi/drivers/das16.c
index 5d47d0a..aa9e3e1 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -541,6 +541,7 @@ static void das16_interrupt(struct comedi_device *dev)
struct comedi_cmd *cmd = &async->cmd;
unsigned long spin_flags;
unsigned long dma_flags;
+   unsigned int nsamples;
int num_bytes, residue;
int buffer_index;
 
@@ -583,8 +584,9 @@ static void das16_interrupt(struct comedi_device *dev)
 
spin_unlock_irqrestore(&dev->spinlock, spin_flags);
 
-   cfc_write_array_to_buffer(s,
- devpriv->dma_buffer[buffer_index], num_bytes);
+   nsamples = num_bytes / bytes_per_sample(s);
+   comedi_buf_write_samples(s, devpriv->dma_buffer[buffer_index],
+nsamples);
 
comedi_handle_events(dev, s);
 }
-- 
2.0.3

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


[PATCH 21/55] staging: comedi: usbduxsigma: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the sample to the async buffer.
That function will determining the number of bytes to add based on the
bytes_per_sample().

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c 
b/drivers/staging/comedi/drivers/usbduxsigma.c
index de3fb41..7b7698c 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -245,8 +245,7 @@ static void usbduxsigma_ai_handle_urb(struct comedi_device 
*dev,
val &= 0x00ff;  /* strip status byte */
val ^= 0x0080;  /* convert to unsigned */
 
-   if (!cfc_write_array_to_buffer(s, &val,
-  sizeof(uint32_t)))
+   if (!comedi_buf_write_samples(s, &val, 1))
return;
}
}
-- 
2.0.3

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


[PATCH 49/55] staging: comedi: ni_pcidio: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the sample to the async buffer. The 32-bit
sample size is automatically determined due to the subddev_flag SDF_LSAMPL.

The async event COMEDI_CB_BLOCK will be automatically set by the core. Remove 
the
unnecessary event in the driver.

This driver also has the SDF_PACKED subdev_flag set so the core will 
automatically
set the COMEDI_CB_EOS event after adding the sample.

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

diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c 
b/drivers/staging/comedi/drivers/ni_pcidio.c
index 0bb7763..db7e8aa 100644
--- a/drivers/staging/comedi/drivers/ni_pcidio.c
+++ b/drivers/staging/comedi/drivers/ni_pcidio.c
@@ -384,11 +384,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
struct comedi_subdevice *s = dev->read_subdev;
struct comedi_async *async = s->async;
struct mite_struct *mite = devpriv->mite;
-
-   /* int i, j; */
-   unsigned int auxdata = 0;
-   unsigned short data1 = 0;
-   unsigned short data2 = 0;
+   unsigned int auxdata;
int flags;
int status;
int work = 0;
@@ -451,13 +447,9 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
goto out;
}
auxdata = readl(dev->mmio + Group_1_FIFO);
-   data1 = auxdata & 0x;
-   data2 = (auxdata & 0x) >> 16;
-   comedi_buf_put(s, data1);
-   comedi_buf_put(s, data2);
+   comedi_buf_write_samples(s, &auxdata, 1);
flags = readb(dev->mmio + Group_1_Flags);
}
-   async->events |= COMEDI_CB_BLOCK;
}
 
if (flags & CountExpired) {
-- 
2.0.3

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


[PATCH 29/55] staging: comedi: amplc_pci230: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events will set properly by the core. A dev_warn() message will
also be output by the core if the buffer overflows. Remove the unnecessary
events and dev_err() message in the driver.

The core will also add the COMEDI_CB_BLOCK event when data is written to
the async buffer. Remove the unnecessary event in the driver.

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

diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c 
b/drivers/staging/comedi/drivers/amplc_pci230.c
index f9b952f..44c967f 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -2053,6 +2053,7 @@ static void pci230_handle_ai(struct comedi_device *dev,
unsigned int i;
unsigned int todo;
unsigned int fifoamount;
+   unsigned short val;
 
/* Determine number of samples to read. */
if (cmd->stop_src != TRIG_COUNT) {
@@ -2099,12 +2100,10 @@ static void pci230_handle_ai(struct comedi_device *dev,
fifoamount = 1;
}
}
-   /* Read sample and store in Comedi's circular buffer. */
-   if (comedi_buf_put(s, pci230_ai_read(dev)) == 0) {
-   events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
-   dev_err(dev->class_dev, "AI buffer overflow\n");
-   break;
-   }
+
+   val = pci230_ai_read(dev);
+   comedi_buf_write_samples(s, &val, 1);
+
fifoamount--;
devpriv->ai_scan_pos++;
if (devpriv->ai_scan_pos == scanlen) {
@@ -2117,9 +2116,6 @@ static void pci230_handle_ai(struct comedi_device *dev,
if (cmd->stop_src == TRIG_COUNT && devpriv->ai_scan_count == 0) {
/* End of acquisition. */
events |= COMEDI_CB_EOA;
-   } else {
-   /* More samples required, tell Comedi to block. */
-   events |= COMEDI_CB_BLOCK;
}
async->events |= events;
if (!(async->events & COMEDI_CB_CANCEL_MASK)) {
-- 
2.0.3

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


[PATCH 25/55] staging: comedi: addi_apci_1564: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set
by the core. Remove the unnecessary events in the driver.

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

diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c 
b/drivers/staging/comedi/drivers/addi_apci_1564.c
index 3395d7f..18865d7 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1564.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1564.c
@@ -147,8 +147,7 @@ static irqreturn_t apci1564_interrupt(int irq, void *d)
 
s->state = inl(dev->iobase + APCI1564_DI_INT_STATUS_REG)
   & 0x;
-   comedi_buf_put(s, s->state);
-   s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
+   comedi_buf_write_samples(s, &s->state, 1);
comedi_handle_events(dev, s);
 
/* enable the interrupt */
-- 
2.0.3

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


[PATCH 38/55] staging: comedi: pcl726: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events will set properly by the core. Remove the unnecessary
events in the driver.

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

diff --git a/drivers/staging/comedi/drivers/pcl726.c 
b/drivers/staging/comedi/drivers/pcl726.c
index be43cda..a1ac567 100644
--- a/drivers/staging/comedi/drivers/pcl726.c
+++ b/drivers/staging/comedi/drivers/pcl726.c
@@ -235,8 +235,7 @@ static irqreturn_t pcl726_interrupt(int irq, void *d)
if (devpriv->cmd_running) {
pcl726_intr_cancel(dev, s);
 
-   comedi_buf_put(s, 0);
-   s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
+   comedi_buf_write_samples(s, &s->state, 1);
comedi_handle_events(dev, s);
}
 
-- 
2.0.3

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


[PATCH 24/55] staging: comedi: addi_apci_1032: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set
by the core. Remove the unnecessary events in the driver.

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

diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c 
b/drivers/staging/comedi/drivers/addi_apci_1032.c
index 12601a9..bf14165 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1032.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1032.c
@@ -258,8 +258,7 @@ static irqreturn_t apci1032_interrupt(int irq, void *d)
outl(ctrl & ~APCI1032_CTRL_INT_ENA, dev->iobase + APCI1032_CTRL_REG);
 
s->state = inl(dev->iobase + APCI1032_STATUS_REG) & 0x;
-   comedi_buf_put(s, s->state);
-   s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
+   comedi_buf_write_samples(s, &s->state, 1);
comedi_handle_events(dev, s);
 
/* enable the interrupt */
-- 
2.0.3

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


[PATCH 26/55] staging: comedi: addi_apci_3xxx: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

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

diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c 
b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
index fe9ac2d..db3ee9c 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
@@ -371,7 +371,7 @@ static irqreturn_t apci3xxx_irq_handler(int irq, void *d)
writel(status, dev->mmio + 16);
 
val = readl(dev->mmio + 28);
-   comedi_buf_put(s, val);
+   comedi_buf_write_samples(s, &val, 1);
 
s->async->events |= COMEDI_CB_EOA;
comedi_handle_events(dev, s);
-- 
2.0.3

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


[PATCH 12/55] staging: comedi: cb_pcidas64: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.
That function will handle single and multi samples writes by determining
the number of bytes to add based on the bytes_per_sample().

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

diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c 
b/drivers/staging/comedi/drivers/cb_pcidas64.c
index 06e846f..9196680 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -2689,9 +2689,10 @@ static void pio_drain_ai_fifo_16(struct comedi_device 
*dev)
}
 
for (i = 0; i < num_samples; i++) {
-   cfc_write_to_buffer(s,
-   readw(devpriv->main_iobase +
- ADC_FIFO_REG));
+   unsigned short val;
+
+   val = readw(devpriv->main_iobase + ADC_FIFO_REG);
+   comedi_buf_write_samples(s, &val, 1);
}
 
} while (read_segment != write_segment);
@@ -2722,11 +2723,15 @@ static void pio_drain_ai_fifo_32(struct comedi_device 
*dev)
 
}
for (i = 0; read_code != write_code && i < max_transfer;) {
+   unsigned short val;
+
fifo_data = readl(dev->mmio + ADC_FIFO_REG);
-   cfc_write_to_buffer(s, fifo_data & 0x);
+   val = fifo_data & 0x;
+   comedi_buf_write_samples(s, &val, 1);
i++;
if (i < max_transfer) {
-   cfc_write_to_buffer(s, (fifo_data >> 16) & 0x);
+   val = (fifo_data >> 16) & 0x;
+   comedi_buf_write_samples(s, &val, 1);
i++;
}
read_code = readw(devpriv->main_iobase + ADC_READ_PNTR_REG) &
@@ -2778,10 +2783,9 @@ static void drain_dma_buffers(struct comedi_device *dev, 
unsigned int channel)
num_samples = devpriv->ai_count;
devpriv->ai_count -= num_samples;
}
-   cfc_write_array_to_buffer(dev->read_subdev,
- devpriv->ai_buffer[devpriv->
-ai_dma_index],
- num_samples * sizeof(uint16_t));
+   comedi_buf_write_samples(dev->read_subdev,
+   devpriv->ai_buffer[devpriv->ai_dma_index],
+   num_samples);
devpriv->ai_dma_index = (devpriv->ai_dma_index + 1) %
ai_dma_ring_count(thisboard);
}
-- 
2.0.3

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


[PATCH 36/55] staging: comedi: ni_atmio16d: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
For aesthetics, use comedi_buf_write_samples() to add the sample to
the async buffer.

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

diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c 
b/drivers/staging/comedi/drivers/ni_atmio16d.c
index 24f8bca..2bac693 100644
--- a/drivers/staging/comedi/drivers/ni_atmio16d.c
+++ b/drivers/staging/comedi/drivers/ni_atmio16d.c
@@ -217,10 +217,12 @@ static irqreturn_t atmio16d_interrupt(int irq, void *d)
 {
struct comedi_device *dev = d;
struct comedi_subdevice *s = dev->read_subdev;
+   unsigned short val;
 
-   comedi_buf_put(s, inw(dev->iobase + AD_FIFO_REG));
-
+   val = inw(dev->iobase + AD_FIFO_REG);
+   comedi_buf_write_samples(s, &val, 1);
comedi_handle_events(dev, s);
+
return IRQ_HANDLED;
 }
 
-- 
2.0.3

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


[PATCH 47/55] staging: comedi: addi_apci_2032: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
The dev->read_subdev used in this driver for async commands returns the
full scan with each sample so it should have the SDF_PACKED subdev_flag
set.

Add the missing subdev_flags and use comedi_buf_write_samples() to add
the sample to the async buffer.

The core sets the async events appropriately. Remove the unnecessary
event handling in the driver.

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

diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c 
b/drivers/staging/comedi/drivers/addi_apci_2032.c
index ad75294..7a5659f 100644
--- a/drivers/staging/comedi/drivers/addi_apci_2032.c
+++ b/drivers/staging/comedi/drivers/addi_apci_2032.c
@@ -211,8 +211,7 @@ static irqreturn_t apci2032_interrupt(int irq, void *d)
bits |= (1 << i);
}
 
-   if (comedi_buf_put(s, bits)) {
-   s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
+   if (comedi_buf_write_samples(s, &bits, 1)) {
if (cmd->stop_src == TRIG_COUNT &&
subpriv->stop_count > 0) {
subpriv->stop_count--;
@@ -221,8 +220,6 @@ static irqreturn_t apci2032_interrupt(int irq, void *d)
s->async->events |= COMEDI_CB_EOA;
}
}
-   } else {
-   s->async->events |= COMEDI_CB_OVERFLOW;
}
}
 
@@ -299,7 +296,7 @@ static int apci2032_auto_attach(struct comedi_device *dev,
return -ENOMEM;
spin_lock_init(&subpriv->spinlock);
s->private  = subpriv;
-   s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
+   s->subdev_flags = SDF_READABLE | SDF_CMD_READ | SDF_PACKED;
s->len_chanlist = 2;
s->do_cmdtest   = apci2032_int_cmdtest;
s->do_cmd   = apci2032_int_cmd;
-- 
2.0.3

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


[PATCH 33/55] staging: comedi: me4000: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_OVERFLOW will be set by the core if the async
buffer overflows. A dev_warn() message will also be output by the core
if the buffer overflows. Remove the unnecessary event and the dev_err()
messages in the driver.

The core will also add the COMEDI_CB_BLOCK event when data is written
to the async buffer. Remove these unnecessary events from the driver.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 6516ac0..97a0674 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -1092,8 +1092,6 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
} else if ((tmp & ME4000_AI_STATUS_BIT_FF_DATA)
   && !(tmp & ME4000_AI_STATUS_BIT_HF_DATA)
   && (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
-   s->async->events |= COMEDI_CB_BLOCK;
-
c = ME4000_AI_FIFO_COUNT / 2;
} else {
dev_err(dev->class_dev,
@@ -1119,7 +1117,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0x;
lval ^= 0x8000;
 
-   if (!comedi_buf_put(s, lval)) {
+   if (!comedi_buf_write_samples(s, &lval, 1)) {
/*
 * Buffer overflow, so stop conversion
 * and disable all interrupts
@@ -1128,11 +1126,6 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
 ME4000_AI_CTRL_BIT_SC_IRQ);
outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
-
-   s->async->events |= COMEDI_CB_OVERFLOW;
-
-   dev_err(dev->class_dev, "Buffer overflow\n");
-
break;
}
}
@@ -1146,7 +1139,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
 
if (inl(dev->iobase + ME4000_IRQ_STATUS_REG) &
ME4000_IRQ_STATUS_BIT_SC) {
-   s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOA;
+   s->async->events |= COMEDI_CB_EOA;
 
/*
 * Acquisition is complete, so stop
@@ -1164,11 +1157,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0x;
lval ^= 0x8000;
 
-   if (!comedi_buf_put(s, lval)) {
-   dev_err(dev->class_dev, "Buffer overflow\n");
-   s->async->events |= COMEDI_CB_OVERFLOW;
+   if (!comedi_buf_write_samples(s, &lval, 1))
break;
-   }
}
 
/* Work is done, so reset the interrupt */
-- 
2.0.3

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


[PATCH 05/55] staging: comedi: ni_at_a2150: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() instead of cfc_write_to_buffer() to add the
single sample to the async buffer.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event in the driver.

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

diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c 
b/drivers/staging/comedi/drivers/ni_at_a2150.c
index f1fe9ef..5c17def 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -237,7 +237,7 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
dpnt = devpriv->dma_buffer[i];
/*  convert from 2's complement to unsigned coding */
dpnt ^= 0x8000;
-   cfc_write_to_buffer(s, dpnt);
+   comedi_buf_write_samples(s, &dpnt, 1);
if (cmd->stop_src == TRIG_COUNT) {
if (--devpriv->count == 0) {/* end of acquisition */
async->events |= COMEDI_CB_EOA;
@@ -253,8 +253,6 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
}
release_dma_lock(flags);
 
-   async->events |= COMEDI_CB_BLOCK;
-
comedi_handle_events(dev, s);
 
/* clear interrupt */
-- 
2.0.3

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


[PATCH 52/55] staging: comedi: comedi_buf: remove comedi_buf_put()

2014-10-22 Thread H Hartley Sweeten
All comedi drivers now use comedi_buf_write_samples() to add the samples to
the async buffer. Remove this unused function.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/comedi/comedi_buf.c | 15 ---
 drivers/staging/comedi/comedidev.h  |  2 --
 2 files changed, 17 deletions(-)

diff --git a/drivers/staging/comedi/comedi_buf.c 
b/drivers/staging/comedi/comedi_buf.c
index a41a414..f4b75d1 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -427,21 +427,6 @@ unsigned int comedi_buf_read_free(struct comedi_subdevice 
*s,
 }
 EXPORT_SYMBOL_GPL(comedi_buf_read_free);
 
-int comedi_buf_put(struct comedi_subdevice *s, unsigned short x)
-{
-   struct comedi_async *async = s->async;
-   unsigned int n = __comedi_buf_write_alloc(s, sizeof(short), 1);
-
-   if (n < sizeof(short)) {
-   async->events |= COMEDI_CB_ERROR;
-   return 0;
-   }
-   *(unsigned short *)(async->prealloc_buf + async->buf_write_ptr) = x;
-   comedi_buf_write_free(s, sizeof(short));
-   return 1;
-}
-EXPORT_SYMBOL_GPL(comedi_buf_put);
-
 static void comedi_buf_memcpy_to(struct comedi_subdevice *s,
 const void *data, unsigned int num_bytes)
 {
diff --git a/drivers/staging/comedi/comedidev.h 
b/drivers/staging/comedi/comedidev.h
index eee4dd4..d60b83c 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -441,8 +441,6 @@ unsigned int comedi_buf_read_n_available(struct 
comedi_subdevice *s);
 unsigned int comedi_buf_read_alloc(struct comedi_subdevice *s, unsigned int n);
 unsigned int comedi_buf_read_free(struct comedi_subdevice *s, unsigned int n);
 
-int comedi_buf_put(struct comedi_subdevice *s, unsigned short x);
-
 unsigned int comedi_write_array_to_buffer(struct comedi_subdevice *s,
  const void *data,
  unsigned int num_bytes);
-- 
2.0.3

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


[PATCH 50/55] staging: comedi: pcmmio: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
The dev->read_subdev used in this driver for async commands returns 32-bit 
samples
and should have the SDF_LSAMPL subdev_flag set. It also returns the full scan 
with
each sample so it should have the SDF_PACKED subdev_flag set.

Add the missing subdev_flags and use comedi_buf_write_samples() to add the 
sample
to the async buffer.

The COMEDI_CB_BLOCK and COMEDI_CB_EOS events will be automatically handled by 
the
core. Remove the unnecessary events in the driver.

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

diff --git a/drivers/staging/comedi/drivers/pcmmio.c 
b/drivers/staging/comedi/drivers/pcmmio.c
index 6d60d40..df47967 100644
--- a/drivers/staging/comedi/drivers/pcmmio.c
+++ b/drivers/staging/comedi/drivers/pcmmio.c
@@ -356,10 +356,7 @@ static void pcmmio_handle_dio_intr(struct comedi_device 
*dev,
val |= (1 << i);
}
 
-   /* Write the scan to the buffer. */
-   if (comedi_buf_put(s, val) &&
-   comedi_buf_put(s, val >> 16))
-   s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
+   comedi_buf_write_samples(s, &val, 1);
 
/* Check for end of acquisition. */
if (cmd->stop_src == TRIG_COUNT && devpriv->stop_count > 0) {
@@ -764,7 +761,7 @@ static int pcmmio_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
s->insn_config  = pcmmio_dio_insn_config;
if (dev->irq) {
dev->read_subdev = s;
-   s->subdev_flags |= SDF_CMD_READ;
+   s->subdev_flags |= SDF_CMD_READ | SDF_LSAMPL | SDF_PACKED;
s->len_chanlist = s->n_chan;
s->cancel   = pcmmio_cancel;
s->do_cmd   = pcmmio_cmd;
-- 
2.0.3

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


[PATCH 48/55] staging: comedi: amplc_dio200_common: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
The dev->read_subdev used in this driver for async commands returns the
full scan with each sample so it should have the SDF_PACKED subdev_flag
set.

Add the missing subdev_flags and use comedi_buf_write_samples() to add
the sample to the async buffer.

The async events will set properly by the core. A dev_warn() message will
also be output by the core if the buffer overflows. Remove the unnecessary
events and dev_err() message in the driver.

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

diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c 
b/drivers/staging/comedi/drivers/amplc_dio200_common.c
index 944d454..c306226 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_common.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c
@@ -267,14 +267,8 @@ static void dio200_read_scan_intr(struct comedi_device 
*dev,
if (triggered & (1U << ch))
val |= (1U << n);
}
-   /* Write the scan to the buffer. */
-   if (comedi_buf_put(s, val)) {
-   s->async->events |= (COMEDI_CB_BLOCK | COMEDI_CB_EOS);
-   } else {
-   /* Error!  Stop acquisition.  */
-   s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
-   dev_err(dev->class_dev, "buffer overflow\n");
-   }
+
+   comedi_buf_write_samples(s, &val, 1);
 
/* Check for end of acquisition. */
if (cmd->stop_src == TRIG_COUNT) {
@@ -463,7 +457,7 @@ static int dio200_subdev_intr_init(struct comedi_device 
*dev,
dio200_write8(dev, subpriv->ofs, 0);
 
s->type = COMEDI_SUBD_DI;
-   s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
+   s->subdev_flags = SDF_READABLE | SDF_CMD_READ | SDF_PACKED;
if (board->has_int_sce) {
s->n_chan = DIO200_MAX_ISNS;
s->len_chanlist = DIO200_MAX_ISNS;
-- 
2.0.3

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


[PATCH 45/55] staging: comedi: hwdrv_apci3120: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the samples to the async buffer.

The COMEDI_CB_EOS and COMEDI_CB_OVERFLOW events will be automatically
handled by the core. Remove the unecessary handling in the driver.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman 
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3120.c   | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c 
b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index 4959fc6..975ee5f 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -1313,18 +1313,13 @@ static int apci3120_interrupt_handle_eos(struct 
comedi_device *dev)
 {
struct apci3120_private *devpriv = dev->private;
struct comedi_subdevice *s = dev->read_subdev;
-   int n_chan, i;
-   int err = 1;
-
-   n_chan = devpriv->ui_AiNbrofChannels;
-
-   for (i = 0; i < n_chan; i++)
-   err &= comedi_buf_put(s, inw(dev->iobase + 0));
-
-   s->async->events |= COMEDI_CB_EOS;
+   unsigned short val;
+   int i;
 
-   if (err == 0)
-   s->async->events |= COMEDI_CB_OVERFLOW;
+   for (i = 0; i < devpriv->ui_AiNbrofChannels; i++) {
+   val = inw(dev->iobase + 0);
+   comedi_buf_write_samples(s, &val, 1);
+   }
 
return 0;
 }
-- 
2.0.3

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


[PATCH 42/55] staging: comedi: quatech_daqp_cs: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
For aesthetics, use comedi_buf_write_samples() to add the sample to the
async buffer.

The core will add the COMEDI_CB_BLOCK event when data is written to the
async buffer. Remove the unnecessary event in the driver.

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

diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c 
b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index 21e99fd..f6c678e 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -221,7 +221,7 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
data |= inb(dev->iobase + DAQP_FIFO) << 8;
data ^= 0x8000;
 
-   comedi_buf_put(s, data);
+   comedi_buf_write_samples(s, &data, 1);
 
/* If there's a limit, decrement it
 * and stop conversion if zero
@@ -245,8 +245,6 @@ static enum irqreturn daqp_interrupt(int irq, void *dev_id)
s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
}
 
-   s->async->events |= COMEDI_CB_BLOCK;
-
comedi_handle_events(dev, s);
}
return IRQ_HANDLED;
-- 
2.0.3

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


[PATCH 44/55] staging: comedi: usbdux: use comedi_buf_write_samples()

2014-10-22 Thread H Hartley Sweeten
Use comedi_buf_write_samples() to add the sample to the async buffer.

The async events COMEDI_CB_BLOCK and COMEDI_CB_EOS will be detected and set
by the core. Remove the unnecessary events in the driver.

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c 
b/drivers/staging/comedi/drivers/usbdux.c
index 53f1e21..579e6bc 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -282,10 +282,9 @@ static void usbduxsub_ai_handle_urb(struct comedi_device 
*dev,
val ^= ((s->maxdata + 1) >> 1);
 
/* transfer data */
-   if (!comedi_buf_put(s, val))
+   if (!comedi_buf_write_samples(s, &val, 1))
return;
}
-   async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
}
 
/* if command is still running, resubmit urb */
-- 
2.0.3

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


[PATCH 00/55] staging: comedi: clean up writing data to the async buffer

2014-10-22 Thread H Hartley Sweeten
Currently there are 5 exported methods to add sample data to the async buffer.

  1) cfc_write_long_to_buffer() - a wrapper around 
comedi_write_array_to_buffer()
 to add a single unsigned int size sample
  2) cfc_write_to_buffer() - a wrapper aropund comedi_write_array_to_buffer() to
 add a single unsigned short size sample
  3) cfc_write_array_to_buffer() - a wrapper aropund 
comedi_write_array_to_buffer()
  4) comedi_write_array_to_buffer() - adds multiple samples
  5) comedi_buf_put() - adds a single unsigned short sample

Introduce a new generic helper function, comedi_buf_write_samples(), to add
samples to the async buffer. Use this function to replace the five "write"
methods above.

H Hartley Sweeten (55):
  staging: comedi: comedi_buf: introduce comedi_buf_write_samples()
  staging: comedi: comedi_fc.h: remove cfc_write_long_to_buffer()
  staging: comedi: comedi_test: use comedi_buf_write_samples()
  staging: comedi: das800: use comedi_buf_write_samples()
  staging: comedi: ni_at_a2150: use comedi_buf_write_samples()
  staging: comedi: s626: use comedi_buf_write_samples()
  staging: comedi: ni_labpc_common: use comedi_buf_write_samples()
  staging: comedi: ni_labpc_isadma: use comedi_buf_write_samples()
  staging: comedi: das1800: use comedi_buf_write_samples()
  staging: comedi: cb_pcidas: use comedi_buf_write_samples()
  staging: comedi: adl_pci9118: use comedi_buf_write_samples()
  staging: comedi: cb_pcidas64: use comedi_buf_write_samples()
  staging: comedi: ni_mio_common: use comedi_buf_write_samples()
  staging: comedi: comedi_fc.h: remove cfc_write_to_buffer()
  staging: comedi: adl_pci9111: use comedi_buf_write_samples()
  staging: comedi: hwdrv_apci3120: use comedi_buf_write_samples()
  staging: comedi: das16m1: use comedi_buf_write_samples()
  staging: comedi: das16: use comedi_buf_write_samples()
  staging: comedi: dt282x: use comedi_buf_write_samples()
  staging: comedi: gsc_hpdi: use comedi_buf_write_samples()
  staging: comedi: usbduxsigma: use comedi_buf_write_samples()
  staging: comedi: usbduxfast: use comedi_buf_write_samples()
  staging: comedi: comedi_fc.h: remove cfc_write_array_to_buffer()
  staging: comedi: addi_apci_1032: use comedi_buf_write_samples()
  staging: comedi: addi_apci_1564: use comedi_buf_write_samples()
  staging: comedi: addi_apci_3xxx: use comedi_buf_write_samples()
  staging: comedi: adv_pci1710: use comedi_buf_write_samples()
  staging: comedi: amplc_pc236_common: use comedi_buf_write_samples()
  staging: comedi: amplc_pci230: use comedi_buf_write_samples()
  staging: comedi: comedi_parport: use comedi_buf_write_samples()
  staging: comedi: dmm32at: use comedi_buf_write_samples()
  staging: comedi: dt3000: use comedi_buf_write_samples()
  staging: comedi: me4000: use comedi_buf_write_samples()
  staging: comedi: ni_6527: use comedi_buf_write_samples()
  staging: comedi: ni_65xx: use comedi_buf_write_samples()
  staging: comedi: ni_atmio16d: use comedi_buf_write_samples()
  staging: comedi: pcl711: use comedi_buf_write_samples()
  staging: comedi: pcl726: use comedi_buf_write_samples()
  staging: comedi: pcl812: use comedi_buf_write_samples()
  staging: comedi: pcl816: use comedi_buf_write_samples()
  staging: comedi: pcl818: use comedi_buf_write_samples()
  staging: comedi: quatech_daqp_cs: use comedi_buf_write_samples()
  staging: comedi: rtd520: use comedi_buf_write_samples()
  staging: comedi: usbdux: use comedi_buf_write_samples()
  staging: comedi: hwdrv_apci3120: use comedi_buf_write_samples()
  staging: comedi: drivers: handle SDF_PACKED in comedi_inc_scan_progress()
  staging: comedi: addi_apci_2032: use comedi_buf_write_samples()
  staging: comedi: amplc_dio200_common: use comedi_buf_write_samples()
  staging: comedi: ni_pcidio: use comedi_buf_write_samples()
  staging: comedi: pcmmio: use comedi_buf_write_samples()
  staging: comedi: pcmuio: use comedi_buf_write_samples()
  staging: comedi: comedi_buf: remove comedi_buf_put()
  staging: comedi: comedi_buf: don't export comedi_write_array_to_buffer()
  staging: comedi: comedi_buf: absorb comedi_write_array_to_buffer()
  staging: comedi: comedi_buf: absorb __comedi_buf_write_alloc()

 drivers/staging/comedi/comedi_buf.c| 76 --
 drivers/staging/comedi/comedidev.h |  7 +-
 drivers/staging/comedi/drivers.c   | 19 --
 .../comedi/drivers/addi-data/hwdrv_apci3120.c  | 19 ++
 drivers/staging/comedi/drivers/addi_apci_1032.c|  3 +-
 drivers/staging/comedi/drivers/addi_apci_1564.c|  3 +-
 drivers/staging/comedi/drivers/addi_apci_2032.c|  7 +-
 drivers/staging/comedi/drivers/addi_apci_3xxx.c|  2 +-
 drivers/staging/comedi/drivers/adl_pci9111.c   |  9 ++-
 drivers/staging/comedi/drivers/adl_pci9118.c   | 19 ++
 drivers/staging/comedi/drivers/adv_pci1710.c   |  6 +-
 .../staging/comedi/drivers/amplc_dio200_common.c   | 12 +---
 .../staging/comedi/drivers/amplc_pc236_common.c|  3 +-
 drive

  1   2   >