[PATCH 1/2] staging: media: lirc Remove the extra braces in if

2015-08-05 Thread Pradheep Shrinivasan
This patche removes the extra braces found in
drivers/staging/media/lirc/lirc_imon.c to fix the warning thrown by
checkpatch.pl

Signed-off-by: Pradheep Shrinivasan 
---
 drivers/staging/media/lirc/lirc_imon.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_imon.c 
b/drivers/staging/media/lirc/lirc_imon.c
index 62ec9f7..05d47dc 100644
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ b/drivers/staging/media/lirc/lirc_imon.c
@@ -785,13 +785,13 @@ static int imon_probe(struct usb_interface *interface,
}
 
driver = kzalloc(sizeof(struct lirc_driver), GFP_KERNEL);
-   if (!driver) {
+   if (!driver)
goto free_context;
-   }
+
rbuf = kmalloc(sizeof(struct lirc_buffer), GFP_KERNEL);
-   if (!rbuf) {
+   if (!rbuf)
goto free_driver;
-   }
+
if (lirc_buffer_init(rbuf, BUF_CHUNK_SIZE, BUF_SIZE)) {
dev_err(dev, "%s: lirc_buffer_init failed\n", __func__);
goto free_rbuf;
-- 
1.9.1

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


[PATCH 2/2] staging: media: lirc This fix changes the spaces to tab in lirc_sasem.c

2015-08-05 Thread Pradheep Shrinivasan
This fix changes the space in the code to tab to fix the ERROR
"ERROR: code indent should use tabs where possible"

Signed-off-by: Pradheep Shrinivasan 
---
 drivers/staging/media/lirc/lirc_sasem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/lirc/lirc_sasem.c 
b/drivers/staging/media/lirc/lirc_sasem.c
index 8ebee96..c14ca7e 100644
--- a/drivers/staging/media/lirc/lirc_sasem.c
+++ b/drivers/staging/media/lirc/lirc_sasem.c
@@ -185,7 +185,7 @@ static void deregister_from_lirc(struct sasem_context 
*context)
   __func__, retval);
else
dev_info(&context->dev->dev,
-"Deregistered Sasem driver (minor:%d)\n", minor);
+"Deregistered Sasem driver (minor:%d)\n", minor);
 
 }
 
-- 
1.9.1

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


Re: [PATCH 05/46] staging: comedi: me4000: remove 'board' from me4000_ai_insn_read()

2015-08-05 Thread Ian Abbott

On 04/08/15 18:57, H Hartley Sweeten wrote:

The 'board' pointer is only used in this function to verify that the
'chan' is valid for an aref of AREF_DIFF. The comedi core ensures that
that aref is only possible if the subdevice has the SDF_DIFF subdevice_flag
set. If so, the maximum channel is half the subdevice 'n_chan'. Use that
instead and remove the 'board' variable.

Signed-off-by: H Hartley Sweeten 
---
  drivers/staging/comedi/drivers/me4000.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index d6b7adc..a1b30f9 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -436,10 +436,10 @@ static void me4000_reset(struct comedi_device *dev)

===*/

  static int me4000_ai_insn_read(struct comedi_device *dev,
-  struct comedi_subdevice *subdevice,
-  struct comedi_insn *insn, unsigned int *data)
+  struct comedi_subdevice *s,
+  struct comedi_insn *insn,
+  unsigned int *data)
  {
-   const struct me4000_board *board = dev->board_ptr;
int chan = CR_CHAN(insn->chanspec);
int rang = CR_RANGE(insn->chanspec);
int aref = CR_AREF(insn->chanspec);
@@ -487,7 +487,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
return -EINVAL;
}

