All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 04/19] staging: comedi: adl_pci6208: document the register map of the device
@ 2012-06-27 21:56 H Hartley Sweeten
  2012-06-28 19:06 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: H Hartley Sweeten @ 2012-06-27 21:56 UTC (permalink / raw)
  To: Linux Kernel; +Cc: devel, abbotti, fmhess, gregkh

Add defines for the register map of the device. These will be
used to clarify the code.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/staging/comedi/drivers/adl_pci6208.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
index f949d20..b6a8439 100644
--- a/drivers/staging/comedi/drivers/adl_pci6208.c
+++ b/drivers/staging/comedi/drivers/adl_pci6208.c
@@ -53,6 +53,18 @@ References:
  */
 #include "../comedidev.h"
 
+/*
+ * PCI-6208/6216-GL register map
+ */
+#define PCI6208_AO_CONTROL(x)		(0x00 + (2 * (x)))
+#define PCI6208_AO_STATUS		0x00
+#define PCI6208_AO_STATUS_DATA_SEND	(1 << 0)
+#define PCI6208_DIO			0x40
+#define PCI6208_DIO_DO_MASK		(0x0f)
+#define PCI6208_DIO_DO_SHIFT		(0)
+#define PCI6208_DIO_DI_MASK		(0xf0)
+#define PCI6208_DIO_DI_SHIFT		(4)
+
 /* Board descriptions */
 struct pci6208_board {
 	const char *name;
-- 
1.7.11


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

* Re: [PATCH 04/19] staging: comedi: adl_pci6208: document the register map of the device
  2012-06-27 21:56 [PATCH 04/19] staging: comedi: adl_pci6208: document the register map of the device H Hartley Sweeten
@ 2012-06-28 19:06 ` Dan Carpenter
  2012-06-28 19:56   ` Joe Perches
  2012-06-28 19:57   ` H Hartley Sweeten
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-06-28 19:06 UTC (permalink / raw)
  To: H Hartley Sweeten; +Cc: Linux Kernel, devel, fmhess, abbotti, gregkh

On Wed, Jun 27, 2012 at 02:56:43PM -0700, H Hartley Sweeten wrote:
> Add defines for the register map of the device. These will be
> used to clarify the code.
> 
> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
> Cc: Ian Abbott <abbotti@mev.co.uk>
> Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/staging/comedi/drivers/adl_pci6208.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
> index f949d20..b6a8439 100644
> --- a/drivers/staging/comedi/drivers/adl_pci6208.c
> +++ b/drivers/staging/comedi/drivers/adl_pci6208.c
> @@ -53,6 +53,18 @@ References:
>   */
>  #include "../comedidev.h"
>  
> +/*
> + * PCI-6208/6216-GL register map
> + */
> +#define PCI6208_AO_CONTROL(x)		(0x00 + (2 * (x)))
> +#define PCI6208_AO_STATUS		0x00
> +#define PCI6208_AO_STATUS_DATA_SEND	(1 << 0)
> +#define PCI6208_DIO			0x40
> +#define PCI6208_DIO_DO_MASK		(0x0f)
> +#define PCI6208_DIO_DO_SHIFT		(0)
> +#define PCI6208_DIO_DI_MASK		(0xf0)
> +#define PCI6208_DIO_DI_SHIFT		(4)

This series is nice and I'm not nacking anything, but really is it
that useful to say:
	status = inw(dev->iobase + PCI6208_AO_STATUS);
instead of just?:
	status = inw(dev->iobase);

I'm not sure what the 0x00 in PCI6208_AO_CONTROL represents.  Some
of these are not used like PCI6208_DIO_DI_SHIFT.

Does checkpatch.pl complain if you leave off these parenthesis?  If
so I will complain again to the checkpatch.pl people.  Extra
parenthesis are silly and there not used consistently.  Only
PCI6208_AO_CONTROL() and PCI6208_AO_STATUS_DATA_SEND() need
paranthesis.

Again, I'm fine with this patch and the whole series.  These are
just comments.

regards,
dan carpenter


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

* Re: [PATCH 04/19] staging: comedi: adl_pci6208: document the register map of the device
  2012-06-28 19:06 ` Dan Carpenter
@ 2012-06-28 19:56   ` Joe Perches
  2012-06-28 19:57   ` H Hartley Sweeten
  1 sibling, 0 replies; 4+ messages in thread
From: Joe Perches @ 2012-06-28 19:56 UTC (permalink / raw)
  To: Dan Carpenter, Andy Whitcroft
  Cc: H Hartley Sweeten, Linux Kernel, devel, fmhess, abbotti, gregkh,
	Andrew Morton

On Thu, 2012-06-28 at 22:06 +0300, Dan Carpenter wrote:
> On Wed, Jun 27, 2012 at 02:56:43PM -0700, H Hartley Sweeten wrote:
> > Add defines for the register map of the device. These will be
> > used to clarify the code.
[]
> > diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
[]
> > @@ -53,6 +53,18 @@ References:
> >   */
> >  #include "../comedidev.h"
> >  
> > +/*
> > + * PCI-6208/6216-GL register map
> > + */
> > +#define PCI6208_AO_CONTROL(x)		(0x00 + (2 * (x)))
> > +#define PCI6208_AO_STATUS		0x00
> > +#define PCI6208_AO_STATUS_DATA_SEND	(1 << 0)
> > +#define PCI6208_DIO			0x40
> > +#define PCI6208_DIO_DO_MASK		(0x0f)
> > +#define PCI6208_DIO_DO_SHIFT		(0)
> > +#define PCI6208_DIO_DI_MASK		(0xf0)
> > +#define PCI6208_DIO_DI_SHIFT		(4)
[]
> Does checkpatch.pl complain if you leave off these parenthesis?

checkpatch does not complain about those.
I also think parentheses around constants aren't necessary.

I think it's useful around the shifts and necessary
with the arithmetic.

It might be useful to add a (--strict?) test for those
extra parentheses.

Maybe something like:

 scripts/checkpatch.pl |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e5bd60f..b6b4d6b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2888,6 +2888,11 @@ sub process {
 			     "Whitepspace after \\ makes next lines useless\n" . $herecurr);
 		}
 
