All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] i2c documentation: rename variable "register" to "reg"
@ 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
  0 siblings, 2 replies; 5+ messages in thread
From: José Manuel Alarcón Roldán @ 2014-08-27 19:54 UTC (permalink / raw)
  To: Randy Dunlap, wsa; +Cc: linux-doc, linux-kernel

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

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

* Re: [PATCH v3] i2c documentation: rename variable "register" to "reg"
  2014-08-27 19:54 [PATCH v3] i2c documentation: rename variable "register" to "reg" José Manuel Alarcón Roldán
@ 2014-08-27 19:56 ` Wolfram Sang
  2014-08-27 19:57 ` José Manuel Alarcón Roldán
  1 sibling, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2014-08-27 19:56 UTC (permalink / raw)
  To: José Manuel Alarcón Roldán
  Cc: Randy Dunlap, linux-doc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 628 bytes --]

On Wed, Aug 27, 2014 at 10:54:21PM +0300, José Manuel Alarcón Roldán wrote:
> 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>

Acked-by: Wolfram Sang <wsa@the-dreams.de>


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v3] i2c documentation: rename variable "register" to "reg"
  2014-08-27 19:54 [PATCH v3] i2c documentation: rename variable "register" to "reg" 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
  1 sibling, 1 reply; 5+ messages in thread
From: José Manuel Alarcón Roldán @ 2014-08-27 19:57 UTC (permalink / raw)
  To: Randy Dunlap, wsa; +Cc: linux-doc, linux-kernel

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 :-(

--
Jose

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

* Re: [PATCH v3] i2c documentation: rename variable "register" to "reg"
  2014-08-27 19:57 ` José Manuel Alarcón Roldán
@ 2014-08-27 20:30   ` Randy Dunlap
  2014-08-27 20:38     ` José Manuel Alarcón Roldán
  0 siblings, 1 reply; 5+ messages in thread
From: Randy Dunlap @ 2014-08-27 20:30 UTC (permalink / raw)
  To: José Manuel Alarcón Roldán, wsa; +Cc: linux-doc, linux-kernel

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

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

* Re: [PATCH v3] i2c documentation: rename variable "register" to "reg"
  2014-08-27 20:30   ` Randy Dunlap
@ 2014-08-27 20:38     ` José Manuel Alarcón Roldán
  0 siblings, 0 replies; 5+ messages in thread
From: José Manuel Alarcón Roldán @ 2014-08-27 20:38 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: wsa, linux-doc, linux-kernel

Gmail. I just had a look at Documentation/email-clients.txt I thought
that selected unformatted text mode would be enough, but obviously it
wasn't. My bad :-(

Will be more careful next time I send a patch. I will use something else.

--
Jose



2014-08-27 23:30 GMT+03:00 Randy Dunlap <rdunlap@infradead.org>:
> 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

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

end of thread, other threads:[~2014-08-27 20:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-27 19:54 [PATCH v3] i2c documentation: rename variable "register" to "reg" 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
2014-08-27 20:38     ` José Manuel Alarcón Roldán

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.