Lines Matching +full:temp +full:- +full:sensor
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * abituguru.c Copyright (c) 2005-2006 Hans de Goede <hdegoede@redhat.com>
6 * This driver supports the sensor part of the first and second revision of
23 #include <linux/hwmon-sysfs.h>
29 #define ABIT_UGURU_SENSOR_BANK1 0x21 /* 16x volt and temp */
32 /* max nr of sensors in bank1, a bank1 sensor can be in, temp or nc */
42 /* uGuru sensor bank 1 flags */ /* Alarm if: */
43 #define ABIT_UGURU_TEMP_HIGH_ALARM_ENABLE 0x01 /* temp over warn */
46 #define ABIT_UGURU_TEMP_HIGH_ALARM_FLAG 0x10 /* temp is over warn */
49 /* uGuru sensor bank 2 flags */ /* Alarm if: */
51 /* uGuru sensor bank common flags */
58 /* Bank1 sensor types */
64 * of the time it will reach this status within 30 - 90 ISA reads, and thus we
99 * sum of strlen of: temp??_input\0, temp??_max\0, temp??_crit\0,
100 * temp??_alarm\0, temp??_alarm_enable\0, temp??_beep\0, temp??_shutdown\0
125 /* Two i/o-ports are used by uGuru */
139 /* in (Volt) sensors go up to 3494 mV, temp to 255000 millidegrees Celsius */
143 * correspond to 300-3000 RPM
165 static int bank1_types[ABIT_UGURU_MAX_BANK1_SENSORS] = { -1, -1, -1, -1, -1,
166 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
169 " -1 autodetect\n"
170 " 0 volt sensor\n"
171 " 1 temp sensor\n"
185 MODULE_PARM_DESC(verbose, "How verbose should the driver be? (0-3):\n"
211 * of a sensor is a volt or a temp sensor, for bank2 and the pwms its
212 * easier todo things the same way. For in sensors we have 9 (temp 7)
213 * sysfs entries per sensor, for bank2 and pwms 6.
222 /* number of and addresses of [0] in, [1] temp sensors */
227 * This array holds 3 entries per sensor for the bank 1 sensor settings
228 * (flags, min, max for voltage / flags, warn, shutdown for temp).
232 * Maximum value for each sensor used for scaling in mV/millidegrees
259 while (inb_p(data->addr + ABIT_UGURU_DATA) != state) { in abituguru_wait()
260 timeout--; in abituguru_wait()
262 return -EBUSY; in abituguru_wait()
278 if (data->uguru_ready) in abituguru_ready()
282 outb(0x00, data->addr + ABIT_UGURU_DATA); in abituguru_ready()
288 return -EIO; in abituguru_ready()
292 while (inb_p(data->addr + ABIT_UGURU_CMD) != 0xAC) { in abituguru_ready()
293 timeout--; in abituguru_ready()
297 return -EIO; in abituguru_ready()
307 while (inb_p(data->addr + ABIT_UGURU_DATA) != ABIT_UGURU_STATUS_INPUT) { in abituguru_ready()
308 timeout--; in abituguru_ready()
312 return -EIO; in abituguru_ready()
317 data->uguru_ready = 1; in abituguru_ready()
322 * Send the bank and then sensor address to the uGuru for the next read/write
342 return -EIO; in abituguru_send_address()
343 outb(bank_addr, data->addr + ABIT_UGURU_DATA); in abituguru_send_address()
344 data->uguru_ready = 0; in abituguru_send_address()
348 * and send the sensor addr in abituguru_send_address()
357 retries--; in abituguru_send_address()
364 return -EBUSY; in abituguru_send_address()
366 outb(sensor_addr, data->addr + ABIT_UGURU_CMD); in abituguru_send_address()
372 * Read count bytes from sensor sensor_addr in bank bank_addr and store the
390 "read state (bank: %d, sensor: %d)\n", in abituguru_read()
394 buf[i] = inb(data->addr + ABIT_UGURU_CMD); in abituguru_read()
404 * Write count bytes from buf to sensor sensor_addr in bank bank_addr, the send
426 "write state (bank: %d, sensor: %d)\n", in abituguru_write()
430 outb(buf[i], data->addr + ABIT_UGURU_CMD); in abituguru_write()
440 "after write (bank: %d, sensor: %d)\n", (int)bank_addr, in abituguru_write()
442 return -EIO; in abituguru_write()
446 while (inb_p(data->addr + ABIT_UGURU_CMD) != 0xAC) { in abituguru_write()
447 timeout--; in abituguru_write()
450 "write (bank: %d, sensor: %d)\n", in abituguru_write()
452 return -EIO; in abituguru_write()
464 * Detect sensor type. Temp and Volt sensors are enabled with
466 * This enables us to test what kind of sensor we're dealing with.
468 * alarm for sensor type X and then enabling the sensor as sensor type
469 * X, if we then get an alarm it is a sensor of type X.
476 int i, ret = -ENODEV; /* error is the most common used retval :| */ in abituguru_detect_bank1_sensor_type()
481 ABIT_UGURU_DEBUG(2, "assuming sensor type %d for bank1 sensor " in abituguru_detect_bank1_sensor_type()
487 /* First read the sensor and the current settings */ in abituguru_detect_bank1_sensor_type()
490 return -ENODEV; in abituguru_detect_bank1_sensor_type()
492 /* Test val is sane / usable for sensor type detection. */ in abituguru_detect_bank1_sensor_type()
494 pr_warn("bank1-sensor: %d reading (%d) too close to limits, " in abituguru_detect_bank1_sensor_type()
495 "unable to determine sensor type, skipping sensor\n", in abituguru_detect_bank1_sensor_type()
498 * assume no sensor is there for sensors for which we can't in abituguru_detect_bank1_sensor_type()
499 * determine the sensor type because their reading is too close in abituguru_detect_bank1_sensor_type()
500 * to their limits, this usually means no sensor is there. in abituguru_detect_bank1_sensor_type()
505 ABIT_UGURU_DEBUG(2, "testing bank1 sensor %d\n", (int)sensor_addr); in abituguru_detect_bank1_sensor_type()
507 * Volt sensor test, enable volt low alarm, set min value ridiculously in abituguru_detect_bank1_sensor_type()
509 * sensor this should always give us an alarm. in abituguru_detect_bank1_sensor_type()
542 ABIT_UGURU_DEBUG(2, " found volt sensor\n"); in abituguru_detect_bank1_sensor_type()
547 "sensor test, but volt range flag not set\n"); in abituguru_detect_bank1_sensor_type()
549 ABIT_UGURU_DEBUG(2, " alarm not raised during volt sensor " in abituguru_detect_bank1_sensor_type()
553 * Temp sensor test, enable sensor as a temp sensor, set beep value in abituguru_detect_bank1_sensor_type()
555 * If its a temp sensor this should always give us an alarm. in abituguru_detect_bank1_sensor_type()
565 * and raise a temp alarm in abituguru_detect_bank1_sensor_type()
569 /* Check for alarm and check the alarm is a temp high alarm. */ in abituguru_detect_bank1_sensor_type()
579 ABIT_UGURU_DEBUG(2, " found temp sensor\n"); in abituguru_detect_bank1_sensor_type()
583 ABIT_UGURU_DEBUG(2, " alarm raised during temp " in abituguru_detect_bank1_sensor_type()
584 "sensor test, but temp high flag not set\n"); in abituguru_detect_bank1_sensor_type()
586 ABIT_UGURU_DEBUG(2, " alarm not raised during temp sensor " in abituguru_detect_bank1_sensor_type()
593 * reported that some BIOS-es hang when entering the uGuru menu with in abituguru_detect_bank1_sensor_type()
598 sensor_addr, data->bank1_settings[sensor_addr], in abituguru_detect_bank1_sensor_type()
604 return -ENODEV; in abituguru_detect_bank1_sensor_type()
612 * the user the possibility to change settings for non-existent sensors / pwm.
623 * Notice these 2 tests are non destructive iow read-only tests, otherwise
634 data->bank2_sensors = fan_sensors; in abituguru_detect_no_bank2_sensors()
637 (int)data->bank2_sensors); in abituguru_detect_no_bank2_sensors()
645 * -0x80 enable shutdown in abituguru_detect_no_bank2_sensors()
646 * -0x08 enable beep in abituguru_detect_no_bank2_sensors()
647 * -0x01 enable alarm in abituguru_detect_no_bank2_sensors()
651 if (data->bank2_settings[i][0] & ~0xC9) { in abituguru_detect_no_bank2_sensors()
652 ABIT_UGURU_DEBUG(2, " bank2 sensor %d does not seem " in abituguru_detect_no_bank2_sensors()
653 "to be a fan sensor: settings[0] = %02X\n", in abituguru_detect_no_bank2_sensors()
654 i, (unsigned int)data->bank2_settings[i][0]); in abituguru_detect_no_bank2_sensors()
659 if (data->bank2_settings[i][1] < in abituguru_detect_no_bank2_sensors()
661 ABIT_UGURU_DEBUG(2, " bank2 sensor %d does not seem " in abituguru_detect_no_bank2_sensors()
662 "to be a fan sensor: the threshold (%d) is " in abituguru_detect_no_bank2_sensors()
664 (int)data->bank2_settings[i][1], in abituguru_detect_no_bank2_sensors()
668 if (data->bank2_settings[i][1] > in abituguru_detect_no_bank2_sensors()
670 ABIT_UGURU_DEBUG(2, " bank2 sensor %d does not seem " in abituguru_detect_no_bank2_sensors()
671 "to be a fan sensor: the threshold (%d) is " in abituguru_detect_no_bank2_sensors()
673 (int)data->bank2_settings[i][1], in abituguru_detect_no_bank2_sensors()
679 data->bank2_sensors = i; in abituguru_detect_no_bank2_sensors()
681 (int)data->bank2_sensors); in abituguru_detect_no_bank2_sensors()
690 data->pwms = pwms; in abituguru_detect_no_pwms()
692 "\"pwms\" module param\n", (int)data->pwms); in abituguru_detect_no_pwms()
700 * nibble is which temp sensor to use, in abituguru_detect_no_pwms()
703 if (data->pwm_settings[i][0] & ~0x8F) { in abituguru_detect_no_pwms()
706 i, (unsigned int)data->pwm_settings[i][0]); in abituguru_detect_no_pwms()
711 * the low nibble must correspond to one of the temp sensors in abituguru_detect_no_pwms()
714 for (j = 0; j < data->bank1_sensors[ABIT_UGURU_TEMP_SENSOR]; in abituguru_detect_no_pwms()
716 if (data->bank1_address[ABIT_UGURU_TEMP_SENSOR][j] == in abituguru_detect_no_pwms()
717 (data->pwm_settings[i][0] & 0x0F)) in abituguru_detect_no_pwms()
720 if (j == data->bank1_sensors[ABIT_UGURU_TEMP_SENSOR]) { in abituguru_detect_no_pwms()
722 "to be a pwm channel: %d is not a valid temp " in abituguru_detect_no_pwms()
723 "sensor address\n", i, in abituguru_detect_no_pwms()
724 data->pwm_settings[i][0] & 0x0F); in abituguru_detect_no_pwms()
736 if (data->pwm_settings[i][j] < min) { in abituguru_detect_no_pwms()
741 (int)data->pwm_settings[i][j], in abituguru_detect_no_pwms()
745 if (data->pwm_settings[i][j] > abituguru_pwm_max[j]) { in abituguru_detect_no_pwms()
750 (int)data->pwm_settings[i][j], in abituguru_detect_no_pwms()
756 /* check that min temp < max temp and min pwm < max pwm */ in abituguru_detect_no_pwms()
757 if (data->pwm_settings[i][1] >= data->pwm_settings[i][2]) { in abituguru_detect_no_pwms()
761 (int)data->pwm_settings[i][1], in abituguru_detect_no_pwms()
762 (int)data->pwm_settings[i][2]); in abituguru_detect_no_pwms()
765 if (data->pwm_settings[i][3] >= data->pwm_settings[i][4]) { in abituguru_detect_no_pwms()
767 "to be a pwm channel: min temp (%d) >= " in abituguru_detect_no_pwms()
768 "max temp (%d)\n", i, in abituguru_detect_no_pwms()
769 (int)data->pwm_settings[i][3], in abituguru_detect_no_pwms()
770 (int)data->pwm_settings[i][4]); in abituguru_detect_no_pwms()
776 data->pwms = i; in abituguru_detect_no_pwms()
777 ABIT_UGURU_DEBUG(2, " found: %d PWM outputs\n", (int)data->pwms); in abituguru_detect_no_pwms()
782 * sensor_device_attribute_2->index: sensor address/offset in the bank
783 * sensor_device_attribute_2->nr: register offset, bitmask or NA.
793 return -EIO; in show_bank1_value()
794 return sprintf(buf, "%d\n", (data->bank1_value[attr->index] * in show_bank1_value()
795 data->bank1_max_value[attr->index] + 128) / 255); in show_bank1_value()
804 (data->bank1_settings[attr->index][attr->nr] * in show_bank1_setting()
805 data->bank1_max_value[attr->index] + 128) / 255); in show_bank1_setting()
814 return -EIO; in show_bank2_value()
815 return sprintf(buf, "%d\n", (data->bank2_value[attr->index] * in show_bank2_value()
825 (data->bank2_settings[attr->index][attr->nr] * in show_bank2_setting()
842 val = (val * 255 + data->bank1_max_value[attr->index] / 2) / in store_bank1_setting()
843 data->bank1_max_value[attr->index]; in store_bank1_setting()
845 return -EINVAL; in store_bank1_setting()
847 mutex_lock(&data->update_lock); in store_bank1_setting()
848 if (data->bank1_settings[attr->index][attr->nr] != val) { in store_bank1_setting()
849 u8 orig_val = data->bank1_settings[attr->index][attr->nr]; in store_bank1_setting()
850 data->bank1_settings[attr->index][attr->nr] = val; in store_bank1_setting()
852 attr->index, data->bank1_settings[attr->index], in store_bank1_setting()
853 3) <= attr->nr) { in store_bank1_setting()
854 data->bank1_settings[attr->index][attr->nr] = orig_val; in store_bank1_setting()
855 ret = -EIO; in store_bank1_setting()
858 mutex_unlock(&data->update_lock); in store_bank1_setting()
880 return -EINVAL; in store_bank2_setting()
882 mutex_lock(&data->update_lock); in store_bank2_setting()
883 if (data->bank2_settings[attr->index][attr->nr] != val) { in store_bank2_setting()
884 u8 orig_val = data->bank2_settings[attr->index][attr->nr]; in store_bank2_setting()
885 data->bank2_settings[attr->index][attr->nr] = val; in store_bank2_setting()
887 attr->index, data->bank2_settings[attr->index], in store_bank2_setting()
888 2) <= attr->nr) { in store_bank2_setting()
889 data->bank2_settings[attr->index][attr->nr] = orig_val; in store_bank2_setting()
890 ret = -EIO; in store_bank2_setting()
893 mutex_unlock(&data->update_lock); in store_bank2_setting()
903 return -EIO; in show_bank1_alarm()
905 * See if the alarm bit for this sensor is set, and if the in show_bank1_alarm()
908 * readonly bits in the settings part of the relevant sensor. in show_bank1_alarm()
909 * The bitmask of the type is passed to us in attr->nr. in show_bank1_alarm()
911 if ((data->alarms[attr->index / 8] & (0x01 << (attr->index % 8))) && in show_bank1_alarm()
912 (data->bank1_settings[attr->index][0] & attr->nr)) in show_bank1_alarm()
924 return -EIO; in show_bank2_alarm()
925 if (data->alarms[2] & (0x01 << attr->index)) in show_bank2_alarm()
936 if (data->bank1_settings[attr->index][0] & attr->nr) in show_bank1_mask()
947 if (data->bank2_settings[attr->index][0] & attr->nr) in show_bank2_mask()
967 mutex_lock(&data->update_lock); in store_bank1_mask()
968 orig_val = data->bank1_settings[attr->index][0]; in store_bank1_mask()
971 data->bank1_settings[attr->index][0] |= attr->nr; in store_bank1_mask()
973 data->bank1_settings[attr->index][0] &= ~attr->nr; in store_bank1_mask()
975 if ((data->bank1_settings[attr->index][0] != orig_val) && in store_bank1_mask()
977 ABIT_UGURU_SENSOR_BANK1 + 2, attr->index, in store_bank1_mask()
978 data->bank1_settings[attr->index], 3) < 1)) { in store_bank1_mask()
979 data->bank1_settings[attr->index][0] = orig_val; in store_bank1_mask()
980 ret = -EIO; in store_bank1_mask()
982 mutex_unlock(&data->update_lock); in store_bank1_mask()
1000 mutex_lock(&data->update_lock); in store_bank2_mask()
1001 orig_val = data->bank2_settings[attr->index][0]; in store_bank2_mask()
1004 data->bank2_settings[attr->index][0] |= attr->nr; in store_bank2_mask()
1006 data->bank2_settings[attr->index][0] &= ~attr->nr; in store_bank2_mask()
1008 if ((data->bank2_settings[attr->index][0] != orig_val) && in store_bank2_mask()
1010 ABIT_UGURU_SENSOR_BANK2 + 2, attr->index, in store_bank2_mask()
1011 data->bank2_settings[attr->index], 2) < 1)) { in store_bank2_mask()
1012 data->bank2_settings[attr->index][0] = orig_val; in store_bank2_mask()
1013 ret = -EIO; in store_bank2_mask()
1015 mutex_unlock(&data->update_lock); in store_bank2_mask()
1025 return sprintf(buf, "%d\n", data->pwm_settings[attr->index][attr->nr] * in show_pwm_setting()
1026 abituguru_pwm_settings_multiplier[attr->nr]); in show_pwm_setting()
1043 val = (val + abituguru_pwm_settings_multiplier[attr->nr] / 2) / in store_pwm_setting()
1044 abituguru_pwm_settings_multiplier[attr->nr]; in store_pwm_setting()
1047 if ((attr->index == 0) && ((attr->nr == 1) || (attr->nr == 2))) in store_pwm_setting()
1050 min = abituguru_pwm_min[attr->nr]; in store_pwm_setting()
1053 if (val < min || val > abituguru_pwm_max[attr->nr]) in store_pwm_setting()
1054 return -EINVAL; in store_pwm_setting()
1056 mutex_lock(&data->update_lock); in store_pwm_setting()
1058 if ((attr->nr & 1) && in store_pwm_setting()
1059 (val >= data->pwm_settings[attr->index][attr->nr + 1])) in store_pwm_setting()
1060 ret = -EINVAL; in store_pwm_setting()
1061 else if (!(attr->nr & 1) && in store_pwm_setting()
1062 (val <= data->pwm_settings[attr->index][attr->nr - 1])) in store_pwm_setting()
1063 ret = -EINVAL; in store_pwm_setting()
1064 else if (data->pwm_settings[attr->index][attr->nr] != val) { in store_pwm_setting()
1065 u8 orig_val = data->pwm_settings[attr->index][attr->nr]; in store_pwm_setting()
1066 data->pwm_settings[attr->index][attr->nr] = val; in store_pwm_setting()
1068 attr->index, data->pwm_settings[attr->index], in store_pwm_setting()
1069 5) <= attr->nr) { in store_pwm_setting()
1070 data->pwm_settings[attr->index][attr->nr] = in store_pwm_setting()
1072 ret = -EIO; in store_pwm_setting()
1075 mutex_unlock(&data->update_lock); in store_pwm_setting()
1086 * We need to walk to the temp sensor addresses to find what in show_pwm_sensor()
1087 * the userspace id of the configured temp sensor is. in show_pwm_sensor()
1089 for (i = 0; i < data->bank1_sensors[ABIT_UGURU_TEMP_SENSOR]; i++) in show_pwm_sensor()
1090 if (data->bank1_address[ABIT_UGURU_TEMP_SENSOR][i] == in show_pwm_sensor()
1091 (data->pwm_settings[attr->index][0] & 0x0F)) in show_pwm_sensor()
1094 return -ENXIO; in show_pwm_sensor()
1111 if (val == 0 || val > data->bank1_sensors[ABIT_UGURU_TEMP_SENSOR]) in store_pwm_sensor()
1112 return -EINVAL; in store_pwm_sensor()
1114 val -= 1; in store_pwm_sensor()
1116 mutex_lock(&data->update_lock); in store_pwm_sensor()
1117 orig_val = data->pwm_settings[attr->index][0]; in store_pwm_sensor()
1118 address = data->bank1_address[ABIT_UGURU_TEMP_SENSOR][val]; in store_pwm_sensor()
1119 data->pwm_settings[attr->index][0] &= 0xF0; in store_pwm_sensor()
1120 data->pwm_settings[attr->index][0] |= address; in store_pwm_sensor()
1121 if (data->pwm_settings[attr->index][0] != orig_val) { in store_pwm_sensor()
1122 if (abituguru_write(data, ABIT_UGURU_FAN_PWM + 1, attr->index, in store_pwm_sensor()
1123 data->pwm_settings[attr->index], 5) < 1) { in store_pwm_sensor()
1124 data->pwm_settings[attr->index][0] = orig_val; in store_pwm_sensor()
1125 ret = -EIO; in store_pwm_sensor()
1128 mutex_unlock(&data->update_lock); in store_pwm_sensor()
1138 if (data->pwm_settings[attr->index][0] & ABIT_UGURU_FAN_PWM_ENABLE) in show_pwm_enable()
1157 mutex_lock(&data->update_lock); in store_pwm_enable()
1158 orig_val = data->pwm_settings[attr->index][0]; in store_pwm_enable()
1161 data->pwm_settings[attr->index][0] &= in store_pwm_enable()
1165 data->pwm_settings[attr->index][0] |= ABIT_UGURU_FAN_PWM_ENABLE; in store_pwm_enable()
1168 ret = -EINVAL; in store_pwm_enable()
1170 if ((data->pwm_settings[attr->index][0] != orig_val) && in store_pwm_enable()
1172 attr->index, data->pwm_settings[attr->index], in store_pwm_enable()
1174 data->pwm_settings[attr->index][0] = orig_val; in store_pwm_enable()
1175 ret = -EIO; in store_pwm_enable()
1177 mutex_unlock(&data->update_lock); in store_pwm_enable()
1209 SENSOR_ATTR_2(temp%d_input, 0444, show_bank1_value, NULL, 0, 0),
1210 SENSOR_ATTR_2(temp%d_alarm, 0444, show_bank1_alarm, NULL,
1212 SENSOR_ATTR_2(temp%d_max, 0644, show_bank1_setting,
1214 SENSOR_ATTR_2(temp%d_crit, 0644, show_bank1_setting,
1216 SENSOR_ATTR_2(temp%d_beep, 0644, show_bank1_mask,
1218 SENSOR_ATTR_2(temp%d_shutdown, 0644, show_bank1_mask,
1220 SENSOR_ATTR_2(temp%d_alarm_enable, 0644, show_bank1_mask,
1260 int i, j, used, sysfs_names_free, sysfs_attr_i, res = -ENODEV; in abituguru_probe()
1265 * BIOS and window-appliction listing order. in abituguru_probe()
1271 data = devm_kzalloc(&pdev->dev, sizeof(struct abituguru_data), in abituguru_probe()
1274 return -ENOMEM; in abituguru_probe()
1276 data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start; in abituguru_probe()
1277 mutex_init(&data->update_lock); in abituguru_probe()
1281 if (inb_p(data->addr + ABIT_UGURU_DATA) == ABIT_UGURU_STATUS_INPUT) in abituguru_probe()
1282 data->uguru_ready = 1; in abituguru_probe()
1286 * - testread / see if one really is there. in abituguru_probe()
1287 * - make an in memory copy of all the uguru settings for future use. in abituguru_probe()
1290 data->alarms, 3, ABIT_UGURU_MAX_RETRIES) != 3) in abituguru_probe()
1295 &data->bank1_value[i], 1, in abituguru_probe()
1299 data->bank1_settings[i], 3, in abituguru_probe()
1312 &data->bank2_value[i], 1, in abituguru_probe()
1316 data->bank2_settings[i], 2, in abituguru_probe()
1322 data->pwm_settings[i], 5, in abituguru_probe()
1326 data->last_updated = jiffies; in abituguru_probe()
1328 /* Detect sensor types and fill the sysfs attr for bank1 */ in abituguru_probe()
1330 sysfs_filename = data->sysfs_names; in abituguru_probe()
1339 /* res 1 (temp) sensors have 7 sysfs entries, 0 (in) 9 */ in abituguru_probe()
1343 attr.name, data->bank1_sensors[res] + res) in abituguru_probe()
1345 data->sysfs_attr[sysfs_attr_i] = in abituguru_probe()
1347 data->sysfs_attr[sysfs_attr_i].dev_attr.attr.name = in abituguru_probe()
1349 data->sysfs_attr[sysfs_attr_i].index = probe_order[i]; in abituguru_probe()
1351 sysfs_names_free -= used; in abituguru_probe()
1354 data->bank1_max_value[probe_order[i]] = in abituguru_probe()
1356 data->bank1_address[res][data->bank1_sensors[res]] = in abituguru_probe()
1358 data->bank1_sensors[res]++; in abituguru_probe()
1362 for (i = 0; i < data->bank2_sensors; i++) { in abituguru_probe()
1367 data->sysfs_attr[sysfs_attr_i] = in abituguru_probe()
1369 data->sysfs_attr[sysfs_attr_i].dev_attr.attr.name = in abituguru_probe()
1371 data->sysfs_attr[sysfs_attr_i].index = i; in abituguru_probe()
1373 sysfs_names_free -= used; in abituguru_probe()
1379 for (i = 0; i < data->pwms; i++) { in abituguru_probe()
1384 data->sysfs_attr[sysfs_attr_i] = in abituguru_probe()
1386 data->sysfs_attr[sysfs_attr_i].dev_attr.attr.name = in abituguru_probe()
1388 data->sysfs_attr[sysfs_attr_i].index = i; in abituguru_probe()
1390 sysfs_names_free -= used; in abituguru_probe()
1398 res = -ENAMETOOLONG; in abituguru_probe()
1405 res = device_create_file(&pdev->dev, in abituguru_probe()
1406 &data->sysfs_attr[i].dev_attr); in abituguru_probe()
1411 res = device_create_file(&pdev->dev, in abituguru_probe()
1417 data->hwmon_dev = hwmon_device_register(&pdev->dev); in abituguru_probe()
1418 if (!IS_ERR(data->hwmon_dev)) in abituguru_probe()
1421 res = PTR_ERR(data->hwmon_dev); in abituguru_probe()
1423 for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++) in abituguru_probe()
1424 device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr); in abituguru_probe()
1426 device_remove_file(&pdev->dev, in abituguru_probe()
1436 hwmon_device_unregister(data->hwmon_dev); in abituguru_remove()
1437 for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++) in abituguru_remove()
1438 device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr); in abituguru_remove()
1440 device_remove_file(&pdev->dev, in abituguru_remove()
1451 mutex_lock(&data->update_lock); in abituguru_update_device()
1452 if (time_after(jiffies, data->last_updated + HZ)) { in abituguru_update_device()
1455 data->alarms, 3, 0); in abituguru_update_device()
1460 i, &data->bank1_value[i], 1, 0); in abituguru_update_device()
1464 i, data->bank1_settings[i], 3, 0); in abituguru_update_device()
1468 for (i = 0; i < data->bank2_sensors; i++) { in abituguru_update_device()
1470 &data->bank2_value[i], 1, 0); in abituguru_update_device()
1476 data->update_timeouts = 0; in abituguru_update_device()
1479 if (!success && (err == -EBUSY || err >= 0)) { in abituguru_update_device()
1481 if (data->update_timeouts < 255u) in abituguru_update_device()
1482 data->update_timeouts++; in abituguru_update_device()
1483 if (data->update_timeouts <= ABIT_UGURU_MAX_TIMEOUTS) { in abituguru_update_device()
1491 (int)data->update_timeouts); in abituguru_update_device()
1495 data->last_updated = jiffies; in abituguru_update_device()
1497 mutex_unlock(&data->update_lock); in abituguru_update_device()
1512 mutex_lock(&data->update_lock); in abituguru_suspend()
1520 if (inb_p(data->addr + ABIT_UGURU_DATA) != ABIT_UGURU_STATUS_INPUT) in abituguru_resume()
1521 data->uguru_ready = 0; in abituguru_resume()
1522 mutex_unlock(&data->update_lock); in abituguru_resume()
1562 return -ENODEV; in abituguru_detect()
1576 return -ENODEV; in abituguru_init()
1589 err = -ENOMEM; in abituguru_init()
1594 res.end = address + ABIT_UGURU_REGION_LENGTH - 1; in abituguru_init()
1626 MODULE_DESCRIPTION("Abit uGuru Sensor device");