Skip to contentSkip to conversation

i2c versioning

DISCUSSION Mark D. Studebaker 2 participants 8 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

ok gang,
we now have rudimentary versioning in i2c.
i2c.h contains:

	#define I2C_DATE "20011118"
	#define I2C_VERSION "2.6.2"

now how am I supposed to use this in an ifdef?

I want to add block read capability to eeprom,
but only if it's supported in i2c.

So i need
#if I2C_VERSION > 2.6.2
i2c_smbus_i2c_block_read_data(...)
#else
regular read...
#endif

but of course that doesn't work because I2C_VERSION is a string.

Do we need something better, like three integers MAJOR, MINOR, whatever like the kernel has?
Or can I do it somehow with strings?

#ifdef I2C_VERSION
#if I2C_VERSION[0] * 100 + I2C_VERSION[2] * 10 + I2C_VERSION[4] > 262
...
#endif
#endif

#1 lore raw

I think I originally had it like the kernel versioning scheme, but we changed it to be consistent. I think Frodo (?) suggested putting version checking in the Makefile instead of in code. What do you think of that? BTW, when treated as a number, aren't the versionings still compariable? E.g., "2.6.2" > "2.6.1"?

I'm glad we are thinking again about version checking. It's a sore spot for most people installing Lm_sensors who have troubles.

Phil

Quoted 30 lines · Mark D. Studebaker

ok gang,
we now have rudimentary versioning in i2c.
i2c.h contains:

	#define I2C_DATE "20011118"
	#define I2C_VERSION "2.6.2"

now how am I supposed to use this in an ifdef?

I want to add block read capability to eeprom,
but only if it's supported in i2c.

So i need
#if I2C_VERSION > 2.6.2
i2c_smbus_i2c_block_read_data(...)
#else
regular read...
#endif

but of course that doesn't work because I2C_VERSION is a string.

Do we need something better, like three integers MAJOR, MINOR, whatever like the kernel has?
Or can I do it somehow with strings?

#ifdef I2C_VERSION
#if I2C_VERSION[0] * 100 + I2C_VERSION[2] * 10 + I2C_VERSION[4] > 262
...
#endif
#endif

Signature · 3 lines
Philip Edelbrock -- IS Manager -- Edge Design, Corvallis, OR
   [email protected] -- http://www.netroedge.com/~phil
 PGP F16: 01 D2 FD 01 B5 46 F4 F0  3A 8B 9D 7E 14 7F FB 7A
#2 lore raw
In reply to Mark D. Studebaker
Quoted 4 lines · Mark D. Studebaker

You can do anything in code but I'm trying to call a function that doesn't exist in 2.6.2 or earlier so I need
to do the comparison in the preprocessor in a #if statement so I don't get an undefined symbol.

I'd tend to lean towards being stubburn and not compiling than littering the code with more #ifdef's if they are using an old I2C. We've been updating I2C a lot for a while, but maybe we won't need to as much in the future?

Phil

Signature · 3 lines
Philip Edelbrock -- IS Manager -- Edge Design, Corvallis, OR
   [email protected] -- http://www.netroedge.com/~phil
 PGP F16: 01 D2 FD 01 B5 46 F4 F0  3A 8B 9D 7E 14 7F FB 7A
#3 lore raw
In reply to Mark D. Studebaker

How about this, let's use the #ifdefs to make life a little easier for users in the short term. But, work on recombing the two projects now that we have a chance with 2.5.x. When 2.6.0 comes out, we can take the #ifdefs out and have a unified project again. If we get lucky, maybe Alan might let a combined lm-sensors/i2c update into 2.4.x so we can start a little earlier. :')

Phil

Quoted 18 lines · Mark D. Studebaker

But I'm so happy to not require people to download and install a new i2c right now. It really will cut down on tickets, etc, if we can hold that line for a while.
As soon as I put in a i2c_smbus_i2c_read_block_data() call without an #ifdef, we're right back where we started.

Quoted 11 lines · [email protected] wrote:
Quoted 4 lines · Mark D. Studebaker

You can do anything in code but I'm trying to call a function that doesn't exist in 2.6.2 or earlier so I need
to do the comparison in the preprocessor in a #if statement so I don't get an undefined symbol.

I'd tend to lean towards being stubburn and not compiling than littering the code with more #ifdef's if they are using an old I2C. We've been updating I2C a lot for a while, but maybe we won't need to as much in the future?

Signature · 3 lines
Philip Edelbrock -- IS Manager -- Edge Design, Corvallis, OR
   [email protected] -- http://www.netroedge.com/~phil
 PGP F16: 01 D2 FD 01 B5 46 F4 F0  3A 8B 9D 7E 14 7F FB 7A
#4 lore raw
In reply to Mark D. Studebaker

I think it's going to have to be converted in the Makefile and then passed in as major, minor, etc. via -D's. Not real pretty, but it's effectively the same thing. You can still do your #if's, but not directly on the string constant. It's surprising that strings can't be compared by cpp...

Phil

Quoted 39 lines · Mark Studebaker

So we're back to my original question.
Write me a #if statement that decides if one string is greater than another. Good luck.

Quoted 34 lines · [email protected] wrote:

How about this, let's use the #ifdefs to make life a little easier for users in the short term. But, work on recombing the two projects now that we have a chance with 2.5.x. When 2.6.0 comes out, we can take the #ifdefs out and have a unified project again. If we get lucky, maybe Alan might let a combined lm-sensors/i2c update into 2.4.x so we can start a little earlier. :')

Phil

