Skip to contentSkip to conversation

Proposed PEC support reimplementation

lm-sensors Jean Delvare 2 participants 3 messages Oct 2, 2005

lore
Share & tools
lore
#0 lore raw

Hi all,

I am done with my software PEC support reimplementation. It was faster and easier than I first thought. Basically, the idea is to operate on i2c_msg structures rather than i2c_smbus_data unions. This allows to handle all transactions on I2C adapters rather than only a few ones. The code is generic rather than transaction specific, so it is significantly shorter, and is less likely to have bugs. The only drawback I can think of is that emulating PEC on non-I2C, non-PEC SMBus masters is no more possible - but this possibility did not seem to be used, and it was only partly possible by design anyway.

Patches are available for review:

http://khali.linux-fr.org/devel/i2c/linux-2.6/i2c-core-drop-pec-funcs.diff

Discard I2C_FUNC_SMBUS_*_PEC defines.

http://khali.linux-fr.org/devel/i2c/linux-2.6/i2c-core-rewrite-swpec.diff

The rewrite itself.

http://khali.linux-fr.org/devel/i2c/linux-2.6/i2c-core-drop-swpec-sizes.diff

Post-rewrite cleanups.

http://khali.linux-fr.org/devel/i2c/linux-2.6/hwmon-lm90-adm1032-pec.diff

Usage demonstration, adding PEC support to the lm90 driver for the ADM1032 chip.

Comments are of course welcome. Testers are very welcome too, both to make sure that I did not break any non-PEC transaction in the process (unlikely) and to test the new PEC implementation. There doesn't seem to be that many PEC-capable devices out there, unfortunately.

Note that all these patches are part of my own current stack of patches, so they may or may not apply to a vanilla tree. You can pick the whole patchset here for easier testing:

http://khali.linux-fr.org/devel/i2c/linux-2.6/linux-2.6.14-rc3-i2c.patch.gz

As the name says, it applies to 2.6.14-rc3. Or for quilt users:

http://khali.linux-fr.org/devel/i2c/linux-2.6/linux-2.6.14-rc3-i2c-broken-out.tar.gz

Thanks,

Signature · 1 line
Jean Delvare
#1 lore raw
Quoted 2 lines · Jean Delvare

Comments are of course welcome. Testers are very welcome too, both to

What is PEC? Why do I want it? I been skimming this thread for days waiting for the penny to drop, it hasn't :(

Cheers,
Grant.

#2 lore raw
In reply to Jean Delvare

Hi Grant,

Quoted 4 lines
Quoted 1 line

Comments are of course welcome. Testers are very welcome too, both to

What is PEC? Why do I want it? I been skimming this thread for days waiting for the penny to drop, it hasn't :(

Didn't you read the SMBus 2.0 specification yet? ;)

PEC stands for Packet Error Code, this is an extension of the SMBus protocol which adds a CRC8 byte at the end of each transaction, for the purpose of improving reliability. For it to work, both the master and the slave must support it for the given transaction.

We had a previous implementation by Mark D. Studebaker which had some bugs and design limitations. I've been reimplementing it in a different way, in fewer lines of code, with hopefully less bugs and less limitations.

If you want to help, you can pick the patches and at least make sure that they don't break anything for you. If you additionally have a PEC-capable master (either an I2C master using the software PEC implementation, or a SMBus master with hardware PEC support), and have at least one slave with PEC, you could see if PEC actually works for you. My impression is that only a very small number of slaves actually support PEC though.

Thanks,

Signature · 1 line
Jean Delvare