sbs: Use i2c_smbus_xfer
A message that is not in the archive (sent off-list or not yet received): [email protected]
Yes, you are right, but we are going to remove i2c objects from sbs driver in near future.
Thanks.
Vladimir.
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: Thursday, February 15, 2007 11:52 PM
To: Lebedev, Vladimir P
Cc: [email protected]
Subject: [PATCH] sbs: Use i2c_smbus_xfer
Use i2c_smbus_xfer() in the ACPI SBS driver, instead of explicitely calling the i2c bus driver's smbus_xfer() function. This is the right thing to do for two reasons:
* i2c-core takes care of concurrent accesses to the bus.
* i2c-core can emulate SMBus transactions over an I2C bus. This will make
it possible to use the sbs driver on top of other i2c bus drivers than i2c_ec.
As a side effect, I fixed a bug in acpi_battery_smbus_err_handler(), which was starting an SMBus block read transaction instead of an SMBus word read.
--- drivers/acpi/sbs.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
--- linux-2.6.21-pre.orig/drivers/acpi/sbs.c 2007-02-15
20:38:33.000000000 +0100
+++ linux-2.6.21-pre/drivers/acpi/sbs.c 2007-02-15 20:46:03.000000000
+0100
@@ -189,10 +189,9 @@ static void acpi_battery_smbus_err_handl
data.word = 0;
- result = smbus->adapter.algo->
- smbus_xfer(&smbus->adapter,
- ACPI_SB_SMBUS_ADDR,
- 0, I2C_SMBUS_READ, 0x16, I2C_SMBUS_BLOCK_DATA,
&data);
+ result = i2c_smbus_xfer(&smbus->adapter, ACPI_SB_SMBUS_ADDR, 0,
+ I2C_SMBUS_READ, 0x16,I2C_SMBUS_WORD_DATA,
+ &data);
err_number = (data.word & 0x000f);
@@ -242,13 +241,12 @@ acpi_sbs_smbus_read_word(struct acpi_ec_
}
for (i = 0; i < MAX_SMBUS_ERR; i++) {
- result =
- smbus->adapter.algo->smbus_xfer(&smbus->adapter,
addr, 0,
- I2C_SMBUS_READ,
func,
- I2C_SMBUS_WORD_DATA,
&data);
+ result = i2c_smbus_xfer(&smbus->adapter, addr, 0,
+ I2C_SMBUS_READ, func,
+ I2C_SMBUS_WORD_DATA, &data);
if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
- "try %i:smbus->adapter.algo->smbus_xfer() failed\n",
+ "try %i: i2c_smbus_xfer()
failed\n",
i));
if (err_handler) {
err_handler(smbus);
@@ -276,14 +274,12 @@ acpi_sbs_smbus_read_str(struct acpi_ec_s
}
for (i = 0; i < MAX_SMBUS_ERR; i++) {
- result =
- smbus->adapter.algo->smbus_xfer(&smbus->adapter,
addr, 0,
- I2C_SMBUS_READ,
func,
-I2C_SMBUS_BLOCK_DATA,
- &data);
+ result = i2c_smbus_xfer(&smbus->adapter, addr, 0,
+ I2C_SMBUS_READ, func,
+ I2C_SMBUS_BLOCK_DATA, &data);
if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
- "try %i:smbus->adapter.algo->smbus_xfer() failed\n",
+ "try %i: i2c_smbus_xfer()
failed\n",
i));
if (err_handler) {
err_handler(smbus);
@@ -315,14 +311,13 @@ acpi_sbs_smbus_write_word(struct acpi_ec
data.word = word;
for (i = 0; i < MAX_SMBUS_ERR; i++) {
- result =
- smbus->adapter.algo->smbus_xfer(&smbus->adapter,
addr, 0,
- I2C_SMBUS_WRITE,
func,
- I2C_SMBUS_WORD_DATA,
&data);
+ result = i2c_smbus_xfer(&smbus->adapter, addr, 0,
+ I2C_SMBUS_WRITE, func,
+ I2C_SMBUS_WORD_DATA, &data);
if (result) {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
- "try %i: smbus->adapter.algo"
- "->smbus_xfer() failed\n",
i));
+ "try %i: i2c_smbus_xfer()
failed\n",
+ i));
if (err_handler) {
err_handler(smbus);
}
Signature · 1 line
Jean Delvare
Vladimir,
Quoted 2 lines · Vladimir P
Yes, you are right, but we are going to remove i2c objects from sbs driver in near future.
How that? How do you plan to access SMBus devices without using i2c functions?
Thanks,
Signature · 1 line
Jean Delvare
Right now sbs driver has access to SBS via 'ec' (read/write) functions, but it uses the i2c functions/structures - this is historical situation, so; there are no problems (some time is needed only) to remove i2c using from sbs driver. We are planning to do it to next release.
Thanks.
Vladimir.
-----Original Message-----
From: Jean Delvare [mailto:[email protected]]
Sent: Friday, February 16, 2007 9:25 AM
To: Lebedev, Vladimir P
Cc: [email protected]
Subject: Re: [PATCH] sbs: Use i2c_smbus_xfer
Vladimir,
Quoted 2 lines · Vladimir P
Yes, you are right, but we are going to remove i2c objects from sbs driver in near future.
How that? How do you plan to access SMBus devices without using i2c functions?
Thanks,
Signature · 1 line
Jean Delvare