mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-31 06:15:15 +00:00
Backport SMBus PEC support rewrite from Linux 2.6:
Discard I2C_FUNC_SMBUS_*_PEC defines. i2c clients are not supposed to check for PEC support of i2c bus drivers on individual SMBus transactions, and i2c bus drivers are not supposed to advertise them. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@3176 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -91,7 +91,7 @@
|
||||
#define PCI_DEVICE_ID_INTEL_ICH7_17 0x27da
|
||||
#endif
|
||||
|
||||
#ifdef I2C_FUNC_SMBUS_BLOCK_DATA_PEC
|
||||
#ifdef I2C_CLIENT_PEC
|
||||
#define HAVE_PEC
|
||||
#endif
|
||||
|
||||
@@ -595,9 +595,7 @@ static u32 i801_func(struct i2c_adapter *adapter)
|
||||
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
|
||||
I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
|
||||
#ifdef HAVE_PEC
|
||||
| (isich4 ? I2C_FUNC_SMBUS_BLOCK_DATA_PEC |
|
||||
I2C_FUNC_SMBUS_HWPEC_CALC
|
||||
: 0)
|
||||
| (isich4 ? I2C_FUNC_SMBUS_HWPEC_CALC : 0)
|
||||
#endif
|
||||
#if 0
|
||||
| (isich5 ? I2C_FUNC_SMBUS_READ_I2C_BLOCK
|
||||
|
@@ -185,7 +185,7 @@ int smbusarp_detect(struct i2c_adapter *adapter, int address,
|
||||
if ((!i2c_check_functionality(adapter,
|
||||
I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_HWPEC_CALC)) &&
|
||||
(!i2c_check_functionality(adapter,
|
||||
I2C_FUNC_SMBUS_BLOCK_DATA_PEC)))
|
||||
I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_I2C)))
|
||||
return(0);
|
||||
|
||||
if (!(data = kmalloc(sizeof(struct arp_data), GFP_KERNEL))) {
|
||||
|
@@ -53,10 +53,6 @@ struct i2c_msg {
|
||||
#define I2C_FUNC_10BIT_ADDR 0x00000002
|
||||
#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
|
||||
#define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */
|
||||
#define I2C_FUNC_SMBUS_READ_WORD_DATA_PEC 0x00000800 /* SMBus 2.0 */
|
||||
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC 0x00001000 /* SMBus 2.0 */
|
||||
#define I2C_FUNC_SMBUS_PROC_CALL_PEC 0x00002000 /* SMBus 2.0 */
|
||||
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL_PEC 0x00004000 /* SMBus 2.0 */
|
||||
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
|
||||
#define I2C_FUNC_SMBUS_QUICK 0x00010000
|
||||
#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
|
||||
@@ -72,8 +68,6 @@ struct i2c_msg {
|
||||
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
|
||||
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */
|
||||
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */
|
||||
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC 0x40000000 /* SMBus 2.0 */
|
||||
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC 0x80000000 /* SMBus 2.0 */
|
||||
|
||||
#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
|
||||
I2C_FUNC_SMBUS_WRITE_BYTE)
|
||||
@@ -87,17 +81,6 @@ struct i2c_msg {
|
||||
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
|
||||
#define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \
|
||||
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2)
|
||||
#define I2C_FUNC_SMBUS_BLOCK_DATA_PEC (I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC | \
|
||||
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA_PEC)
|
||||
#define I2C_FUNC_SMBUS_WORD_DATA_PEC (I2C_FUNC_SMBUS_READ_WORD_DATA_PEC | \
|
||||
I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC)
|
||||
|
||||
#define I2C_FUNC_SMBUS_READ_BYTE_PEC I2C_FUNC_SMBUS_READ_BYTE_DATA
|
||||
#define I2C_FUNC_SMBUS_WRITE_BYTE_PEC I2C_FUNC_SMBUS_WRITE_BYTE_DATA
|
||||
#define I2C_FUNC_SMBUS_READ_BYTE_DATA_PEC I2C_FUNC_SMBUS_READ_WORD_DATA
|
||||
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA_PEC I2C_FUNC_SMBUS_WRITE_WORD_DATA
|
||||
#define I2C_FUNC_SMBUS_BYTE_PEC I2C_FUNC_SMBUS_BYTE_DATA
|
||||
#define I2C_FUNC_SMBUS_BYTE_DATA_PEC I2C_FUNC_SMBUS_WORD_DATA
|
||||
|
||||
/*
|
||||
* Data for SMBus Messages
|
||||
|
@@ -183,74 +183,35 @@ int main(int argc, char *argv[])
|
||||
|
||||
switch(size) {
|
||||
case I2C_SMBUS_BYTE:
|
||||
if (pec) {
|
||||
if (!(funcs & I2C_FUNC_SMBUS_BYTE_PEC)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus "
|
||||
"%d does not have byte w/ PEC "
|
||||
"capability\n", i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
if (!(funcs & I2C_FUNC_SMBUS_BYTE)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus "
|
||||
"%d does not have byte capability\n",
|
||||
i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
if (!((funcs & I2C_FUNC_SMBUS_BYTE) == I2C_FUNC_SMBUS_BYTE)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus %d does "
|
||||
"not have byte capability\n", i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case I2C_SMBUS_BYTE_DATA:
|
||||
if (pec) {
|
||||
if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA_PEC)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus "
|
||||
"%d does not have byte read w/ PEC "
|
||||
"capability\n", i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus "
|
||||
"%d does not have byte read "
|
||||
"capability\n", i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
if (!(funcs & I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus %d does "
|
||||
"not have byte read capability\n", i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case I2C_SMBUS_WORD_DATA:
|
||||
if (pec) {
|
||||
if (!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA_PEC)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus "
|
||||
"%d does not have word read w/ PEC "
|
||||
"capability\n", i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
if (!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus "
|
||||
"%d does not have word read "
|
||||
"capability\n", i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
if (!(funcs & I2C_FUNC_SMBUS_READ_WORD_DATA)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus %d does "
|
||||
"not have word read capability\n", i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
case I2C_SMBUS_BLOCK_DATA:
|
||||
if (pec) {
|
||||
if (!(funcs & I2C_FUNC_SMBUS_READ_BLOCK_DATA_PEC)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus "
|
||||
"%d does not have smbus block read "
|
||||
"w/ PEC capability\n", i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
if (!(funcs & I2C_FUNC_SMBUS_READ_BLOCK_DATA)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus "
|
||||
"%d does not have smbus block read "
|
||||
"capability\n", i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
if (!(funcs & I2C_FUNC_SMBUS_READ_BLOCK_DATA)) {
|
||||
fprintf(stderr, "Error: Adapter for i2c bus %d does "
|
||||
"not have smbus block read capability\n",
|
||||
i2cbus);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -278,6 +239,10 @@ int main(int argc, char *argv[])
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if (!(funcs & (I2C_FUNC_SMBUS_HWPEC_CALC | I2C_FUNC_I2C))) {
|
||||
fprintf(stderr, "Warning: Adapter for i2c bus %d does "
|
||||
"not seem to actually support PEC\n", i2cbus);
|
||||
}
|
||||
}
|
||||
|
||||
if (!yes) {
|
||||
|
Reference in New Issue
Block a user