All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: comedi: fix coding style issues in unioxx5.c
@ 2013-11-01 12:31 Conrad Gomes
  2013-11-12  0:15 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Conrad Gomes @ 2013-11-01 12:31 UTC (permalink / raw)
  To: abbotti, hsweeten, gregkh; +Cc: joe, devel, linux-kernel, 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 <conrad.s.j.gomes@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Staging: comedi: fix coding style issues in unioxx5.c
  2013-11-01 12:31 [PATCH] Staging: comedi: fix coding style issues in unioxx5.c Conrad Gomes
@ 2013-11-12  0:15 ` Greg KH
       [not found]   ` <CALxff2GmatgMQF_2yQ9g=tZzh=J-5fKt89sFAU4oYq_FBJHNag@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2013-11-12  0:15 UTC (permalink / raw)
  To: Conrad Gomes; +Cc: abbotti, hsweeten, joe, devel, linux-kernel

On Fri, Nov 01, 2013 at 06:01:56PM +0530, Conrad Gomes wrote:
> 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

Drivers should never call printk() as they all have access to a struct
device somewhere.  So please call dev_info() or dev_err() instead.

> 2) Reinitialized n_subd before for loop to fix over 80 character
>    warning
> 3) Reworded comment to fix 80 character warning
>

Patches should do one thing, not 3 things.  Care to break this up into
"one logical change per patch"?  Yes, it's a small thing, but if you had
done this already, I could have taken the other 2 patches and you would
have just had to redo one patch in this series...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Staging: comedi: fix coding style issues in unioxx5.c
       [not found]   ` <CALxff2GmatgMQF_2yQ9g=tZzh=J-5fKt89sFAU4oYq_FBJHNag@mail.gmail.com>
@ 2013-11-18 10:40     ` Ian Abbott
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Abbott @ 2013-11-18 10:40 UTC (permalink / raw)
  To: Conrad Gomes, Greg KH
  Cc: Ian Abbott, hsweeten@visionengravers.com, joe@perches.com,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org

On 2013-11-17 03:42, Conrad Gomes wrote:
> Hi,
>
> No problem, I'll break this up and resend it.
>
> In order to use dev_info type functions I was planning on assigning the
> comedi device's struct device to the struct subdevice's class_dev as
> follows in comedi_alloc_subdevices as it appears that is is not used(I
> could be wrong):
>
> diff --git a/drivers/staging/comedi/drivers.c
> b/drivers/staging/comedi/drivers.c
> index 8f02bf6..e4c44ae 100644
> --- a/drivers/staging/comedi/drivers.c
> +++ b/drivers/staging/comedi/drivers.c
> @@ -90,6 +90,7 @@ int comedi_alloc_subdevices(struct comedi_device *dev,
> int num_subdevices)
>                  s->async_dma_dir = DMA_NONE;
>                  spin_lock_init(&s->spin_lock);
>                  s->minor = -1;
> +               s->class_dev = dev->class_dev;
>          }
>          return 0;
>   }

The class_dev member is assigned by comedi_alloc_subdevice_minor(s) 
(which will be called if the subdevice supports asynchronous comedi 
commands) and is kept around for the call to comedi_free_subdevice_minor(s).

The struct comedi_subdevice has a pointer back to the struct 
comedi_device.  The class_dev member in the struct comedi_device can be 
used as the device pointer parameter of dev_info() etc.

> And adding a reference to the subdevice in the private  data structure
> unioxx5_subd_priv in order to substitute pr_info with dev_info. If this
> is fine I'll remove all references of pr_info in the file:
>
> diff --git a/drivers/staging/comedi/drivers/unioxx5.c
> b/drivers/staging/comedi/drivers/unioxx5.c
> index 2b1ece8..bb8f5a4 100644
> --- a/drivers/staging/comedi/drivers/unioxx5.c
> +++ b/drivers/staging/comedi/drivers/unioxx5.c
> @@ -72,6 +72,7 @@ Devices: [Fastwel] UNIOxx-5 (unioxx5),
>
>   /* 'private' structure for each subdevice */
>   struct unioxx5_subd_priv {
> +       struct comedi_subdevice *subdevice;
>          int usp_iobase;
>          /* 12 modules. each can be 70L or 73L */
>          unsigned char usp_module_type[12];
> @@ -94,9 +95,10 @@ static int __unioxx5_define_chan_offset(int chan_num)
>   static void __unioxx5_digital_config(struct unioxx5_subd_priv *usp,
> int mode)
>   {
>          int i, mask;
> +       struct device *dev = usp->subdevice->class_dev;
>
>          mask = (mode == ALL_2_OUTPUT) ? 0xFF : 0x00;
> -       printk("COMEDI: mode = %d\n", mask);
> +       dev_info(dev, "COMEDI: mode = %d\n", mask);
>
>          outb(1, usp->usp_iobase + 0);

It would be better to change those functions to pass the pointer to the 
struct comedi_subdevice instead of the pointer to the struct 
unioxx5_subd_priv.

A variable or parameter named 'dev' in the comedi drivers is usually of 
type struct comedi_device for consistency.

The message passed to dev_info() wouldn't need the "COMEDI:" prefix - 
it's redundant.

Also, this particular message should be a dev_dbg() at best, and 
probably better not to have it at all!

For the sake of example, the above function could start as follows:

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;
	dev_dbg(csdev, "mode = %d\n", mask);

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-18 10:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-01 12:31 [PATCH] Staging: comedi: fix coding style issues in unioxx5.c Conrad Gomes
2013-11-12  0:15 ` Greg KH
     [not found]   ` <CALxff2GmatgMQF_2yQ9g=tZzh=J-5fKt89sFAU4oYq_FBJHNag@mail.gmail.com>
2013-11-18 10:40     ` Ian Abbott

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.