[PATCH] Staging: comedi: fix coding style issues in unioxx5.c

2013-11-01 Thread Conrad Gomes
This is a patch which fixes  coding style issues in unioxx5.c found
by checkpatch.pl

1) Replaced printk with pr_info and pr_err
2) Reinitialized n_subd before for loop to fix over 80 character
   warning
3) Reworded comment to fix 80 character warning

Signed-off-by: Conrad Gomes 
---
 drivers/staging/comedi/drivers/unioxx5.c |   10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/unioxx5.c 
b/drivers/staging/comedi/drivers/unioxx5.c
index 93eec2f..de68e3a 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -96,7 +96,7 @@ static void __unioxx5_digital_config(struct unioxx5_subd_priv 
*usp, int mode)
int i, mask;
 
mask = (mode == ALL_2_OUTPUT) ? 0xFF : 0x00;
-   printk("COMEDI: mode = %d\n", mask);
+   pr_info("COMEDI: mode = %d\n", mask);
 
outb(1, usp->usp_iobase + 0);
 
@@ -185,7 +185,7 @@ static int __unioxx5_analog_read(struct unioxx5_subd_priv 
*usp,
 
/* if four bytes readding error occurs - return 0(false) */
if ((control & Rx4CA_ERR_MASK)) {
-   printk("COMEDI: 4 bytes error\n");
+   pr_err("COMEDI: 4 bytes error\n");
return 0;
}
 
@@ -436,8 +436,10 @@ static int unioxx5_attach(struct comedi_device *dev,
dev->iobase = iobase;
iobase += UNIOXX5_SUBDEV_BASE;
 
-   /* defining number of subdevices and getting they types (it must be 
'g01')  */
-   for (i = n_subd = 0, ba = iobase; i < 4; i++, ba += 
UNIOXX5_SUBDEV_ODDS) {
+   n_subd = 0;
+
+   /* getting number of subdevices with types 'g01'*/
+   for (i = 0, ba = iobase; i < 4; i++, ba += UNIOXX5_SUBDEV_ODDS) {
id = inb(ba + 0xE);
num = inb(ba + 0xF);
 
-- 
1.7.9.5

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


[PATCH V2 5/7] Staging: comedi: change pr_err to dev_err in __unioxx5_digital_write

2013-11-21 Thread Conrad Gomes
This is a patch which subsitutes pr_err with the preferred dev_err
for device drivers in __unioxx5_digital_write.

The function definition of __unioxx5_digital_write has been changed
to take the pointer to the struct comedi_subdevice as a parameter
instead of the pointer to struct unioxx5_subd_priv.

The pointers to the stuct device and the struct unioxx5_subd_priv are
obtained through the pointer to the struct comedi_subdevice in this
function.

The function call to __unioxx5_digital_write in unioxx5_subdev_write
has been changed to pass the pointer to the struct comedi_subdevice

Signed-off-by: Conrad Gomes 
---
 drivers/staging/comedi/drivers/unioxx5.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/unioxx5.c 
b/drivers/staging/comedi/drivers/unioxx5.c
index 7edbd5e..343ba96 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -205,15 +205,17 @@ static int __unioxx5_analog_read(struct comedi_subdevice 
*s,
return 1;
 }
 
-static int __unioxx5_digital_write(struct unioxx5_subd_priv *usp,
+static int __unioxx5_digital_write(struct comedi_subdevice *s,
   unsigned int *data, int channel, int minor)
 {
+   struct unioxx5_subd_priv *usp = s->private;
+   struct device *csdev = s->device->class_dev;
int channel_offset, val;
int mask = 1 << (channel & 0x07);
 
channel_offset = __unioxx5_define_chan_offset(channel);
if (channel_offset < 0) {
-   pr_err("comedi%d: undefined channel %d. channel range is 0 .. 
23\n",
+   dev_err(csdev, "comedi%d: undefined channel %d. channel range 
is 0 .. 23\n",
   minor, channel);
return 0;
}
@@ -303,7 +305,7 @@ static int unioxx5_subdev_write(struct comedi_device *dev,
type = usp->usp_module_type[channel / 2];
 
if (type == MODULE_DIGITAL) {
-   if (!__unioxx5_digital_write(usp, data, channel, dev->minor))
+   if (!__unioxx5_digital_write(subdev, data, channel, dev->minor))
return -1;
} else {
if (!__unioxx5_analog_write(usp, data, channel, dev->minor))
-- 
1.7.9.5

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


[PATCH V2 1/7] Staging: comedi: fix line over 80 character warning in unioxx5.c

2013-11-21 Thread Conrad Gomes
This is a patch to unioxx5.c that fixes the line over 80 character
warning found by checkpatch.pl by initializing n_subd before the
for loop

Signed-off-by: Conrad Gomes 
---
 drivers/staging/comedi/drivers/unioxx5.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/unioxx5.c 
b/drivers/staging/comedi/drivers/unioxx5.c
index 93eec2f..725595f 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -435,9 +435,10 @@ static int unioxx5_attach(struct comedi_device *dev,
 
dev->iobase = iobase;
iobase += UNIOXX5_SUBDEV_BASE;
+   n_subd = 0;
 
/* defining number of subdevices and getting they types (it must be 
'g01')  */
-   for (i = n_subd = 0, ba = iobase; i < 4; i++, ba += 
UNIOXX5_SUBDEV_ODDS) {
+   for (i = 0, ba = iobase; i < 4; i++, ba += UNIOXX5_SUBDEV_ODDS) {
id = inb(ba + 0xE);
num = inb(ba + 0xF);
 
-- 
1.7.9.5

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


[PATCH V2 4/7] Staging: comedi: change pr_err to dev_err in __unioxx5_analog_read

2013-11-21 Thread Conrad Gomes
This is a patch which subsitutes pr_err with dev_err in
__unioxx5_analog_read as it is the preferred way to log in device
drivers

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

diff --git a/drivers/staging/comedi/drivers/unioxx5.c 
b/drivers/staging/comedi/drivers/unioxx5.c
index 31736ed..7edbd5e 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -175,7 +175,7 @@ static int __unioxx5_analog_read(struct comedi_subdevice *s,
 
/* defining if given module can work on input */
if (usp->usp_module_type[module_no] & MODULE_OUTPUT_MASK) {
-   pr_err("comedi%d: module in position %d with id 0x%02x is for 
output only",
+   dev_err(csdev, "comedi%d: module in position %d with id 0x%02x 
is for output only",
   minor, module_no, usp->usp_module_type[module_no]);
return 0;
}
-- 
1.7.9.5

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


[PATCH V2 3/7] Staging: comedi: change printk to dev_err/dev_dbg in unioxx5.c

2013-11-21 Thread Conrad Gomes
This is a patch which fixes coding style issues due to printk usage in
unioxx5.c found by checkpatch.pl in the following functions:
1) __unioxx5_digital_read
2) __unioxx5_analog_read
3) __unioxx5_digital_config

To subsitute printk with dev_err/dev_dbg, access to the struct device is
required. The function definitions of the above functions have been changed
to take the pointer to the struct comedi_subdevice as a parameter instead
of the pointer to struct unioxx5_subd_priv.

The pointers to the stuct device and the struct unioxx5_subd_priv are
obtained through the pointer to the struct comedi_subdevice in these functions.

The function calls of __unioxx5_digital_read and __unioxx5_analog_read in
unioxx5_subdev_read have been changed to pass the pointer to the struct
comedi_subdevice.

Signed-off-by: Conrad Gomes 
---
 drivers/staging/comedi/drivers/unioxx5.c |   26 +-
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/comedi/drivers/unioxx5.c 
b/drivers/staging/comedi/drivers/unioxx5.c
index 2b1ece8..31736ed 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -91,12 +91,14 @@ static int __unioxx5_define_chan_offset(int chan_num)
 }
 
 #if 0  /* not used? */
-static void __unioxx5_digital_config(struct unioxx5_subd_priv *usp, int mode)
+static void __unioxx5_digital_config(struct comedi_subdevice *s, int mode)
 {
+   struct unioxx5_subd_priv *usp = s->private;
+   struct device *csdev = s->device->class_dev;
int i, mask;
 
mask = (mode == ALL_2_OUTPUT) ? 0xFF : 0x00;
-   printk("COMEDI: mode = %d\n", mask);
+   dev_dbg(csdev, "mode = %d\n", mask);
 
outb(1, usp->usp_iobase + 0);
 
@@ -135,15 +137,18 @@ static void __unioxx5_analog_config(struct 
unioxx5_subd_priv *usp, int channel)
usp->usp_prev_cn_val[channel_offset - 1] = conf;
 }
 
-static int __unioxx5_digital_read(struct unioxx5_subd_priv *usp,
+static int __unioxx5_digital_read(struct comedi_subdevice *s,
  unsigned int *data, int channel, int minor)
 {
+   struct unioxx5_subd_priv *usp = s->private;
+   struct device *csdev = s->device->class_dev;
int channel_offset, mask = 1 << (channel & 0x07);
 
channel_offset = __unioxx5_define_chan_offset(channel);
if (channel_offset < 0) {
-   pr_err("comedi%d: undefined channel %d. channel range is 0 .. 
23\n",
-  minor, channel);
+   dev_err(csdev,
+   "comedi%d: undefined channel %d. channel range is 0 .. 
23\n",
+   minor, channel);
return 0;
}
 
@@ -157,9 +162,11 @@ static int __unioxx5_digital_read(struct unioxx5_subd_priv 
*usp,
return 1;
 }
 
-static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp,
+static int __unioxx5_analog_read(struct comedi_subdevice *s,
 unsigned int *data, int channel, int minor)
 {
+   struct unioxx5_subd_priv *usp = s->private;
+   struct device *csdev = s->device->class_dev;
int module_no, read_ch;
char control;
 
@@ -185,7 +192,8 @@ static int __unioxx5_analog_read(struct unioxx5_subd_priv 
*usp,
 
/* if four bytes readding error occurs - return 0(false) */
if ((control & Rx4CA_ERR_MASK)) {
-   printk("COMEDI: 4 bytes error\n");
+   dev_err(csdev,
+   "comedi%d: 4 bytes error\n", minor);
return 0;
}
 
@@ -273,10 +281,10 @@ static int unioxx5_subdev_read(struct comedi_device *dev,
type = usp->usp_module_type[channel / 2];
 
if (type == MODULE_DIGITAL) {
-   if (!__unioxx5_digital_read(usp, data, channel, dev->minor))
+   if (!__unioxx5_digital_read(subdev, data, channel, dev->minor))
return -1;
} else {
-   if (!__unioxx5_analog_read(usp, data, channel, dev->minor))
+   if (!__unioxx5_analog_read(subdev, data, channel, dev->minor))
return -1;
}
 
-- 
1.7.9.5

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


[PATCH V2 6/7] Staging: comedi: change pr_err to dev_err in __unioxx5_analog_write

2013-11-21 Thread Conrad Gomes
This is a patch which subsitutes pr_err with the preferred dev_err
for device drivers in __unioxx5_analog_write.

The function definition of __unioxx5_analog_write has been changed
to take the pointer to the struct comedi_subdevice as a parameter
instead of the pointer to struct unioxx5_subd_priv.

The pointers to the stuct device and the struct unioxx5_subd_priv are
obtained through the pointer to the struct comedi_subdevice in this
function.

The function call to __unioxx5_analog_write in unioxx5_subdev_write
has been changed to pass the pointer to the struct comedi_subdevice

Signed-off-by: Conrad Gomes 
---
 drivers/staging/comedi/drivers/unioxx5.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/unioxx5.c 
b/drivers/staging/comedi/drivers/unioxx5.c
index 343ba96..6bbc934 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -235,9 +235,11 @@ static int __unioxx5_digital_write(struct comedi_subdevice 
*s,
return 1;
 }
 
-static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp,
+static int __unioxx5_analog_write(struct comedi_subdevice *s,
  unsigned int *data, int channel, int minor)
 {
+   struct unioxx5_subd_priv *usp = s->private;
+   struct device *csdev = s->device->class_dev;
int module, i;
 
module = channel / 2;   /* definig module number(0 .. 11) */
@@ -245,7 +247,7 @@ static int __unioxx5_analog_write(struct unioxx5_subd_priv 
*usp,
 
/* defining if given module can work on output */
if (!(usp->usp_module_type[module] & MODULE_OUTPUT_MASK)) {
-   pr_err("comedi%d: module in position %d with id 0x%0x is for 
input only!\n",
+   dev_err(csdev, "comedi%d: module in position %d with id 0x%0x 
is for input only!\n",
   minor, module, usp->usp_module_type[module]);
return 0;
}
@@ -308,7 +310,7 @@ static int unioxx5_subdev_write(struct comedi_device *dev,
if (!__unioxx5_digital_write(subdev, data, channel, dev->minor))
return -1;
} else {
-   if (!__unioxx5_analog_write(usp, data, channel, dev->minor))
+   if (!__unioxx5_analog_write(subdev, data, channel, dev->minor))
return -1;
}
 
-- 
1.7.9.5

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


[PATCH V2 0/7] Staging: comedi: fix coding style issues in unioxx5.c

2013-11-21 Thread Conrad Gomes
This series contains various fixes to coding style issues in unioxx5.c
found by checkpatch.pl and due to the usage of pr_err instead of the 
preferred dev_err type functions for device drivers.

Conrad Gomes (7):
  Staging: comedi: fix line over 80 character warning in unioxx5.c
  Staging: comedi: fix line over 80 character warning in unioxx5.c
  Staging: comedi: change printk to dev_err/dev_dbg in unioxx5.c
  Staging: comedi: change pr_err to dev_err in __unioxx5_analog_read
  Staging: comedi: change pr_err to dev_err in __unioxx5_digital_write
  Staging: comedi: change pr_err to dev_err in __unioxx5_analog_write
  Staging: comedi: remove MACRO pr_fmt in unioxx5.c

 drivers/staging/comedi/drivers/unioxx5.c |   50 ++
 1 file changed, 31 insertions(+), 19 deletions(-)

-- 
1.7.9.5

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


[PATCH V2 2/7] Staging: comedi: fix line over 80 character warning in unioxx5.c

2013-11-21 Thread Conrad Gomes
This is a patch to fix a line over 80 character warning found by
checkpatch.pl in a comment. The comment was reworded to fix
the warning

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

diff --git a/drivers/staging/comedi/drivers/unioxx5.c 
b/drivers/staging/comedi/drivers/unioxx5.c
index 725595f..2b1ece8 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -437,7 +437,7 @@ static int unioxx5_attach(struct comedi_device *dev,
iobase += UNIOXX5_SUBDEV_BASE;
n_subd = 0;
 
-   /* defining number of subdevices and getting they types (it must be 
'g01')  */
+   /* getting number of subdevices with types 'g01' */
for (i = 0, ba = iobase; i < 4; i++, ba += UNIOXX5_SUBDEV_ODDS) {
id = inb(ba + 0xE);
num = inb(ba + 0xF);
-- 
1.7.9.5

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


[PATCH V2 7/7] Staging: comedi: remove MACRO pr_fmt in unioxx5.c

2013-11-21 Thread Conrad Gomes
This patch removes MACRO definition pr_fmt which was initially
required by pr_info and pr_err logging functions.

Signed-off-by: Conrad Gomes 
---
 drivers/staging/comedi/drivers/unioxx5.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/unioxx5.c 
b/drivers/staging/comedi/drivers/unioxx5.c
index 6bbc934..d6b75d6 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -38,7 +38,6 @@ Devices: [Fastwel] UNIOxx-5 (unioxx5),
 
 */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include 
 #include 
-- 
1.7.9.5

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