adt7475.c (e5451c8f8330e03ad3cfa16048b4daf961af434f) adt7475.c (1d05303cc94eefee9f0de0a0e919fcc9ffd0c687)
1/*
2 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives
3 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc.
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
5 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com>
6 * Copyright (C) 2009 Jean Delvare <jdelvare@suse.de>
7 *
8 * Derived from the lm83 driver by Jean Delvare

--- 842 unchanged lines hidden (view full) ---

851
852 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
853 data->range[sattr->index]);
854
855 mutex_unlock(&data->lock);
856 return count;
857}
858
1/*
2 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives
3 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc.
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
5 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com>
6 * Copyright (C) 2009 Jean Delvare <jdelvare@suse.de>
7 *
8 * Derived from the lm83 driver by Jean Delvare

--- 842 unchanged lines hidden (view full) ---

851
852 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
853 data->range[sattr->index]);
854
855 mutex_unlock(&data->lock);
856 return count;
857}
858
859static ssize_t show_pwm_at_crit(struct device *dev,
860 struct device_attribute *devattr, char *buf)
859static ssize_t pwm_use_point2_pwm_at_crit_show(struct device *dev,
860 struct device_attribute *devattr,
861 char *buf)
861{
862 struct adt7475_data *data = adt7475_update_device(dev);
863 return sprintf(buf, "%d\n", !!(data->config4 & CONFIG4_MAXDUTY));
864}
865
862{
863 struct adt7475_data *data = adt7475_update_device(dev);
864 return sprintf(buf, "%d\n", !!(data->config4 & CONFIG4_MAXDUTY));
865}
866
866static ssize_t set_pwm_at_crit(struct device *dev,
867 struct device_attribute *devattr,
868 const char *buf, size_t count)
867static ssize_t pwm_use_point2_pwm_at_crit_store(struct device *dev,
868 struct device_attribute *devattr,
869 const char *buf, size_t count)
869{
870 struct i2c_client *client = to_i2c_client(dev);
871 struct adt7475_data *data = i2c_get_clientdata(client);
872 long val;
873
874 if (kstrtol(buf, 10, &val))
875 return -EINVAL;
876 if (val != 0 && val != 1)

--- 6 unchanged lines hidden (view full) ---

883 else
884 data->config4 &= ~CONFIG4_MAXDUTY;
885 i2c_smbus_write_byte_data(client, REG_CONFIG4, data->config4);
886 mutex_unlock(&data->lock);
887
888 return count;
889}
890
870{
871 struct i2c_client *client = to_i2c_client(dev);
872 struct adt7475_data *data = i2c_get_clientdata(client);
873 long val;
874
875 if (kstrtol(buf, 10, &val))
876 return -EINVAL;
877 if (val != 0 && val != 1)

--- 6 unchanged lines hidden (view full) ---

884 else
885 data->config4 &= ~CONFIG4_MAXDUTY;
886 i2c_smbus_write_byte_data(client, REG_CONFIG4, data->config4);
887 mutex_unlock(&data->lock);
888
889 return count;
890}
891
891static ssize_t show_vrm(struct device *dev, struct device_attribute *devattr,
892static ssize_t vrm_show(struct device *dev, struct device_attribute *devattr,
892 char *buf)
893{
894 struct adt7475_data *data = dev_get_drvdata(dev);
895 return sprintf(buf, "%d\n", (int)data->vrm);
896}
897
893 char *buf)
894{
895 struct adt7475_data *data = dev_get_drvdata(dev);
896 return sprintf(buf, "%d\n", (int)data->vrm);
897}
898
898static ssize_t set_vrm(struct device *dev, struct device_attribute *devattr,
899 const char *buf, size_t count)
899static ssize_t vrm_store(struct device *dev, struct device_attribute *devattr,
900 const char *buf, size_t count)
900{
901 struct adt7475_data *data = dev_get_drvdata(dev);
902 long val;
903
904 if (kstrtol(buf, 10, &val))
905 return -EINVAL;
906 if (val < 0 || val > 255)
907 return -EINVAL;
908 data->vrm = val;
909
910 return count;
911}
912
901{
902 struct adt7475_data *data = dev_get_drvdata(dev);
903 long val;
904
905 if (kstrtol(buf, 10, &val))
906 return -EINVAL;
907 if (val < 0 || val > 255)
908 return -EINVAL;
909 data->vrm = val;
910
911 return count;
912}
913
913static ssize_t show_vid(struct device *dev, struct device_attribute *devattr,
914 char *buf)
914static ssize_t cpu0_vid_show(struct device *dev,
915 struct device_attribute *devattr, char *buf)
915{
916 struct adt7475_data *data = adt7475_update_device(dev);
917 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
918}
919
920static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_voltage, NULL, INPUT, 0);
921static SENSOR_DEVICE_ATTR_2(in0_max, S_IRUGO | S_IWUSR, show_voltage,
922 set_voltage, MAX, 0);

--- 129 unchanged lines hidden (view full) ---

1052static SENSOR_DEVICE_ATTR_2(pwm3_auto_channels_temp, S_IRUGO | S_IWUSR,
1053 show_pwmchan, set_pwmchan, INPUT, 2);
1054static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
1055 set_pwm, MIN, 2);
1056static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
1057 set_pwm, MAX, 2);
1058
1059/* Non-standard name, might need revisiting */
916{
917 struct adt7475_data *data = adt7475_update_device(dev);
918 return sprintf(buf, "%d\n", vid_from_reg(data->vid, data->vrm));
919}
920
921static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_voltage, NULL, INPUT, 0);
922static SENSOR_DEVICE_ATTR_2(in0_max, S_IRUGO | S_IWUSR, show_voltage,
923 set_voltage, MAX, 0);

