提交 86b581f6 编写于 作者: L Linus Torvalds

Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fix from Guenter Roeck:
 "Fix HIH-6130 driver to work with BeagleBone"

* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
  hwmon: HIH-6130: Support I2C bus drivers without I2C_FUNC_SMBUS_QUICK
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
* @last_update: time of last update (jiffies) * @last_update: time of last update (jiffies)
* @temperature: cached temperature measurement value * @temperature: cached temperature measurement value
* @humidity: cached humidity measurement value * @humidity: cached humidity measurement value
* @write_length: length for I2C measurement request
*/ */
struct hih6130 { struct hih6130 {
struct device *hwmon_dev; struct device *hwmon_dev;
...@@ -51,6 +52,7 @@ struct hih6130 { ...@@ -51,6 +52,7 @@ struct hih6130 {
unsigned long last_update; unsigned long last_update;
int temperature; int temperature;
int humidity; int humidity;
size_t write_length;
}; };
/** /**
...@@ -121,8 +123,15 @@ static int hih6130_update_measurements(struct i2c_client *client) ...@@ -121,8 +123,15 @@ static int hih6130_update_measurements(struct i2c_client *client)
*/ */
if (time_after(jiffies, hih6130->last_update + HZ) || !hih6130->valid) { 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) if (ret < 0)
goto out; goto out;
...@@ -252,6 +261,9 @@ static int hih6130_probe(struct i2c_client *client, ...@@ -252,6 +261,9 @@ static int hih6130_probe(struct i2c_client *client,
goto fail_remove_sysfs; goto fail_remove_sysfs;
} }
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_QUICK))
hih6130->write_length = 1;
return 0; return 0;
fail_remove_sysfs: fail_remove_sysfs:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册