-   if (chan >= board->ai_diff_nchan) {
+   if (chan >= (s->n_chan / 2)) {


You also need to check that differential input mode is supported because 
the comedi core doesn't verify the aref flags.  Since you are removing 
the 'board' variable, that can be done by checking 's->subdev_flags & 
SDF_DIFF' (since patch 03 ensures that is only set if differential mode 
supported).



dev_err(dev->class_dev,
"Analog input is not available\n");
return -EINVAL;




--
-=( 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 06/46] staging: comedi: me4000: remove 'board' from me4000_ai_check_chanlist()

2015-08-05 Thread Ian Abbott

On 04/08/15 18:57, H Hartley Sweeten wrote:

The maximum differential channel is half the subdevice 'n_chan'. Use
that instead and remove the need for the 'board' variable.

Signed-off-by: H Hartley Sweeten 
---
  drivers/staging/comedi/drivers/me4000.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index a1b30f9..2243e64 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -562,8 +562,6 @@ static int me4000_ai_check_chanlist(struct comedi_device 
*dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
  {
-   const struct me4000_board *board = dev->board_ptr;
-   unsigned int max_diff_chan = board->ai_diff_nchan;
unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
int i;

@@ -579,7 +577,7 @@ static int me4000_ai_check_chanlist(struct comedi_device 
*dev,
}

if (aref == AREF_DIFF) {
-   if (chan >= max_diff_chan) {
+   if (chan >= (s->n_chan / 2)) {


As for patch 05, you need to check that differential input is supported.


dev_dbg(dev->class_dev,
"Channel number to high\n");
return -EINVAL;




--
-=( 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 13/46] staging: comedi: me4000: remove unnecessary ME4000_AI_LIST_INPUT_SINGLE_ENDED

2015-08-05 Thread Ian Abbott

On 04/08/15 18:57, H Hartley Sweeten wrote:

This define evaluates to 0 and is OR'ed with the 'entry' value that is
written to the ME4000_AI_CHANNEL_LIST_REG when the channel aref is a
single-ended type (AREF_GROUND or AREF_COMMON). OR'ing a zero value is
pretty silly, just remove it.

Simplify me4000_ai_insn_read() a bit. The 'aref' is validated by the core
and will always be valid.


Actually, the core doesn't validate the 'aref' as it's deemed too much 
bother for the user to set unless they really care about it.


Most drivers don't care if 'aref' has an invalid value either and will 
use some default supported value in that case.  It's okay for me4000 to 
default to single-ended for everything except AREF_DIFF.  So the patch 
is fine, but the 2nd paragraph is a little inaccurate.




Signed-off-by: H Hartley Sweeten 
---
  drivers/staging/comedi/drivers/me4000.c | 17 +++--
  1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index cf7f17f..c3653a35 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -110,7 +110,6 @@ broken.
  #define ME4000_AI_STATUS_BIT_FSM  (1 << 29)
  #define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH   (1 << 31)
  #define ME4000_AI_CHANNEL_LIST_REG0x78
-#define ME4000_AI_LIST_INPUT_SINGLE_ENDED  (0 << 5)
  #define ME4000_AI_LIST_INPUT_DIFFERENTIAL (1 << 5)
  #define ME4000_AI_LIST_RANGE_BIPOLAR_10   (0 << 6)
  #define ME4000_AI_LIST_RANGE_BIPOLAR_2_5  (1 << 6)
@@ -474,13 +473,9 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
return -EINVAL;
}

-   switch (aref) {
-   case AREF_GROUND:
-   case AREF_COMMON:
-   entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED | chan;
-   break;
+   entry |= chan;

-   case AREF_DIFF:
+   if (aref == AREF_DIFF) {
if (rang == 0 || rang == 1) {
dev_err(dev->class_dev,
"Range must be bipolar when aref = diff\n");
@@ -492,11 +487,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
"Analog input is not available\n");
return -EINVAL;
}
-   entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL | chan;
-   break;
-   default:
-   dev_err(dev->class_dev, "Invalid aref specified\n");
-   return -EINVAL;
+   entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
}

entry |= ME4000_AI_LIST_LAST_ENTRY;
@@ -691,8 +682,6 @@ static int ai_write_chanlist(struct comedi_device *dev,

if (aref == AREF_DIFF)
entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
-   else
-   entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED;

outl(entry, dev->iobase + ME4000_AI_CHANNEL_LIST_REG);
}




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


Re: [PATCH 4/6] drivers, staging, unisys Add visorbus module autoloading code

2015-08-05 Thread Prarit Bhargava
Top posting ;)  Greg -- I know you're busy but I just wanted to make sure you
didn't miss this question re: drivers/staging and patches that touch other areas
of the kernel.

Thanks!

P.

On 08/03/2015 01:21 PM, Prarit Bhargava wrote:
> On 07/31/2015 07:07 PM, Greg KH wrote:> On Fri, Jul 24, 2015 at 12:06:54PM 
> -0400, Benjamin Romer wrote:
>>> From: Prarit Bhargava 
>>>
>>> This patch adds an module alias and a MODULE_DEVICE_TABLE to autoload the
>>> visorhba driver when an appropriate device is created by the visorbus.
>>>
>>> Signed-off-by: Prarit Bhargava 
>>> ---
>>>  drivers/staging/unisys/visorhba/visorhba_main.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c 
>>> b/drivers/staging/unisys/visorhba/visorhba_main.c
>>> index 031c6fa..50ecdf2 100644
>>> --- a/drivers/staging/unisys/visorhba/visorhba_main.c
>>> +++ b/drivers/staging/unisys/visorhba/visorhba_main.c
>>> @@ -80,6 +80,8 @@ static struct visor_driver visorhba_driver = {
>>> .resume = visorhba_resume,
>>> .channel_interrupt = NULL,
>>>  };
>>> +MODULE_DEVICE_TABLE(visorbus, visorhba_channel_types);
>>> +MODULE_ALIAS("visorbus:" SPAR_VHBA_CHANNEL_PROTOCOL_UUID_STR);
>>
>> You shouldn't have to write MODULE_ALIAS lines "by hand", they should be
>> generated for you automagically from the MODULE_DEVICE_TABLE() define,
>> if you do it right.
>>
>> You all didn't do it right :)
>>
> 
> Greg,
> 
> I need further clarification on the right approach for the autoload code.
> 
> In order to "do it right" I would have to do something like the following
> which would correctly add module alias entries for the visorbus bus.
> The issue that I have with this patch is that it touches code outside
> of drivers/staging for a driver that is solely within drivers/staging.
> 
> Is modifying non drivers/staging okay to do?  Or is simply doing
> 
> MODULE_ALIAS("visorbus:" SPAR_VHBA_CHANNEL_PROTOCOL_UUID_STR);
> 
> with a loud /* FIXME before submitting ... */ warning a better approach?
> 
> Thanks,
> 
> P.
> 
> ---8<---
> 
> drivers/staging: visorbus, add module autoload functionality
> 
> This patch adds module autoload functionality to the visorbus bus drivers
> (currently only visornic is in tree).  This patch adds visorbus alias
> creation entries to modpost, and moves the appropriate structure define
> into include/linux/mod_devicetable.h.
> 
> Signed-off-by: Prarit Bhargava 
> ---
>  drivers/staging/unisys/include/visorbus.h   |  8 
>  drivers/staging/unisys/visorbus/visorbus_main.c |  1 +
>  include/linux/mod_devicetable.h | 11 +++
>  scripts/mod/devicetable-offsets.c   |  4 
>  scripts/mod/file2alias.c| 11 +++
>  5 files changed, 27 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/unisys/include/visorbus.h 
> b/drivers/staging/unisys/include/visorbus.h
> index a0144c6..35da159 100644
> --- a/drivers/staging/unisys/include/visorbus.h
> +++ b/drivers/staging/unisys/include/visorbus.h
> @@ -53,14 +53,6 @@ struct visorchipset_state {
>   /* Remaining bits in this 32-bit word are unused. */
>  };
>  
> -/** This struct describes a specific Supervisor channel, by providing its
> - *  GUID, name, and sizes.
> - */
> -struct visor_channeltype_descriptor {
> - const uuid_le guid;
> - const char *name;
> -};
> -
>  /** Information provided by each visor driver when it registers with the
>   *  visorbus driver.
>   */
> diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c 
> b/drivers/staging/unisys/visorbus/visorbus_main.c
> index cc4a029..fcb491a 100644
> --- a/drivers/staging/unisys/visorbus/visorbus_main.c
> +++ b/drivers/staging/unisys/visorbus/visorbus_main.c
> @@ -15,6 +15,7 @@
>   */
>  
>  #include 
> +#include 
>  
>  #include "visorbus.h"
>  #include "visorbus_private.h"
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index 34f25b7..acb70ed 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -650,4 +650,15 @@ struct ulpi_device_id {
>   kernel_ulong_t driver_data;
>  };
>  
> +/**
> + * struct visor_channeltype_descriptor - VISORBUS Channel Type Descriptor
> + * @guid: UUID for the channel
> + * @name: name of the channel
> + *
> + * describes a specific Supervisor channel, by providing its * GUID and name.
> + */
> +struct visor_channeltype_descriptor {
> + uuid_le guid;
> + char *name;
> +};
>  #endif /* LINUX_MOD_DEVICETABLE_H */
> diff --git a/scripts/mod/devicetable-offsets.c 
> b/scripts/mod/devicetable-offsets.c
> index e70fcd1..4b8797b 100644
> --- a/scripts/mod/devicetable-offsets.c
> +++ b/scripts/mod/devicetable-offsets.c
> @@ -196,5 +196,9 @@ int main(void)
>   DEVID_FIELD(ulpi_device_id, vendor);
>   DEVID_FIELD(ulpi_device_id, product);
>  
> + DEVID(visor_channeltype_descriptor);
> + DEVID_FIELD(visor_channeltype_descriptor, guid);
> + DEVID_FIE

Re: [PATCH 14/46] staging: comedi: me4000: simplify analog input range programming

2015-08-05 Thread Ian Abbott

On 04/08/15 18:57, H Hartley Sweeten wrote:

The comedi_lrange table for the analog inputs is inverted compared
to the values that need to be written to the ME4000_AI_CHANNEL_LIST_REG
to select the range.

Create a macro, ME4000_AI_LIST_RANGE(), to handle the inversion. Remove
the old defines and simplify the code a bit.

Signed-off-by: H Hartley Sweeten 
---
  drivers/staging/comedi/drivers/me4000.c | 41 -
  1 file changed, 9 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index c3653a35..db0a18f 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -111,10 +111,7 @@ broken.
  #define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH   (1 << 31)
  #define ME4000_AI_CHANNEL_LIST_REG0x78
  #define ME4000_AI_LIST_INPUT_DIFFERENTIAL (1 << 5)
-#define ME4000_AI_LIST_RANGE_BIPOLAR_10(0 << 6)
-#define ME4000_AI_LIST_RANGE_BIPOLAR_2_5   (1 << 6)
-#define ME4000_AI_LIST_RANGE_UNIPOLAR_10   (2 << 6)
-#define ME4000_AI_LIST_RANGE_UNIPOLAR_2_5  (3 << 6)
+#define ME4000_AI_LIST_RANGE(x)((3 - ((x) & 3)) << 6)


You could also use '((~(x) & 3) << 6)' but yours is probably more readable!

--
-=( 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: iio_simple_dummy: Fix indentation errors

2015-08-05 Thread Daniel Baluta
On Wed, Aug 5, 2015 at 3:15 PM, Lars Svensson
 wrote:
> Fixing indentation errors in
> drivers/staging/iio/iio_simple_dummy_events.c.
>
> Signed-off-by: Lars Svensson 

Good catch.

Acked-by: Daniel Baluta 


> ---
>  drivers/staging/iio/iio_simple_dummy_events.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/iio/iio_simple_dummy_events.c 
> b/drivers/staging/iio/iio_simple_dummy_events.c
> index ecc563c..73108ba 100644
> --- a/drivers/staging/iio/iio_simple_dummy_events.c
> +++ b/drivers/staging/iio/iio_simple_dummy_events.c
> @@ -120,7 +120,7 @@ int iio_simple_dummy_read_event_value(struct iio_dev 
> *indio_dev,
>   const struct iio_chan_spec *chan,
>   enum iio_event_type type,
>   enum iio_event_direction dir,
> - enum iio_event_info info,
> + enum iio_event_info info,
>   int *val, int *val2)
>  {
> struct iio_dummy_state *st = iio_priv(indio_dev);
> @@ -143,7 +143,7 @@ int iio_simple_dummy_write_event_value(struct iio_dev 
> *indio_dev,
>const struct iio_chan_spec *chan,
>enum iio_event_type type,
>enum iio_event_direction dir,
> -  enum iio_event_info info,
> +  enum iio_event_info info,
>int val, int val2)
>  {
> struct iio_dummy_state *st = iio_priv(indio_dev);
> --
> 1.8.2.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: iio_simple_dummy: Fix indentation errors

2015-08-05 Thread Lars Svensson
Fixing indentation errors in
drivers/staging/iio/iio_simple_dummy_events.c.

Signed-off-by: Lars Svensson 
---
 drivers/staging/iio/iio_simple_dummy_events.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/iio_simple_dummy_events.c 
b/drivers/staging/iio/iio_simple_dummy_events.c
index ecc563c..73108ba 100644
--- a/drivers/staging/iio/iio_simple_dummy_events.c
+++ b/drivers/staging/iio/iio_simple_dummy_events.c
@@ -120,7 +120,7 @@ int iio_simple_dummy_read_event_value(struct iio_dev 
*indio_dev,
  const struct iio_chan_spec *chan,
  enum iio_event_type type,
  enum iio_event_direction dir,
- enum iio_event_info info,
+ enum iio_event_info info,
  int *val, int *val2)
 {
struct iio_dummy_state *st = iio_priv(indio_dev);
@@ -143,7 +143,7 @@ int iio_simple_dummy_write_event_value(struct iio_dev 
*indio_dev,
   const struct iio_chan_spec *chan,
   enum iio_event_type type,
   enum iio_event_direction dir,
-  enum iio_event_info info,
+  enum iio_event_info info,
   int val, int val2)
 {
struct iio_dummy_state *st = iio_priv(indio_dev);
-- 
1.8.2.2

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


Re: [PATCH 18/46] staging: comedi: me4000: fix me4000_ai_insn_read()

2015-08-05 Thread Ian Abbott

On 04/08/15 18:57, H Hartley Sweeten wrote:

The coemdi (*insn_read) functions are supposed to read insn->n values
from the hardware. Make this function work like the core expects.

Use the comedi_offset_munge() helper to munge the two's complement
values to offset binary.


My guess would be that the format of the output value could be 
controlled by the ME4000_AI_CTRL_BIT_OFFSET bit, but that's only a 
guess, and the guy at Meilhaus who wrote the original driver didn't use it!


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


Re: [PATCH 39/46] staging: comedi: me4000: fix me4000_detach()

2015-08-05 Thread Ian Abbott

On 04/08/15 18:58, H Hartley Sweeten wrote:

There is no real reason to reset the board when detaching. But the PLX
interrupts should be disabled. Currently the PLX interrupt is left
enabled when the driver is detached.

Signed-off-by: H Hartley Sweeten 
---
  drivers/staging/comedi/drivers/me4000.c | 8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 09234d4..b917e46 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -1263,8 +1263,12 @@ static int me4000_auto_attach(struct comedi_device *dev,

  static void me4000_detach(struct comedi_device *dev)
  {
-   if (dev->iobase)
-   me4000_reset(dev);
+   if (dev->irq) {
+   struct me4000_private *devpriv = dev->private;
+
+   /* Disable interrupts on the PLX */
+   outl(0, devpriv->plx_regbase + PLX9052_INTCSR);
+   }
comedi_pci_detach(dev);
  }




Perhaps me4000_reset() should disable the PLX interrupts too so they are 
in a clean state before enabled within me4000_auto_attach().


--
-=( 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


[PATCH] staging: sm750fb: fix sparse warning for lock

2015-08-05 Thread Peng Fan
Use __acquire() and __release() in the right place to silence the sparse
lock checking warning.

drivers/staging/sm750fb/sm750.c:177:13: warning: context imbalance in 
'lynxfb_ops_fillrect' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:243:9: warning: context imbalance in 
'lynxfb_ops_copyarea' - different lock contexts for basic block
drivers/staging/sm750fb/sm750.c:247:13: warning: context imbalance in 
'lynxfb_ops_imageblit' - different lock contexts for basic block

Signed-off-by: Peng Fan 
Cc: Sudip Mukherjee 
Cc: Teddy Wang 
Cc: Greg Kroah-Hartman 
---
 drivers/staging/sm750fb/sm750.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 8e201f1..5ba1c06 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -203,6 +203,8 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 */
if (share->dual)
spin_lock(&share->slock);
+   else
+   __acquire(&share->slock);
 
share->accel.de_fillrect(&share->accel,
 base, pitch, Bpp,
@@ -211,6 +213,8 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 color, rop);
if (share->dual)
spin_unlock(&share->slock);
+   else
+   __release(&share->slock);
 }
 
 static void lynxfb_ops_copyarea(struct fb_info *info,
@@ -235,6 +239,8 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 */
if (share->dual)
spin_lock(&share->slock);
+   else
+   __acquire(&share->slock);
 
share->accel.de_copyarea(&share->accel,
 base, pitch, region->sx, region->sy,
@@ -242,6 +248,8 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 region->width, region->height, HW_ROP2_COPY);
if (share->dual)
spin_unlock(&share->slock);
+   else
+   __release(&share->slock);
 }
 
 static void lynxfb_ops_imageblit(struct fb_info *info,
@@ -282,6 +290,8 @@ _do_work:
 */
if (share->dual)
spin_lock(&share->slock);
+   else
+   __acquire(&share->slock);
 
share->accel.de_imageblit(&share->accel,
  image->data, image->width>>3, 0,
@@ -291,6 +301,8 @@ _do_work:
  fgcol, bgcol, HW_ROP2_COPY);
if (share->dual)
spin_unlock(&share->slock);
+   else
+   __release(&share->slock);
 }
 
 static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,
-- 
1.8.4

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


[PATCH] staging: comedi: fix coding style issue.

2015-08-05 Thread Ted Chen
fixed coding style issue by replacing ENOSYS
with EIO because it means 'invalid syscall nr'
and nothing else.

Signed-off-by: Ted Chen 
---
 drivers/staging/comedi/drivers.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index ed0b60c..b03bc66 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -820,7 +820,7 @@ int comedi_device_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 "driver '%s' does not support attach using 
comedi_config\n",
 driv->driver_name);
module_put(driv->module);
-   ret = -ENOSYS;
+   ret = -EIO;
goto out;
}
dev->driver = driv;
-- 
1.7.9.5

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


Re: [PATCH] staging: comedi: fix coding style issue.

2015-08-05 Thread Ian Abbott

On 04/08/15 15:56, Ted Chen wrote:

fixed coding style issue by replacing ENOSYS
with EIO because it means 'invalid syscall nr'
and nothing else.

Signed-off-by: Ted Chen 
---
  drivers/staging/comedi/drivers.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index ed0b60c..b03bc66 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -820,7 +820,7 @@ int comedi_device_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 "driver '%s' does not support attach using 
comedi_config\n",
 driv->driver_name);
module_put(driv->module);
-   ret = -ENOSYS;
+   ret = -EIO;
goto out;
}
dev->driver = driv;



The subject line of the patch is a bit generic and could be made more 
explicit, such as "staging: comedi: don't return -ENOSYS".


--
-=( 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


[PATCH] staging: lustre-libcfs: fix sparse warning

2015-08-05 Thread Patrick Boettcher
Hi all,

Please consider applying the following patch. It fixes some
sparse-warning related to global variable not being correctly declared.

Applies to linux-next/next-20150804.

Best Regards,
--
Patrick.
>From b04a87fd78f5e0dcdfe83362df367e4c244a4e3e Mon Sep 17 00:00:00 2001
From: Patrick Boettcher 
Date: Wed, 5 Aug 2015 09:13:04 +0200
Subject: [PATCH] staging: lustre-libcfs: fix sparse warning

Fix sparse warnings of the following type:

warning: symbol '' was not declared. Should it be static?

Signed-off-by: Patrick Boettcher 
---
 drivers/staging/lustre/include/linux/libcfs/libcfs.h  | 13 +
 drivers/staging/lustre/lustre/libcfs/linux/linux-module.c |  2 --
 drivers/staging/lustre/lustre/libcfs/module.c | 13 ++---
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index d585041..a1ece6d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -148,4 +148,17 @@ void *libcfs_kvzalloc(size_t size, gfp_t flags);
 void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size,
 			  gfp_t flags);
 
+extern struct miscdevice libcfs_dev;
+/**
+ * The path of debug log dump upcall script.
+ */
+extern char lnet_upcall[1024];
+extern char lnet_debug_log_upcall[1024];
+
+extern void libcfs_init_nidstrings(void);
+
+extern struct cfs_psdev_ops	  libcfs_psdev_ops;
+
+extern struct cfs_wi_sched *cfs_sched_rehash;
+
 #endif /* _LIBCFS_H */
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
index e962f89..3014120 100644
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
@@ -96,8 +96,6 @@ int libcfs_ioctl_popdata(void *arg, void *data, int size)
 	return 0;
 }
 
-extern struct cfs_psdev_ops	  libcfs_psdev_ops;
-
 static int
 libcfs_psdev_open(struct inode *inode, struct file *file)
 {
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
index 1ab4232..2035034 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -66,19 +66,10 @@ MODULE_AUTHOR("Peter J. Braam ");
 MODULE_DESCRIPTION("Portals v3.1");
 MODULE_LICENSE("GPL");
 
-extern struct miscdevice libcfs_dev;
-extern struct cfs_wi_sched *cfs_sched_rehash;
-extern void libcfs_init_nidstrings(void);
-
 static void insert_debugfs(void);
 static void remove_debugfs(void);
 
 static struct dentry *lnet_debugfs_root;
-extern char lnet_upcall[1024];
-/**
- * The path of debug log dump upcall script.
- */
-extern char lnet_debug_log_upcall[1024];
 
 static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
 {
@@ -716,7 +707,7 @@ struct lnet_debugfs_symlink_def {
 	char *target;
 };
 
-struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = {
+static const struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = {
 	{ "console_ratelimit",
 	  "/sys/module/libcfs/parameters/libcfs_console_ratelimit"},
 	{ "debug_path",
@@ -771,7 +762,7 @@ static void insert_debugfs(void)
 {
 	struct ctl_table *table;
 	struct dentry *entry;
-	struct lnet_debugfs_symlink_def *symlinks;
+	const struct lnet_debugfs_symlink_def *symlinks;
 
 	if (lnet_debugfs_root == NULL)
 		lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
-- 
2.1.4

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


[PATCH RESENT] staging: lustre-libcfs: fix sparse warning

2015-08-05 Thread Patrick Boettcher
Hi all,

Please consider applying the following patch. It fixes some
sparse-warning related to global variable not being correctly declared.

This is a resent with the patch inline. Greg's bot was picky about it
for a reason!

Applies to linux-next/next-20150804.




>From b04a87fd78f5e0dcdfe83362df367e4c244a4e3e Mon Sep 17 00:00:00 2001
From: Patrick Boettcher 
Date: Wed, 5 Aug 2015 09:13:04 +0200
Subject: [PATCH] staging: lustre-libcfs: fix sparse warning

Fix sparse warnings of the following type:

warning: symbol '' was not declared. Should it be static?

Signed-off-by: Patrick Boettcher 
---
 drivers/staging/lustre/include/linux/libcfs/libcfs.h  | 13 +
 drivers/staging/lustre/lustre/libcfs/linux/linux-module.c |  2 --
 drivers/staging/lustre/lustre/libcfs/module.c | 13 ++---
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index d585041..a1ece6d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -148,4 +148,17 @@ void *libcfs_kvzalloc(size_t size, gfp_t flags);
 void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size,
  gfp_t flags);
 
+extern struct miscdevice libcfs_dev;
+/**
+ * The path of debug log dump upcall script.
+ */
+extern char lnet_upcall[1024];
+extern char lnet_debug_log_upcall[1024];
+
+extern void libcfs_init_nidstrings(void);
+
+extern struct cfs_psdev_ops  libcfs_psdev_ops;
+
+extern struct cfs_wi_sched *cfs_sched_rehash;
+
 #endif /* _LIBCFS_H */
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c 
b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
index e962f89..3014120 100644
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c
@@ -96,8 +96,6 @@ int libcfs_ioctl_popdata(void *arg, void *data, int size)
return 0;
 }
 
-extern struct cfs_psdev_ops  libcfs_psdev_ops;
-
 static int
 libcfs_psdev_open(struct inode *inode, struct file *file)
 {
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c 
b/drivers/staging/lustre/lustre/libcfs/module.c
index 1ab4232..2035034 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -66,19 +66,10 @@ MODULE_AUTHOR("Peter J. Braam ");
 MODULE_DESCRIPTION("Portals v3.1");
 MODULE_LICENSE("GPL");
 
-extern struct miscdevice libcfs_dev;
-extern struct cfs_wi_sched *cfs_sched_rehash;
-extern void libcfs_init_nidstrings(void);
-
 static void insert_debugfs(void);
 static void remove_debugfs(void);
 
 static struct dentry *lnet_debugfs_root;
-extern char lnet_upcall[1024];
-/**
- * The path of debug log dump upcall script.
- */
-extern char lnet_debug_log_upcall[1024];
 
 static void kportal_memhog_free(struct libcfs_device_userstate *ldu)
 {
@@ -716,7 +707,7 @@ struct lnet_debugfs_symlink_def {
char *target;
 };
 
-struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = {
+static const struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = {
{ "console_ratelimit",
  "/sys/module/libcfs/parameters/libcfs_console_ratelimit"},
{ "debug_path",
@@ -771,7 +762,7 @@ static void insert_debugfs(void)
 {
struct ctl_table *table;
struct dentry *entry;
-   struct lnet_debugfs_symlink_def *symlinks;
+   const struct lnet_debugfs_symlink_def *symlinks;
 
if (lnet_debugfs_root == NULL)
lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
-- 
2.1.4

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


Re: [PATCH RESENT] staging: lustre-libcfs: fix sparse warning

2015-08-05 Thread Greg Kroah-Hartman
On Wed, Aug 05, 2015 at 05:26:22PM +0200, Patrick Boettcher wrote:
> Hi all,
> 
> Please consider applying the following patch. It fixes some
> sparse-warning related to global variable not being correctly declared.
> 
> This is a resent with the patch inline. Greg's bot was picky about it
> for a reason!
> 
> Applies to linux-next/next-20150804.
> 
> 
> 
> 
> From b04a87fd78f5e0dcdfe83362df367e4c244a4e3e Mon Sep 17 00:00:00 2001
> From: Patrick Boettcher 
> Date: Wed, 5 Aug 2015 09:13:04 +0200
> Subject: [PATCH] staging: lustre-libcfs: fix sparse warning
> 
> Fix sparse warnings of the following type:
> 
> warning: symbol '' was not declared. Should it be static?
> 
> Signed-off-by: Patrick Boettcher 

Again, just send this as the email, no need for the top introduction, it
would require me to hand-edit the patch to be able to apply it.

And when dealing with thousands of patches, that does not scale, just
use 'git send-email' to send the patch out as-is.

thanks,

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


RE: [PATCH 05/46] staging: comedi: me4000: remove 'board' from me4000_ai_insn_read()

2015-08-05 Thread Hartley Sweeten
On Wednesday, August 05, 2015 4:38 AM, Ian Abbott wrote:
> On 04/08/15 18:57, H Hartley Sweeten wrote:
>> The 'board' pointer is only used in this function to verify that the
>> 'chan' is valid for an aref of AREF_DIFF. The comedi core ensures that
>> that aref is only possible if the subdevice has the SDF_DIFF subdevice_flag
>> set. If so, the maximum channel is half the subdevice 'n_chan'. Use that
>> instead and remove the 'board' variable.
>>
>> Signed-off-by: H Hartley Sweeten 
>> ---
>>   drivers/staging/comedi/drivers/me4000.c | 8 
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/staging/comedi/drivers/me4000.c 
>> b/drivers/staging/comedi/drivers/me4000.c
>> index d6b7adc..a1b30f9 100644
>> --- a/drivers/staging/comedi/drivers/me4000.c
>> +++ b/drivers/staging/comedi/drivers/me4000.c
>> @@ -436,10 +436,10 @@ static void me4000_reset(struct comedi_device *dev)
>> 
>> ===*/
>>
>>   static int me4000_ai_insn_read(struct comedi_device *dev,
>> -   struct comedi_subdevice *subdevice,
>> -   struct comedi_insn *insn, unsigned int *data)
>> +   struct comedi_subdevice *s,
>> +   struct comedi_insn *insn,
>> +   unsigned int *data)
>>   {
>> -const struct me4000_board *board = dev->board_ptr;
>>  int chan = CR_CHAN(insn->chanspec);
>>  int rang = CR_RANGE(insn->chanspec);
>>  int aref = CR_AREF(insn->chanspec);
>> @@ -487,7 +487,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
>>  return -EINVAL;
>>  }
>>
>> -if (chan >= board->ai_diff_nchan) {
>> +if (chan >= (s->n_chan / 2)) {
>
> You also need to check that differential input mode is supported because 
> the comedi core doesn't verify the aref flags.  Since you are removing 
> the 'board' variable, that can be done by checking 's->subdev_flags & 
> SDF_DIFF' (since patch 03 ensures that is only set if differential mode 
> supported).

Gah... Now that you mentioned it, I knew that but forgot... I think I missed
It due the removal of the (unused) aref_invalid() function in range.c.

We might want to add a comment about the aref flags not being checked.

You had some other comments that I need to address in this series. I'll
do that and post a v2 later.

Thanks,
Hartley



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


[PATCH] staging: comedi: do not return -ENOSYS.

2015-08-05 Thread Ted Chen
fixed coding style issue by replacing ENOSYS
with EIO because it means 'invalid syscall nr'
and nothing else.

Signed-off-by: Ted Chen 
---
 drivers/staging/comedi/drivers.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index ed0b60c..b03bc66 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -820,7 +820,7 @@ int comedi_device_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 "driver '%s' does not support attach using 
comedi_config\n",
 driv->driver_name);
module_put(driv->module);
-   ret = -ENOSYS;
+   ret = -EIO;
goto out;
}
dev->driver = driv;
-- 
1.7.9.5

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


[PATCH v2 0/3] drivers: staging: wilc1000: Fix a few style errors

2015-08-05 Thread Chandra S Gorentla
v2 - Resending as v1 patch series did not apply cleanly.

These patches fixes a few style errors reported by checkpatch.pl.
PATCH 3/3 should be applied after PATCH 2/3.

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


[PATCH v2 3/3] drivers: staging: wilc1000: remove space after '('

2015-08-05 Thread Chandra S Gorentla
The character ' ' is removed after the character '('.  This fixes the
checkpatch.pl error - "space prohibited after that open
parenthesis '('".

---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 779ec5a..c886891 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1675,7 +1675,7 @@ static int WILC_WFI_get_station(struct wiphy *wiphy, 
struct net_device *dev,
 * kernel version 3.0.0
 */
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
-   BIT( 
NL80211_STA_INFO_RX_PACKETS) |
+   
BIT(NL80211_STA_INFO_RX_PACKETS) |

BIT(NL80211_STA_INFO_TX_PACKETS) |
BIT(NL80211_STA_INFO_TX_FAILED) 
|

BIT(NL80211_STA_INFO_TX_BITRATE);
-- 
2.5.0

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


[PATCH v2 1/3] drivers: staging: wilc1000: use 'void' for no arguments functions

2015-08-05 Thread Chandra S Gorentla
Added 'void' keyword in the paranthesis of function definitions, when
there are no arguments to the functions.  This fixes the checkpatch.pl
error - "Bad function definition 'function()' should probably be
function(void)".

---
 drivers/staging/wilc1000/linux_mon.c  | 2 +-
 drivers/staging/wilc1000/linux_wlan.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_mon.c 
b/drivers/staging/wilc1000/linux_mon.c
index aa20421..123468a 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -558,7 +558,7 @@ struct net_device *WILC_WFI_init_mon_interface(const char 
*name, struct net_devi
  *  @date  12 JUL 2012
  *  @version   1.0
  */
-int WILC_WFI_deinit_mon_interface()
+int WILC_WFI_deinit_mon_interface(void)
 {
bool rollback_lock = false;
 
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 3e55a8a..0a8052e 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -202,7 +202,7 @@ void printk_later(const char *format, ...)
 
 }
 
-void dump_logs()
+void dump_logs(void)
 {
if (DebugBuffer[0]) {
DebugBuffer[DEGUG_BUFFER_LENGTH] = 0;
@@ -216,7 +216,7 @@ void dump_logs()
}
 }
 
-void Reset_WatchDogdebugger()
+void Reset_WatchDogdebugger(void)
 {
WatchDogdebuggerCounter = 0;
 }
-- 
2.5.0

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


[PATCH v2 2/3] drivers: staging: wilc1000: move { to previous line

2015-08-05 Thread Chandra S Gorentla
Moved the opening brace of code blocks to the previous lines.  This
fixes the checkpatch.pl error - "that open brace { should be on the
previous line".

---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index c2ef46f..779ec5a 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1205,8 +1205,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct 
net_device *netdev, u8 k
 
 
 
-   if (!pairwise)
-   {
+   if (!pairwise) {
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
else
@@ -1304,8 +1303,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct 
net_device *netdev, u8 k
 
{
u8mode = 0;
-   if (!pairwise)
-   {
+   if (!pairwise) {
if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
/* swap the tx mic by rx mic */
pu8RxMic = params->key + 24;
@@ -1531,8 +1529,7 @@ static int WILC_WFI_get_key(struct wiphy *wiphy, struct 
net_device *netdev, u8 k
priv = wiphy_priv(wiphy);
 
 
-   if (!pairwise)
-   {
+   if (!pairwise) {
PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
 
key_params.key = priv->wilc_gtk[key_index]->key;
-- 
2.5.0

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


Re: [PATCH] staging: comedi: do not return -ENOSYS.

2015-08-05 Thread Ian Abbott

On 04/08/15 18:18, Ted Chen wrote:

fixed coding style issue by replacing ENOSYS
with EIO because it means 'invalid syscall nr'
and nothing else.

Signed-off-by: Ted Chen 
---
  drivers/staging/comedi/drivers.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index ed0b60c..b03bc66 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -820,7 +820,7 @@ int comedi_device_attach(struct comedi_device *dev, struct 
comedi_devconfig *it)
 "driver '%s' does not support attach using 
comedi_config\n",
 driv->driver_name);
module_put(driv->module);
-   ret = -ENOSYS;
+   ret = -EIO;
goto out;
}
dev->driver = driv;



Thanks.

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 1/3] drivers: staging: wilc1000: use 'void' for no arguments functions

2015-08-05 Thread Greg KH
On Wed, Aug 05, 2015 at 09:43:00PM +0530, Chandra S Gorentla wrote:
> Added 'void' keyword in the paranthesis of function definitions, when
> there are no arguments to the functions.  This fixes the checkpatch.pl
> error - "Bad function definition 'function()' should probably be
> function(void)".
> 
> ---
>  drivers/staging/wilc1000/linux_mon.c  | 2 +-
>  drivers/staging/wilc1000/linux_wlan.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch does not have a Signed-off-by: line.  Please read the
  kernel file, Documentation/SubmittingPatches and resend it after
  adding that line.  Note, the line needs to be in the body of the
  email, before the patch, not at the bottom of the patch or in the
  email signature.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 1/3] drivers: staging: wilc1000: use 'void' for no arguments functions

2015-08-05 Thread Chandra S Gorentla
Added 'void' keyword in the paranthesis of function definitions, when
there are no arguments to the functions.  This fixes the checkpatch.pl
error - "Bad function definition 'function()' should probably be
function(void)".

Signed-off-by: Chandra S Gorentla 
---
 drivers/staging/wilc1000/linux_mon.c  | 2 +-
 drivers/staging/wilc1000/linux_wlan.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_mon.c 
b/drivers/staging/wilc1000/linux_mon.c
index aa20421..123468a 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -558,7 +558,7 @@ struct net_device *WILC_WFI_init_mon_interface(const char 
*name, struct net_devi
  *  @date  12 JUL 2012
  *  @version   1.0
  */
-int WILC_WFI_deinit_mon_interface()
+int WILC_WFI_deinit_mon_interface(void)
 {
bool rollback_lock = false;
 
diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 3e55a8a..0a8052e 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -202,7 +202,7 @@ void printk_later(const char *format, ...)
 
 }
 
-void dump_logs()
+void dump_logs(void)
 {
if (DebugBuffer[0]) {
DebugBuffer[DEGUG_BUFFER_LENGTH] = 0;
@@ -216,7 +216,7 @@ void dump_logs()
}
 }
 
-void Reset_WatchDogdebugger()
+void Reset_WatchDogdebugger(void)
 {
WatchDogdebuggerCounter = 0;
 }
-- 
2.5.0

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


[PATCH v3 0/3] drivers: staging: wilc1000: Fix a few style errors

2015-08-05 Thread Chandra S Gorentla
v3 - Resending as v2 patch was series missing signedoff line.  Corrected now.

v2 - Resending as v1 patch series did not apply cleanly.

These patches fixes a few style errors reported by checkpatch.pl.
PATCH 3/3 should be applied after PATCH 2/3.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 2/3] drivers: staging: wilc1000: move { to previous line

2015-08-05 Thread Chandra S Gorentla
Moved the opening brace of code blocks to the previous lines.  This
fixes the checkpatch.pl error - "that open brace { should be on the
previous line".

Signed-off-by: Chandra S Gorentla 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index c2ef46f..779ec5a 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1205,8 +1205,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct 
net_device *netdev, u8 k
 
 
 
-   if (!pairwise)
-   {
+   if (!pairwise) {
if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
else
@@ -1304,8 +1303,7 @@ static int WILC_WFI_add_key(struct wiphy *wiphy, struct 
net_device *netdev, u8 k
 
{
u8mode = 0;
-   if (!pairwise)
-   {
+   if (!pairwise) {
if (params->key_len > 16 && params->cipher == 
WLAN_CIPHER_SUITE_TKIP) {
/* swap the tx mic by rx mic */
pu8RxMic = params->key + 24;
@@ -1531,8 +1529,7 @@ static int WILC_WFI_get_key(struct wiphy *wiphy, struct 
net_device *netdev, u8 k
priv = wiphy_priv(wiphy);
 
 
-   if (!pairwise)
-   {
+   if (!pairwise) {
PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
 
key_params.key = priv->wilc_gtk[key_index]->key;
-- 
2.5.0

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


[PATCH v3 3/3] drivers: staging: wilc1000: remove space after '('

2015-08-05 Thread Chandra S Gorentla
The character ' ' is removed after the character '('.  This fixes the
checkpatch.pl error - "space prohibited after that open
parenthesis '('".

Signed-off-by: Chandra S Gorentla 
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 779ec5a..c886891 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1675,7 +1675,7 @@ static int WILC_WFI_get_station(struct wiphy *wiphy, 
struct net_device *dev,
 * kernel version 3.0.0
 */
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
-   BIT( 
NL80211_STA_INFO_RX_PACKETS) |
+   
BIT(NL80211_STA_INFO_RX_PACKETS) |

BIT(NL80211_STA_INFO_TX_PACKETS) |
BIT(NL80211_STA_INFO_TX_FAILED) 
|

BIT(NL80211_STA_INFO_TX_BITRATE);
-- 
2.5.0

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


[PATCH] staging: comedi: improve comedi_check_chanlist() documentation

2015-08-05 Thread Ian Abbott
Signed-off-by: Ian Abbott 
---
 drivers/staging/comedi/range.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c
index 6a393b2..ce3a58a 100644
--- a/drivers/staging/comedi/range.c
+++ b/drivers/staging/comedi/range.c
@@ -102,7 +102,18 @@ int do_rangeinfo_ioctl(struct comedi_device *dev,
  * @s: comedi_subdevice struct
  * @n: number of elements in the chanlist
  * @chanlist: the chanlist to validate
-*/
+ *
+ * Each element consists of a channel number, a range index, an analog
+ * reference type and some flags, all packed into an unsigned int.
+ *
+ * This checks that the channel number and range index are supported by
+ * the comedi subdevice.  It does not check whether the analog reference
+ * type and the flags are supported.  Drivers that care should check those
+ * themselves.
+ *
+ * Return: %0 if all @chanlist elements are valid (success),
+ * %-EINVAL if one or more elements are invalid.
+ */
 int comedi_check_chanlist(struct comedi_subdevice *s, int n,
  unsigned int *chanlist)
 {
-- 
2.4.6

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


RE: [PATCH] staging: comedi: improve comedi_check_chanlist() documentation

2015-08-05 Thread Hartley Sweeten
On Wednesday, August 05, 2015 10:13 AM, Ian Abbott wrote:
>
> Signed-off-by: Ian Abbott 
> ---
>  drivers/staging/comedi/range.c | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c
> index 6a393b2..ce3a58a 100644
> --- a/drivers/staging/comedi/range.c
> +++ b/drivers/staging/comedi/range.c
> @@ -102,7 +102,18 @@ int do_rangeinfo_ioctl(struct comedi_device *dev,
>   * @s: comedi_subdevice struct
>   * @n: number of elements in the chanlist
>   * @chanlist: the chanlist to validate
> -*/
> + *
> + * Each element consists of a channel number, a range index, an analog
> + * reference type and some flags, all packed into an unsigned int.
> + *
> + * This checks that the channel number and range index are supported by
> + * the comedi subdevice.  It does not check whether the analog reference
> + * type and the flags are supported.  Drivers that care should check those
> + * themselves.
> + *
> + * Return: %0 if all @chanlist elements are valid (success),
> + * %-EINVAL if one or more elements are invalid.
> + */
>  int comedi_check_chanlist(struct comedi_subdevice *s, int n,
> unsigned int *chanlist)
>  {

Thanks,

Reviewed-by: H Hartley Sweeten 

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


[PATCH v2 01/46] staging: comedi: me4000: remove 'dio_nchan' boardinfo

2015-08-05 Thread H Hartley Sweeten
All the boards supported by this driver have 32 digital I/O channels.
Remove the unnecessary boardinfo.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index a8f3ca4..2b37c53 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -194,7 +194,6 @@ struct me4000_board {
int ai_diff_nchan;
int ai_sh_nchan;
int ex_trig_analog;
-   int dio_nchan;
int has_counter;
 };
 
@@ -202,20 +201,17 @@ static const struct me4000_board me4000_boards[] = {
[BOARD_ME4650] = {
.name   = "ME-4650",
.ai_nchan   = 16,
-   .dio_nchan  = 32,
},
[BOARD_ME4660] = {
.name   = "ME-4660",
.ai_nchan   = 32,
.ai_diff_nchan  = 16,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4660I] = {
.name   = "ME-4660i",
.ai_nchan   = 32,
.ai_diff_nchan  = 16,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4660S] = {
@@ -223,7 +219,6 @@ static const struct me4000_board me4000_boards[] = {
.ai_nchan   = 32,
.ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4660IS] = {
@@ -231,7 +226,6 @@ static const struct me4000_board me4000_boards[] = {
.ai_nchan   = 32,
.ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4670] = {
@@ -240,7 +234,6 @@ static const struct me4000_board me4000_boards[] = {
.ai_nchan   = 32,
.ai_diff_nchan  = 16,
.ex_trig_analog = 1,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4670I] = {
@@ -249,7 +242,6 @@ static const struct me4000_board me4000_boards[] = {
.ai_nchan   = 32,
.ai_diff_nchan  = 16,
.ex_trig_analog = 1,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4670S] = {
@@ -259,7 +251,6 @@ static const struct me4000_board me4000_boards[] = {
.ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
.ex_trig_analog = 1,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4670IS] = {
@@ -269,7 +260,6 @@ static const struct me4000_board me4000_boards[] = {
.ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
.ex_trig_analog = 1,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4680] = {
@@ -279,7 +269,6 @@ static const struct me4000_board me4000_boards[] = {
.ai_nchan   = 32,
.ai_diff_nchan  = 16,
.ex_trig_analog = 1,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4680I] = {
@@ -289,7 +278,6 @@ static const struct me4000_board me4000_boards[] = {
.ai_nchan   = 32,
.ai_diff_nchan  = 16,
.ex_trig_analog = 1,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4680S] = {
@@ -300,7 +288,6 @@ static const struct me4000_board me4000_boards[] = {
.ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
.ex_trig_analog = 1,
-   .dio_nchan  = 32,
.has_counter= 1,
},
[BOARD_ME4680IS] = {
@@ -311,7 +298,6 @@ static const struct me4000_board me4000_boards[] = {
.ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
.ex_trig_analog = 1,
-   .dio_nchan  = 32,
.has_counter= 1,
},
 };
@@ -1343,23 +1329,15 @@ static int me4000_auto_attach(struct comedi_device *dev,
s->type = COMEDI_SUBD_UNUSED;
}
 
-/*=
-  Digital I/O subdevice
-  
*/
-
+   /* Digital I/O subdevice */
s = &dev->subdevices[2];
-
-   if (board->dio_nchan) {
-   s->type = COMEDI_SUBD_DIO;
-   s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
-   s->n_chan = board->dio_ncha

[PATCH v2 02/46] staging: comedi: me4000: all board types have analog inputs

2015-08-05 Thread H Hartley Sweeten
All the boards supported by this driver have analog inputs. They just
differ in the number of channels (32 or 16).

Always initialize the analog input subdevice in me4000_auto_attach().

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 2b37c53..3d45217 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -1281,31 +1281,22 @@ static int me4000_auto_attach(struct comedi_device *dev,
if (result)
return result;
 
-/*=
-  Analog input subdevice
-  
*/
-
+   /* Analog Input subdevice */
s = &dev->subdevices[0];
-
-   if (board->ai_nchan) {
-   s->type = COMEDI_SUBD_AI;
-   s->subdev_flags =
-   SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF;
-   s->n_chan = board->ai_nchan;
-   s->maxdata = 0x;/*  16 bit ADC */
-   s->len_chanlist = ME4000_AI_CHANNEL_LIST_COUNT;
-   s->range_table = &me4000_ai_range;
-   s->insn_read = me4000_ai_insn_read;
-
-   if (dev->irq) {
-   dev->read_subdev = s;
-   s->subdev_flags |= SDF_CMD_READ;
-   s->cancel = me4000_ai_cancel;
-   s->do_cmdtest = me4000_ai_do_cmd_test;
-   s->do_cmd = me4000_ai_do_cmd;
-   }
-   } else {
-   s->type = COMEDI_SUBD_UNUSED;
+   s->type = COMEDI_SUBD_AI;
+   s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF;
+   s->n_chan   = board->ai_nchan;
+   s->maxdata  = 0x;
+   s->len_chanlist = ME4000_AI_CHANNEL_LIST_COUNT;
+   s->range_table  = &me4000_ai_range;
+   s->insn_read= me4000_ai_insn_read;
+
+   if (dev->irq) {
+   dev->read_subdev = s;
+   s->subdev_flags |= SDF_CMD_READ;
+   s->cancel   = me4000_ai_cancel;
+   s->do_cmdtest   = me4000_ai_do_cmd_test;
+   s->do_cmd   = me4000_ai_do_cmd;
}
 
 /*=
-- 
2.4.3

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


[PATCH v2 00/46] staging: comedi: me4000: cleanup driver

2015-08-05 Thread H Hartley Sweeten
Here's the big cleanup series for the Comedi me4000 driver.

This fixes all the checkpatch issues and removes a bunch of cruft
from the driver.

v2: Address some issues pointed out by Ian Abbott, the comedi core
does not validate the 'aref' so the driver needs to handle it.

H Hartley Sweeten (46):
  staging: comedi: me4000: remove 'dio_nchan' boardinfo
  staging: comedi: me4000: all board types have analog inputs
  staging: comedi: me4000: only set SDF_DIFF when supported
  staging: comedi: me4000: remove 'chan' check in me4000_ai_insn_read()
  staging: comedi: me4000: remove 'board' from me4000_ai_insn_read()
  staging: comedi: me4000: remove 'board' from me4000_ai_check_chanlist()
  staging: comedi: me4000: make boardinfo flags bit-fields
  staging: comedi: me4000: refactor 'ai_diff_nchan' boardinfo
  staging: comedi: me4000: refactor 'ao_nchan' boardinfo
  staging: comedi: me4000: refactor 'ao_fifo' boardinfo
  staging: comedi: me4000: refactor 'ai_sh_nchan' boardinfo
  staging: comedi: me4000: rename local variables used for 'dev->private'
  staging: comedi: me4000: remove unnecessary ME4000_AI_LIST_INPUT_SINGLE_ENDED
  staging: comedi: me4000: simplify analog input range programming
  staging: comedi: me4000: fix ai_write_chanlist()
  staging: comedi: me4000: tidy up ME4000_AI_CHANNEL_LIST_REG bit defines
  staging: comedi: me4000: use comedi_timeout() to wait for ai (*insn_read)
  staging: comedi: me4000: fix me4000_ai_insn_read()
  staging: comedi: me4000: use correct types for extracted chanspec values
  staging: comedi: me4000: use comedi_range_is_bipolar() in ai (*insn_read)
  staging: comedi: me4000: tidy up ME4000_AI_STATUS_REG bit defines
  staging: comedi: me4000: tidy up ME4000_AI_CTRL_REG bit defines
  staging: comedi: me4000: tidy up ME4000_IRQ_STATUS_REG bit defines
  staging: comedi: me4000: tidy up ME4000_AO_STATUS_REG bit defines
  staging: comedi: me4000: tidy up ME4000_AO_CTRL_REG bit defines
  staging: comedi: me4000: tidy up ME4000_DIO_CTRL_REG bit defines
  staging: comedi: me4000: return void from ai_round_cmd_args()
  staging: comedi: me4000: move ai command timing values into private data
  staging: comedi: me4000: simplify ai_prepare()
  staging: comedi: me4000: absorb ai_prepare()
  staging: comedi: me4000: absorb ai_write_timer()
  staging: comedi: me4000: return void from me4000_ai_write_chanlist()
  staging: comedi: me4000: fix me4000_ai_cancel()
  staging: comedi: me4000: remove unnecessary ai control register reset
  staging: comedi: me4000: remove unnecessary me4000_ai_cancel()
  staging: comedi: me4000: clear the ME4000_AI_CTRL_REG in me4000_reset()
  staging: comedi: me4000: introduce me4000_ai_reset()
  staging: comedi: me4000: only enable PLX interrupt if we have and irq
  staging: comedi: me4000: fix me4000_detach()
  staging: comedi: me4000: tidy up analog output subdevice init
  staging: comedi: me4000: comedi_handle_events() will stop conversions
  staging: comedi: me4000: introduce me4000_ai_get_sample()
  staging: comedi: me4000: usleep_range is preferred over udelay
  staging: comedi: me4000: cleanup multi-line comments
  staging: comedi: me4000: updata driver status in comedi comment
  staging: comedi: me4000: update MODULE_DESCRIPTION

 drivers/staging/comedi/drivers/me4000.c | 1000 +--
 1 file changed, 422 insertions(+), 578 deletions(-)

-- 
2.4.3

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


[PATCH v2 03/46] staging: comedi: me4000: only set SDF_DIFF when supported

2015-08-05 Thread H Hartley Sweeten
Some of the boards supported by this driver do not have differential analog
inputs. Only set the SDF_DIFF subdev_flag when the board supports it.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 3d45217..171749b 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -1284,7 +1284,9 @@ static int me4000_auto_attach(struct comedi_device *dev,
/* Analog Input subdevice */
s = &dev->subdevices[0];
s->type = COMEDI_SUBD_AI;
-   s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF;
+   s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND;
+   if (board->ai_diff_nchan)
+   s->subdev_flags |= SDF_DIFF;
s->n_chan   = board->ai_nchan;
s->maxdata  = 0x;
s->len_chanlist = ME4000_AI_CHANNEL_LIST_COUNT;
-- 
2.4.3

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


[PATCH v2 04/46] staging: comedi: me4000: remove 'chan' check in me4000_ai_insn_read()

2015-08-05 Thread H Hartley Sweeten
The comedi core validates that the 'chan' is valid for the subdevice
before calling the (*insn_read) operation. Remove the unnecessary check.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 171749b..d6b7adc 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -477,11 +477,6 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
switch (aref) {
case AREF_GROUND:
case AREF_COMMON:
-   if (chan >= board->ai_nchan) {
-   dev_err(dev->class_dev,
-   "Analog input is not available\n");
-   return -EINVAL;
-   }
entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED | chan;
break;
 
-- 
2.4.3

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


[PATCH v2 05/46] staging: comedi: me4000: remove 'board' from me4000_ai_insn_read()

2015-08-05 Thread H Hartley Sweeten
The 'board' pointer is only used in this function to verify that the
'chan' is valid for an aref of AREF_DIFF. For differential inputs, the
maximum channel is half the subdevice 'n_chan'. Use that instead and
remove the 'board' variable.

Also, the comedi core does not validate the aref flags. Add a check
to ensure that the subdevice actually supports the AREF_DIFF mode.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index d6b7adc..335fafc 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -436,10 +436,10 @@ static void me4000_reset(struct comedi_device *dev)
   ===*/
 
 static int me4000_ai_insn_read(struct comedi_device *dev,
-  struct comedi_subdevice *subdevice,
-  struct comedi_insn *insn, unsigned int *data)
+  struct comedi_subdevice *s,
+  struct comedi_insn *insn,
+  unsigned int *data)
 {
-   const struct me4000_board *board = dev->board_ptr;
int chan = CR_CHAN(insn->chanspec);
int rang = CR_RANGE(insn->chanspec);
int aref = CR_AREF(insn->chanspec);
@@ -481,13 +481,19 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
break;
 
case AREF_DIFF:
+   if (!(s->subdev_flags && SDF_DIFF)) {
+   dev_err(dev->class_dev,
+   "Differential inputs are not available\n");
+   return -EINVAL;
+   }
+
if (rang == 0 || rang == 1) {
dev_err(dev->class_dev,
"Range must be bipolar when aref = diff\n");
return -EINVAL;
}
 
-   if (chan >= board->ai_diff_nchan) {
+   if (chan >= (s->n_chan / 2)) {
dev_err(dev->class_dev,
"Analog input is not available\n");
return -EINVAL;
-- 
2.4.3

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


[PATCH v2 06/46] staging: comedi: me4000: remove 'board' from me4000_ai_check_chanlist()

2015-08-05 Thread H Hartley Sweeten
The maximum differential channel is half the subdevice 'n_chan'. Use
that instead and remove the need for the 'board' variable.

Also, the comedi core does no validate the aref flags. Add a check
to ensure that the subdevice actually supports the AREF_DIFF mode.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 335fafc..008929e 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -568,8 +568,6 @@ static int me4000_ai_check_chanlist(struct comedi_device 
*dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
 {
-   const struct me4000_board *board = dev->board_ptr;
-   unsigned int max_diff_chan = board->ai_diff_nchan;
unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
int i;
 
@@ -585,7 +583,13 @@ static int me4000_ai_check_chanlist(struct comedi_device 
*dev,
}
 
if (aref == AREF_DIFF) {
-   if (chan >= max_diff_chan) {
+   if (!(s->subdev_flags && SDF_DIFF)) {
+   dev_err(dev->class_dev,
+   "Differential inputs are not 
available\n");
+   return -EINVAL;
+   }
+
+   if (chan >= (s->n_chan / 2)) {
dev_dbg(dev->class_dev,
"Channel number to high\n");
return -EINVAL;
-- 
2.4.3

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


[PATCH v2 07/46] staging: comedi: me4000: make boardinfo flags bit-fields

2015-08-05 Thread H Hartley Sweeten
Change the boardinfo 'has_counter' and 'ai_trig_analog' flags into
bit-fields to save a bit of space.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 008929e..cc05c88 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -193,8 +193,8 @@ struct me4000_board {
int ai_nchan;
int ai_diff_nchan;
int ai_sh_nchan;
-   int ex_trig_analog;
-   int has_counter;
+   unsigned int ex_trig_analog:1;
+   unsigned int has_counter:1;
 };
 
 static const struct me4000_board me4000_boards[] = {
-- 
2.4.3

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


[PATCH v2 08/46] staging: comedi: me4000: refactor 'ai_diff_nchan' boardinfo

2015-08-05 Thread H Hartley Sweeten
This member of the boardinfo is only used as a flag indicating that the
board supports differential analog inputs. Convert the member to a bit-
field to save a bit of space. For aesthetics, rename the member to
'can_do_diff_ai'.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index cc05c88..7eade91 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -191,8 +191,8 @@ struct me4000_board {
int ao_nchan;
int ao_fifo;
int ai_nchan;
-   int ai_diff_nchan;
int ai_sh_nchan;
+   unsigned int can_do_diff_ai:1;
unsigned int ex_trig_analog:1;
unsigned int has_counter:1;
 };
@@ -205,34 +205,34 @@ static const struct me4000_board me4000_boards[] = {
[BOARD_ME4660] = {
.name   = "ME-4660",
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
+   .can_do_diff_ai = 1,
.has_counter= 1,
},
[BOARD_ME4660I] = {
.name   = "ME-4660i",
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
+   .can_do_diff_ai = 1,
.has_counter= 1,
},
[BOARD_ME4660S] = {
.name   = "ME-4660s",
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
+   .can_do_diff_ai = 1,
.has_counter= 1,
},
[BOARD_ME4660IS] = {
.name   = "ME-4660is",
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
+   .can_do_diff_ai = 1,
.has_counter= 1,
},
[BOARD_ME4670] = {
.name   = "ME-4670",
.ao_nchan   = 4,
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
+   .can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_counter= 1,
},
@@ -240,7 +240,7 @@ static const struct me4000_board me4000_boards[] = {
.name   = "ME-4670i",
.ao_nchan   = 4,
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
+   .can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_counter= 1,
},
@@ -248,8 +248,8 @@ static const struct me4000_board me4000_boards[] = {
.name   = "ME-4670s",
.ao_nchan   = 4,
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
+   .can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_counter= 1,
},
@@ -257,8 +257,8 @@ static const struct me4000_board me4000_boards[] = {
.name   = "ME-4670is",
.ao_nchan   = 4,
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
+   .can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_counter= 1,
},
@@ -267,7 +267,7 @@ static const struct me4000_board me4000_boards[] = {
.ao_nchan   = 4,
.ao_fifo= 4,
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
+   .can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_counter= 1,
},
@@ -276,7 +276,7 @@ static const struct me4000_board me4000_boards[] = {
.ao_nchan   = 4,
.ao_fifo= 4,
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
+   .can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_counter= 1,
},
@@ -285,8 +285,8 @@ static const struct me4000_board me4000_boards[] = {
.ao_nchan   = 4,
.ao_fifo= 4,
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
+   .can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_counter= 1,
},
@@ -295,8 +295,8 @@ static const struct me4000_board me4000_boards[] = {
.ao_nchan   = 4,
.ao_fifo= 4,
.ai_nchan   = 32,
-   .ai_diff_nchan  = 16,
.ai_sh_nchan= 8,
+   .can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_counter= 1,
},
@@ -1290,7 +1290,7 @@ static int me4000_auto_attach(struct comedi_device *dev,
   

[PATCH v2 11/46] staging: comedi: me4000: refactor 'ai_sh_nchan' boardinfo

2015-08-05 Thread H Hartley Sweeten
Some of the boards supported by this driver can do analog input sample &
hold on 8 of the channels. The 'ai_sh_nchan' member of the boardinfo is
used to indicate which boards support this feature. To save a bit of space,
convert this member to a bit-field, 'can_do_sh_ai'. Note, this feature is
not currently supported.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 1d88c71..2a975e6 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -189,8 +189,8 @@ enum me4000_boardid {
 struct me4000_board {
const char *name;
int ai_nchan;
-   int ai_sh_nchan;
unsigned int can_do_diff_ai:1;
+   unsigned int can_do_sh_ai:1;/* sample & hold (8 channels) */
unsigned int ex_trig_analog:1;
unsigned int has_ao:1;
unsigned int has_ao_fifo:1;
@@ -217,15 +217,15 @@ static const struct me4000_board me4000_boards[] = {
[BOARD_ME4660S] = {
.name   = "ME-4660s",
.ai_nchan   = 32,
-   .ai_sh_nchan= 8,
.can_do_diff_ai = 1,
+   .can_do_sh_ai   = 1,
.has_counter= 1,
},
[BOARD_ME4660IS] = {
.name   = "ME-4660is",
.ai_nchan   = 32,
-   .ai_sh_nchan= 8,
.can_do_diff_ai = 1,
+   .can_do_sh_ai   = 1,
.has_counter= 1,
},
[BOARD_ME4670] = {
@@ -247,8 +247,8 @@ static const struct me4000_board me4000_boards[] = {
[BOARD_ME4670S] = {
.name   = "ME-4670s",
.ai_nchan   = 32,
-   .ai_sh_nchan= 8,
.can_do_diff_ai = 1,
+   .can_do_sh_ai   = 1,
.ex_trig_analog = 1,
.has_ao = 1,
.has_counter= 1,
@@ -256,8 +256,8 @@ static const struct me4000_board me4000_boards[] = {
[BOARD_ME4670IS] = {
.name   = "ME-4670is",
.ai_nchan   = 32,
-   .ai_sh_nchan= 8,
.can_do_diff_ai = 1,
+   .can_do_sh_ai   = 1,
.ex_trig_analog = 1,
.has_ao = 1,
.has_counter= 1,
@@ -283,8 +283,8 @@ static const struct me4000_board me4000_boards[] = {
[BOARD_ME4680S] = {
.name   = "ME-4680s",
.ai_nchan   = 32,
-   .ai_sh_nchan= 8,
.can_do_diff_ai = 1,
+   .can_do_sh_ai   = 1,
.ex_trig_analog = 1,
.has_ao = 1,
.has_ao_fifo= 1,
@@ -293,8 +293,8 @@ static const struct me4000_board me4000_boards[] = {
[BOARD_ME4680IS] = {
.name   = "ME-4680is",
.ai_nchan   = 32,
-   .ai_sh_nchan= 8,
.can_do_diff_ai = 1,
+   .can_do_sh_ai   = 1,
.ex_trig_analog = 1,
.has_ao = 1,
.has_ao_fifo= 1,
-- 
2.4.3

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


[PATCH v2 09/46] staging: comedi: me4000: refactor 'ao_nchan' boardinfo

2015-08-05 Thread H Hartley Sweeten
For the boards that have analog output capability, there are always
4 analog output channels. Convert the 'ao_nchan' member of the boardinfo
into a bit-field, 'has_ao', to save a bit of space and set the analog
output subdevice 'n_chan' to 4 when supported.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 7eade91..2f11cdd 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -188,12 +188,12 @@ enum me4000_boardid {
 
 struct me4000_board {
const char *name;
-   int ao_nchan;
int ao_fifo;
int ai_nchan;
int ai_sh_nchan;
unsigned int can_do_diff_ai:1;
unsigned int ex_trig_analog:1;
+   unsigned int has_ao:1;
unsigned int has_counter:1;
 };
 
@@ -230,74 +230,74 @@ static const struct me4000_board me4000_boards[] = {
},
[BOARD_ME4670] = {
.name   = "ME-4670",
-   .ao_nchan   = 4,
.ai_nchan   = 32,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
+   .has_ao = 1,
.has_counter= 1,
},
[BOARD_ME4670I] = {
.name   = "ME-4670i",
-   .ao_nchan   = 4,
.ai_nchan   = 32,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
+   .has_ao = 1,
.has_counter= 1,
},
[BOARD_ME4670S] = {
.name   = "ME-4670s",
-   .ao_nchan   = 4,
.ai_nchan   = 32,
.ai_sh_nchan= 8,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
+   .has_ao = 1,
.has_counter= 1,
},
[BOARD_ME4670IS] = {
.name   = "ME-4670is",
-   .ao_nchan   = 4,
.ai_nchan   = 32,
.ai_sh_nchan= 8,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
+   .has_ao = 1,
.has_counter= 1,
},
[BOARD_ME4680] = {
.name   = "ME-4680",
-   .ao_nchan   = 4,
.ao_fifo= 4,
.ai_nchan   = 32,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
+   .has_ao = 1,
.has_counter= 1,
},
[BOARD_ME4680I] = {
.name   = "ME-4680i",
-   .ao_nchan   = 4,
.ao_fifo= 4,
.ai_nchan   = 32,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
+   .has_ao = 1,
.has_counter= 1,
},
[BOARD_ME4680S] = {
.name   = "ME-4680s",
-   .ao_nchan   = 4,
.ao_fifo= 4,
.ai_nchan   = 32,
.ai_sh_nchan= 8,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
+   .has_ao = 1,
.has_counter= 1,
},
[BOARD_ME4680IS] = {
.name   = "ME-4680is",
-   .ao_nchan   = 4,
.ao_fifo= 4,
.ai_nchan   = 32,
.ai_sh_nchan= 8,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
+   .has_ao = 1,
.has_counter= 1,
},
 };
@@ -1312,10 +1312,10 @@ static int me4000_auto_attach(struct comedi_device *dev,
 
s = &dev->subdevices[1];
 
-   if (board->ao_nchan) {
+   if (board->has_ao) {
s->type = COMEDI_SUBD_AO;
s->subdev_flags = SDF_WRITABLE | SDF_COMMON | SDF_GROUND;
-   s->n_chan = board->ao_nchan;
+   s->n_chan = 4;
s->maxdata = 0x;/*  16 bit DAC */
s->range_table = &range_bipolar10;
s->insn_write = me4000_ao_insn_write;
-- 
2.4.3

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


[PATCH v2 12/46] staging: comedi: me4000: rename local variables used for 'dev->private'

2015-08-05 Thread H Hartley Sweeten
In comedi drivers the local variable used for the dev->private pointer is
normally named 'devpriv'. For aesthetics, rename the variables in this
driver. Also, rename the struct to follow the norm.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 2a975e6..0a85ea5 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -166,7 +166,7 @@ broken.
 
 #define ME4000_AI_CHANNEL_LIST_COUNT   1024
 
-struct me4000_info {
+struct me4000_private {
unsigned long plx_regbase;
 };
 
@@ -316,7 +316,7 @@ static int me4000_xilinx_download(struct comedi_device *dev,
  unsigned long context)
 {
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
-   struct me4000_info *info = dev->private;
+   struct me4000_private *devpriv = dev->private;
unsigned long xilinx_iobase = pci_resource_start(pcidev, 5);
unsigned int file_length;
unsigned int val;
@@ -329,28 +329,28 @@ static int me4000_xilinx_download(struct comedi_device 
*dev,
 * Set PLX local interrupt 2 polarity to high.
 * Interrupt is thrown by init pin of xilinx.
 */
-   outl(PLX9052_INTCSR_LI2POL, info->plx_regbase + PLX9052_INTCSR);
+   outl(PLX9052_INTCSR_LI2POL, devpriv->plx_regbase + PLX9052_INTCSR);
 
/* Set /CS and /WRITE of the Xilinx */
-   val = inl(info->plx_regbase + PLX9052_CNTRL);
+   val = inl(devpriv->plx_regbase + PLX9052_CNTRL);
val |= PLX9052_CNTRL_UIO2_DATA;
-   outl(val, info->plx_regbase + PLX9052_CNTRL);
+   outl(val, devpriv->plx_regbase + PLX9052_CNTRL);
 
/* Init Xilinx with CS1 */
inb(xilinx_iobase + 0xC8);
 
/* Wait until /INIT pin is set */
udelay(20);
-   val = inl(info->plx_regbase + PLX9052_INTCSR);
+   val = inl(devpriv->plx_regbase + PLX9052_INTCSR);
if (!(val & PLX9052_INTCSR_LI2STAT)) {
dev_err(dev->class_dev, "Can't init Xilinx\n");
return -EIO;
}
 
/* Reset /CS and /WRITE of the Xilinx */
-   val = inl(info->plx_regbase + PLX9052_CNTRL);
+   val = inl(devpriv->plx_regbase + PLX9052_CNTRL);
val &= ~PLX9052_CNTRL_UIO2_DATA;
-   outl(val, info->plx_regbase + PLX9052_CNTRL);
+   outl(val, devpriv->plx_regbase + PLX9052_CNTRL);
 
/* Download Xilinx firmware */
file_length = (((unsigned int)data[0] & 0xff) << 24) +
@@ -364,7 +364,7 @@ static int me4000_xilinx_download(struct comedi_device *dev,
udelay(10);
 
/* Check if BUSY flag is low */
-   val = inl(info->plx_regbase + PLX9052_CNTRL);
+   val = inl(devpriv->plx_regbase + PLX9052_CNTRL);
if (val & PLX9052_CNTRL_UIO1_DATA) {
dev_err(dev->class_dev,
"Xilinx is still busy (i = %d)\n", i);
@@ -373,7 +373,7 @@ static int me4000_xilinx_download(struct comedi_device *dev,
}
 
/* If done flag is high download was successful */
-   val = inl(info->plx_regbase + PLX9052_CNTRL);
+   val = inl(devpriv->plx_regbase + PLX9052_CNTRL);
if (!(val & PLX9052_CNTRL_UIO0_DATA)) {
dev_err(dev->class_dev, "DONE flag is not set\n");
dev_err(dev->class_dev, "Download not successful\n");
@@ -381,25 +381,25 @@ static int me4000_xilinx_download(struct comedi_device 
*dev,
}
 
/* Set /CS and /WRITE */
-   val = inl(info->plx_regbase + PLX9052_CNTRL);
+   val = inl(devpriv->plx_regbase + PLX9052_CNTRL);
val |= PLX9052_CNTRL_UIO2_DATA;
-   outl(val, info->plx_regbase + PLX9052_CNTRL);
+   outl(val, devpriv->plx_regbase + PLX9052_CNTRL);
 
return 0;
 }
 
 static void me4000_reset(struct comedi_device *dev)
 {
-   struct me4000_info *info = dev->private;
+   struct me4000_private *devpriv = dev->private;
unsigned int val;
int chan;
 
/* Make a hardware reset */
-   val = inl(info->plx_regbase + PLX9052_CNTRL);
+   val = inl(devpriv->plx_regbase + PLX9052_CNTRL);
val |= PLX9052_CNTRL_PCI_RESET;
-   outl(val, info->plx_regbase + PLX9052_CNTRL);
+   outl(val, devpriv->plx_regbase + PLX9052_CNTRL);
val &= ~PLX9052_CNTRL_PCI_RESET;
-   outl(val, info->plx_regbase + PLX9052_CNTRL);
+   outl(val, devpriv->plx_regbase + PLX9052_CNTRL);
 
/* 0x8000 to the DACs means an output voltage of 0V */
for (chan = 0; chan < 4; chan++)
@@ -417,7 +417,7 @@ static void me4000_reset(struct comedi_device *dev)
/* Enable interrupts on the PLX */
outl(PLX9052_INTCSR_LI1ENAB |
 PLX9052_INTCSR_LI1POL |
-

[PATCH v2 13/46] staging: comedi: me4000: remove unnecessary ME4000_AI_LIST_INPUT_SINGLE_ENDED

2015-08-05 Thread H Hartley Sweeten
This define evaluates to 0 and is OR'ed with the 'entry' value that is
written to the ME4000_AI_CHANNEL_LIST_REG when the channel aref is a
single-ended type (AREF_GROUND or AREF_COMMON). OR'ing a zero value is
pretty silly, just remove it.

Remove the switch() in me4000_ai_insn_read() to simplify the code.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 0a85ea5..ba3313c 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -110,7 +110,6 @@ broken.
 #define ME4000_AI_STATUS_BIT_FSM   (1 << 29)
 #define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH(1 << 31)
 #define ME4000_AI_CHANNEL_LIST_REG 0x78
-#define ME4000_AI_LIST_INPUT_SINGLE_ENDED  (0 << 5)
 #define ME4000_AI_LIST_INPUT_DIFFERENTIAL  (1 << 5)
 #define ME4000_AI_LIST_RANGE_BIPOLAR_10(0 << 6)
 #define ME4000_AI_LIST_RANGE_BIPOLAR_2_5   (1 << 6)
@@ -474,13 +473,8 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
return -EINVAL;
}
 
-   switch (aref) {
-   case AREF_GROUND:
-   case AREF_COMMON:
-   entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED | chan;
-   break;
-
-   case AREF_DIFF:
+   entry |= chan;
+   if (aref == AREF_DIFF) {
if (!(s->subdev_flags && SDF_DIFF)) {
dev_err(dev->class_dev,
"Differential inputs are not available\n");
@@ -498,11 +492,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
"Analog input is not available\n");
return -EINVAL;
}
-   entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL | chan;
-   break;
-   default:
-   dev_err(dev->class_dev, "Invalid aref specified\n");
-   return -EINVAL;
+   entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
}
 
entry |= ME4000_AI_LIST_LAST_ENTRY;
@@ -703,8 +693,6 @@ static int ai_write_chanlist(struct comedi_device *dev,
 
if (aref == AREF_DIFF)
entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
-   else
-   entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED;
 
outl(entry, dev->iobase + ME4000_AI_CHANNEL_LIST_REG);
}
-- 
2.4.3

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


[PATCH v2 10/46] staging: comedi: me4000: refactor 'ao_fifo' boardinfo

2015-08-05 Thread H Hartley Sweeten
This member of the boardinfo is always '4' for the boards that have an
analog output FIFO. Covert it to a bit-field, 'has_ao_fifo', to save a
bit of space.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 2f11cdd..1d88c71 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -188,12 +188,12 @@ enum me4000_boardid {
 
 struct me4000_board {
const char *name;
-   int ao_fifo;
int ai_nchan;
int ai_sh_nchan;
unsigned int can_do_diff_ai:1;
unsigned int ex_trig_analog:1;
unsigned int has_ao:1;
+   unsigned int has_ao_fifo:1;
unsigned int has_counter:1;
 };
 
@@ -264,40 +264,40 @@ static const struct me4000_board me4000_boards[] = {
},
[BOARD_ME4680] = {
.name   = "ME-4680",
-   .ao_fifo= 4,
.ai_nchan   = 32,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_ao = 1,
+   .has_ao_fifo= 1,
.has_counter= 1,
},
[BOARD_ME4680I] = {
.name   = "ME-4680i",
-   .ao_fifo= 4,
.ai_nchan   = 32,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_ao = 1,
+   .has_ao_fifo= 1,
.has_counter= 1,
},
[BOARD_ME4680S] = {
.name   = "ME-4680s",
-   .ao_fifo= 4,
.ai_nchan   = 32,
.ai_sh_nchan= 8,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_ao = 1,
+   .has_ao_fifo= 1,
.has_counter= 1,
},
[BOARD_ME4680IS] = {
.name   = "ME-4680is",
-   .ao_fifo= 4,
.ai_nchan   = 32,
.ai_sh_nchan= 8,
.can_do_diff_ai = 1,
.ex_trig_analog = 1,
.has_ao = 1,
+   .has_ao_fifo= 1,
.has_counter= 1,
},
 };
-- 
2.4.3

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


[PATCH v2 14/46] staging: comedi: me4000: simplify analog input range programming

2015-08-05 Thread H Hartley Sweeten
The comedi_lrange table for the analog inputs is inverted compared
to the values that need to be written to the ME4000_AI_CHANNEL_LIST_REG
to select the range.

Create a macro, ME4000_AI_LIST_RANGE(), to handle the inversion. Remove
the old defines and simplify the code a bit.

Signed-off-by: H Hartley Sweeten 
Cc: Ian Abbott 
Cc: Greg Kroah-Hartman # Please enter the commit 
message for your changes. Lines starting
---
 drivers/staging/comedi/drivers/me4000.c | 41 -
 1 file changed, 9 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index ba3313c..1001d63 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -111,10 +111,7 @@ broken.
 #define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH(1 << 31)
 #define ME4000_AI_CHANNEL_LIST_REG 0x78
 #define ME4000_AI_LIST_INPUT_DIFFERENTIAL  (1 << 5)
-#define ME4000_AI_LIST_RANGE_BIPOLAR_10(0 << 6)
-#define ME4000_AI_LIST_RANGE_BIPOLAR_2_5   (1 << 6)
-#define ME4000_AI_LIST_RANGE_UNIPOLAR_10   (2 << 6)
-#define ME4000_AI_LIST_RANGE_UNIPOLAR_2_5  (3 << 6)
+#define ME4000_AI_LIST_RANGE(x)((3 - ((x) & 3)) << 6)
 #define ME4000_AI_LIST_LAST_ENTRY  (1 << 8)
 #define ME4000_AI_DATA_REG 0x7c
 #define ME4000_AI_CHAN_TIMER_REG   0x80
@@ -301,6 +298,12 @@ static const struct me4000_board me4000_boards[] = {
},
 };
 
+/*
+ * NOTE: the ranges here are inverted compared to the values
+ * written to the ME4000_AI_CHANNEL_LIST_REG,
+ *
+ * The ME4000_AI_LIST_RANGE() macro handles the inversion.
+ */
 static const struct comedi_lrange me4000_ai_range = {
4, {
UNI_RANGE(2.5),
@@ -455,24 +458,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
return -EINVAL;
}
 
-   switch (rang) {
-   case 0:
-   entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_2_5;
-   break;
-   case 1:
-   entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_10;
-   break;
-   case 2:
-   entry |= ME4000_AI_LIST_RANGE_BIPOLAR_2_5;
-   break;
-   case 3:
-   entry |= ME4000_AI_LIST_RANGE_BIPOLAR_10;
-   break;
-   default:
-   dev_err(dev->class_dev, "Invalid range specified\n");
-   return -EINVAL;
-   }
-
+   entry |= ME4000_AI_LIST_RANGE(rang);
entry |= chan;
if (aref == AREF_DIFF) {
if (!(s->subdev_flags && SDF_DIFF)) {
@@ -680,16 +666,7 @@ static int ai_write_chanlist(struct comedi_device *dev,
rang = CR_RANGE(cmd->chanlist[i]);
aref = CR_AREF(cmd->chanlist[i]);
 
-   entry = chan;
-
-   if (rang == 0)
-   entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_2_5;
-   else if (rang == 1)
-   entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_10;
-   else if (rang == 2)
-   entry |= ME4000_AI_LIST_RANGE_BIPOLAR_2_5;
-   else
-   entry |= ME4000_AI_LIST_RANGE_BIPOLAR_10;
+   entry = chan | ME4000_AI_LIST_RANGE(rang);
 
if (aref == AREF_DIFF)
entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
-- 
2.4.3

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


[PATCH v2 15/46] staging: comedi: me4000: fix ai_write_chanlist()

2015-08-05 Thread H Hartley Sweeten
Rename this function so it has namespace associated with the driver.

The last entry of the chanlist needs the ME4000_AI_LIST_LAST_ENTRY bit
set to end the list. Fix the function and tidy if up a bit.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 1001d63..5b798a6 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -652,25 +652,26 @@ static void ai_write_timer(struct comedi_device *dev,
outl(chan_ticks - 1, dev->iobase + ME4000_AI_CHAN_TIMER_REG);
 }
 
-static int ai_write_chanlist(struct comedi_device *dev,
-struct comedi_subdevice *s, struct comedi_cmd *cmd)
+static int me4000_ai_write_chanlist(struct comedi_device *dev,
+   struct comedi_subdevice *s,
+   struct comedi_cmd *cmd)
 {
-   unsigned int entry;
-   unsigned int chan;
-   unsigned int rang;
-   unsigned int aref;
int i;
 
for (i = 0; i < cmd->chanlist_len; i++) {
-   chan = CR_CHAN(cmd->chanlist[i]);
-   rang = CR_RANGE(cmd->chanlist[i]);
-   aref = CR_AREF(cmd->chanlist[i]);
+   unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+   unsigned int range = CR_RANGE(cmd->chanlist[i]);
+   unsigned int aref = CR_AREF(cmd->chanlist[i]);
+   unsigned int entry;
 
-   entry = chan | ME4000_AI_LIST_RANGE(rang);
+   entry = chan | ME4000_AI_LIST_RANGE(range);
 
if (aref == AREF_DIFF)
entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
 
+   if (i == (cmd->chanlist_len - 1))
+   entry |= ME4000_AI_LIST_LAST_ENTRY;
+
outl(entry, dev->iobase + ME4000_AI_CHANNEL_LIST_REG);
}
 
@@ -738,7 +739,7 @@ static int ai_prepare(struct comedi_device *dev,
outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
 
/* Write the channel list */
-   ai_write_chanlist(dev, s, cmd);
+   me4000_ai_write_chanlist(dev, s, cmd);
 
return 0;
 }
-- 
2.4.3

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


[PATCH v2 16/46] staging: comedi: me4000: tidy up ME4000_AI_CHANNEL_LIST_REG bit defines

2015-08-05 Thread H Hartley Sweeten
Use the BIT() macro to define the bits of this register.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 5b798a6..39dbdaf 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -110,9 +110,9 @@ broken.
 #define ME4000_AI_STATUS_BIT_FSM   (1 << 29)
 #define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH(1 << 31)
 #define ME4000_AI_CHANNEL_LIST_REG 0x78
-#define ME4000_AI_LIST_INPUT_DIFFERENTIAL  (1 << 5)
+#define ME4000_AI_LIST_INPUT_DIFFERENTIAL  BIT(5)
 #define ME4000_AI_LIST_RANGE(x)((3 - ((x) & 3)) << 6)
-#define ME4000_AI_LIST_LAST_ENTRY  (1 << 8)
+#define ME4000_AI_LIST_LAST_ENTRY  BIT(8)
 #define ME4000_AI_DATA_REG 0x7c
 #define ME4000_AI_CHAN_TIMER_REG   0x80
 #define ME4000_AI_CHAN_PRE_TIMER_REG   0x84
-- 
2.4.3

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


[PATCH v2 17/46] staging: comedi: me4000: use comedi_timeout() to wait for ai (*insn_read)

2015-08-05 Thread H Hartley Sweeten
Use the comedi_timeout() helper to busy-wait for the analog input end-of-
conversion instead of the udelay().

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 39dbdaf..4231e39 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -433,9 +433,18 @@ static void me4000_reset(struct comedi_device *dev)
outl(0x1, dev->iobase + ME4000_DIO_CTRL_REG);
 }
 
-/*=
-  Analog input section
-  ===*/
+static int me4000_ai_eoc(struct comedi_device *dev,
+struct comedi_subdevice *s,
+struct comedi_insn *insn,
+unsigned long context)
+{
+   unsigned int status;
+
+   status = inl(dev->iobase + ME4000_AI_STATUS_REG);
+   if (status & ME4000_AI_STATUS_BIT_EF_DATA)
+   return 0;
+   return -EBUSY;
+}
 
 static int me4000_ai_insn_read(struct comedi_device *dev,
   struct comedi_subdevice *s,
@@ -445,10 +454,10 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
int chan = CR_CHAN(insn->chanspec);
int rang = CR_RANGE(insn->chanspec);
int aref = CR_AREF(insn->chanspec);
-
unsigned int entry = 0;
unsigned int tmp;
unsigned int lval;
+   int ret;
 
if (insn->n == 0) {
return 0;
@@ -509,13 +518,9 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
/* Start conversion by dummy read */
inl(dev->iobase + ME4000_AI_START_REG);
 
-   /* Wait until ready */
-   udelay(10);
-   if (!(inl(dev->iobase + ME4000_AI_STATUS_REG) &
-ME4000_AI_STATUS_BIT_EF_DATA)) {
-   dev_err(dev->class_dev, "Value not available after wait\n");
-   return -EIO;
-   }
+   ret = comedi_timeout(dev, s, insn, me4000_ai_eoc, 0);
+   if (ret)
+   return ret;
 
/* Read value from data fifo */
lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0x;
-- 
2.4.3

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


[PATCH v2 19/46] staging: comedi: me4000: use correct types for extracted chanspec values

2015-08-05 Thread H Hartley Sweeten
The chanspec channel, range, and aref are unsigned int values. Use the
correct types when extracting them.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index c15e731..c7136c5 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -451,9 +451,9 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
   struct comedi_insn *insn,
   unsigned int *data)
 {
-   int chan = CR_CHAN(insn->chanspec);
-   int rang = CR_RANGE(insn->chanspec);
-   int aref = CR_AREF(insn->chanspec);
+   unsigned int chan = CR_CHAN(insn->chanspec);
+   unsigned int rang = CR_RANGE(insn->chanspec);
+   unsigned int aref = CR_AREF(insn->chanspec);
unsigned int entry = 0;
unsigned int tmp;
int ret;
@@ -1107,7 +1107,7 @@ static int me4000_ao_insn_write(struct comedi_device *dev,
struct comedi_insn *insn,
unsigned int *data)
 {
-   int chan = CR_CHAN(insn->chanspec);
+   unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int tmp;
 
/* Stop any running conversion */
-- 
2.4.3

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


[PATCH v2 20/46] staging: comedi: me4000: use comedi_range_is_bipolar() in ai (*insn_read)

2015-08-05 Thread H Hartley Sweeten
Use the helper function to check the range type instead of relying on the
value. For aesthetics, rename the local variable used for the range.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index c7136c5..c5a677a 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -452,15 +452,14 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
   unsigned int *data)
 {
unsigned int chan = CR_CHAN(insn->chanspec);
-   unsigned int rang = CR_RANGE(insn->chanspec);
+   unsigned int range = CR_RANGE(insn->chanspec);
unsigned int aref = CR_AREF(insn->chanspec);
-   unsigned int entry = 0;
+   unsigned int entry;
unsigned int tmp;
int ret;
int i;
 
-   entry |= ME4000_AI_LIST_RANGE(rang);
-   entry |= chan;
+   entry = chan | ME4000_AI_LIST_RANGE(range);
if (aref == AREF_DIFF) {
if (!(s->subdev_flags && SDF_DIFF)) {
dev_err(dev->class_dev,
@@ -468,7 +467,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
return -EINVAL;
}
 
-   if (rang == 0 || rang == 1) {
+   if (!comedi_range_is_bipolar(s, range)) {
dev_err(dev->class_dev,
"Range must be bipolar when aref = diff\n");
return -EINVAL;
-- 
2.4.3

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


[PATCH v2 18/46] staging: comedi: me4000: fix me4000_ai_insn_read()

2015-08-05 Thread H Hartley Sweeten
The coemdi (*insn_read) functions are supposed to read insn->n values
from the hardware. Make this function work like the core expects.

Use the comedi_offset_munge() helper to munge the two's complement
values to offset binary.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 4231e39..c15e731 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -456,16 +456,8 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
int aref = CR_AREF(insn->chanspec);
unsigned int entry = 0;
unsigned int tmp;
-   unsigned int lval;
int ret;
-
-   if (insn->n == 0) {
-   return 0;
-   } else if (insn->n > 1) {
-   dev_err(dev->class_dev, "Invalid instruction length %d\n",
-   insn->n);
-   return -EINVAL;
-   }
+   int i;
 
entry |= ME4000_AI_LIST_RANGE(rang);
entry |= chan;
@@ -515,18 +507,22 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
outl(ME4000_AI_MIN_TICKS, dev->iobase + ME4000_AI_CHAN_TIMER_REG);
outl(ME4000_AI_MIN_TICKS, dev->iobase + ME4000_AI_CHAN_PRE_TIMER_REG);
 
-   /* Start conversion by dummy read */
-   inl(dev->iobase + ME4000_AI_START_REG);
+   for (i = 0; i < insn->n; i++) {
+   unsigned int val;
 
-   ret = comedi_timeout(dev, s, insn, me4000_ai_eoc, 0);
-   if (ret)
-   return ret;
+   /* start conversion by dummy read */
+   inl(dev->iobase + ME4000_AI_START_REG);
 
-   /* Read value from data fifo */
-   lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0x;
-   data[0] = lval ^ 0x8000;
+   ret = comedi_timeout(dev, s, insn, me4000_ai_eoc, 0);
+   if (ret)
+   return ret;
 
-   return 1;
+   /* read two's complement value and munge to offset binary */
+   val = inl(dev->iobase + ME4000_AI_DATA_REG);
+   data[i] = comedi_offset_munge(s, val);
+   }
+
+   return insn->n;
 }
 
 static int me4000_ai_cancel(struct comedi_device *dev,
-- 
2.4.3

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


[PATCH v2 21/46] staging: comedi: me4000: tidy up ME4000_AI_STATUS_REG bit defines

2015-08-05 Thread H Hartley Sweeten
Use the BIT() marco to define the bits of this register.

For aesthetics, rename all the defines to remove the '_BIT' from the
name. Also, use ME4000_AI_STATUS_REG instead of ME4000_AI_CTRL_REG
when reading the register (they happen to be the same).

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index c5a677a..e31efa4 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -100,14 +100,14 @@ broken.
 #define ME4000_AI_CTRL_BIT_SC_IRQ  (1 << 19)
 #define ME4000_AI_CTRL_BIT_SC_IRQ_RESET(1 << 20)
 #define ME4000_AI_CTRL_BIT_SC_RELOAD   (1 << 21)
-#define ME4000_AI_STATUS_BIT_EF_CHANNEL(1 << 22)
-#define ME4000_AI_STATUS_BIT_HF_CHANNEL(1 << 23)
-#define ME4000_AI_STATUS_BIT_FF_CHANNEL(1 << 24)
-#define ME4000_AI_STATUS_BIT_EF_DATA   (1 << 25)
-#define ME4000_AI_STATUS_BIT_HF_DATA   (1 << 26)
-#define ME4000_AI_STATUS_BIT_FF_DATA   (1 << 27)
-#define ME4000_AI_STATUS_BIT_LE(1 << 28)
-#define ME4000_AI_STATUS_BIT_FSM   (1 << 29)
+#define ME4000_AI_STATUS_EF_CHANNELBIT(22)
+#define ME4000_AI_STATUS_HF_CHANNELBIT(23)
+#define ME4000_AI_STATUS_FF_CHANNELBIT(24)
+#define ME4000_AI_STATUS_EF_DATA   BIT(25)
+#define ME4000_AI_STATUS_HF_DATA   BIT(26)
+#define ME4000_AI_STATUS_FF_DATA   BIT(27)
+#define ME4000_AI_STATUS_LEBIT(28)
+#define ME4000_AI_STATUS_FSM   BIT(29)
 #define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH(1 << 31)
 #define ME4000_AI_CHANNEL_LIST_REG 0x78
 #define ME4000_AI_LIST_INPUT_DIFFERENTIAL  BIT(5)
@@ -441,7 +441,7 @@ static int me4000_ai_eoc(struct comedi_device *dev,
unsigned int status;
 
status = inl(dev->iobase + ME4000_AI_STATUS_REG);
-   if (status & ME4000_AI_STATUS_BIT_EF_DATA)
+   if (status & ME4000_AI_STATUS_EF_DATA)
return 0;
return -EBUSY;
 }
@@ -998,11 +998,11 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
if (inl(dev->iobase + ME4000_IRQ_STATUS_REG) &
ME4000_IRQ_STATUS_BIT_AI_HF) {
/* Read status register to find out what happened */
-   tmp = inl(dev->iobase + ME4000_AI_CTRL_REG);
+   tmp = inl(dev->iobase + ME4000_AI_STATUS_REG);
 
-   if (!(tmp & ME4000_AI_STATUS_BIT_FF_DATA) &&
-   !(tmp & ME4000_AI_STATUS_BIT_HF_DATA) &&
-   (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
+   if (!(tmp & ME4000_AI_STATUS_FF_DATA) &&
+   !(tmp & ME4000_AI_STATUS_HF_DATA) &&
+   (tmp & ME4000_AI_STATUS_EF_DATA)) {
c = ME4000_AI_FIFO_COUNT;
 
/*
@@ -1017,9 +1017,9 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
s->async->events |= COMEDI_CB_ERROR;
 
dev_err(dev->class_dev, "FIFO overflow\n");
-   } else if ((tmp & ME4000_AI_STATUS_BIT_FF_DATA)
-  && !(tmp & ME4000_AI_STATUS_BIT_HF_DATA)
-  && (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
+   } else if ((tmp & ME4000_AI_STATUS_FF_DATA) &&
+  !(tmp & ME4000_AI_STATUS_HF_DATA) &&
+  (tmp & ME4000_AI_STATUS_EF_DATA)) {
c = ME4000_AI_FIFO_COUNT / 2;
} else {
dev_err(dev->class_dev,
@@ -1079,8 +1079,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
 
/* Poll data until fifo empty */
-   while (inl(dev->iobase + ME4000_AI_CTRL_REG) &
-  ME4000_AI_STATUS_BIT_EF_DATA) {
+   while (inl(dev->iobase + ME4000_AI_STATUS_REG) &
+  ME4000_AI_STATUS_EF_DATA) {
/* Read value from data fifo */
lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0x;
lval ^= 0x8000;
-- 
2.4.3

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


[PATCH v2 22/46] staging: comedi: me4000: tidy up ME4000_AI_CTRL_REG bit defines

2015-08-05 Thread H Hartley Sweeten
Use the BIT() marco to define the bits of this register.

For aesthetics, rename all the defines to remove the '_BIT' from the
name.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index e31efa4..b54f1de 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -78,28 +78,28 @@ broken.
 #define ME4000_AO_TIMER_REG(x) (0x10 + ME4000_AO_CHAN(x))
 #define ME4000_AI_CTRL_REG 0x74
 #define ME4000_AI_STATUS_REG   0x74
-#define ME4000_AI_CTRL_BIT_MODE_0  (1 << 0)
-#define ME4000_AI_CTRL_BIT_MODE_1  (1 << 1)
-#define ME4000_AI_CTRL_BIT_MODE_2  (1 << 2)
-#define ME4000_AI_CTRL_BIT_SAMPLE_HOLD (1 << 3)
-#define ME4000_AI_CTRL_BIT_IMMEDIATE_STOP  (1 << 4)
-#define ME4000_AI_CTRL_BIT_STOP(1 << 5)
-#define ME4000_AI_CTRL_BIT_CHANNEL_FIFO(1 << 6)
-#define ME4000_AI_CTRL_BIT_DATA_FIFO   (1 << 7)
-#define ME4000_AI_CTRL_BIT_FULLSCALE   (1 << 8)
-#define ME4000_AI_CTRL_BIT_OFFSET  (1 << 9)
-#define ME4000_AI_CTRL_BIT_EX_TRIG_ANALOG  (1 << 10)
-#define ME4000_AI_CTRL_BIT_EX_TRIG (1 << 11)
-#define ME4000_AI_CTRL_BIT_EX_TRIG_FALLING (1 << 12)
-#define ME4000_AI_CTRL_BIT_EX_IRQ  (1 << 13)
-#define ME4000_AI_CTRL_BIT_EX_IRQ_RESET(1 << 14)
-#define ME4000_AI_CTRL_BIT_LE_IRQ  (1 << 15)
-#define ME4000_AI_CTRL_BIT_LE_IRQ_RESET(1 << 16)
-#define ME4000_AI_CTRL_BIT_HF_IRQ  (1 << 17)
-#define ME4000_AI_CTRL_BIT_HF_IRQ_RESET(1 << 18)
-#define ME4000_AI_CTRL_BIT_SC_IRQ  (1 << 19)
-#define ME4000_AI_CTRL_BIT_SC_IRQ_RESET(1 << 20)
-#define ME4000_AI_CTRL_BIT_SC_RELOAD   (1 << 21)
+#define ME4000_AI_CTRL_MODE_0  BIT(0)
+#define ME4000_AI_CTRL_MODE_1  BIT(1)
+#define ME4000_AI_CTRL_MODE_2  BIT(2)
+#define ME4000_AI_CTRL_SAMPLE_HOLD BIT(3)
+#define ME4000_AI_CTRL_IMMEDIATE_STOP  BIT(4)
+#define ME4000_AI_CTRL_STOPBIT(5)
+#define ME4000_AI_CTRL_CHANNEL_FIFOBIT(6)
+#define ME4000_AI_CTRL_DATA_FIFO   BIT(7)
+#define ME4000_AI_CTRL_FULLSCALE   BIT(8)
+#define ME4000_AI_CTRL_OFFSET  BIT(9)
+#define ME4000_AI_CTRL_EX_TRIG_ANALOG  BIT(10)
+#define ME4000_AI_CTRL_EX_TRIG BIT(11)
+#define ME4000_AI_CTRL_EX_TRIG_FALLING BIT(12)
+#define ME4000_AI_CTRL_EX_IRQ  BIT(13)
+#define ME4000_AI_CTRL_EX_IRQ_RESETBIT(14)
+#define ME4000_AI_CTRL_LE_IRQ  BIT(15)
+#define ME4000_AI_CTRL_LE_IRQ_RESETBIT(16)
+#define ME4000_AI_CTRL_HF_IRQ  BIT(17)
+#define ME4000_AI_CTRL_HF_IRQ_RESETBIT(18)
+#define ME4000_AI_CTRL_SC_IRQ  BIT(19)
+#define ME4000_AI_CTRL_SC_IRQ_RESETBIT(20)
+#define ME4000_AI_CTRL_SC_RELOAD   BIT(21)
 #define ME4000_AI_STATUS_EF_CHANNELBIT(22)
 #define ME4000_AI_STATUS_HF_CHANNELBIT(23)
 #define ME4000_AI_STATUS_FF_CHANNELBIT(24)
@@ -108,7 +108,7 @@ broken.
 #define ME4000_AI_STATUS_FF_DATA   BIT(27)
 #define ME4000_AI_STATUS_LEBIT(28)
 #define ME4000_AI_STATUS_FSM   BIT(29)
-#define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH(1 << 31)
+#define ME4000_AI_CTRL_EX_TRIG_BOTHBIT(31)
 #define ME4000_AI_CHANNEL_LIST_REG 0x78
 #define ME4000_AI_LIST_INPUT_DIFFERENTIAL  BIT(5)
 #define ME4000_AI_LIST_RANGE(x)((3 - ((x) & 3)) << 6)
@@ -408,7 +408,7 @@ static void me4000_reset(struct comedi_device *dev)
outl(0x8000, dev->iobase + ME4000_AO_SINGLE_REG(chan));
 
/* Set both stop bits in the analog input control register */
-   outl(ME4000_AI_CTRL_BIT_IMMEDIATE_STOP | ME4000_AI_CTRL_BIT_STOP,
+   outl(ME4000_AI_CTRL_IMMEDIATE_STOP | ME4000_AI_CTRL_STOP,
 dev->iobase + ME4000_AI_CTRL_REG);
 
/* Set both stop bits in the analog output control register */
@@ -485,18 +485,17 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
 
/* Clear channel list, data fifo and both stop bits */
tmp = inl(dev->iobase + ME4000_AI_CTRL_REG);
-   tmp &= ~(ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
-ME4000_AI_CTRL_BIT_DATA_FIFO |
-ME4000_AI_CTRL_BIT_STOP | ME4000_AI_CTRL_BIT_IMMEDIATE_STOP);
+   tmp &= ~(ME4000_AI_CTRL_CHANNEL_FIFO | ME4000_AI_CTRL_DATA_FIFO |
+ME4000_AI_CTRL_STOP | ME4000_AI_CTRL_IMMEDIATE_STOP);
outl(tmp, dev

[PATCH v2 23/46] staging: comedi: me4000: tidy up ME4000_IRQ_STATUS_REG bit defines

2015-08-05 Thread H Hartley Sweeten
Use the BIT() marco to define the bits of this register.

For aesthetics, rename all the defines to remove the '_BIT' from the
name.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index b54f1de..e6e1d63 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -122,14 +122,14 @@ broken.
 #define ME4000_AI_SCAN_PRE_TIMER_HIGH_REG  0x94
 #define ME4000_AI_START_REG0x98
 #define ME4000_IRQ_STATUS_REG  0x9c
-#define ME4000_IRQ_STATUS_BIT_EX   (1 << 0)
-#define ME4000_IRQ_STATUS_BIT_LE   (1 << 1)
-#define ME4000_IRQ_STATUS_BIT_AI_HF(1 << 2)
-#define ME4000_IRQ_STATUS_BIT_AO_0_HF  (1 << 3)
-#define ME4000_IRQ_STATUS_BIT_AO_1_HF  (1 << 4)
-#define ME4000_IRQ_STATUS_BIT_AO_2_HF  (1 << 5)
-#define ME4000_IRQ_STATUS_BIT_AO_3_HF  (1 << 6)
-#define ME4000_IRQ_STATUS_BIT_SC   (1 << 7)
+#define ME4000_IRQ_STATUS_EX   BIT(0)
+#define ME4000_IRQ_STATUS_LE   BIT(1)
+#define ME4000_IRQ_STATUS_AI_HFBIT(2)
+#define ME4000_IRQ_STATUS_AO_0_HF  BIT(3)
+#define ME4000_IRQ_STATUS_AO_1_HF  BIT(4)
+#define ME4000_IRQ_STATUS_AO_2_HF  BIT(5)
+#define ME4000_IRQ_STATUS_AO_3_HF  BIT(6)
+#define ME4000_IRQ_STATUS_SC   BIT(7)
 #define ME4000_DIO_PORT_0_REG  0xa0
 #define ME4000_DIO_PORT_1_REG  0xa4
 #define ME4000_DIO_PORT_2_REG  0xa8
@@ -995,7 +995,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
return IRQ_NONE;
 
if (inl(dev->iobase + ME4000_IRQ_STATUS_REG) &
-   ME4000_IRQ_STATUS_BIT_AI_HF) {
+   ME4000_IRQ_STATUS_AI_HF) {
/* Read status register to find out what happened */
tmp = inl(dev->iobase + ME4000_AI_STATUS_REG);
 
@@ -1065,7 +1065,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) {
+   ME4000_IRQ_STATUS_SC) {
s->async->events |= COMEDI_CB_EOA;
 
/*
-- 
2.4.3

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


[PATCH v2 25/46] staging: comedi: me4000: tidy up ME4000_AO_CTRL_REG bit defines

2015-08-05 Thread H Hartley Sweeten
Use the BIT() marco to define the bits of this register.

For aesthetics, rename all the defines to remove the '_BIT' from the
name.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index a38ad88..a40b301 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -57,17 +57,16 @@ broken.
 #define ME4000_AO_CHAN(x)  ((x) * 0x18)
 
 #define ME4000_AO_CTRL_REG(x)  (0x00 + ME4000_AO_CHAN(x))
-#define ME4000_AO_CTRL_BIT_MODE_0  (1 << 0)
-#define ME4000_AO_CTRL_BIT_MODE_1  (1 << 1)
-#define ME4000_AO_CTRL_MASK_MODE   (3 << 0)
-#define ME4000_AO_CTRL_BIT_STOP(1 << 2)
-#define ME4000_AO_CTRL_BIT_ENABLE_FIFO (1 << 3)
-#define ME4000_AO_CTRL_BIT_ENABLE_EX_TRIG  (1 << 4)
-#define ME4000_AO_CTRL_BIT_EX_TRIG_EDGE(1 << 5)
-#define ME4000_AO_CTRL_BIT_IMMEDIATE_STOP  (1 << 7)
-#define ME4000_AO_CTRL_BIT_ENABLE_DO   (1 << 8)
-#define ME4000_AO_CTRL_BIT_ENABLE_IRQ  (1 << 9)
-#define ME4000_AO_CTRL_BIT_RESET_IRQ   (1 << 10)
+#define ME4000_AO_CTRL_MODE_0  BIT(0)
+#define ME4000_AO_CTRL_MODE_1  BIT(1)
+#define ME4000_AO_CTRL_STOPBIT(2)
+#define ME4000_AO_CTRL_ENABLE_FIFO BIT(3)
+#define ME4000_AO_CTRL_ENABLE_EX_TRIG  BIT(4)
+#define ME4000_AO_CTRL_EX_TRIG_EDGEBIT(5)
+#define ME4000_AO_CTRL_IMMEDIATE_STOP  BIT(7)
+#define ME4000_AO_CTRL_ENABLE_DO   BIT(8)
+#define ME4000_AO_CTRL_ENABLE_IRQ  BIT(9)
+#define ME4000_AO_CTRL_RESET_IRQ   BIT(10)
 #define ME4000_AO_STATUS_REG(x)(0x04 + 
ME4000_AO_CHAN(x))
 #define ME4000_AO_STATUS_FSM   BIT(0)
 #define ME4000_AO_STATUS_FFBIT(1)
@@ -412,7 +411,7 @@ static void me4000_reset(struct comedi_device *dev)
 dev->iobase + ME4000_AI_CTRL_REG);
 
/* Set both stop bits in the analog output control register */
-   val = ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP;
+   val = ME4000_AO_CTRL_IMMEDIATE_STOP | ME4000_AO_CTRL_STOP;
for (chan = 0; chan < 4; chan++)
outl(val, dev->iobase + ME4000_AO_CTRL_REG(chan));
 
@@ -1110,7 +1109,7 @@ static int me4000_ao_insn_write(struct comedi_device *dev,
 
/* Stop any running conversion */
tmp = inl(dev->iobase + ME4000_AO_CTRL_REG(chan));
-   tmp |= ME4000_AO_CTRL_BIT_IMMEDIATE_STOP;
+   tmp |= ME4000_AO_CTRL_IMMEDIATE_STOP;
outl(tmp, dev->iobase + ME4000_AO_CTRL_REG(chan));
 
/* Clear control register and set to single mode */
-- 
2.4.3

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


[PATCH v2 24/46] staging: comedi: me4000: tidy up ME4000_AO_STATUS_REG bit defines

2015-08-05 Thread H Hartley Sweeten
Use the BIT() marco to define the bits of this register.

For aesthetics, rename all the defines to remove the '_BIT' from the
name.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index e6e1d63..a38ad88 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -69,10 +69,10 @@ broken.
 #define ME4000_AO_CTRL_BIT_ENABLE_IRQ  (1 << 9)
 #define ME4000_AO_CTRL_BIT_RESET_IRQ   (1 << 10)
 #define ME4000_AO_STATUS_REG(x)(0x04 + 
ME4000_AO_CHAN(x))
-#define ME4000_AO_STATUS_BIT_FSM   (1 << 0)
-#define ME4000_AO_STATUS_BIT_FF(1 << 1)
-#define ME4000_AO_STATUS_BIT_HF(1 << 2)
-#define ME4000_AO_STATUS_BIT_EF(1 << 3)
+#define ME4000_AO_STATUS_FSM   BIT(0)
+#define ME4000_AO_STATUS_FFBIT(1)
+#define ME4000_AO_STATUS_HFBIT(2)
+#define ME4000_AO_STATUS_EFBIT(3)
 #define ME4000_AO_FIFO_REG(x)  (0x08 + ME4000_AO_CHAN(x))
 #define ME4000_AO_SINGLE_REG(x)(0x0c + 
ME4000_AO_CHAN(x))
 #define ME4000_AO_TIMER_REG(x) (0x10 + ME4000_AO_CHAN(x))
-- 
2.4.3

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


[PATCH v2 26/46] staging: comedi: me4000: tidy up ME4000_DIO_CTRL_REG bit defines

2015-08-05 Thread H Hartley Sweeten
Use the BIT() marco to define the bits of this register.

For aesthetics, rename all the defines to remove the '_BIT' from the
name.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index a40b301..97c243f 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -136,20 +136,20 @@ broken.
 #define ME4000_DIO_DIR_REG 0xb0
 #define ME4000_AO_LOADSETREG_XX0xb4
 #define ME4000_DIO_CTRL_REG0xb8
-#define ME4000_DIO_CTRL_BIT_MODE_0 (1 << 0)
-#define ME4000_DIO_CTRL_BIT_MODE_1 (1 << 1)
-#define ME4000_DIO_CTRL_BIT_MODE_2 (1 << 2)
-#define ME4000_DIO_CTRL_BIT_MODE_3 (1 << 3)
-#define ME4000_DIO_CTRL_BIT_MODE_4 (1 << 4)
-#define ME4000_DIO_CTRL_BIT_MODE_5 (1 << 5)
-#define ME4000_DIO_CTRL_BIT_MODE_6 (1 << 6)
-#define ME4000_DIO_CTRL_BIT_MODE_7 (1 << 7)
-#define ME4000_DIO_CTRL_BIT_FUNCTION_0 (1 << 8)
-#define ME4000_DIO_CTRL_BIT_FUNCTION_1 (1 << 9)
-#define ME4000_DIO_CTRL_BIT_FIFO_HIGH_0(1 << 10)
-#define ME4000_DIO_CTRL_BIT_FIFO_HIGH_1(1 << 11)
-#define ME4000_DIO_CTRL_BIT_FIFO_HIGH_2(1 << 12)
-#define ME4000_DIO_CTRL_BIT_FIFO_HIGH_3(1 << 13)
+#define ME4000_DIO_CTRL_MODE_0 BIT(0)
+#define ME4000_DIO_CTRL_MODE_1 BIT(1)
+#define ME4000_DIO_CTRL_MODE_2 BIT(2)
+#define ME4000_DIO_CTRL_MODE_3 BIT(3)
+#define ME4000_DIO_CTRL_MODE_4 BIT(4)
+#define ME4000_DIO_CTRL_MODE_5 BIT(5)
+#define ME4000_DIO_CTRL_MODE_6 BIT(6)
+#define ME4000_DIO_CTRL_MODE_7 BIT(7)
+#define ME4000_DIO_CTRL_FUNCTION_0 BIT(8)
+#define ME4000_DIO_CTRL_FUNCTION_1 BIT(9)
+#define ME4000_DIO_CTRL_FIFO_HIGH_0BIT(10)
+#define ME4000_DIO_CTRL_FIFO_HIGH_1BIT(11)
+#define ME4000_DIO_CTRL_FIFO_HIGH_2BIT(12)
+#define ME4000_DIO_CTRL_FIFO_HIGH_3BIT(13)
 #define ME4000_AO_DEMUX_ADJUST_REG 0xbc
 #define ME4000_AO_DEMUX_ADJUST_VALUE   0x4c
 #define ME4000_AI_SAMPLE_COUNTER_REG   0xc0
@@ -1172,18 +1172,18 @@ static int me4000_dio_insn_config(struct comedi_device 
*dev,
return ret;
 
tmp = inl(dev->iobase + ME4000_DIO_CTRL_REG);
-   tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | ME4000_DIO_CTRL_BIT_MODE_1 |
-ME4000_DIO_CTRL_BIT_MODE_2 | ME4000_DIO_CTRL_BIT_MODE_3 |
-ME4000_DIO_CTRL_BIT_MODE_4 | ME4000_DIO_CTRL_BIT_MODE_5 |
-ME4000_DIO_CTRL_BIT_MODE_6 | ME4000_DIO_CTRL_BIT_MODE_7);
+   tmp &= ~(ME4000_DIO_CTRL_MODE_0 | ME4000_DIO_CTRL_MODE_1 |
+ME4000_DIO_CTRL_MODE_2 | ME4000_DIO_CTRL_MODE_3 |
+ME4000_DIO_CTRL_MODE_4 | ME4000_DIO_CTRL_MODE_5 |
+ME4000_DIO_CTRL_MODE_6 | ME4000_DIO_CTRL_MODE_7);
if (s->io_bits & 0x00ff)
-   tmp |= ME4000_DIO_CTRL_BIT_MODE_0;
+   tmp |= ME4000_DIO_CTRL_MODE_0;
if (s->io_bits & 0xff00)
-   tmp |= ME4000_DIO_CTRL_BIT_MODE_2;
+   tmp |= ME4000_DIO_CTRL_MODE_2;
if (s->io_bits & 0x00ff)
-   tmp |= ME4000_DIO_CTRL_BIT_MODE_4;
+   tmp |= ME4000_DIO_CTRL_MODE_4;
if (s->io_bits & 0xff00)
-   tmp |= ME4000_DIO_CTRL_BIT_MODE_6;
+   tmp |= ME4000_DIO_CTRL_MODE_6;
 
/*
 * Check for optoisolated ME-4000 version.
@@ -1193,9 +1193,8 @@ static int me4000_dio_insn_config(struct comedi_device 
*dev,
if (inl(dev->iobase + ME4000_DIO_DIR_REG)) {
s->io_bits |= 0x00ff;
s->io_bits &= ~0xff00;
-   tmp |= ME4000_DIO_CTRL_BIT_MODE_0;
-   tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 |
-ME4000_DIO_CTRL_BIT_MODE_3);
+   tmp |= ME4000_DIO_CTRL_MODE_0;
+   tmp &= ~(ME4000_DIO_CTRL_MODE_2 | ME4000_DIO_CTRL_MODE_3);
}
 
outl(tmp, dev->iobase + ME4000_DIO_CTRL_REG);
@@ -1307,7 +1306,7 @@ static int me4000_auto_attach(struct comedi_device *dev,
 */
if (!inl(dev->iobase + ME4000_DIO_DIR_REG)) {
s->io_bits |= 0xFF;
-   outl(ME4000_DIO_CTRL_BIT_MODE_0,
+   outl(ME4000_DIO_CTRL_MODE_0,
 dev->iobase + ME4000_DIO_DIR_REG);
}
 
-- 
2.4.3

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


[PATCH v2 29/46] staging: comedi: me4000: simplify ai_prepare()

2015-08-05 Thread H Hartley Sweeten
The ai (*do_cmd_test) validates the trigger sources in Step 2b to ensure
that they are compatible. Save the 'ai_ctrl_mode' that will be used in the
private data so that ai_prepare(), which is called by the ai (*do_cmd),
does not have to recheck the sources in order to figure it out.

Also, tidy up the stop trigger checks so that the ME4000_AI_CTRL_HF_IRQ
bit is set in the common code path.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index ebc4307..60f62f3 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -163,6 +163,7 @@ broken.
 
 struct me4000_private {
unsigned long plx_regbase;
+   unsigned int ai_ctrl_mode;
unsigned int ai_init_ticks;
unsigned int ai_scan_ticks;
unsigned int ai_chan_ticks;
@@ -684,59 +685,35 @@ static int ai_prepare(struct comedi_device *dev,
  struct comedi_subdevice *s,
  struct comedi_cmd *cmd)
 {
-   unsigned int tmp = 0;
+   struct me4000_private *devpriv = dev->private;
+   unsigned int ctrl;
 
/* Write timer arguments */
ai_write_timer(dev);
 
/* Reset control register */
-   outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
+   outl(0, dev->iobase + ME4000_AI_CTRL_REG);
 
/* Start sources */
-   if ((cmd->start_src == TRIG_EXT &&
-cmd->scan_begin_src == TRIG_TIMER &&
-cmd->convert_src == TRIG_TIMER) ||
-   (cmd->start_src == TRIG_EXT &&
-cmd->scan_begin_src == TRIG_FOLLOW &&
-cmd->convert_src == TRIG_TIMER)) {
-   tmp = ME4000_AI_CTRL_MODE_1 |
- ME4000_AI_CTRL_CHANNEL_FIFO |
- ME4000_AI_CTRL_DATA_FIFO;
-   } else if (cmd->start_src == TRIG_EXT &&
-  cmd->scan_begin_src == TRIG_EXT &&
-  cmd->convert_src == TRIG_TIMER) {
-   tmp = ME4000_AI_CTRL_MODE_2 |
- ME4000_AI_CTRL_CHANNEL_FIFO |
- ME4000_AI_CTRL_DATA_FIFO;
-   } else if (cmd->start_src == TRIG_EXT &&
-  cmd->scan_begin_src == TRIG_EXT &&
-  cmd->convert_src == TRIG_EXT) {
-   tmp = ME4000_AI_CTRL_MODE_0 |
- ME4000_AI_CTRL_MODE_1 |
- ME4000_AI_CTRL_CHANNEL_FIFO |
- ME4000_AI_CTRL_DATA_FIFO;
-   } else {
-   tmp = ME4000_AI_CTRL_MODE_0 |
- ME4000_AI_CTRL_CHANNEL_FIFO |
- ME4000_AI_CTRL_DATA_FIFO;
-   }
+   ctrl = devpriv->ai_ctrl_mode |
+  ME4000_AI_CTRL_CHANNEL_FIFO |
+  ME4000_AI_CTRL_DATA_FIFO;
 
/* Stop triggers */
if (cmd->stop_src == TRIG_COUNT) {
outl(cmd->chanlist_len * cmd->stop_arg,
 dev->iobase + ME4000_AI_SAMPLE_COUNTER_REG);
-   tmp |= ME4000_AI_CTRL_HF_IRQ | ME4000_AI_CTRL_SC_IRQ;
+   ctrl |= ME4000_AI_CTRL_SC_IRQ;
} else if (cmd->stop_src == TRIG_NONE &&
   cmd->scan_end_src == TRIG_COUNT) {
outl(cmd->scan_end_arg,
 dev->iobase + ME4000_AI_SAMPLE_COUNTER_REG);
-   tmp |= ME4000_AI_CTRL_HF_IRQ | ME4000_AI_CTRL_SC_IRQ;
-   } else {
-   tmp |= ME4000_AI_CTRL_HF_IRQ;
+   ctrl |= ME4000_AI_CTRL_SC_IRQ;
}
+   ctrl |= ME4000_AI_CTRL_HF_IRQ;
 
/* Write the setup to the control register */
-   outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
+   outl(ctrl, dev->iobase + ME4000_AI_CTRL_REG);
 
/* Write the channel list */
me4000_ai_write_chanlist(dev, s, cmd);
@@ -800,21 +777,28 @@ static int me4000_ai_do_cmd_test(struct comedi_device 
*dev,
if (cmd->start_src == TRIG_NOW &&
cmd->scan_begin_src == TRIG_TIMER &&
cmd->convert_src == TRIG_TIMER) {
+   devpriv->ai_ctrl_mode = ME4000_AI_CTRL_MODE_0;
} else if (cmd->start_src == TRIG_NOW &&
   cmd->scan_begin_src == TRIG_FOLLOW &&
   cmd->convert_src == TRIG_TIMER) {
+   devpriv->ai_ctrl_mode = ME4000_AI_CTRL_MODE_0;
} else if (cmd->start_src == TRIG_EXT &&
   cmd->scan_begin_src == TRIG_TIMER &&
   cmd->convert_src == TRIG_TIMER) {
+   devpriv->ai_ctrl_mode = ME4000_AI_CTRL_MODE_1;
} else if (cmd->start_src == TRIG_EXT &&
   cmd->scan_begin_src == TRIG_FOLLOW &&
   cmd->convert_src == TRIG_TIMER) {
+   devpriv->ai_ctrl_mode = ME4000_AI_CTRL_MODE_1;
} else if (cmd->start_src == TRIG_EXT &&
   cmd->scan_begin_src == TRIG_EXT 

[PATCH v2 31/46] staging: comedi: me4000: absorb ai_write_timer()

2015-08-05 Thread H Hartley Sweeten
This function is only called by me4000_ai_do_cmd(). Absorb it.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index c467eb7..ecdf673 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -635,26 +635,6 @@ static void me4000_ai_round_cmd_args(struct comedi_device 
*dev,
}
 }
 
-static void ai_write_timer(struct comedi_device *dev)
-{
-   struct me4000_private *devpriv = dev->private;
-
-   outl(devpriv->ai_init_ticks - 1,
-dev->iobase + ME4000_AI_SCAN_PRE_TIMER_LOW_REG);
-   outl(0x0, dev->iobase + ME4000_AI_SCAN_PRE_TIMER_HIGH_REG);
-
-   if (devpriv->ai_scan_ticks) {
-   outl(devpriv->ai_scan_ticks - 1,
-dev->iobase + ME4000_AI_SCAN_TIMER_LOW_REG);
-   outl(0x0, dev->iobase + ME4000_AI_SCAN_TIMER_HIGH_REG);
-   }
-
-   outl(devpriv->ai_chan_ticks - 1,
-dev->iobase + ME4000_AI_CHAN_PRE_TIMER_REG);
-   outl(devpriv->ai_chan_ticks - 1,
-dev->iobase + ME4000_AI_CHAN_TIMER_REG);
-}
-
 static int me4000_ai_write_chanlist(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_cmd *cmd)
@@ -695,7 +675,20 @@ static int me4000_ai_do_cmd(struct comedi_device *dev,
return err;
 
/* Write timer arguments */
-   ai_write_timer(dev);
+   outl(devpriv->ai_init_ticks - 1,
+dev->iobase + ME4000_AI_SCAN_PRE_TIMER_LOW_REG);
+   outl(0x0, dev->iobase + ME4000_AI_SCAN_PRE_TIMER_HIGH_REG);
+
+   if (devpriv->ai_scan_ticks) {
+   outl(devpriv->ai_scan_ticks - 1,
+dev->iobase + ME4000_AI_SCAN_TIMER_LOW_REG);
+   outl(0x0, dev->iobase + ME4000_AI_SCAN_TIMER_HIGH_REG);
+   }
+
+   outl(devpriv->ai_chan_ticks - 1,
+dev->iobase + ME4000_AI_CHAN_PRE_TIMER_REG);
+   outl(devpriv->ai_chan_ticks - 1,
+dev->iobase + ME4000_AI_CHAN_TIMER_REG);
 
/* Reset control register */
outl(0, dev->iobase + ME4000_AI_CTRL_REG);
-- 
2.4.3

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


[PATCH v2 27/46] staging: comedi: me4000: return void from ai_round_cmd_args()

2015-08-05 Thread H Hartley Sweeten
This function always succeeds. Change the return type to void and
remove the unnecessary error check in me4000_ai_do_cmd().

Move the function call in me4000_ai_do_cmd_test() from before Step 1
to Step 3 where the arguments are validated. There is no reason to
get the values if the previous steps fail.

Rename the function so it has namespace associated with the driver.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 97c243f..cd7dbb6d 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -580,11 +580,12 @@ static int me4000_ai_check_chanlist(struct comedi_device 
*dev,
return 0;
 }
 
-static int ai_round_cmd_args(struct comedi_device *dev,
-struct comedi_subdevice *s,
-struct comedi_cmd *cmd,
-unsigned int *init_ticks,
-unsigned int *scan_ticks, unsigned int *chan_ticks)
+static void me4000_ai_round_cmd_args(struct comedi_device *dev,
+struct comedi_subdevice *s,
+struct comedi_cmd *cmd,
+unsigned int *init_ticks,
+unsigned int *scan_ticks,
+unsigned int *chan_ticks)
 {
int rest;
 
@@ -630,8 +631,6 @@ static int ai_round_cmd_args(struct comedi_device *dev,
(*chan_ticks)++;
}
}
-
-   return 0;
 }
 
 static void ai_write_timer(struct comedi_device *dev,
@@ -757,10 +756,8 @@ static int me4000_ai_do_cmd(struct comedi_device *dev,
return err;
 
/* Round the timer arguments */
-   err = ai_round_cmd_args(dev,
-   s, cmd, &init_ticks, &scan_ticks, &chan_ticks);
-   if (err)
-   return err;
+   me4000_ai_round_cmd_args(dev, s, cmd,
+&init_ticks, &scan_ticks, &chan_ticks);
 
/* Prepare the AI for acquisition */
err = ai_prepare(dev, s, cmd, init_ticks, scan_ticks, chan_ticks);
@@ -782,9 +779,6 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
unsigned int scan_ticks;
int err = 0;
 
-   /* Round the timer arguments */
-   ai_round_cmd_args(dev, s, cmd, &init_ticks, &scan_ticks, &chan_ticks);
-
/* Step 1 : check if triggers are trivially valid */
 
err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
@@ -842,6 +836,11 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev,
cmd->chanlist_len = 1;
err |= -EINVAL;
}
+
+   /* Round the timer arguments */
+   me4000_ai_round_cmd_args(dev, s, cmd,
+&init_ticks, &scan_ticks, &chan_ticks);
+
if (init_ticks < 66) {
cmd->start_arg = 2000;
err |= -EINVAL;
-- 
2.4.3

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


[PATCH v2 28/46] staging: comedi: me4000: move ai command timing values into private data

2015-08-05 Thread H Hartley Sweeten
The ai (*do_cmd_test) calls me4000_ai_round_cmd_args() to calculate the
timing values needed to the command. The the command test passes, the
core will then call the ai (*do_cmd) which then has to call
me4000_ai_round_cmd_args() again in order to get the same values to
pass to ai_prepare() in order to program the timing.

Add members to the private data to allow the (*do_cmd_test) to calculate
and save to values needed by ai_prepare().

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index cd7dbb6d..ebc4307 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -163,6 +163,9 @@ broken.
 
 struct me4000_private {
unsigned long plx_regbase;
+   unsigned int ai_init_ticks;
+   unsigned int ai_scan_ticks;
+   unsigned int ai_chan_ticks;
 };
 
 enum me4000_boardid {
@@ -582,71 +585,73 @@ static int me4000_ai_check_chanlist(struct comedi_device 
*dev,
 
 static void me4000_ai_round_cmd_args(struct comedi_device *dev,
 struct comedi_subdevice *s,
-struct comedi_cmd *cmd,
-unsigned int *init_ticks,
-unsigned int *scan_ticks,
-unsigned int *chan_ticks)
+struct comedi_cmd *cmd)
 {
+   struct me4000_private *devpriv = dev->private;
int rest;
 
-   *init_ticks = 0;
-   *scan_ticks = 0;
-   *chan_ticks = 0;
+   devpriv->ai_init_ticks = 0;
+   devpriv->ai_scan_ticks = 0;
+   devpriv->ai_chan_ticks = 0;
 
if (cmd->start_arg) {
-   *init_ticks = (cmd->start_arg * 33) / 1000;
+   devpriv->ai_init_ticks = (cmd->start_arg * 33) / 1000;
rest = (cmd->start_arg * 33) % 1000;
 
if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_NEAREST) {
if (rest > 33)
-   (*init_ticks)++;
+   devpriv->ai_init_ticks++;
} else if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_UP) {
if (rest)
-   (*init_ticks)++;
+   devpriv->ai_init_ticks++;
}
}
 
if (cmd->scan_begin_arg) {
-   *scan_ticks = (cmd->scan_begin_arg * 33) / 1000;
+   devpriv->ai_scan_ticks = (cmd->scan_begin_arg * 33) / 1000;
rest = (cmd->scan_begin_arg * 33) % 1000;
 
if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_NEAREST) {
if (rest > 33)
-   (*scan_ticks)++;
+   devpriv->ai_scan_ticks++;
} else if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_UP) {
if (rest)
-   (*scan_ticks)++;
+   devpriv->ai_scan_ticks++;
}
}
 
if (cmd->convert_arg) {
-   *chan_ticks = (cmd->convert_arg * 33) / 1000;
+   devpriv->ai_chan_ticks = (cmd->convert_arg * 33) / 1000;
rest = (cmd->convert_arg * 33) % 1000;
 
if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_NEAREST) {
if (rest > 33)
-   (*chan_ticks)++;
+   devpriv->ai_chan_ticks++;
} else if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_UP) {
if (rest)
-   (*chan_ticks)++;
+   devpriv->ai_chan_ticks++;
}
}
 }
 
-static void ai_write_timer(struct comedi_device *dev,
-  unsigned int init_ticks,
-  unsigned int scan_ticks, unsigned int chan_ticks)
+static void ai_write_timer(struct comedi_device *dev)
 {
-   outl(init_ticks - 1, dev->iobase + ME4000_AI_SCAN_PRE_TIMER_LOW_REG);
+   struct me4000_private *devpriv = dev->private;
+
+   outl(devpriv->ai_init_ticks - 1,
+dev->iobase + ME4000_AI_SCAN_PRE_TIMER_LOW_REG);
outl(0x0, dev->iobase + ME4000_AI_SCAN_PRE_TIMER_HIGH_REG);
 
-   if (scan_ticks) {
-   outl(scan_ticks - 1, dev->iobase + 
ME4000_AI_SCAN_TIMER_LOW_REG);
+   if (devpriv->ai_scan_ticks) {
+   outl(devpriv->ai_scan_ticks - 1,
+dev->iobase + ME4000_AI_SCAN_TIMER_LOW_REG);
outl(0x0, dev->iobase + ME4000_AI_SCAN_TIMER_HIGH_REG);
}
 
-   outl(chan_ticks - 1, dev->iobase + ME4000_AI_CHAN_PRE_TIMER_REG);
-   outl(chan_ticks - 1, dev->iobase + ME400

[PATCH v2 30/46] staging: comedi: me4000: absorb ai_prepare()

2015-08-05 Thread H Hartley Sweeten
This function never fails and it's only called by me4000_ai_do_cmd().

Absorb it and remove the unnecessary failure check.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 60f62f3..c467eb7 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -681,12 +681,18 @@ static int me4000_ai_write_chanlist(struct comedi_device 
*dev,
return 0;
 }
 
-static int ai_prepare(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_cmd *cmd)
+static int me4000_ai_do_cmd(struct comedi_device *dev,
+   struct comedi_subdevice *s)
 {
struct me4000_private *devpriv = dev->private;
+   struct comedi_cmd *cmd = &s->async->cmd;
unsigned int ctrl;
+   int err;
+
+   /* Reset the analog input */
+   err = me4000_ai_cancel(dev, s);
+   if (err)
+   return err;
 
/* Write timer arguments */
ai_write_timer(dev);
@@ -718,25 +724,6 @@ static int ai_prepare(struct comedi_device *dev,
/* Write the channel list */
me4000_ai_write_chanlist(dev, s, cmd);
 
-   return 0;
-}
-
-static int me4000_ai_do_cmd(struct comedi_device *dev,
-   struct comedi_subdevice *s)
-{
-   int err;
-   struct comedi_cmd *cmd = &s->async->cmd;
-
-   /* Reset the analog input */
-   err = me4000_ai_cancel(dev, s);
-   if (err)
-   return err;
-
-   /* Prepare the AI for acquisition */
-   err = ai_prepare(dev, s, cmd);
-   if (err)
-   return err;
-
/* Start acquistion by dummy read */
inl(dev->iobase + ME4000_AI_START_REG);
 
-- 
2.4.3

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


[PATCH v2 32/46] staging: comedi: me4000: return void from me4000_ai_write_chanlist()

2015-08-05 Thread H Hartley Sweeten
This function always returns 0 and the return value is never checked.
Just return void.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index ecdf673..b30305b 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -635,9 +635,9 @@ static void me4000_ai_round_cmd_args(struct comedi_device 
*dev,
}
 }
 
-static int me4000_ai_write_chanlist(struct comedi_device *dev,
-   struct comedi_subdevice *s,
-   struct comedi_cmd *cmd)
+static void me4000_ai_write_chanlist(struct comedi_device *dev,
+struct comedi_subdevice *s,
+struct comedi_cmd *cmd)
 {
int i;
 
@@ -657,8 +657,6 @@ static int me4000_ai_write_chanlist(struct comedi_device 
*dev,
 
outl(entry, dev->iobase + ME4000_AI_CHANNEL_LIST_REG);
}
-
-   return 0;
 }
 
 static int me4000_ai_do_cmd(struct comedi_device *dev,
-- 
2.4.3

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


[PATCH v2 34/46] staging: comedi: me4000: remove unnecessary ai control register reset

2015-08-05 Thread H Hartley Sweeten
The me4000_ai_cancel() already reset this register.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index a171971..4a051b8 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -688,9 +688,6 @@ static int me4000_ai_do_cmd(struct comedi_device *dev,
outl(devpriv->ai_chan_ticks - 1,
 dev->iobase + ME4000_AI_CHAN_TIMER_REG);
 
-   /* Reset control register */
-   outl(0, dev->iobase + ME4000_AI_CTRL_REG);
-
/* Start sources */
ctrl = devpriv->ai_ctrl_mode |
   ME4000_AI_CTRL_CHANNEL_FIFO |
-- 
2.4.3

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


[PATCH v2 33/46] staging: comedi: me4000: fix me4000_ai_cancel()

2015-08-05 Thread H Hartley Sweeten
The STOP and IMMEDIATE_STOP bits in the ME4000_AI_CTRL_REG should be set,
not cleared, to stop any running conversions.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index b30305b..a171971 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -529,12 +529,12 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
 static int me4000_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
 {
-   unsigned int tmp;
+   unsigned int ctrl;
 
/* Stop any running conversion */
-   tmp = inl(dev->iobase + ME4000_AI_CTRL_REG);
-   tmp &= ~(ME4000_AI_CTRL_STOP | ME4000_AI_CTRL_IMMEDIATE_STOP);
-   outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
+   ctrl = inl(dev->iobase + ME4000_AI_CTRL_REG);
+   ctrl |= ME4000_AI_CTRL_STOP | ME4000_AI_CTRL_IMMEDIATE_STOP;
+   outl(ctrl, dev->iobase + ME4000_AI_CTRL_REG);
 
/* Clear the control register */
outl(0x0, dev->iobase + ME4000_AI_CTRL_REG);
-- 
2.4.3

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


[PATCH v2 36/46] staging: comedi: me4000: clear the ME4000_AI_CTRL_REG in me4000_reset()

2015-08-05 Thread H Hartley Sweeten
Reset the analog input control register after ensuring that any active
conversions have been stopped. This mimics what the ai subdevice (*cancel)
does.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index b3d871b..3d4a9c8 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -414,6 +414,9 @@ static void me4000_reset(struct comedi_device *dev)
outl(ME4000_AI_CTRL_IMMEDIATE_STOP | ME4000_AI_CTRL_STOP,
 dev->iobase + ME4000_AI_CTRL_REG);
 
+   /* Clear the analog input control register */
+   outl(0x0, dev->iobase + ME4000_AI_CTRL_REG);
+
/* Set both stop bits in the analog output control register */
val = ME4000_AO_CTRL_IMMEDIATE_STOP | ME4000_AO_CTRL_STOP;
for (chan = 0; chan < 4; chan++)
-- 
2.4.3

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


[PATCH v2 37/46] staging: comedi: me4000: introduce me4000_ai_reset()

2015-08-05 Thread H Hartley Sweeten
Introduce a helper function to stop any ai conversions and reset the
ai control register. This consolidates the common code in me4000_reset()
and me4000_ai_cancel().

Use the new helper in the ai (*insn_read) to ensure that the ai control
register is set to a known state after reading the samples.

The ai control register will now always be '0' after the (*cancel) of
a command or doing an (*insn_read). Knowing this the programming of
the register for single acquisition mode in the (*insn_read) can be
simplified.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 3d4a9c8..da0075b 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -393,6 +393,19 @@ static int me4000_xilinx_download(struct comedi_device 
*dev,
return 0;
 }
 
+static void me4000_ai_reset(struct comedi_device *dev)
+{
+   unsigned int ctrl;
+
+   /* Stop any running conversion */
+   ctrl = inl(dev->iobase + ME4000_AI_CTRL_REG);
+   ctrl |= ME4000_AI_CTRL_STOP | ME4000_AI_CTRL_IMMEDIATE_STOP;
+   outl(ctrl, dev->iobase + ME4000_AI_CTRL_REG);
+
+   /* Clear the control register */
+   outl(0x0, dev->iobase + ME4000_AI_CTRL_REG);
+}
+
 static void me4000_reset(struct comedi_device *dev)
 {
struct me4000_private *devpriv = dev->private;
@@ -410,12 +423,7 @@ static void me4000_reset(struct comedi_device *dev)
for (chan = 0; chan < 4; chan++)
outl(0x8000, dev->iobase + ME4000_AO_SINGLE_REG(chan));
 
-   /* Set both stop bits in the analog input control register */
-   outl(ME4000_AI_CTRL_IMMEDIATE_STOP | ME4000_AI_CTRL_STOP,
-dev->iobase + ME4000_AI_CTRL_REG);
-
-   /* Clear the analog input control register */
-   outl(0x0, dev->iobase + ME4000_AI_CTRL_REG);
+   me4000_ai_reset(dev);
 
/* Set both stop bits in the analog output control register */
val = ME4000_AO_CTRL_IMMEDIATE_STOP | ME4000_AO_CTRL_STOP;
@@ -461,8 +469,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
unsigned int range = CR_RANGE(insn->chanspec);
unsigned int aref = CR_AREF(insn->chanspec);
unsigned int entry;
-   unsigned int tmp;
-   int ret;
+   int ret = 0;
int i;
 
entry = chan | ME4000_AI_LIST_RANGE(range);
@@ -489,20 +496,9 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
 
entry |= ME4000_AI_LIST_LAST_ENTRY;
 
-   /* Clear channel list, data fifo and both stop bits */
-   tmp = inl(dev->iobase + ME4000_AI_CTRL_REG);
-   tmp &= ~(ME4000_AI_CTRL_CHANNEL_FIFO | ME4000_AI_CTRL_DATA_FIFO |
-ME4000_AI_CTRL_STOP | ME4000_AI_CTRL_IMMEDIATE_STOP);
-   outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
-
-   /* Set the acquisition mode to single */
-   tmp &= ~(ME4000_AI_CTRL_MODE_0 | ME4000_AI_CTRL_MODE_1 |
-ME4000_AI_CTRL_MODE_2);
-   outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
-
-   /* Enable channel list and data fifo */
-   tmp |= ME4000_AI_CTRL_CHANNEL_FIFO | ME4000_AI_CTRL_DATA_FIFO;
-   outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
+   /* Enable channel list and data fifo for single acquisition mode */
+   outl(ME4000_AI_CTRL_CHANNEL_FIFO | ME4000_AI_CTRL_DATA_FIFO,
+dev->iobase + ME4000_AI_CTRL_REG);
 
/* Generate channel list entry */
outl(entry, dev->iobase + ME4000_AI_CHANNEL_LIST_REG);
@@ -519,28 +515,22 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
 
ret = comedi_timeout(dev, s, insn, me4000_ai_eoc, 0);
if (ret)
-   return ret;
+   break;
 
/* read two's complement value and munge to offset binary */
val = inl(dev->iobase + ME4000_AI_DATA_REG);
data[i] = comedi_offset_munge(s, val);
}
 
-   return insn->n;
+   me4000_ai_reset(dev);
+
+   return ret ? ret : insn->n;
 }
 
 static int me4000_ai_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
 {
-   unsigned int ctrl;
-
-   /* Stop any running conversion */
-   ctrl = inl(dev->iobase + ME4000_AI_CTRL_REG);
-   ctrl |= ME4000_AI_CTRL_STOP | ME4000_AI_CTRL_IMMEDIATE_STOP;
-   outl(ctrl, dev->iobase + ME4000_AI_CTRL_REG);
-
-   /* Clear the control register */
-   outl(0x0, dev->iobase + ME4000_AI_CTRL_REG);
+   me4000_ai_reset(dev);
 
return 0;
 }
-- 
2.4.3

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


[PATCH v2 35/46] staging: comedi: me4000: remove unnecessary me4000_ai_cancel()

2015-08-05 Thread H Hartley Sweeten
The comedi core ensures that the subdevice is not busy before it allows
starting a new command. The subdevice (*cancel) is called when the
subdevice is set to not busy. In this driver the me4000_ai_cancel()
is the ai (*cancel) so the extra call in the ai (*do_cmd) is not
necessary. Remove it.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 4a051b8..b3d871b 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -665,12 +665,6 @@ static int me4000_ai_do_cmd(struct comedi_device *dev,
struct me4000_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int ctrl;
-   int err;
-
-   /* Reset the analog input */
-   err = me4000_ai_cancel(dev, s);
-   if (err)
-   return err;
 
/* Write timer arguments */
outl(devpriv->ai_init_ticks - 1,
-- 
2.4.3

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


[PATCH v2 40/46] staging: comedi: me4000: tidy up analog output subdevice init

2015-08-05 Thread H Hartley Sweeten
For aesthetics, add some white space to the analog output subdevice
initialization.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 4f2ff86..b2d9d61 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -1213,25 +1213,21 @@ static int me4000_auto_attach(struct comedi_device *dev,
s->do_cmd   = me4000_ai_do_cmd;
}
 
-/*=
-  Analog output subdevice
-  
*/
-
+   /* Analog Output subdevice */
s = &dev->subdevices[1];
-
if (board->has_ao) {
-   s->type = COMEDI_SUBD_AO;
-   s->subdev_flags = SDF_WRITABLE | SDF_COMMON | SDF_GROUND;
-   s->n_chan = 4;
-   s->maxdata = 0x;/*  16 bit DAC */
-   s->range_table = &range_bipolar10;
-   s->insn_write = me4000_ao_insn_write;
+   s->type = COMEDI_SUBD_AO;
+   s->subdev_flags = SDF_WRITABLE | SDF_COMMON | SDF_GROUND;
+   s->n_chan   = 4;
+   s->maxdata  = 0x;
+   s->range_table  = &range_bipolar10;
+   s->insn_write   = me4000_ao_insn_write;
 
result = comedi_alloc_subdev_readback(s);
if (result)
return result;
} else {
-   s->type = COMEDI_SUBD_UNUSED;
+   s->type = COMEDI_SUBD_UNUSED;
}
 
/* Digital I/O subdevice */
-- 
2.4.3

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


[PATCH v2 38/46] staging: comedi: me4000: only enable PLX interrupt if we have and irq

2015-08-05 Thread H Hartley Sweeten
Currently me4000_reset() always enables the PLX interrupt. Move the
enable of the interrupt into me4000_auto_attach() and only do the
enable if we actually have and irq.

Make sure the PLX interrupt is disabled in me4000_reset() before we
try to request the irq.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index da0075b..a4c28fa 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -412,7 +412,10 @@ static void me4000_reset(struct comedi_device *dev)
unsigned int val;
int chan;
 
-   /* Make a hardware reset */
+   /* Disable interrupts on the PLX */
+   outl(0, devpriv->plx_regbase + PLX9052_INTCSR);
+
+   /* Software reset the PLX */
val = inl(devpriv->plx_regbase + PLX9052_CNTRL);
val |= PLX9052_CNTRL_PCI_RESET;
outl(val, devpriv->plx_regbase + PLX9052_CNTRL);
@@ -430,11 +433,6 @@ static void me4000_reset(struct comedi_device *dev)
for (chan = 0; chan < 4; chan++)
outl(val, dev->iobase + ME4000_AO_CTRL_REG(chan));
 
-   /* Enable interrupts on the PLX */
-   outl(PLX9052_INTCSR_LI1ENAB |
-PLX9052_INTCSR_LI1POL |
-PLX9052_INTCSR_PCIENAB, devpriv->plx_regbase + PLX9052_INTCSR);
-
/* Set the adustment register for AO demux */
outl(ME4000_AO_DEMUX_ADJUST_VALUE,
 dev->iobase + ME4000_AO_DEMUX_ADJUST_REG);
@@ -1181,8 +1179,14 @@ static int me4000_auto_attach(struct comedi_device *dev,
if (pcidev->irq > 0) {
result = request_irq(pcidev->irq, me4000_ai_isr, IRQF_SHARED,
 dev->board_name, dev);
-   if (result == 0)
+   if (result == 0) {
dev->irq = pcidev->irq;
+
+   /* Enable interrupts on the PLX */
+   outl(PLX9052_INTCSR_LI1ENAB | PLX9052_INTCSR_LI1POL |
+PLX9052_INTCSR_PCIENAB,
+devpriv->plx_regbase + PLX9052_INTCSR);
+   }
}
 
result = comedi_alloc_subdevices(dev, 4);
-- 
2.4.3

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


[PATCH v2 41/46] staging: comedi: me4000: comedi_handle_events() will stop conversions

2015-08-05 Thread H Hartley Sweeten
The irq handler does not need to manually stop conversions and disable
interrupts when "end-of-acquisition", "error", or "overflow" events are
detected. The comedi_handle_events() will call the subdevice (*cancel)
when these are detected and stop the acquisition.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index b2d9d61..b17183d 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -939,41 +939,17 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
if (!(tmp & ME4000_AI_STATUS_FF_DATA) &&
!(tmp & ME4000_AI_STATUS_HF_DATA) &&
(tmp & ME4000_AI_STATUS_EF_DATA)) {
-   c = ME4000_AI_FIFO_COUNT;
-
-   /*
-* FIFO overflow, so stop conversion
-* and disable all interrupts
-*/
-   tmp |= ME4000_AI_CTRL_IMMEDIATE_STOP;
-   tmp &= ~(ME4000_AI_CTRL_HF_IRQ |
-ME4000_AI_CTRL_SC_IRQ);
-   outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
-
-   s->async->events |= COMEDI_CB_ERROR;
-
dev_err(dev->class_dev, "FIFO overflow\n");
+   s->async->events |= COMEDI_CB_ERROR;
+   c = ME4000_AI_FIFO_COUNT;
} else if ((tmp & ME4000_AI_STATUS_FF_DATA) &&
   !(tmp & ME4000_AI_STATUS_HF_DATA) &&
   (tmp & ME4000_AI_STATUS_EF_DATA)) {
c = ME4000_AI_FIFO_COUNT / 2;
} else {
-   dev_err(dev->class_dev,
-   "Can't determine state of fifo\n");
-   c = 0;
-
-   /*
-* Undefined state, so stop conversion
-* and disable all interrupts
-*/
-   tmp |= ME4000_AI_CTRL_IMMEDIATE_STOP;
-   tmp &= ~(ME4000_AI_CTRL_HF_IRQ |
-ME4000_AI_CTRL_SC_IRQ);
-   outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
-
-   s->async->events |= COMEDI_CB_ERROR;
-
dev_err(dev->class_dev, "Undefined FIFO state\n");
+   s->async->events |= COMEDI_CB_ERROR;
+   c = 0;
}
 
for (i = 0; i < c; i++) {
@@ -981,17 +957,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_write_samples(s, &lval, 1)) {
-   /*
-* Buffer overflow, so stop conversion
-* and disable all interrupts
-*/
-   tmp |= ME4000_AI_CTRL_IMMEDIATE_STOP;
-   tmp &= ~(ME4000_AI_CTRL_HF_IRQ |
-ME4000_AI_CTRL_SC_IRQ);
-   outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
+   if (!comedi_buf_write_samples(s, &lval, 1))
break;
-   }
}
 
/* Work is done, so reset the interrupt */
@@ -1003,17 +970,9 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
 
if (inl(dev->iobase + ME4000_IRQ_STATUS_REG) &
ME4000_IRQ_STATUS_SC) {
+   /* Acquisition is complete */
s->async->events |= COMEDI_CB_EOA;
 
-   /*
-* Acquisition is complete, so stop
-* conversion and disable all interrupts
-*/
-   tmp = inl(dev->iobase + ME4000_AI_CTRL_REG);
-   tmp |= ME4000_AI_CTRL_IMMEDIATE_STOP;
-   tmp &= ~(ME4000_AI_CTRL_HF_IRQ | ME4000_AI_CTRL_SC_IRQ);
-   outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
-
/* Poll data until fifo empty */
while (inl(dev->iobase + ME4000_AI_STATUS_REG) &
   ME4000_AI_STATUS_EF_DATA) {
@@ -1026,6 +985,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
}
 
/* Work is done, so reset the interrupt */
+   tmp = inl(dev->iobase + ME4000_AI_CTRL_REG);
tmp |= ME4000_AI_CTRL_SC_IRQ_RESET;
outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
tmp &= ~ME4000_AI_CTRL_SC_IRQ_RESET;
-- 
2.4.3

__

[PATCH v2 42/46] staging: comedi: me4000: introduce me4000_ai_get_sample()

2015-08-05 Thread H Hartley Sweeten
The hardware returns two's complement values for the analog input
samples. These need to be converted to the unsigned binary format
that the comedi core expects. Introduce a helper function to handle
this.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index b17183d..3974f59 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -445,6 +445,16 @@ static void me4000_reset(struct comedi_device *dev)
outl(0x1, dev->iobase + ME4000_DIO_CTRL_REG);
 }
 
+static unsigned int me4000_ai_get_sample(struct comedi_device *dev,
+struct comedi_subdevice *s)
+{
+   unsigned int val;
+
+   /* read two's complement value and munge to offset binary */
+   val = inl(dev->iobase + ME4000_AI_DATA_REG);
+   return comedi_offset_munge(s, val);
+}
+
 static int me4000_ai_eoc(struct comedi_device *dev,
 struct comedi_subdevice *s,
 struct comedi_insn *insn,
@@ -515,8 +525,7 @@ static int me4000_ai_insn_read(struct comedi_device *dev,
if (ret)
break;
 
-   /* read two's complement value and munge to offset binary */
-   val = inl(dev->iobase + ME4000_AI_DATA_REG);
+   val = me4000_ai_get_sample(dev, s);
data[i] = comedi_offset_munge(s, val);
}
 
@@ -953,10 +962,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
}
 
for (i = 0; i < c; i++) {
-   /* Read value from data fifo */
-   lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0x;
-   lval ^= 0x8000;
-
+   lval = me4000_ai_get_sample(dev, s);
if (!comedi_buf_write_samples(s, &lval, 1))
break;
}
@@ -976,10 +982,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
/* Poll data until fifo empty */
while (inl(dev->iobase + ME4000_AI_STATUS_REG) &
   ME4000_AI_STATUS_EF_DATA) {
-   /* Read value from data fifo */
-   lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0x;
-   lval ^= 0x8000;
-
+   lval = me4000_ai_get_sample(dev, s);
if (!comedi_buf_write_samples(s, &lval, 1))
break;
}
-- 
2.4.3

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


[PATCH v2 39/46] staging: comedi: me4000: fix me4000_detach()

2015-08-05 Thread H Hartley Sweeten
There is no real reason to reset the board when detaching. The comedi core
will ensure that any commands are canceled before the detach.

But the PLX interrupts should be disabled.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index a4c28fa..4f2ff86 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -1276,8 +1276,12 @@ static int me4000_auto_attach(struct comedi_device *dev,
 
 static void me4000_detach(struct comedi_device *dev)
 {
-   if (dev->iobase)
-   me4000_reset(dev);
+   if (dev->irq) {
+   struct me4000_private *devpriv = dev->private;
+
+   /* Disable interrupts on the PLX */
+   outl(0, devpriv->plx_regbase + PLX9052_INTCSR);
+   }
comedi_pci_detach(dev);
 }
 
-- 
2.4.3

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


[PATCH v2 45/46] staging: comedi: me4000: updata driver status in comedi comment

2015-08-05 Thread H Hartley Sweeten
Firmware loading was fixed by:

Commit: ac584af5
"staging: comedi: me4000: fix firmware downloading"

Change the driver status to "untested" and remove the comments about
the driver being broken,

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 56da64d..ac6931a 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -23,7 +23,7 @@
  * ME-4680is
  * Author: gg (Guenter Gebhardt )
  * Updated: Mon, 18 Mar 2002 15:34:01 -0800
- * Status: broken (no support for loading firmware)
+ * Status: untested
  *
  * Supports:
  * - Analog Input
@@ -35,9 +35,7 @@
  *
  * The firmware required by these boards is available in the
  * comedi_nonfree_firmware tarball available from
- * http://www.comedi.org.  However, the driver's support for
- * loading the firmware through comedi_config is currently
- * broken.
+ * http://www.comedi.org.
  */
 
 #include 
-- 
2.4.3

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


[PATCH v2 44/46] staging: comedi: me4000: cleanup multi-line comments

2015-08-05 Thread H Hartley Sweeten
Format the multi-line comments in the kernel CodingStyle.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 74c16db..56da64d 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -1,43 +1,43 @@
 /*
-   comedi/drivers/me4000.c
-   Source code for the Meilhaus ME-4000 board family.
-
-   COMEDI - Linux Control and Measurement Device Interface
-   Copyright (C) 2000 David A. Schleef 
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+ * me4000.c
+ * Source code for the Meilhaus ME-4000 board family.
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 2000 David A. Schleef 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  */
-/*
-Driver: me4000
-Description: Meilhaus ME-4000 series boards
-Devices: [Meilhaus] ME-4650 (me4000), ME-4670i, ME-4680, ME-4680i, ME-4680is
-Author: gg (Guenter Gebhardt )
-Updated: Mon, 18 Mar 2002 15:34:01 -0800
-Status: broken (no support for loading firmware)
-
-Supports:
-
-- Analog Input
-- Analog Output
-- Digital I/O
-- Counter
-
-Configuration Options: not applicable, uses PCI auto config
-
-The firmware required by these boards is available in the
-comedi_nonfree_firmware tarball available from
-http://www.comedi.org.  However, the driver's support for
-loading the firmware through comedi_config is currently
-broken.
 
+/*
+ * Driver: me4000
+ * Description: Meilhaus ME-4000 series boards
+ * Devices: [Meilhaus] ME-4650 (me4000), ME-4670i, ME-4680, ME-4680i,
+ * ME-4680is
+ * Author: gg (Guenter Gebhardt )
+ * Updated: Mon, 18 Mar 2002 15:34:01 -0800
+ * Status: broken (no support for loading firmware)
+ *
+ * Supports:
+ * - Analog Input
+ * - Analog Output
+ * - Digital I/O
+ * - Counter
+ *
+ * Configuration Options: not applicable, uses PCI auto config
+ *
+ * The firmware required by these boards is available in the
+ * comedi_nonfree_firmware tarball available from
+ * http://www.comedi.org.  However, the driver's support for
+ * loading the firmware through comedi_config is currently
+ * broken.
  */
 
 #include 
-- 
2.4.3

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


[PATCH v2 43/46] staging: comedi: me4000: usleep_range is preferred over udelay

2015-08-05 Thread H Hartley Sweeten
Fix checkpatch issue: "CHECK: usleep_range is preferred over udelay; see
Documentation/timers/timers-howto.txt".  `udelay()` is only used in the
firmware upload process.  Replace them with `usleep_range()` with a
reasonable upper limit.

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index 3974f59..74c16db 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -345,7 +345,7 @@ static int me4000_xilinx_download(struct comedi_device *dev,
inb(xilinx_iobase + 0xC8);
 
/* Wait until /INIT pin is set */
-   udelay(20);
+   usleep_range(20, 1000);
val = inl(devpriv->plx_regbase + PLX9052_INTCSR);
if (!(val & PLX9052_INTCSR_LI2STAT)) {
dev_err(dev->class_dev, "Can't init Xilinx\n");
@@ -362,11 +362,11 @@ static int me4000_xilinx_download(struct comedi_device 
*dev,
  (((unsigned int)data[1] & 0xff) << 16) +
  (((unsigned int)data[2] & 0xff) << 8) +
  ((unsigned int)data[3] & 0xff);
-   udelay(10);
+   usleep_range(10, 1000);
 
for (i = 0; i < file_length; i++) {
outb(data[16 + i], xilinx_iobase);
-   udelay(10);
+   usleep_range(10, 1000);
 
/* Check if BUSY flag is low */
val = inl(devpriv->plx_regbase + PLX9052_CNTRL);
-- 
2.4.3

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


[PATCH v2 46/46] staging: comedi: me4000: update MODULE_DESCRIPTION

2015-08-05 Thread H Hartley Sweeten
Change the MODULE_DESCRIPTION to something more useful than "Comedi low-
level driver"

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

diff --git a/drivers/staging/comedi/drivers/me4000.c 
b/drivers/staging/comedi/drivers/me4000.c
index ac6931a..5aa1780 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -1282,6 +1282,6 @@ static struct pci_driver me4000_pci_driver = {
 module_comedi_pci_driver(me4000_driver, me4000_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org";);
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("Comedi driver for Meilhaus ME-4000 series boards");
 MODULE_LICENSE("GPL");
 MODULE_FIRMWARE(ME4000_FIRMWARE);
-- 
2.4.3

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


Re: [PATCH V3] staging: android: lowmemorykiller: imporve lmk to avoid deadlock issue

2015-08-05 Thread gre...@linuxfoundation.org
On Mon, Aug 03, 2015 at 08:26:40AM +, Wang, Biao wrote:
> Consider the following case:
> Task A trigger lmk with a lock held, while task B try to get this lock, but 
> unfortunately B is the very culprit task lmk select to kill. Then B will 
> never be killed, and A will forever select B to kill.
> Such dead lock will trigger softlock up issue.
> 
> This patch try to pick the next task to break this loop.
> 
> Signed-off-by: Wang Biao 
> Reviewed-by: Zhang Di 
> ---
>  drivers/staging/android/lowmemorykiller.c |5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Please address Dave's review comments, I'll not take this as-is, sorry.

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


Re: [PATCH v2 2/2] Staging: ft1000: ft1000-usb: use USB API functions rather than constants

2015-08-05 Thread Greg Kroah-Hartman
On Wed, Aug 05, 2015 at 03:18:04AM +0530, Shraddha Barke wrote:
> This patch introduces the use of the function usb_endpoint_type.
> 
> The Coccinelle semantic patch that makes these changes is as follows:
> 
> @@ struct usb_endpoint_descriptor *epd; @@
> 
> - (epd->bmAttributes & \(USB_ENDPOINT_XFERTYPE_MASK\|3\))
> + usb_endpoint_type(epd)
> 
> Signed-off-by: Shraddha Barke 
> ---
> Changes in v2:
>   -Fix subject line
> 
>  drivers/staging/ft1000/ft1000-usb/ft1000_usb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c 
> b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
> index fd255c6..abdb0ab 100644
> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c
> @@ -112,7 +112,7 @@ static int ft1000_probe(struct usb_interface *interface,
>   pr_debug("bEndpointAddress=%x, bmAttributes=%x\n",
>endpoint->bEndpointAddress, endpoint->bmAttributes);
>   if ((endpoint->bEndpointAddress & USB_DIR_IN)
> - && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
> + && (usb_endpoint_type(endpoint) ==
>   USB_ENDPOINT_XFER_BULK)) {

All of that mess should be replaced with usb_endpoint_is_bulk_in().

>   ft1000dev->bulk_in_endpointAddr =
>   endpoint->bEndpointAddress;
> @@ -120,7 +120,7 @@ static int ft1000_probe(struct usb_interface *interface,
>   }
>  
>   if (!(endpoint->bEndpointAddress & USB_DIR_IN)
> - && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
> + && (usb_endpoint_type(endpoint) ==
>   USB_ENDPOINT_XFER_BULK)) {

Same here.

thanks,

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


Re: [PATCH] Staging: vme: fix a wrong waring in vme_user_probe()

2015-08-05 Thread Greg Kroah-Hartman
On Wed, Aug 05, 2015 at 01:24:52PM +0800, Navy Cheng wrote:
> The waring message will mislead developers and users. This will cause a
> potential damage. Fix the waring message to give developers and users the
> correct guidance.

"waring"?



> 
> Signed-off-by: Navy Cheng 
> ---
>  drivers/staging/vme/devices/vme_user.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/vme/devices/vme_user.c 
> b/drivers/staging/vme/devices/vme_user.c
> index 19ba749..40097fe 100644
> --- a/drivers/staging/vme/devices/vme_user.c
> +++ b/drivers/staging/vme/devices/vme_user.c
> @@ -785,7 +785,7 @@ static int vme_user_probe(struct vme_dev *vdev)
>   vme_user_cdev->owner = THIS_MODULE;
>   err = cdev_add(vme_user_cdev, MKDEV(VME_MAJOR, 0), VME_DEVS);
>   if (err) {
> - dev_warn(&vdev->dev, "cdev_all failed\n");
> + dev_warn(&vdev->dev, "cdev_add failed\n");

The only way this can fail is if we don't have enough memory, and a
message will be printed out there, so might as well just remove this
message entirely as well.

thanks,

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


Re: [PATCH] staging: sm750fb: fix sparse warning for lock

2015-08-05 Thread Greg KH
On Wed, Aug 05, 2015 at 09:26:44PM +0800, Peng Fan wrote:
> Use __acquire() and __release() in the right place to silence the sparse
> lock checking warning.
> 
> drivers/staging/sm750fb/sm750.c:177:13: warning: context imbalance in 
> 'lynxfb_ops_fillrect' - different lock contexts for basic block
> drivers/staging/sm750fb/sm750.c:243:9: warning: context imbalance in 
> 'lynxfb_ops_copyarea' - different lock contexts for basic block
> drivers/staging/sm750fb/sm750.c:247:13: warning: context imbalance in 
> 'lynxfb_ops_imageblit' - different lock contexts for basic block
> 
> Signed-off-by: Peng Fan 
> Cc: Sudip Mukherjee 
> Cc: Teddy Wang 
> Cc: Greg Kroah-Hartman 
> ---
>  drivers/staging/sm750fb/sm750.c | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
> index 8e201f1..5ba1c06 100644
> --- a/drivers/staging/sm750fb/sm750.c
> +++ b/drivers/staging/sm750fb/sm750.c
> @@ -203,6 +203,8 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
>*/
>   if (share->dual)
>   spin_lock(&share->slock);
> + else
> + __acquire(&share->slock);

That's horrid, please don't do stuff like this just to make a static
checker "quiet".

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


[PATCH] staging: panel: Fix coding style issue.

2015-08-05 Thread Lior Pugatch
This patch fixes checkpatch.pl warning,
all warnings are releted to comments code style.

---
 drivers/staging/panel/panel.c | 38 +-
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 3e9ee7e..6b96369 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -785,6 +785,7 @@ static void long_sleep(int ms)
  * send a serial byte to the LCD panel. The caller is responsible for locking
  * if needed.
  */
+
 static void lcd_send_serial(int byte)
 {
int bit;
@@ -910,7 +911,8 @@ static void lcd_gotoxy(void)
lcd_write_cmd(LCD_CMD_SET_DDRAM_ADDR
  | (lcd.addr.y ? lcd.hwidth : 0)
  /* we force the cursor to stay at the end of the
-line if it wants to go farther */
+  * line if it wants to go farther
+  */
  | ((lcd.addr.x < lcd.bwidth) ? lcd.addr.x &
 (lcd.hwidth - 1) : lcd.bwidth - 1));
 }
@@ -1064,11 +1066,9 @@ static void lcd_init_display(void)
lcd_clear_display();
 }
 
-/*
- * These are the file operation function for user access to /dev/lcd
+/* These are the file operation function for user access to /dev/lcd
  * This function can also be called from inside the kernel, by
  * setting file and ppos to NULL.
- *
  */
 
 static inline int handle_lcd_special_code(void)
@@ -1295,7 +1295,8 @@ static inline int handle_lcd_special_code(void)
lcd_backlight(1);
else if (lcd.light_tempo == 0)
/* switch off the light only when the tempo
-  lighting is gone */
+*  lighting is gone
+*/
lcd_backlight(0);
}
}
@@ -1324,7 +1325,8 @@ static void lcd_write_char(char c)
/* go back one char and clear it */
if (lcd.addr.x > 0) {
/* check if we're not at the
-  end of the line */
+*  end of the line
+*/
if (lcd.addr.x < lcd.bwidth)
/* back one char */
lcd_write_cmd(LCD_CMD_SHIFT);
@@ -1341,7 +1343,8 @@ static void lcd_write_char(char c)
break;
case '\n':
/* flush the remainder of the current line and
-  go to the beginning of the next line */
+* go to the beginning of the next line
+*/
for (; lcd.addr.x < lcd.bwidth; lcd.addr.x++)
lcd_write_data(' ');
lcd.addr.x = 0;
@@ -1365,7 +1368,9 @@ static void lcd_write_char(char c)
}
 
/* now we'll see if we're in an escape mode and if the current
-  escape sequence can be understood. */
+*  escape sequence can be understood.
+*/
+
if (lcd.esc_seq.len >= 2) {
int processed = 0;
 
@@ -1388,8 +1393,10 @@ static void lcd_write_char(char c)
}
 
/* LCD special escape codes */
+
/* flush the escape sequence if it's been processed
-  or if it is getting too long. */
+* or if it is getting too long.
+*/
if (processed || (lcd.esc_seq.len >= LCD_ESCAPE_LEN))
lcd.esc_seq.len = -1;
} /* escape codes */
@@ -1404,7 +1411,8 @@ static ssize_t lcd_write(struct file *file,
for (; count-- > 0; (*ppos)++, tmp++) {
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
/* let's be a little nice with other processes
-  that need some CPU */
+* that need some CPU.
+*/
schedule();
 
if (get_user(c, tmp))
@@ -1460,7 +1468,8 @@ static void panel_lcd_print(const char *s)
for (; count-- > 0; tmp++) {
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
/* let's be a little nice with other processes
-  that need some CPU */
+* that need some CPU.
+*/
schedule();
 
lcd_write_char(*tmp);
@@ -1636,7 +1645,9 @@ static void lcd_init(void)
 
/* before this line, we must NOT send anything to the display.
 * Since lcd_init_display() needs to write data, we have to
-* enable mark the LCD ini

Re: [PATCHv5 3/5] Staging: most: hdm-usb/hdm_usb.c. Fix "missing static keyword" warnings

2015-08-05 Thread Christian Gromm
On Tue, 4 Aug 2015 20:44:53 +0200
Adrian Remonda  wrote:

> This is a patch to the most/hdm-usb/hdm_usb.c file. It
> makes several local functions and structures static to prevent global
> visibility.
> 
> Signed-off-by: Adrian Remonda 
> ---
>  drivers/staging/most/hdm-usb/hdm_usb.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c 
> b/drivers/staging/most/hdm-usb/hdm_usb.c
> index 514ce3529b7a..db92b2ba423d 100644
> --- a/drivers/staging/most/hdm-usb/hdm_usb.c
> +++ b/drivers/staging/most/hdm-usb/hdm_usb.c
> @@ -290,7 +290,7 @@ static unsigned int get_stream_frame_size(struct 
> most_channel_config *cfg)
>   *
>   * Returns 0 on success or error code otherwise.
>   */
> -int hdm_poison_channel(struct most_interface *iface, int channel)
> +static int hdm_poison_channel(struct most_interface *iface, int channel)
>  {
>   struct most_dev *mdev;
>  
> @@ -328,7 +328,7 @@ int hdm_poison_channel(struct most_interface *iface, int 
> channel)
>   * This inserts the INIC hardware specific padding bytes into a streaming
>   * channel's buffer
>   */
> -int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
> +static int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo 
> *mbo)
>  {
>   struct most_channel_config *conf = &mdev->conf[channel];
>   unsigned int j, num_frames, frame_size;
> @@ -365,7 +365,7 @@ int hdm_add_padding(struct most_dev *mdev, int channel, 
> struct mbo *mbo)
>   * This takes the INIC hardware specific padding bytes off a streaming
>   * channel's buffer.
>   */
> -int hdm_remove_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
> +static int hdm_remove_padding(struct most_dev *mdev, int channel, struct mbo 
> *mbo)
>  {
>   unsigned int j, num_frames, frame_size;
>   struct most_channel_config *const conf = &mdev->conf[channel];
> @@ -644,7 +644,7 @@ static void hdm_read_completion(struct urb *urb)
>   *
>   * Context: Could in _some_ cases be interrupt!
>   */
> -int hdm_enqueue(struct most_interface *iface, int channel, struct mbo *mbo)
> +static int hdm_enqueue(struct most_interface *iface, int channel, struct mbo 
> *mbo)
>  {
>   struct most_dev *mdev;
>   struct buf_anchor *anchor;
> @@ -743,8 +743,8 @@ _error:
>   * @channel: channel ID
>   * @conf: structure that holds the configuration information
>   */
> -int hdm_configure_channel(struct most_interface *iface, int channel,
> -   struct most_channel_config *conf)
> +static int hdm_configure_channel(struct most_interface *iface, int channel,
> + struct most_channel_config *conf)
This is still not aligned.

regards,
Chris   

>  {
>   unsigned int num_frames;
>   unsigned int frame_size;
> @@ -824,7 +824,7 @@ exit:
>   * This triggers the USB vendor requests to read the hardware address and
>   * the current link status of the attached device.
>   */
> -int hdm_update_netinfo(struct most_dev *mdev)
> +static int hdm_update_netinfo(struct most_dev *mdev)
>  {
>   struct device *dev = &mdev->usb_device->dev;
>   int i;
> @@ -873,7 +873,7 @@ int hdm_update_netinfo(struct most_dev *mdev)
>   * polls for the NI state of the INIC every 2 seconds.
>   *
>   */
> -void hdm_request_netinfo(struct most_interface *iface, int channel)
> +static void hdm_request_netinfo(struct most_interface *iface, int channel)
>  {
>   struct most_dev *mdev;
>  

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


Re: [PATCH 0/3] VME bus error handling overhaul

2015-08-05 Thread Greg Kroah-Hartman
On Mon, Jul 06, 2015 at 01:31:47PM +0100, Martyn Welch wrote:
> Hi Dmitry,
> 
> These are looking good to me.

Can I get an "Acked-by:" or something so that I know it's ok to apply
these?

thanks,

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


[PATCH] staging: octeon: fix coding style warnings for block comments

2015-08-05 Thread Okash Khawaja
The Linux kernel coding style suggests starting every line in a block
comment with an asterisk and finishing the block comment with */ on a
separate line. This patch fixes those warnings, clearing all warnings
and errors in this file, as reported by the checkpatch script.


Signed-off-by: Okash Khawaja 
---
 drivers/staging/octeon/ethernet-rgmii.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-rgmii.c 
b/drivers/staging/octeon/ethernet-rgmii.c
index beb7aac..51dcb61 100644
--- a/drivers/staging/octeon/ethernet-rgmii.c
+++ b/drivers/staging/octeon/ethernet-rgmii.c
@@ -118,9 +118,10 @@ static void cvm_oct_rgmii_poll(struct net_device *dev)
}
 
/* Since the 10Mbps preamble workaround is allowed we need to enable
-  preamble checking, FCS stripping, and clear error bits on
-  every speed change. If errors occur during 10Mbps operation
-  the above code will change this stuff */
+* preamble checking, FCS stripping, and clear error bits on
+* every speed change. If errors occur during 10Mbps operation
+* the above code will change this stuff
+*/
cvm_oct_set_hw_preamble(priv, true);
 
if (priv->phydev == NULL) {
-- 
2.4.1

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


[PATCH] Fix coding style issues.

2015-08-05 Thread Lior Pugatch
This patch fixes checkpatch.pl warnings,
related to comments.

Signed-off-by: Lior Pugatch 
---
 drivers/staging/panel/panel.c | 38 +-
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 3e9ee7e..6b96369 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -785,6 +785,7 @@ static void long_sleep(int ms)
  * send a serial byte to the LCD panel. The caller is responsible for locking
  * if needed.
  */
+
 static void lcd_send_serial(int byte)
 {
int bit;
@@ -910,7 +911,8 @@ static void lcd_gotoxy(void)
lcd_write_cmd(LCD_CMD_SET_DDRAM_ADDR
  | (lcd.addr.y ? lcd.hwidth : 0)
  /* we force the cursor to stay at the end of the
-line if it wants to go farther */
+  * line if it wants to go farther
+  */
  | ((lcd.addr.x < lcd.bwidth) ? lcd.addr.x &
 (lcd.hwidth - 1) : lcd.bwidth - 1));
 }
@@ -1064,11 +1066,9 @@ static void lcd_init_display(void)
lcd_clear_display();
 }
 
-/*
- * These are the file operation function for user access to /dev/lcd
+/* These are the file operation function for user access to /dev/lcd
  * This function can also be called from inside the kernel, by
  * setting file and ppos to NULL.
- *
  */
 
 static inline int handle_lcd_special_code(void)
@@ -1295,7 +1295,8 @@ static inline int handle_lcd_special_code(void)
lcd_backlight(1);
else if (lcd.light_tempo == 0)
/* switch off the light only when the tempo
-  lighting is gone */
+*  lighting is gone
+*/
lcd_backlight(0);
}
}
@@ -1324,7 +1325,8 @@ static void lcd_write_char(char c)
/* go back one char and clear it */
if (lcd.addr.x > 0) {
/* check if we're not at the
-  end of the line */
+*  end of the line
+*/
if (lcd.addr.x < lcd.bwidth)
/* back one char */
lcd_write_cmd(LCD_CMD_SHIFT);
@@ -1341,7 +1343,8 @@ static void lcd_write_char(char c)
break;
case '\n':
/* flush the remainder of the current line and
-  go to the beginning of the next line */
+* go to the beginning of the next line
+*/
for (; lcd.addr.x < lcd.bwidth; lcd.addr.x++)
lcd_write_data(' ');
lcd.addr.x = 0;
@@ -1365,7 +1368,9 @@ static void lcd_write_char(char c)
}
 
/* now we'll see if we're in an escape mode and if the current
-  escape sequence can be understood. */
+*  escape sequence can be understood.
+*/
+
if (lcd.esc_seq.len >= 2) {
int processed = 0;
 
@@ -1388,8 +1393,10 @@ static void lcd_write_char(char c)
}
 
/* LCD special escape codes */
+
/* flush the escape sequence if it's been processed
-  or if it is getting too long. */
+* or if it is getting too long.
+*/
if (processed || (lcd.esc_seq.len >= LCD_ESCAPE_LEN))
lcd.esc_seq.len = -1;
} /* escape codes */
@@ -1404,7 +1411,8 @@ static ssize_t lcd_write(struct file *file,
for (; count-- > 0; (*ppos)++, tmp++) {
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
/* let's be a little nice with other processes
-  that need some CPU */
+* that need some CPU.
+*/
schedule();
 
if (get_user(c, tmp))
@@ -1460,7 +1468,8 @@ static void panel_lcd_print(const char *s)
for (; count-- > 0; tmp++) {
if (!in_interrupt() && (((count + 1) & 0x1f) == 0))
/* let's be a little nice with other processes
-  that need some CPU */
+* that need some CPU.
+*/
schedule();
 
lcd_write_char(*tmp);
@@ -1636,7 +1645,9 @@ static void lcd_init(void)
 
/* before this line, we must NOT send anything to the display.
 * Since lcd_init_display() needs to write data, we have to
-* enable mark the LCD i

Re: [PATCH] staging: panel: Fix coding style issue.

2015-08-05 Thread Willy Tarreau
On Wed, Aug 05, 2015 at 10:43:23PM +0300, Lior Pugatch wrote:
> This patch fixes checkpatch.pl warning,
> all warnings are releted to comments code style.

Acked-by: Willy Tarreau 

Thanks!
Willy

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


BEST OFFER 2015

2015-08-05 Thread Marcos Larmon
Attn: Applicant,

I am a loan lender offering out loans with interest rate of 3% my offer is 
guaranteed and also very fast and easy.

Do you want to be financially equipped?

DO you want a loan to start up your own business?

Have you been looking for a legitimate loan lender?

Do you want to pay off your debt?

Apply with:

1.Full Name:

2.Country:

3.Age:

4.Sex:

5.Phone Number:

6.Amount Needed As Loan:

7.Loan Duration:

This is an opportunity l think you wouldn't want to miss. 

Feel free to contact me both business firm and individuals for a loan that does 
come through. 

Have a nice day.

Sincerly Yours,

Marcos Larmona.
Tel+34631 664 705
email-loan.specal...@aol.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Fix coding style issues.

2015-08-05 Thread Greg KH
On Wed, Aug 05, 2015 at 11:19:53PM +0300, Lior Pugatch wrote:
> This patch fixes checkpatch.pl warnings,
> related to comments.
> 
> Signed-off-by: Lior Pugatch 
> ---
>  drivers/staging/panel/panel.c | 38 +-
>  1 file changed, 25 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
> index 3e9ee7e..6b96369 100644
> --- a/drivers/staging/panel/panel.c
> +++ b/drivers/staging/panel/panel.c
> @@ -785,6 +785,7 @@ static void long_sleep(int ms)
>   * send a serial byte to the LCD panel. The caller is responsible for locking
>   * if needed.
>   */
> +

Why is this line added?

And please fix up your subject to say what part of the kernel you are
changing and be more specific, something like:
staging: panel: fix comment...

thanks,

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


Re: [PATCH] zram: Replace pr_* with dev_*

2015-08-05 Thread Dan Carpenter
On Tue, Aug 04, 2015 at 07:19:01PM +0100, Salah Triki wrote:
> @@ -508,14 +509,15 @@ static struct zram_meta *zram_meta_alloc(int device_id, 
> u64 disksize)
>   num_pages = disksize >> PAGE_SHIFT;
>   meta->table = vzalloc(num_pages * sizeof(*meta->table));
>   if (!meta->table) {
> - pr_err("Error allocating zram address table\n");
> + dev_err("Error allocating zram address table for device %d",
> + device_id);

Does this even compile?

regards,
dan carpenter

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


Re: [PATCH] staging: sm750fb: fix sparse warning for lock

2015-08-05 Thread Dan Carpenter
On Wed, Aug 05, 2015 at 09:26:44PM +0800, Peng Fan wrote:
> Use __acquire() and __release() in the right place to silence the sparse
> lock checking warning.
> 
> drivers/staging/sm750fb/sm750.c:177:13: warning: context imbalance in 
> 'lynxfb_ops_fillrect' - different lock contexts for basic block
> drivers/staging/sm750fb/sm750.c:243:9: warning: context imbalance in 
> 'lynxfb_ops_copyarea' - different lock contexts for basic block
> drivers/staging/sm750fb/sm750.c:247:13: warning: context imbalance in 
> 'lynxfb_ops_imageblit' - different lock contexts for basic block
> 

Sparse is really bad at locking stuff.  Smatch is also really bad for
locking and I have been promising to re-write that check for years, but
I take comfort always in the fact that at least it's not as bad as
Sparse.

You should pretty much ignore Sparse locking warnings.

regards,
dan carpenter

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


Re: [PATCH] zram: Replace pr_* with dev_*

2015-08-05 Thread Salah Triki
Hi Sanjeev,

thanx for comments.

best regards,
salah triki

On Wed, Aug 05, 2015 at 10:10:58AM +0530, sanjeev sharma wrote:
> Hello Salah,
> 
> It would be good,if you provide some information why you are doing so like
> " messages that are associated with a particular device"  should be tagged
> with the right level: dev_err(), dev_warn(), dev_info(), and so forth.
> 
> Regards
> Sanjeev Sharma
> 
> 
> On Tue, Aug 4, 2015 at 11:49 PM, Salah Triki  wrote:
> 
> > This patch replaces pr_info/pr_warn/pr_err with
> > dev_info/dev_warn/dev_err.
> >
> > Signed-off-by: Salah Triki 
> > ---
> >  drivers/block/zram/zram_drv.c | 40
> > +++-
> >  1 file changed, 23 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> > index fb655e8..8eecb72 100644
> > --- a/drivers/block/zram/zram_drv.c
> > +++ b/drivers/block/zram/zram_drv.c
> > @@ -333,7 +333,8 @@ static ssize_t max_comp_streams_store(struct device
> > *dev,
> > down_write(&zram->init_lock);
> > if (init_done(zram)) {
> > if (!zcomp_set_max_streams(zram->comp, num)) {
> > -   pr_info("Cannot change max compression streams\n");
> > +   dev_warn(dev, "Cannot change max compression
> > streams to %d",
> > +   num);
> > ret = -EINVAL;
> > goto out;
> > }
> > @@ -368,7 +369,7 @@ static ssize_t comp_algorithm_store(struct device *dev,
> > down_write(&zram->init_lock);
> > if (init_done(zram)) {
> > up_write(&zram->init_lock);
> > -   pr_info("Can't change algorithm for initialized device\n");
> > +   dev_warn(dev, "Can't change algorithm for initialized
> > device");
> > return -EBUSY;
> > }
> > strlcpy(zram->compressor, buf, sizeof(zram->compressor));
> > @@ -508,14 +509,15 @@ static struct zram_meta *zram_meta_alloc(int
> > device_id, u64 disksize)
> > num_pages = disksize >> PAGE_SHIFT;
> > meta->table = vzalloc(num_pages * sizeof(*meta->table));
> > if (!meta->table) {
> > -   pr_err("Error allocating zram address table\n");
> > +   dev_err("Error allocating zram address table for device
> > %d",
> > +   device_id);
> > goto out_error;
> > }
> >
> > snprintf(pool_name, sizeof(pool_name), "zram%d", device_id);
> > meta->mem_pool = zs_create_pool(pool_name, GFP_NOIO |
> > __GFP_HIGHMEM);
> > if (!meta->mem_pool) {
> > -   pr_err("Error creating memory pool\n");
> > +   dev_err("Error creating memory pool for device %d",
> > device_id);
> > goto out_error;
> > }
> >
> > @@ -587,7 +589,8 @@ static int zram_decompress_page(struct zram *zram,
> > char *mem, u32 index)
> >
> > /* Should NEVER happen. Return bio error if it does. */
> > if (unlikely(ret)) {
> > -   pr_err("Decompression failed! err=%d, page=%u\n", ret,
> > index);
> > +   dev_err(disk_to_dev(zram->disk), "Decompression failed!
> > err=%d, page=%u",
> > +   ret, index);
> > return ret;
> > }
> >
> > @@ -621,7 +624,7 @@ static int zram_bvec_read(struct zram *zram, struct
> > bio_vec *bvec,
> > uncmem = user_mem;
> >
> > if (!uncmem) {
> > -   pr_info("Unable to allocate temp memory\n");
> > +   dev_warn("Unable to allocate temp memory");
> > ret = -ENOMEM;
> > goto out_cleanup;
> > }
> > @@ -706,7 +709,8 @@ static int zram_bvec_write(struct zram *zram, struct
> > bio_vec *bvec, u32 index,
> > }
> >
> > if (unlikely(ret)) {
> > -   pr_err("Compression failed! err=%d\n", ret);
> > +   dev_err(disk_to_dev(zram->disk), "Compression failed!
> > err=%d",
> > +   ret);
> > goto out;
> > }
> > src = zstrm->buffer;
> > @@ -718,7 +722,7 @@ static int zram_bvec_write(struct zram *zram, struct
> > bio_vec *bvec, u32 index,
> >
> > handle = zs_malloc(meta->mem_pool, clen);
> > if (!handle) {
> > -   pr_info("Error allocating memory for compressed page: %u,
> > size=%zu\n",
> > +   dev_warn(dev, "Error allocating memory for compressed
> > page: %u, size=%zu",
> > index, clen);
> > ret = -ENOMEM;
> > goto out;
> > @@ -1037,7 +1041,7 @@ static ssize_t disksize_store(struct device *dev,
> >
> > comp = zcomp_create(zram->compressor, zram->max_comp_streams);
> > if (IS_ERR(comp)) {
> > -   pr_info("Cannot initialise %s compressing backend\n",
> > +   dev_info(dev, "Cannot initialise %s compressing backend",
> >   

[PATCH v4 REPOST 0/8] clean up wlan_bssdef.h

2015-08-05 Thread Joshua Clayton
I posted v4 of this patch set a week ago and there have been no 
comments. I hope this is a good sign that the patches are good.
However, I have noticed that I managed to use the same message id
for the coverletter of v4 as for v3, which might have caused people 
to hold off reviewing, perhaps thinking that earlier comments
had not been addressed.

Better safe than sorry, so I am reposting v4
My apologies for the noise on the mailing list.

The main goal of this series is to get rid of a needless typedef
in the rtl8712 wlan driver.

In the course of fixing that, I found a bug that can (at least in theory)
lead to a overrun during a memcpy, as well as an identical struct with
a different name, which use the typedef.
Finally after cleaning up the typedef, change the name of the primary
variable that used the typedef from "SupportedRates" to "rates", to
conform to kernel coding style.

Changes since V1:
Do not make other logic changes while Changing the name of SupportedRates
New patch 3/6 fixes a buggy comment that referred to the typedef

Changes since V2:
broke former patch 4 into 3 parts, as it was too big for git-send-email

Changes since V3:
In patch 8/8 Change the line wrapping of lines that fit within 80
characters, removing superfluous "== true" expressions that would 
otherwise keep the lines overlong.


Joshua Clayton (8):
  staging: rtl8712: fix buggy size calculation
  staging: rtl8712: simplify size calculation
  staging: rtl8712: fix comment
  staging: rtl8712: removed unused wrapper structs
  staging: rtl8712: remove duplicate struct
  staging: rtl8712: rename function
  staging: rtl8712: remove typedefs
  staging: rtl8712: change SupportedRates to rates

 drivers/staging/rtl8712/ieee80211.c   | 25 +++---
 drivers/staging/rtl8712/rtl871x_cmd.c | 28 +---
 drivers/staging/rtl8712/rtl871x_cmd.h | 18 --
 drivers/staging/rtl8712/rtl871x_event.h   |  2 +-
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 34 +--
 drivers/staging/rtl8712/rtl871x_mlme.c| 47 ++-
 drivers/staging/rtl8712/rtl871x_mlme.h|  2 +-
 drivers/staging/rtl8712/rtl871x_mp_ioctl.c|  6 ++--
 drivers/staging/rtl8712/wlan_bssdef.h | 42 +++-
 9 files changed, 62 insertions(+), 142 deletions(-)

-- 
2.5.0

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


[PATCH v4 REPOST 2/8] staging: rtl8712: simplify size calculation

2015-08-05 Thread Joshua Clayton
replace item-by-item  size calculation of a struct
with the size of the struct.

This gets rid of a use of typedef NDIS_802_11_RATES_EX

Signed-off-by: Joshua Clayton 
---
 drivers/staging/rtl8712/rtl871x_cmd.c | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c 
b/drivers/staging/rtl8712/rtl871x_cmd.c
index e35854d..f07050d 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -471,7 +471,6 @@ u8 r8712_createbss_cmd(struct _adapter *padapter)
 
 u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
 {
-   uint t_len = 0;
struct ndis_wlan_bssid_ex *psecnetwork;
struct cmd_obj  *pcmd;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
@@ -486,14 +485,6 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct 
wlan_network *pnetwork)
pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
if (pcmd == NULL)
return _FAIL;
-   t_len = sizeof(u32) + 6 * sizeof(unsigned char) + 2 +
-   sizeof(struct ndis_802_11_ssid) + sizeof(u32) +
-   sizeof(s32) +
-   sizeof(enum NDIS_802_11_NETWORK_TYPE) +
-   sizeof(struct NDIS_802_11_CONFIGURATION) +
-   sizeof(enum NDIS_802_11_NETWORK_INFRASTRUCTURE) +
-   sizeof(NDIS_802_11_RATES_EX) +
-   sizeof(u32) + MAX_IE_SZ;
 
/* for hidden ap to set fw_state here */
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) !=
@@ -516,7 +507,7 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct 
wlan_network *pnetwork)
kfree(pcmd);
return _FAIL;
}
-   memcpy(psecnetwork, &pnetwork->network, t_len);
+   memcpy(psecnetwork, &pnetwork->network, sizeof(*psecnetwork));
psecuritypriv->authenticator_ie[0] = (unsigned char)
 psecnetwork->IELength;
if ((psecnetwork->IELength-12) < (256 - 1))
-- 
2.5.0

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


[PATCH v4 REPOST 5/8] staging: rtl8712: remove duplicate struct

2015-08-05 Thread Joshua Clayton
struct ndis_wlan_bssid_ex is a doppelganger of struct wlan_bssid_ex,
and is used about a third as often.

Switch all instances to wlan_bssid_ex, and remove ndis_wlan_bssid_ex

This also gets rid of a use of typedef NDIS_802_11_RATES_EX

Signed-off-by: Joshua Clayton 
---
 drivers/staging/rtl8712/rtl871x_cmd.c | 11 ---
 drivers/staging/rtl8712/rtl871x_event.h   |  2 +-
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 10 +-
 drivers/staging/rtl8712/rtl871x_mlme.c| 23 +++
 drivers/staging/rtl8712/rtl871x_mlme.h|  2 +-
 drivers/staging/rtl8712/rtl871x_mp_ioctl.c|  4 ++--
 drivers/staging/rtl8712/wlan_bssdef.h | 23 ++-
 7 files changed, 26 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c 
b/drivers/staging/rtl8712/rtl871x_cmd.c
index f07050d..06d9844 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.c
+++ b/drivers/staging/rtl8712/rtl871x_cmd.c
@@ -456,9 +456,7 @@ u8 r8712_createbss_cmd(struct _adapter *padapter)
INIT_LIST_HEAD(&pcmd->list);
pcmd->cmdcode = _CreateBss_CMD_;
pcmd->parmbuf = (unsigned char *)pdev_network;
-   pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz((
-   struct ndis_wlan_bssid_ex *)
-   pdev_network);
+   pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz(pdev_network);
pcmd->rsp = NULL;
pcmd->rspsz = 0;
/* notes: translate IELength & Length after assign to cmdsz; */
@@ -471,7 +469,7 @@ u8 r8712_createbss_cmd(struct _adapter *padapter)
 
 u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct wlan_network *pnetwork)
 {
-   struct ndis_wlan_bssid_ex *psecnetwork;
+   struct wlan_bssid_ex *psecnetwork;
struct cmd_obj  *pcmd;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
struct mlme_priv*pmlmepriv = &padapter->mlmepriv;
@@ -502,7 +500,7 @@ u8 r8712_joinbss_cmd(struct _adapter  *padapter, struct 
wlan_network *pnetwork)
break;
}
}
-   psecnetwork = (struct ndis_wlan_bssid_ex *)&psecuritypriv->sec_bss;
+   psecnetwork = &psecuritypriv->sec_bss;
if (psecnetwork == NULL) {
kfree(pcmd);
return _FAIL;
@@ -894,8 +892,7 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter,
struct sta_info *psta = NULL;
struct wlan_network *pwlan = NULL;
struct  mlme_priv *pmlmepriv = &padapter->mlmepriv;
-   struct ndis_wlan_bssid_ex *pnetwork = (struct ndis_wlan_bssid_ex *)
- pcmd->parmbuf;
+   struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf;
struct wlan_network *tgt_network = &(pmlmepriv->cur_network);
 
if (pcmd->res != H2C_SUCCESS)
diff --git a/drivers/staging/rtl8712/rtl871x_event.h 
b/drivers/staging/rtl8712/rtl871x_event.h
index e03ee90..697c8d7 100644
--- a/drivers/staging/rtl8712/rtl871x_event.h
+++ b/drivers/staging/rtl8712/rtl871x_event.h
@@ -36,7 +36,7 @@
  * Used to report a bss has been scanned
 */
 struct survey_event{
-   struct ndis_wlan_bssid_ex bss;
+   struct wlan_bssid_ex bss;
 };
 
 /*
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 3388f97..4f5f69c 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -634,7 +634,7 @@ static int r8711_wx_get_name(struct net_device *dev,
char *p;
u8 ht_cap = false;
struct  mlme_priv   *pmlmepriv = &(padapter->mlmepriv);
-   struct ndis_wlan_bssid_ex  *pcur_bss = &pmlmepriv->cur_network.network;
+   struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
NDIS_802_11_RATES_EX *prates = NULL;
 
if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) ==
@@ -723,7 +723,7 @@ static int r8711_wx_get_freq(struct net_device *dev,
 {
struct _adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-   struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+   struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
 
if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
wrqu->freq.m = ieee80211_wlan_frequencies[
@@ -,7 +,7 @@ static int r8711_wx_get_wap(struct net_device *dev,
 {
struct _adapter *padapter = netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-   struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+   struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
 
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE |
@@ -1327,7 +1327,7 @@ static int r8711_wx_get_essid(struct net_device *dev,
 {
struct _adapter *pa

[PATCH v4 REPOST 3/8] staging: rtl8712: fix comment

2015-08-05 Thread Joshua Clayton
The old comment refers to a typedef name which is being removed,
and to a style of calculation which is no longer being used.
It falsely states that IELength is variable length, instead of IEs.

Change comment to simply state that the IEs field is a buffer of
variable size and that IELength refers to the current size.

Signed-off-by: Joshua Clayton 
---
 drivers/staging/rtl8712/wlan_bssdef.h | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8712/wlan_bssdef.h 
b/drivers/staging/rtl8712/wlan_bssdef.h
index 2ea8a3d..8c5d6e7 100644
--- a/drivers/staging/rtl8712/wlan_bssdef.h
+++ b/drivers/staging/rtl8712/wlan_bssdef.h
@@ -83,17 +83,6 @@ struct NDIS_802_11_FIXED_IEs {
u16 Capabilities;
 };
 
-/*
- * Length is the 4 bytes multiples of the sume of
- * 6 * sizeof (unsigned char) + 2 + sizeof (ndis_802_11_ssid) + sizeof (u32)
- * + sizeof (s32) + sizeof (NDIS_802_11_NETWORK_TYPE)
- * + sizeof (struct NDIS_802_11_CONFIGURATION)
- * + sizeof (NDIS_802_11_RATES_EX) + IELength
-
- * Except the IELength, all other fields are fixed length. Therefore, we can
- * define a macro to present the partial sum.
- */
-
 struct ndis_wlan_bssid_ex {
u32 Length;
unsigned char  MacAddress[6];
@@ -105,6 +94,7 @@ struct ndis_wlan_bssid_ex {
struct NDIS_802_11_CONFIGURATION  Configuration;
enum NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
NDIS_802_11_RATES_EX  SupportedRates;
+   /* number of content bytes in EIs, which varies */
u32 IELength;
/*(timestamp, beacon interval, and capability information) */
u8 IEs[MAX_IE_SZ];
-- 
2.5.0

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


[PATCH v4 REPOST 1/8] staging: rtl8712: fix buggy size calculation

2015-08-05 Thread Joshua Clayton
r8712_get_ndis_wlan_bssid_ex_sz has a "6 * sizeof(unsigned long)"
where the underlying struct has a 6 * unsigned char.
Simplify the calculation by just subtracting the variable part from
the size of the struct.

This also gets rid of a use of typedef NDIS_802_11_RATES_EX

Signed-off-by: Joshua Clayton 
---
 drivers/staging/rtl8712/rtl871x_mlme.c | 12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c 
b/drivers/staging/rtl8712/rtl871x_mlme.c
index c044b0e..6b3451f 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -210,17 +210,7 @@ void r8712_generate_random_ibss(u8 *pibss)
 
 uint r8712_get_ndis_wlan_bssid_ex_sz(struct ndis_wlan_bssid_ex *bss)
 {
-   uint t_len;
-
-   t_len = sizeof(u32) + 6 * sizeof(unsigned long) + 2 +
-   sizeof(struct ndis_802_11_ssid) + sizeof(u32) +
-   sizeof(s32) +
-   sizeof(enum NDIS_802_11_NETWORK_TYPE) +
-   sizeof(struct NDIS_802_11_CONFIGURATION) +
-   sizeof(enum NDIS_802_11_NETWORK_INFRASTRUCTURE) +
-   sizeof(NDIS_802_11_RATES_EX) +
-   sizeof(u32) + bss->IELength;
-   return t_len;
+   return sizeof(*bss) + bss->IELength - MAX_IE_SZ;
 }
 
 u8 *r8712_get_capability_from_ie(u8 *ie)
-- 
2.5.0

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


[PATCH v4 REPOST 7/8] staging: rtl8712: remove typedefs

2015-08-05 Thread Joshua Clayton
Coding style fix.
Get rid of typedefs NDIS_802_11_RATES and NDIS_802_11_RATES_EX
Undo any casting that was done as a result of the typedef.

Signed-off-by: Joshua Clayton 
---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 12 ++--
 drivers/staging/rtl8712/wlan_bssdef.h |  7 +--
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 4f5f69c..83d4bca 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -203,13 +203,13 @@ static inline char *translate_scan(struct _adapter 
*padapter,
}
/* Add the protocol name */
iwe.cmd = SIOCGIWNAME;
-   if ((r8712_is_cckratesonly_included((u8 *)&pnetwork->network.
+   if ((r8712_is_cckratesonly_included(pnetwork->network.
 SupportedRates)) == true) {
if (ht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn");
else
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b");
-   } else if ((r8712_is_cckrates_included((u8 *)&pnetwork->network.
+   } else if ((r8712_is_cckrates_included(pnetwork->network.
SupportedRates)) == true) {
if (ht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn");
@@ -635,7 +635,7 @@ static int r8711_wx_get_name(struct net_device *dev,
u8 ht_cap = false;
struct  mlme_priv   *pmlmepriv = &(padapter->mlmepriv);
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
-   NDIS_802_11_RATES_EX *prates = NULL;
+   u8 *prates;
 
if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) ==
true) {
@@ -644,15 +644,15 @@ static int r8711_wx_get_name(struct net_device *dev,
 &ht_ielen, pcur_bss->IELength - 12);
if (p && ht_ielen > 0)
ht_cap = true;
-   prates = &pcur_bss->SupportedRates;
-   if (r8712_is_cckratesonly_included((u8 *)prates) == true) {
+   prates = pcur_bss->SupportedRates;
+   if (r8712_is_cckratesonly_included(prates) == true) {
if (ht_cap == true)
snprintf(wrqu->name, IFNAMSIZ,
 "IEEE 802.11bn");
else
snprintf(wrqu->name, IFNAMSIZ,
 "IEEE 802.11b");
-   } else if ((r8712_is_cckrates_included((u8 *)prates)) == true) {
+   } else if ((r8712_is_cckrates_included(prates)) == true) {
if (ht_cap == true)
snprintf(wrqu->name, IFNAMSIZ,
 "IEEE 802.11bgn");
diff --git a/drivers/staging/rtl8712/wlan_bssdef.h 
b/drivers/staging/rtl8712/wlan_bssdef.h
index cd3e62a..ff86fbd 100644
--- a/drivers/staging/rtl8712/wlan_bssdef.h
+++ b/drivers/staging/rtl8712/wlan_bssdef.h
@@ -32,11 +32,6 @@
 #define NDIS_802_11_LENGTH_RATES8
 #define NDIS_802_11_LENGTH_RATES_EX 16
 
-/* Set of 8 data rates*/
-typedef unsigned char   NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES];
-/* Set of 16 data rates */
-typedef unsigned char   NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];
-
 struct ndis_802_11_ssid {
u32 SsidLength;
u8  Ssid[32];
@@ -93,7 +88,7 @@ struct wlan_bssid_ex {
enum NDIS_802_11_NETWORK_TYPE  NetworkTypeInUse;
struct NDIS_802_11_CONFIGURATION  Configuration;
enum NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
-   NDIS_802_11_RATES_EX  SupportedRates;
+   u8 SupportedRates[NDIS_802_11_LENGTH_RATES_EX];
/* number of content bytes in EIs, which varies */
u32 IELength;
/*(timestamp, beacon interval, and capability information) */
-- 
2.5.0

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


[PATCH v4 REPOST 4/8] staging: rtl8712: removed unused wrapper structs

2015-08-05 Thread Joshua Clayton
Remove wrapper structs that just wrap struct ndis_wlan_bssid_ex,
and are unused.

Signed-off-by: Joshua Clayton 
---
 drivers/staging/rtl8712/rtl871x_cmd.h | 18 --
 1 file changed, 18 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h 
b/drivers/staging/rtl8712/rtl871x_cmd.h
index cb8225b..818cd88 100644
--- a/drivers/staging/rtl8712/rtl871x_cmd.h
+++ b/drivers/staging/rtl8712/rtl871x_cmd.h
@@ -123,15 +123,6 @@ struct usb_suspend_parm {
 };
 
 /*
- * Caller Mode: Infra, Ad-Hoc
- * Notes: To join the specified bss
- * Command Event Mode
- */
-struct joinbss_parm {
-   struct ndis_wlan_bssid_ex network;
-};
-
-/*
  * Caller Mode: Infra, Ad-HoC(C)
  * Notes: To disconnect the current associated BSS
  * Command Mode
@@ -141,15 +132,6 @@ struct disconnect_parm {
 };
 
 /*
- * Caller Mode: AP, Ad-HoC(M)
- * Notes: To create a BSS
- * Command Mode
- */
-struct createbss_parm {
-   struct ndis_wlan_bssid_ex network;
-};
-
-/*
  * Caller Mode: AP, Ad-HoC, Infra
  * Notes: To set the NIC mode of RTL8711
  * Command Mode
-- 
2.5.0

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


  1   2   >