History

Documentation: i2c: rename variable "register" to "reg"

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. Another couple of typos has been fixed as well. [Change "! =" to "!=".]

Jose Manuel Alarcon Roldan committed 12 years ago

Commit 257d6ef1 parent 77be4da1 file · +5 −5Browse files

Unified · Split

Documentation/i2c/dev-interface+5−5
@@ -57,12 +57,12 @@ Well, you are all set up now. You can now use SMBus commands or plain · 56 unmodified lines
5757 I2C to communicate with your device. SMBus commands are preferred if
5858 the device supports them. Both are illustrated below.
5959
60− __u8 register = 0x10; /* Device register to access */
60+ __u8 reg = 0x10; /* Device register to access */
6161 __s32 res;
6262 char buf[10];
6363
6464 /* Using SMBus commands */
65− res = i2c_smbus_read_word_data(file, register);
65+ res = i2c_smbus_read_word_data(file, reg);
6666 if (res < 0) {
6767 /* ERROR HANDLING: i2c transaction failed */
6868 } else {
@@ -70,11 +70,11 @@ the device supports them. Both are illustrated below. · 1 unmodified line
7070 }
7171
7272 /* Using I2C Write, equivalent of
73− i2c_smbus_write_word_data(file, register, 0x6543) */
74− buf[0] = register;
73+ i2c_smbus_write_word_data(file, reg, 0x6543) */
74+ buf[0] = reg;
7575 buf[1] = 0x43;
7676 buf[2] = 0x65;
77− if (write(file, buf, 3) ! =3) {
77+ if (write(file, buf, 3) != 3) {
7878 /* ERROR HANDLING: i2c transaction failed */
7979 }
8080