diff options
-rw-r--r-- | Documentation/hwmon/sht15 | 29 | ||||
-rw-r--r-- | drivers/hwmon/sht15.c | 247 | ||||
-rw-r--r-- | include/linux/sht15.h | 4 |
3 files changed, 245 insertions, 35 deletions
diff --git a/Documentation/hwmon/sht15 b/Documentation/hwmon/sht15 index 2919c516fdbc..d1939b25eb16 100644 --- a/Documentation/hwmon/sht15 +++ b/Documentation/hwmon/sht15 | |||
@@ -4,6 +4,7 @@ Kernel driver sht15 | |||
4 | Authors: | 4 | Authors: |
5 | * Wouter Horre | 5 | * Wouter Horre |
6 | * Jonathan Cameron | 6 | * Jonathan Cameron |
7 | * Vivien Didelot <vivien.didelot@savoirfairelinux.com> | ||
7 | 8 | ||
8 | Supported chips: | 9 | Supported chips: |
9 | * Sensirion SHT10 | 10 | * Sensirion SHT10 |
@@ -30,13 +31,37 @@ Description | |||
30 | The SHT10, SHT11, SHT15, SHT71, and SHT75 are humidity and temperature | 31 | The SHT10, SHT11, SHT15, SHT71, and SHT75 are humidity and temperature |
31 | sensors. | 32 | sensors. |
32 | 33 | ||
33 | The devices communicate using two GPIO lines and use the default | 34 | The devices communicate using two GPIO lines. |
34 | resolution settings of 14 bits for temperature and 12 bits for humidity. | 35 | |
36 | Supported resolutions for the measurements are 14 bits for temperature and 12 | ||
37 | bits for humidity, or 12 bits for temperature and 8 bits for humidity. | ||
38 | |||
39 | The humidity calibration coefficients are programmed into an OTP memory on the | ||
40 | chip. These coefficients are used to internally calibrate the signals from the | ||
41 | sensors. Disabling the reload of those coefficients allows saving 10ms for each | ||
42 | measurement and decrease power consumption, while loosing on precision. | ||
43 | |||
44 | Some options may be set directly in the sht15_platform_data structure | ||
45 | or via sysfs attributes. | ||
35 | 46 | ||
36 | Note: The regulator supply name is set to "vcc". | 47 | Note: The regulator supply name is set to "vcc". |
37 | 48 | ||
49 | Platform data | ||
50 | ------------- | ||
51 | |||
52 | * no_otp_reload: | ||
53 | flag to indicate not to reload from OTP (default to false). | ||
54 | * low_resolution: | ||
55 | flag to indicate the temp/humidity resolution to use (default to false). | ||
56 | |||
38 | Sysfs interface | 57 | Sysfs interface |
39 | --------------- | 58 | --------------- |
40 | 59 | ||
41 | * temp1_input: temperature input | 60 | * temp1_input: temperature input |
42 | * humidity1_input: humidity input | 61 | * humidity1_input: humidity input |
62 | * heater_enable: write 1 in this attribute to enable the on-chip heater, | ||
63 | 0 to disable it. Be careful not to enable the heater | ||
64 | for too long. | ||
65 | * temp1_fault: if 1, this means that the voltage is low (below 2.47V) and | ||
66 | measurement may be invalid. | ||
67 | * humidity1_fault: same as temp1_fault. | ||
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index 3182b3f578e2..49da089b5de9 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c | |||
@@ -1,6 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * sht15.c - support for the SHT15 Temperature and Humidity Sensor | 2 | * sht15.c - support for the SHT15 Temperature and Humidity Sensor |
3 | * | 3 | * |
4 | * Portions Copyright (c) 2010-2011 Savoir-faire Linux Inc. | ||
5 | * Vivien Didelot <vivien.didelot@savoirfairelinux.com> | ||
6 | * | ||
4 | * Copyright (c) 2009 Jonathan Cameron | 7 | * Copyright (c) 2009 Jonathan Cameron |
5 | * | 8 | * |
6 | * Copyright (c) 2007 Wouter Horre | 9 | * Copyright (c) 2007 Wouter Horre |
@@ -33,6 +36,8 @@ | |||
33 | /* Commands */ | 36 | /* Commands */ |
34 | #define SHT15_MEASURE_TEMP 0x03 | 37 | #define SHT15_MEASURE_TEMP 0x03 |
35 | #define SHT15_MEASURE_RH 0x05 | 38 | #define SHT15_MEASURE_RH 0x05 |
39 | #define SHT15_WRITE_STATUS 0x06 | ||
40 | #define SHT15_READ_STATUS 0x07 | ||
36 | #define SHT15_SOFT_RESET 0x1E | 41 | #define SHT15_SOFT_RESET 0x1E |
37 | 42 | ||
38 | /* Min timings */ | 43 | /* Min timings */ |
@@ -41,6 +46,12 @@ | |||
41 | #define SHT15_TSU 150 /* (nsecs) data setup time */ | 46 | #define SHT15_TSU 150 /* (nsecs) data setup time */ |
42 | #define SHT15_TSRST 11 /* (msecs) soft reset time */ | 47 | #define SHT15_TSRST 11 /* (msecs) soft reset time */ |
43 | 48 | ||
49 | /* Status Register Bits */ | ||
50 | #define SHT15_STATUS_LOW_RESOLUTION 0x01 | ||
51 | #define SHT15_STATUS_NO_OTP_RELOAD 0x02 | ||
52 | #define SHT15_STATUS_HEATER 0x04 | ||
53 | #define SHT15_STATUS_LOW_BATTERY 0x40 | ||
54 | |||
44 | /* Actions the driver may be doing */ | 55 | /* Actions the driver may be doing */ |
45 | enum sht15_state { | 56 | enum sht15_state { |
46 | SHT15_READING_NOTHING, | 57 | SHT15_READING_NOTHING, |
@@ -74,9 +85,12 @@ static const struct sht15_temppair temppoints[] = { | |||
74 | * @wait_queue: wait queue for getting values from device. | 85 | * @wait_queue: wait queue for getting values from device. |
75 | * @val_temp: last temperature value read from device. | 86 | * @val_temp: last temperature value read from device. |
76 | * @val_humid: last humidity value read from device. | 87 | * @val_humid: last humidity value read from device. |
88 | * @val_status: last status register value read from device. | ||
77 | * @state: state identifying the action the driver is doing. | 89 | * @state: state identifying the action the driver is doing. |
78 | * @measurements_valid: are the current stored measures valid (start condition). | 90 | * @measurements_valid: are the current stored measures valid (start condition). |
91 | * @status_valid: is the current stored status valid (start condition). | ||
79 | * @last_measurement: time of last measure. | 92 | * @last_measurement: time of last measure. |
93 | * @last_status: time of last status reading. | ||
80 | * @read_lock: mutex to ensure only one read in progress at a time. | 94 | * @read_lock: mutex to ensure only one read in progress at a time. |
81 | * @dev: associate device structure. | 95 | * @dev: associate device structure. |
82 | * @hwmon_dev: device associated with hwmon subsystem. | 96 | * @hwmon_dev: device associated with hwmon subsystem. |
@@ -97,9 +111,12 @@ struct sht15_data { | |||
97 | wait_queue_head_t wait_queue; | 111 | wait_queue_head_t wait_queue; |
98 | uint16_t val_temp; | 112 | uint16_t val_temp; |
99 | uint16_t val_humid; | 113 | uint16_t val_humid; |
114 | u8 val_status; | ||
100 | enum sht15_state state; | 115 | enum sht15_state state; |
101 | bool measurements_valid; | 116 | bool measurements_valid; |
117 | bool status_valid; | ||
102 | unsigned long last_measurement; | 118 | unsigned long last_measurement; |
119 | unsigned long last_status; | ||
103 | struct mutex read_lock; | 120 | struct mutex read_lock; |
104 | struct device *dev; | 121 | struct device *dev; |
105 | struct device *hwmon_dev; | 122 | struct device *hwmon_dev; |
@@ -244,11 +261,106 @@ static int sht15_soft_reset(struct sht15_data *data) | |||
244 | if (ret) | 261 | if (ret) |
245 | return ret; | 262 | return ret; |
246 | msleep(SHT15_TSRST); | 263 | msleep(SHT15_TSRST); |
264 | /* device resets default hardware status register value */ | ||
265 | data->val_status = 0; | ||
266 | |||
267 | return ret; | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * sht15_end_transmission() - notify device of end of transmission | ||
272 | * @data: device state. | ||
273 | * | ||
274 | * This is basically a NAK (single clock pulse, data high). | ||
275 | */ | ||
276 | static void sht15_end_transmission(struct sht15_data *data) | ||
277 | { | ||
278 | gpio_direction_output(data->pdata->gpio_data, 1); | ||
279 | ndelay(SHT15_TSU); | ||
280 | gpio_set_value(data->pdata->gpio_sck, 1); | ||
281 | ndelay(SHT15_TSCKH); | ||
282 | gpio_set_value(data->pdata->gpio_sck, 0); | ||
283 | ndelay(SHT15_TSCKL); | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * sht15_read_byte() - Read a byte back from the device | ||
288 | * @data: device state. | ||
289 | */ | ||
290 | static u8 sht15_read_byte(struct sht15_data *data) | ||
291 | { | ||
292 | int i; | ||
293 | u8 byte = 0; | ||
294 | |||
295 | for (i = 0; i < 8; ++i) { | ||
296 | byte <<= 1; | ||
297 | gpio_set_value(data->pdata->gpio_sck, 1); | ||
298 | ndelay(SHT15_TSCKH); | ||
299 | byte |= !!gpio_get_value(data->pdata->gpio_data); | ||
300 | gpio_set_value(data->pdata->gpio_sck, 0); | ||
301 | ndelay(SHT15_TSCKL); | ||
302 | } | ||
303 | return byte; | ||
304 | } | ||
305 | |||
306 | /** | ||
307 | * sht15_send_status() - write the status register byte | ||
308 | * @data: sht15 specific data. | ||
309 | * @status: the byte to set the status register with. | ||
310 | * | ||
311 | * As described in figure 14 and table 5 of the datasheet. | ||
312 | */ | ||
313 | static int sht15_send_status(struct sht15_data *data, u8 status) | ||
314 | { | ||
315 | int ret; | ||
316 | |||
317 | ret = sht15_send_cmd(data, SHT15_WRITE_STATUS); | ||
318 | if (ret) | ||
319 | return ret; | ||
320 | gpio_direction_output(data->pdata->gpio_data, 1); | ||
321 | ndelay(SHT15_TSU); | ||
322 | sht15_send_byte(data, status); | ||
323 | ret = sht15_wait_for_response(data); | ||
324 | if (ret) | ||
325 | return ret; | ||
247 | 326 | ||
327 | data->val_status = status; | ||
248 | return 0; | 328 | return 0; |
249 | } | 329 | } |
250 | 330 | ||
251 | /** | 331 | /** |
332 | * sht15_update_status() - get updated status register from device if too old | ||
333 | * @data: device instance specific data. | ||
334 | * | ||
335 | * As described in figure 15 and table 5 of the datasheet. | ||
336 | */ | ||
337 | static int sht15_update_status(struct sht15_data *data) | ||
338 | { | ||
339 | int ret = 0; | ||
340 | u8 status; | ||
341 | int timeout = HZ; | ||
342 | |||
343 | mutex_lock(&data->read_lock); | ||
344 | if (time_after(jiffies, data->last_status + timeout) | ||
345 | || !data->status_valid) { | ||
346 | ret = sht15_send_cmd(data, SHT15_READ_STATUS); | ||
347 | if (ret) | ||
348 | goto error_ret; | ||
349 | status = sht15_read_byte(data); | ||
350 | |||
351 | sht15_end_transmission(data); | ||
352 | |||
353 | data->val_status = status; | ||
354 | data->status_valid = true; | ||
355 | data->last_status = jiffies; | ||
356 | } | ||
357 | error_ret: | ||
358 | mutex_unlock(&data->read_lock); | ||
359 | |||
360 | return ret; | ||
361 | } | ||
362 | |||
363 | /** | ||
252 | * sht15_measurement() - get a new value from device | 364 | * sht15_measurement() - get a new value from device |
253 | * @data: device instance specific data | 365 | * @data: device instance specific data |
254 | * @command: command sent to request value | 366 | * @command: command sent to request value |
@@ -324,6 +436,7 @@ error_ret: | |||
324 | static inline int sht15_calc_temp(struct sht15_data *data) | 436 | static inline int sht15_calc_temp(struct sht15_data *data) |
325 | { | 437 | { |
326 | int d1 = temppoints[0].d1; | 438 | int d1 = temppoints[0].d1; |
439 | int d2 = (data->val_status & SHT15_STATUS_LOW_RESOLUTION) ? 40 : 10; | ||
327 | int i; | 440 | int i; |
328 | 441 | ||
329 | for (i = ARRAY_SIZE(temppoints) - 1; i > 0; i--) | 442 | for (i = ARRAY_SIZE(temppoints) - 1; i > 0; i--) |
@@ -336,7 +449,7 @@ static inline int sht15_calc_temp(struct sht15_data *data) | |||
336 | break; | 449 | break; |
337 | } | 450 | } |
338 | 451 | ||
339 | return data->val_temp * 10 + d1; | 452 | return data->val_temp * d2 + d1; |
340 | } | 453 | } |
341 | 454 | ||
342 | /** | 455 | /** |
@@ -353,19 +466,86 @@ static inline int sht15_calc_humid(struct sht15_data *data) | |||
353 | { | 466 | { |
354 | int rh_linear; /* milli percent */ | 467 | int rh_linear; /* milli percent */ |
355 | int temp = sht15_calc_temp(data); | 468 | int temp = sht15_calc_temp(data); |
356 | 469 | int c2, c3; | |
470 | int t2; | ||
357 | const int c1 = -4; | 471 | const int c1 = -4; |
358 | const int c2 = 40500; /* x 10 ^ -6 */ | 472 | |
359 | const int c3 = -28; /* x 10 ^ -7 */ | 473 | if (data->val_status & SHT15_STATUS_LOW_RESOLUTION) { |
474 | c2 = 648000; /* x 10 ^ -6 */ | ||
475 | c3 = -7200; /* x 10 ^ -7 */ | ||
476 | t2 = 1280; | ||
477 | } else { | ||
478 | c2 = 40500; /* x 10 ^ -6 */ | ||
479 | c3 = -28; /* x 10 ^ -7 */ | ||
480 | t2 = 80; | ||
481 | } | ||
360 | 482 | ||
361 | rh_linear = c1 * 1000 | 483 | rh_linear = c1 * 1000 |
362 | + c2 * data->val_humid / 1000 | 484 | + c2 * data->val_humid / 1000 |
363 | + (data->val_humid * data->val_humid * c3) / 10000; | 485 | + (data->val_humid * data->val_humid * c3) / 10000; |
364 | return (temp - 25000) * (10000 + 80 * data->val_humid) | 486 | return (temp - 25000) * (10000 + t2 * data->val_humid) |
365 | / 1000000 + rh_linear; | 487 | / 1000000 + rh_linear; |
366 | } | 488 | } |
367 | 489 | ||
368 | /** | 490 | /** |
491 | * sht15_show_status() - show status information in sysfs | ||
492 | * @dev: device. | ||
493 | * @attr: device attribute. | ||
494 | * @buf: sysfs buffer where information is written to. | ||
495 | * | ||
496 | * Will be called on read access to temp1_fault, humidity1_fault | ||
497 | * and heater_enable sysfs attributes. | ||
498 | * Returns number of bytes written into buffer, negative errno on error. | ||
499 | */ | ||
500 | static ssize_t sht15_show_status(struct device *dev, | ||
501 | struct device_attribute *attr, | ||
502 | char *buf) | ||
503 | { | ||
504 | int ret; | ||
505 | struct sht15_data *data = dev_get_drvdata(dev); | ||
506 | u8 bit = to_sensor_dev_attr(attr)->index; | ||
507 | |||
508 | ret = sht15_update_status(data); | ||
509 | |||
510 | return ret ? ret : sprintf(buf, "%d\n", !!(data->val_status & bit)); | ||
511 | } | ||
512 | |||
513 | /** | ||
514 | * sht15_store_heater() - change heater state via sysfs | ||
515 | * @dev: device. | ||
516 | * @attr: device attribute. | ||
517 | * @buf: sysfs buffer to read the new heater state from. | ||
518 | * @count: length of the data. | ||
519 | * | ||
520 | * Will be called on read access to heater_enable sysfs attribute. | ||
521 | * Returns number of bytes actually decoded, negative errno on error. | ||
522 | */ | ||
523 | static ssize_t sht15_store_heater(struct device *dev, | ||
524 | struct device_attribute *attr, | ||
525 | const char *buf, size_t count) | ||
526 | { | ||
527 | int ret; | ||
528 | struct sht15_data *data = dev_get_drvdata(dev); | ||
529 | long value; | ||
530 | u8 status; | ||
531 | |||
532 | if (strict_strtol(buf, 10, &value)) | ||
533 | return -EINVAL; | ||
534 | |||
535 | mutex_lock(&data->read_lock); | ||
536 | status = data->val_status & 0x07; | ||
537 | if (!!value) | ||
538 | status |= SHT15_STATUS_HEATER; | ||
539 | else | ||
540 | status &= ~SHT15_STATUS_HEATER; | ||
541 | |||
542 | ret = sht15_send_status(data, status); | ||
543 | mutex_unlock(&data->read_lock); | ||
544 | |||
545 | return ret ? ret : count; | ||
546 | } | ||
547 | |||
548 | /** | ||
369 | * sht15_show_temp() - show temperature measurement value in sysfs | 549 | * sht15_show_temp() - show temperature measurement value in sysfs |
370 | * @dev: device. | 550 | * @dev: device. |
371 | * @attr: device attribute. | 551 | * @attr: device attribute. |
@@ -407,7 +587,6 @@ static ssize_t sht15_show_humidity(struct device *dev, | |||
407 | ret = sht15_update_measurements(data); | 587 | ret = sht15_update_measurements(data); |
408 | 588 | ||
409 | return ret ? ret : sprintf(buf, "%d\n", sht15_calc_humid(data)); | 589 | return ret ? ret : sprintf(buf, "%d\n", sht15_calc_humid(data)); |
410 | |||
411 | } | 590 | } |
412 | 591 | ||
413 | static ssize_t show_name(struct device *dev, | 592 | static ssize_t show_name(struct device *dev, |
@@ -422,10 +601,19 @@ static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, | |||
422 | sht15_show_temp, NULL, 0); | 601 | sht15_show_temp, NULL, 0); |
423 | static SENSOR_DEVICE_ATTR(humidity1_input, S_IRUGO, | 602 | static SENSOR_DEVICE_ATTR(humidity1_input, S_IRUGO, |
424 | sht15_show_humidity, NULL, 0); | 603 | sht15_show_humidity, NULL, 0); |
604 | static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, sht15_show_status, NULL, | ||
605 | SHT15_STATUS_LOW_BATTERY); | ||
606 | static SENSOR_DEVICE_ATTR(humidity1_fault, S_IRUGO, sht15_show_status, NULL, | ||
607 | SHT15_STATUS_LOW_BATTERY); | ||
608 | static SENSOR_DEVICE_ATTR(heater_enable, S_IRUGO | S_IWUSR, sht15_show_status, | ||
609 | sht15_store_heater, SHT15_STATUS_HEATER); | ||
425 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 610 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); |
426 | static struct attribute *sht15_attrs[] = { | 611 | static struct attribute *sht15_attrs[] = { |
427 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 612 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
428 | &sensor_dev_attr_humidity1_input.dev_attr.attr, | 613 | &sensor_dev_attr_humidity1_input.dev_attr.attr, |
614 | &sensor_dev_attr_temp1_fault.dev_attr.attr, | ||
615 | &sensor_dev_attr_humidity1_fault.dev_attr.attr, | ||
616 | &sensor_dev_attr_heater_enable.dev_attr.attr, | ||
429 | &dev_attr_name.attr, | 617 | &dev_attr_name.attr, |
430 | NULL, | 618 | NULL, |
431 | }; | 619 | }; |
@@ -466,25 +654,8 @@ static void sht15_ack(struct sht15_data *data) | |||
466 | gpio_direction_input(data->pdata->gpio_data); | 654 | gpio_direction_input(data->pdata->gpio_data); |
467 | } | 655 | } |
468 | 656 | ||
469 | /** | ||
470 | * sht15_end_transmission() - notify device of end of transmission | ||
471 | * @data: device state | ||
472 | * | ||
473 | * This is basically a NAK. (single clock pulse, data high) | ||
474 | */ | ||
475 | static void sht15_end_transmission(struct sht15_data *data) | ||
476 | { | ||
477 | gpio_direction_output(data->pdata->gpio_data, 1); | ||
478 | ndelay(SHT15_TSU); | ||
479 | gpio_set_value(data->pdata->gpio_sck, 1); | ||
480 | ndelay(SHT15_TSCKH); | ||
481 | gpio_set_value(data->pdata->gpio_sck, 0); | ||
482 | ndelay(SHT15_TSCKL); | ||
483 | } | ||
484 | |||
485 | static void sht15_bh_read_data(struct work_struct *work_s) | 657 | static void sht15_bh_read_data(struct work_struct *work_s) |
486 | { | 658 | { |
487 | int i; | ||
488 | uint16_t val = 0; | 659 | uint16_t val = 0; |
489 | struct sht15_data *data | 660 | struct sht15_data *data |
490 | = container_of(work_s, struct sht15_data, | 661 | = container_of(work_s, struct sht15_data, |
@@ -505,16 +676,10 @@ static void sht15_bh_read_data(struct work_struct *work_s) | |||
505 | } | 676 | } |
506 | 677 | ||
507 | /* Read the data back from the device */ | 678 | /* Read the data back from the device */ |
508 | for (i = 0; i < 16; ++i) { | 679 | val = sht15_read_byte(data); |
509 | val <<= 1; | 680 | val <<= 8; |
510 | gpio_set_value(data->pdata->gpio_sck, 1); | 681 | sht15_ack(data); |
511 | ndelay(SHT15_TSCKH); | 682 | val |= sht15_read_byte(data); |
512 | val |= !!gpio_get_value(data->pdata->gpio_data); | ||
513 | gpio_set_value(data->pdata->gpio_sck, 0); | ||
514 | ndelay(SHT15_TSCKL); | ||
515 | if (i == 7) | ||
516 | sht15_ack(data); | ||
517 | } | ||
518 | 683 | ||
519 | /* Tell the device we are done */ | 684 | /* Tell the device we are done */ |
520 | sht15_end_transmission(data); | 685 | sht15_end_transmission(data); |
@@ -568,6 +733,7 @@ static int __devinit sht15_probe(struct platform_device *pdev) | |||
568 | { | 733 | { |
569 | int ret = 0; | 734 | int ret = 0; |
570 | struct sht15_data *data = kzalloc(sizeof(*data), GFP_KERNEL); | 735 | struct sht15_data *data = kzalloc(sizeof(*data), GFP_KERNEL); |
736 | u8 status = 0; | ||
571 | 737 | ||
572 | if (!data) { | 738 | if (!data) { |
573 | ret = -ENOMEM; | 739 | ret = -ENOMEM; |
@@ -588,6 +754,10 @@ static int __devinit sht15_probe(struct platform_device *pdev) | |||
588 | } | 754 | } |
589 | data->pdata = pdev->dev.platform_data; | 755 | data->pdata = pdev->dev.platform_data; |
590 | data->supply_uV = data->pdata->supply_mv * 1000; | 756 | data->supply_uV = data->pdata->supply_mv * 1000; |
757 | if (data->pdata->no_otp_reload) | ||
758 | status |= SHT15_STATUS_NO_OTP_RELOAD; | ||
759 | if (data->pdata->low_resolution) | ||
760 | status |= SHT15_STATUS_LOW_RESOLUTION; | ||
591 | 761 | ||
592 | /* | 762 | /* |
593 | * If a regulator is available, | 763 | * If a regulator is available, |
@@ -646,6 +816,13 @@ static int __devinit sht15_probe(struct platform_device *pdev) | |||
646 | if (ret) | 816 | if (ret) |
647 | goto err_release_irq; | 817 | goto err_release_irq; |
648 | 818 | ||
819 | /* write status with platform data options */ | ||
820 | if (status) { | ||
821 | ret = sht15_send_status(data, status); | ||
822 | if (ret) | ||
823 | goto err_release_irq; | ||
824 | } | ||
825 | |||
649 | ret = sysfs_create_group(&pdev->dev.kobj, &sht15_attr_group); | 826 | ret = sysfs_create_group(&pdev->dev.kobj, &sht15_attr_group); |
650 | if (ret) { | 827 | if (ret) { |
651 | dev_err(&pdev->dev, "sysfs create failed\n"); | 828 | dev_err(&pdev->dev, "sysfs create failed\n"); |
@@ -689,6 +866,10 @@ static int __devexit sht15_remove(struct platform_device *pdev) | |||
689 | * prevent new ones beginning | 866 | * prevent new ones beginning |
690 | */ | 867 | */ |
691 | mutex_lock(&data->read_lock); | 868 | mutex_lock(&data->read_lock); |
869 | if (sht15_soft_reset(data)) { | ||
870 | mutex_unlock(&data->read_lock); | ||
871 | return -EFAULT; | ||
872 | } | ||
692 | hwmon_device_unregister(data->hwmon_dev); | 873 | hwmon_device_unregister(data->hwmon_dev); |
693 | sysfs_remove_group(&pdev->dev.kobj, &sht15_attr_group); | 874 | sysfs_remove_group(&pdev->dev.kobj, &sht15_attr_group); |
694 | if (!IS_ERR(data->reg)) { | 875 | if (!IS_ERR(data->reg)) { |
diff --git a/include/linux/sht15.h b/include/linux/sht15.h index 1e302146bdc8..d836ca617323 100644 --- a/include/linux/sht15.h +++ b/include/linux/sht15.h | |||
@@ -19,10 +19,14 @@ | |||
19 | * @gpio_sck: no. of gpio to which the data clock is connected. | 19 | * @gpio_sck: no. of gpio to which the data clock is connected. |
20 | * @supply_mv: supply voltage in mv. Overridden by regulator if | 20 | * @supply_mv: supply voltage in mv. Overridden by regulator if |
21 | * available. | 21 | * available. |
22 | * @no_otp_reload: flag to indicate no reload from OTP. | ||
23 | * @low_resolution: flag to indicate the temp/humidity resolution to use. | ||
22 | */ | 24 | */ |
23 | struct sht15_platform_data { | 25 | struct sht15_platform_data { |
24 | int gpio_data; | 26 | int gpio_data; |
25 | int gpio_sck; | 27 | int gpio_sck; |
26 | int supply_mv; | 28 | int supply_mv; |
29 | bool no_otp_reload; | ||
30 | bool low_resolution; | ||
27 | }; | 31 | }; |
28 | 32 | ||