Quoted 6 lines · Mark D. Studebaker

But I'm so happy to not require people to download and install a new i2c right now. It really will cut down on tickets, etc, if we can hold that line for a while.
As soon as I put in a i2c_smbus_i2c_read_block_data() call without an #ifdef, we're right back where we started.

Quoted 12 lines
Quoted 11 lines · [email protected] wrote:
Quoted 4 lines · Mark D. Studebaker

You can do anything in code but I'm trying to call a function that doesn't exist in 2.6.2 or earlier so I need
to do the comparison in the preprocessor in a #if statement so I don't get an undefined symbol.

I'd tend to lean towards being stubburn and not compiling than littering the code with more #ifdef's if they are using an old I2C. We've been updating I2C a lot for a while, but maybe we won't need to as much in the future?

--
Philip Edelbrock -- IS Manager -- Edge Design, Corvallis, OR
[email protected] -- http://www.netroedge.com/~phil
PGP F16: 01 D2 FD 01 B5 46 F4 F0 3A 8B 9D 7E 14 7F FB 7A

Signature · 3 lines
Philip Edelbrock -- IS Manager -- Edge Design, Corvallis, OR
   [email protected] -- http://www.netroedge.com/~phil
 PGP F16: 01 D2 FD 01 B5 46 F4 F0  3A 8B 9D 7E 14 7F FB 7A
#5 lore raw
In reply to Mark D. Studebaker

You can do anything in code but I'm trying to call a function that doesn't exist in 2.6.2 or earlier so I need
to do the comparison in the preprocessor in a #if statement so I don't get an undefined symbol.

Quoted 48 lines · [email protected] wrote:

I think I originally had it like the kernel versioning scheme, but we changed it to be consistent. I think Frodo (?) suggested putting version checking in the Makefile instead of in code. What do you think of that? BTW, when treated as a number, aren't the versionings still compariable? E.g., "2.6.2" > "2.6.1"?

I'm glad we are thinking again about version checking. It's a sore spot for most people installing Lm_sensors who have troubles.

Phil

Quoted 25 lines · Mark D. Studebaker

ok gang,
we now have rudimentary versioning in i2c.
i2c.h contains:

      #define I2C_DATE "20011118"
      #define I2C_VERSION "2.6.2"

now how am I supposed to use this in an ifdef?

I want to add block read capability to eeprom,
but only if it's supported in i2c.

So i need
#if I2C_VERSION > 2.6.2
i2c_smbus_i2c_block_read_data(...)
#else
regular read...
#endif

but of course that doesn't work because I2C_VERSION is a string.

Do we need something better, like three integers MAJOR, MINOR, whatever like the kernel has?
Or can I do it somehow with strings?

Quoted 5 lines

#ifdef I2C_VERSION
#if I2C_VERSION[0] * 100 + I2C_VERSION[2] * 10 + I2C_VERSION[4] > 262
...
#endif
#endif

--
Philip Edelbrock -- IS Manager -- Edge Design, Corvallis, OR
[email protected] -- http://www.netroedge.com/~phil
PGP F16: 01 D2 FD 01 B5 46 F4 F0 3A 8B 9D 7E 14 7F FB 7A

#6 lore raw
In reply to Mark D. Studebaker

But I'm so happy to not require people to download and install a new i2c right now. It really will cut down on tickets, etc, if we can hold that line for a while.
As soon as I put in a i2c_smbus_i2c_read_block_data() call without an #ifdef, we're right back where we started.

Quoted 11 lines · [email protected] wrote:
Quoted 4 lines · Mark D. Studebaker

You can do anything in code but I'm trying to call a function that doesn't exist in 2.6.2 or earlier so I need
to do the comparison in the preprocessor in a #if statement so I don't get an undefined symbol.

I'd tend to lean towards being stubburn and not compiling than littering the code with more #ifdef's if they are using an old I2C. We've been updating I2C a lot for a while, but maybe we won't need to as much in the future?

#7 lore raw
In reply to Mark D. Studebaker

So we're back to my original question.
Write me a #if statement that decides if one string is greater than another. Good luck.

Quoted 34 lines · [email protected] wrote:

How about this, let's use the #ifdefs to make life a little easier for users in the short term. But, work on recombing the two projects now that we have a chance with 2.5.x. When 2.6.0 comes out, we can take the #ifdefs out and have a unified project again. If we get lucky, maybe Alan might let a combined lm-sensors/i2c update into 2.4.x so we can start a little earlier. :')

Phil

Quoted 6 lines · Mark D. Studebaker

But I'm so happy to not require people to download and install a new i2c right now. It really will cut down on tickets, etc, if we can hold that line for a while.
As soon as I put in a i2c_smbus_i2c_read_block_data() call without an #ifdef, we're right back where we started.

Quoted 12 lines
Quoted 11 lines · [email protected] wrote:
Quoted 4 lines · Mark D. Studebaker

You can do anything in code but I'm trying to call a function that doesn't exist in 2.6.2 or earlier so I need
to do the comparison in the preprocessor in a #if statement so I don't get an undefined symbol.

I'd tend to lean towards being stubburn and not compiling than littering the code with more #ifdef's if they are using an old I2C. We've been updating I2C a lot for a while, but maybe we won't need to as much in the future?

--
Philip Edelbrock -- IS Manager -- Edge Design, Corvallis, OR
[email protected] -- http://www.netroedge.com/~phil
PGP F16: 01 D2 FD 01 B5 46 F4 F0 3A 8B 9D 7E 14 7F FB 7A