lkml.org 
[lkml]   [2012]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [NEW DRIVER V2 5/7] DA9058 GPIO driver
From
On Wed, Aug 15, 2012 at 12:08 PM, Opensource [Anthony Olech]
<anthony.olech.opensource@diasemi.com> wrote:
> [Me]

>> > + if (offset > 1)
>> > + return -EINVAL;
>> So there are two GPIO pins, 0 and 1? That seems odd, but OK.
>
> That is a feature of the hardware. I believe that calling them "0" and
> "1" is the correct thing to do. Correct me if they should have been
> called "1" and "2", or something else.

It's correct, what I thought was odd was the fact that there were only
two GPIO pins on this device. But some have only one even, just wanted
to verify...

> HANDLING NIBBLES
> ================
>
> The handling of nibbles within a byte follows the rule that constants
> for the nibble NOT being operated on have those bits set to zero,
> and thus only bits being operated on may be non-zero. Thus to set,
> for example, the value 0xB into the MSH the operation is:
> byte &= ~0xF0
> byte |= 0xB0
> it being obvious that it is the upper nibble being operated on.
> It seems that you are following a different rule for handling nibbles,
> and I can't find any standard for doing so in the kernel, so could
> you send me your reference documents?

In this case as stated elsewhere, I'm happy that you do things
this way, if you #define the magic values you're using
in your bytes and nibbles, because else it's just hard to read.

#define FOO_MASK 0xF0
#define BAR_FEATURE 0xB0

byte &= ~FOO_MASK;
byte |= BAR_FEATURE;

It's more readble.

Yours,
Linus Walleij


\
 
 \ /
  Last update: 2012-08-15 17:43    [W:0.045 / U:0.716 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site