mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: "José Manuel Alarcón Roldán" <jose.alarcon.roldan@gmail.com>,
	wsa@the-dreams.de
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] i2c documentation: rename variable "register" to "reg"
Date: Wed, 27 Aug 2014 13:30:26 -0700	[thread overview]
Message-ID: <53FE3FE2.7030709@infradead.org> (raw)
In-Reply-To: <CAGhpvopiH4MWaRCDsZeOcfznW7qccQ3bM-bnMLm7fhJGdbnfkA@mail.gmail.com>

On 08/27/14 12:57, José Manuel Alarcón Roldán wrote:
> 2014-08-27 22:54 GMT+03:00 José Manuel Alarcón Roldán
> <jose.alarcon.roldan@gmail.com>:
>> The example code provided with the i2c device interface documentation
>> won't compile since it uses the reserved word "register" to name a
>> variable.
>>
>> The compiler fails with this error message:
>>
>>  error: expected identifier or '(' before '=' token
>>    __u8 register = 0x20; /* Device register to access */
>>                  ^
>>
>> Rename the variable "register" to simply "reg"
>> in the example code.
>>
>> Signed-off-by: Jose Alarcon Roldan <jose.alarcon.roldan@gmail.com>
>> ---
>>  Documentation/i2c/dev-interface | 10 +++++-----
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/Documentation/i2c/dev-interface b/Documentation/i2c/dev-interface
>> index 3e742ba..2ac78ae 100644
>> --- a/Documentation/i2c/dev-interface
>> +++ b/Documentation/i2c/dev-interface
>> @@ -57,12 +57,12 @@ Well, you are all set up now. You can now use
>> SMBus commands or plain
>>  I2C to communicate with your device. SMBus commands are preferred if
>>  the device supports them. Both are illustrated below.
>>
>> -  __u8 register = 0x10; /* Device register to access */
>> +  __u8 reg = 0x10; /* Device register to access */
>>    __s32 res;
>>    char buf[10];
>>
>>    /* Using SMBus commands */
>> -  res = i2c_smbus_read_word_data(file, register);
>> +  res = i2c_smbus_read_word_data(file, reg);
>>    if (res < 0) {
>>      /* ERROR HANDLING: i2c transaction failed */
>>    } else {
>> @@ -70,11 +70,11 @@ the device supports them. Both are illustrated below.
>>    }
>>
>>    /* Using I2C Write, equivalent of
>> -     i2c_smbus_write_word_data(file, register, 0x6543) */
>> -  buf[0] = register;
>> +     i2c_smbus_write_word_data(file, reg, 0x6543) */
>> +  buf[0] = reg;
>>    buf[1] = 0x43;
>>    buf[2] = 0x65;
>> -  if (write(file, buf, 3) ! =3) {
>> +  if (write(file, buf, 3) != 3) {
>>      /* ERROR HANDLING: i2c transaction failed */
>>    }
>>
>> --
>> 1.9.1
> 
> Again something went wrong. Sorry about that :-(

What email client are you using?

-- 
~Randy

  reply	other threads:[~2014-08-27 20:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27 19:54 José Manuel Alarcón Roldán
2014-08-27 19:56 ` Wolfram Sang
2014-08-27 19:57 ` José Manuel Alarcón Roldán
2014-08-27 20:30   ` Randy Dunlap [this message]
2014-08-27 20:38     ` José Manuel Alarcón Roldán

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53FE3FE2.7030709@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=jose.alarcon.roldan@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®