* [PATCH] hwmon: HIH-6130: Support I2C bus drivers without I2C_FUNC_SMBUS_QUICK
@ 2013-12-11 0:57 José Miguel Gonçalves
0 siblings, 0 replies; 5+ messages in thread
From: José Miguel Gonçalves @ 2013-12-11 0:57 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck, lm-sensors, linux-kernel
Cc: José Miguel Gonçalves
Some I2C bus drivers do not allow zero-lenght data transfers which are
required to start a mesurement with the HIH6130/1 sensor. Nevertheless,
we can overcome this limitation by writing a zero dummy byte. This byte
is ignored by the sensor and was verified to be working with the OMAP
I2C bus driver in a BeagleBone board.
Signed-off-by: José Miguel Gonçalves <jose.goncalves@inov.pt>
---
drivers/hwmon/hih6130.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/hih6130.c b/drivers/hwmon/hih6130.c
index 2dc37c7..a860cc4 100644
--- a/drivers/hwmon/hih6130.c
+++ b/drivers/hwmon/hih6130.c
@@ -121,8 +121,20 @@ static int hih6130_update_measurements(struct i2c_client *client)
*/
if (time_after(jiffies, hih6130->last_update + HZ) || !hih6130->valid) {
- /* write to slave address, no data, to request a measurement */
- ret = i2c_master_send(client, tmp, 0);
+ /*
+ * Write to slave address, to request a measurement.
+ * According with the datasheet it should be with no data, but
+ * for systems with I2C bus drivers that do not allow zero
+ * length packets we write one dummy byte to allow sensor
+ * measurements on them.
+ */
+ if (i2c_get_functionality(client->adapter) &
+ I2C_FUNC_SMBUS_QUICK) {
+ ret = i2c_master_send(client, tmp, 0);
+ } else {
+ tmp[0] = 0;
+ ret = i2c_master_send(client, tmp, 1);
+ }
if (ret < 0)
goto out;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] hwmon: HIH-6130: Support I2C bus drivers without I2C_FUNC_SMBUS_QUICK
@ 2013-12-11 11:11 José Miguel Gonçalves
2013-12-11 19:29 ` Guenter Roeck
0 siblings, 1 reply; 5+ messages in thread
From: José Miguel Gonçalves @ 2013-12-11 11:11 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck, lm-sensors, linux-kernel
Cc: José Miguel Gonçalves
Some I2C bus drivers do not allow zero-length data transfers which are
required to start a measurement with the HIH6130/1 sensor. Nevertheless,
we can overcome this limitation by writing a zero dummy byte. This byte
is ignored by the sensor and was verified to be working with the OMAP
I2C bus driver in a BeagleBone board.
Signed-off-by: José Miguel Gonçalves <jose.goncalves@inov.pt>
---
v2: Use a field in struct hih6130 to store the measurement request's
write length when probing.
drivers/hwmon/hih6130.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/hih6130.c b/drivers/hwmon/hih6130.c
index 2dc37c7..8e46265 100644
--- a/drivers/hwmon/hih6130.c
+++ b/drivers/hwmon/hih6130.c
@@ -43,6 +43,7 @@
* @last_update: time of last update (jiffies)
* @temperature: cached temperature measurement value
* @humidity: cached humidity measurement value
+ * @write_length: length for I2C measurement request
*/
struct hih6130 {
struct device *hwmon_dev;
@@ -51,6 +52,7 @@ struct hih6130 {
unsigned long last_update;
int temperature;
int humidity;
+ size_t write_length;
};
/**
@@ -121,8 +123,15 @@ static int hih6130_update_measurements(struct i2c_client *client)
*/
if (time_after(jiffies, hih6130->last_update + HZ) || !hih6130->valid) {
- /* write to slave address, no data, to request a measurement */
- ret = i2c_master_send(client, tmp, 0);
+ /*
+ * Write to slave address to request a measurement.
+ * According with the datasheet it should be with no data, but
+ * for systems with I2C bus drivers that do not allow zero
+ * length packets we write one dummy byte to allow sensor
+ * measurements on them.
+ */
+ tmp[0] = 0;
+ ret = i2c_master_send(client, tmp, hih6130->write_length);
if (ret < 0)
goto out;
@@ -252,6 +261,9 @@ static int hih6130_probe(struct i2c_client *client,
goto fail_remove_sysfs;
}
+ hih6130->write_length = (i2c_get_functionality(client->adapter) &
+ I2C_FUNC_SMBUS_QUICK ? 0 : 1);
+
return 0;
fail_remove_sysfs:
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] hwmon: HIH-6130: Support I2C bus drivers without I2C_FUNC_SMBUS_QUICK
2013-12-11 11:11 [PATCH] hwmon: HIH-6130: Support I2C bus drivers without I2C_FUNC_SMBUS_QUICK José Miguel Gonçalves
@ 2013-12-11 19:29 ` Guenter Roeck
2013-12-11 19:51 ` José Miguel Gonçalves
0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2013-12-11 19:29 UTC (permalink / raw)
To: José Miguel Gonçalves; +Cc: Jean Delvare, lm-sensors, linux-kernel
On Wed, Dec 11, 2013 at 11:11:13AM +0000, José Miguel Gonçalves wrote:
> Some I2C bus drivers do not allow zero-length data transfers which are
> required to start a measurement with the HIH6130/1 sensor. Nevertheless,
> we can overcome this limitation by writing a zero dummy byte. This byte
> is ignored by the sensor and was verified to be working with the OMAP
> I2C bus driver in a BeagleBone board.
>
> Signed-off-by: José Miguel Gonçalves <jose.goncalves@inov.pt>
Applied, after simplifying write_length initialization a bit.
Should this go to -stable ?
Guenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hwmon: HIH-6130: Support I2C bus drivers without I2C_FUNC_SMBUS_QUICK
2013-12-11 19:29 ` Guenter Roeck
@ 2013-12-11 19:51 ` José Miguel Gonçalves
2013-12-11 21:28 ` Guenter Roeck
0 siblings, 1 reply; 5+ messages in thread
From: José Miguel Gonçalves @ 2013-12-11 19:51 UTC (permalink / raw)
To: Guenter Roeck; +Cc: Jean Delvare, lm-sensors, linux-kernel
On 11-12-2013 19:29, Guenter Roeck wrote:
> On Wed, Dec 11, 2013 at 11:11:13AM +0000, José Miguel Gonçalves wrote:
>> Some I2C bus drivers do not allow zero-length data transfers which are
>> required to start a measurement with the HIH6130/1 sensor. Nevertheless,
>> we can overcome this limitation by writing a zero dummy byte. This byte
>> is ignored by the sensor and was verified to be working with the OMAP
>> I2C bus driver in a BeagleBone board.
>>
>> Signed-off-by: José Miguel Gonçalves <jose.goncalves@inov.pt>
> Applied, after simplifying write_length initialization a bit.
>
> Should this go to -stable ?
Any BeagleBone user that tries to use this sensor will encounter this issue. As
this board is very popular, this will potentially solve the problems of many
users. Nevertheless, it does not seems to me that this patch fixes "something
critical", which is one of the conditions to be accepted in the -stable tree.
José Gonçalves
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hwmon: HIH-6130: Support I2C bus drivers without I2C_FUNC_SMBUS_QUICK
2013-12-11 19:51 ` José Miguel Gonçalves
@ 2013-12-11 21:28 ` Guenter Roeck
0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2013-12-11 21:28 UTC (permalink / raw)
To: José Miguel Gonçalves; +Cc: Jean Delvare, lm-sensors, linux-kernel
On Wed, Dec 11, 2013 at 07:51:54PM +0000, José Miguel Gonçalves wrote:
> On 11-12-2013 19:29, Guenter Roeck wrote:
> >On Wed, Dec 11, 2013 at 11:11:13AM +0000, José Miguel Gonçalves wrote:
> >>Some I2C bus drivers do not allow zero-length data transfers which are
> >>required to start a measurement with the HIH6130/1 sensor. Nevertheless,
> >>we can overcome this limitation by writing a zero dummy byte. This byte
> >>is ignored by the sensor and was verified to be working with the OMAP
> >>I2C bus driver in a BeagleBone board.
> >>
> >>Signed-off-by: José Miguel Gonçalves <jose.goncalves@inov.pt>
> >Applied, after simplifying write_length initialization a bit.
> >
> >Should this go to -stable ?
>
> Any BeagleBone user that tries to use this sensor will encounter
> this issue. As this board is very popular, this will potentially
> solve the problems of many users. Nevertheless, it does not seems to
> me that this patch fixes "something critical", which is one of the
> conditions to be accepted in the -stable tree.
>
Depends on the definition of "critical".
Guenter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-11 21:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-11 11:11 [PATCH] hwmon: HIH-6130: Support I2C bus drivers without I2C_FUNC_SMBUS_QUICK José Miguel Gonçalves
2013-12-11 19:29 ` Guenter Roeck
2013-12-11 19:51 ` José Miguel Gonçalves
2013-12-11 21:28 ` Guenter Roeck
-- strict thread matches above, loose matches on Subject: below --
2013-12-11 0:57 José Miguel Gonçalves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox