diff options
Diffstat (limited to 'drivers/hwmon/hih6130.c')
| -rw-r--r-- | drivers/hwmon/hih6130.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/hwmon/hih6130.c b/drivers/hwmon/hih6130.c index e8ee75f5547..7d68a08baaa 100644 --- a/drivers/hwmon/hih6130.c +++ b/drivers/hwmon/hih6130.c @@ -33,6 +33,7 @@ #include <linux/mutex.h> #include <linux/device.h> #include <linux/delay.h> +#include <linux/jiffies.h> /** * struct hih6130 - HIH-6130 device specific data @@ -42,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; @@ -50,6 +52,7 @@ struct hih6130 { unsigned long last_update; int temperature; int humidity; + size_t write_length; }; /** @@ -120,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; @@ -219,7 +229,7 @@ static const struct attribute_group hih6130_attr_group = { * device's name. * Returns 0 on success. */ -static int __devinit hih6130_probe(struct i2c_client *client, +static int hih6130_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct hih6130 *hih6130; @@ -251,6 +261,9 @@ static int __devinit hih6130_probe(struct i2c_client *client, goto fail_remove_sysfs; } + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_QUICK)) + hih6130->write_length = 1; + return 0; fail_remove_sysfs: @@ -262,7 +275,7 @@ fail_remove_sysfs: * hih6130_remove() - remove device * @client: I2C client device */ -static int __devexit hih6130_remove(struct i2c_client *client) +static int hih6130_remove(struct i2c_client *client) { struct hih6130 *hih6130 = i2c_get_clientdata(client); @@ -282,7 +295,7 @@ MODULE_DEVICE_TABLE(i2c, hih6130_id); static struct i2c_driver hih6130_driver = { .driver.name = "hih6130", .probe = hih6130_probe, - .remove = __devexit_p(hih6130_remove), + .remove = hih6130_remove, .id_table = hih6130_id, }; |