--- 129 unchanged lines hidden (view full) ---

1053static SENSOR_DEVICE_ATTR_2(pwm3_auto_channels_temp, S_IRUGO | S_IWUSR,
1054 show_pwmchan, set_pwmchan, INPUT, 2);
1055static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
1056 set_pwm, MIN, 2);
1057static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
1058 set_pwm, MAX, 2);
1059
1060/* Non-standard name, might need revisiting */
1060static DEVICE_ATTR(pwm_use_point2_pwm_at_crit, S_IWUSR | S_IRUGO,
1061 show_pwm_at_crit, set_pwm_at_crit);
1061static DEVICE_ATTR_RW(pwm_use_point2_pwm_at_crit);
1062
1062
1063static DEVICE_ATTR(vrm, S_IWUSR | S_IRUGO, show_vrm, set_vrm);
1064static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
1063static DEVICE_ATTR_RW(vrm);
1064static DEVICE_ATTR_RO(cpu0_vid);
1065
1066static struct attribute *adt7475_attrs[] = {
1067 &sensor_dev_attr_in1_input.dev_attr.attr,
1068 &sensor_dev_attr_in1_max.dev_attr.attr,
1069 &sensor_dev_attr_in1_min.dev_attr.attr,
1070 &sensor_dev_attr_in1_alarm.dev_attr.attr,
1071 &sensor_dev_attr_in2_input.dev_attr.attr,
1072 &sensor_dev_attr_in2_max.dev_attr.attr,

--- 559 unchanged lines hidden ---
1065
1066static struct attribute *adt7475_attrs[] = {
1067 &sensor_dev_attr_in1_input.dev_attr.attr,
1068 &sensor_dev_attr_in1_max.dev_attr.attr,
1069 &sensor_dev_attr_in1_min.dev_attr.attr,
1070 &sensor_dev_attr_in1_alarm.dev_attr.attr,
1071 &sensor_dev_attr_in2_input.dev_attr.attr,
1072 &sensor_dev_attr_in2_max.dev_attr.attr,

--- 559 unchanged lines hidden ---