+		if ($line =~ /^.\s*#\s*define\s+$Ident\s+\(\s*($Constant)\s*\)\s*$/) {
+			CHK("UNNECESSARY_PARENTHESIS",
+			    "Unnecessary parenthesis in #define around constant $1\n" . $herecurr);
+		}
+
 #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
 		if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) {
 			my $file = "$1.h";



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

* RE: [PATCH 04/19] staging: comedi: adl_pci6208: document the register map of the device
  2012-06-28 19:06 ` Dan Carpenter
  2012-06-28 19:56   ` Joe Perches
@ 2012-06-28 19:57   ` H Hartley Sweeten
  1 sibling, 0 replies; 4+ messages in thread
From: H Hartley Sweeten @ 2012-06-28 19:57 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Linux Kernel, devel, fmhess, abbotti, gregkh

On Thursday, June 28, 2012 12:06 PM, Dan Carpenter wrote:
> On Wed, Jun 27, 2012 at 02:56:43PM -0700, H Hartley Sweeten wrote:
>> Add defines for the register map of the device. These will be
>> used to clarify the code.
>> 
>> Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
>> Cc: Ian Abbott <abbotti@mev.co.uk>
>> Cc: Frank Mori Hess <fmhess@users.sourceforge.net>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> ---
>>  drivers/staging/comedi/drivers/adl_pci6208.c | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>> 
>> diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
>> index f949d20..b6a8439 100644
>> --- a/drivers/staging/comedi/drivers/adl_pci6208.c
>> +++ b/drivers/staging/comedi/drivers/adl_pci6208.c
>> @@ -53,6 +53,18 @@ References:
>>   */
>>  #include "../comedidev.h"
>>  
>> +/*
>> + * PCI-6208/6216-GL register map
>> + */
>> +#define PCI6208_AO_CONTROL(x)		(0x00 + (2 * (x)))
>> +#define PCI6208_AO_STATUS		0x00
>> +#define PCI6208_AO_STATUS_DATA_SEND	(1 << 0)
>> +#define PCI6208_DIO			0x40
>> +#define PCI6208_DIO_DO_MASK		(0x0f)
>> +#define PCI6208_DIO_DO_SHIFT		(0)
>> +#define PCI6208_DIO_DI_MASK		(0xf0)
>> +#define PCI6208_DIO_DI_SHIFT		(4)
>
> This series is nice and I'm not nacking anything, but really is it
> that useful to say:
> 	status = inw(dev->iobase + PCI6208_AO_STATUS);
> instead of just?:
> 	status = inw(dev->iobase);

Either would work.

But the '+ PCI6208_AO_STATUS' used in the function makes it
easily apparent that the 'status' register is being read without
having to go back and see what the assumed '+ 0' register is.

> I'm not sure what the 0x00 in PCI6208_AO_CONTROL represents.  Some
> of these are not used like PCI6208_DIO_DI_SHIFT.

Sorry about that. Maybe there should be a comment.

The PCI-6208 has 8 separate "control" registers, one for each DAC output
(the PCI-6216 has 16). They are at offsets 0x00, 0x02, 0x04, ... 0x0e (0x1e for
The PCI-6216). The PCI6208_AO_CONTROL macro is used to calculate the
necessary offset based on the DAC channel. The original code used the
same open-coded logic.

The unused ones can be removed. When I created the patch that added
them I just added everything that might be useful from the manual for
the PCI-6208. I was quite sure what ones would end up un used.

> Does checkpatch.pl complain if you leave off these parenthesis?  If
> so I will complain again to the checkpatch.pl people.  Extra
> parenthesis are silly and there not used consistently.  Only
> PCI6208_AO_CONTROL() and PCI6208_AO_STATUS_DATA_SEND() need
> paranthesis.

No, checkpatch.pl does not complain about the parenthesis either way.
I usually use the parenthesis in the 'bit' defines and not for the 'register'
defines. It helps my brain keep them separate... ;-)

But, they can be removed it needed.

> Again, I'm fine with this patch and the whole series.  These are
> just comments.

Thanks for the comments!

Regards,
Hartley

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

end of thread, other threads:[~2012-06-28 19:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 21:56 [PATCH 04/19] staging: comedi: adl_pci6208: document the register map of the device H Hartley Sweeten
2012-06-28 19:06 ` Dan Carpenter
2012-06-28 19:56   ` Joe Perches
2012-06-28 19:57   ` H Hartley Sweeten

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.