adt7475.c (1d58f5efbf2d8599a9062e4c800a072e2f015625) adt7475.c (3490c92a0963280f7f01ebb23989066a67dfd18d)
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

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

847 count = r;
848 mutex_unlock(&data->lock);
849
850 return count;
851}
852
853/* List of frequencies for the PWM */
854static const int pwmfreq_table[] = {
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

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

847 count = r;
848 mutex_unlock(&data->lock);
849
850 return count;
851}
852
853/* List of frequencies for the PWM */
854static const int pwmfreq_table[] = {
855 11, 14, 22, 29, 35, 44, 58, 88
855 11, 14, 22, 29, 35, 44, 58, 88, 22500
856};
857
858static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr,
859 char *buf)
860{
861 struct adt7475_data *data = adt7475_update_device(dev);
862 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
856};
857
858static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr,
859 char *buf)
860{
861 struct adt7475_data *data = adt7475_update_device(dev);
862 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
863 int i = clamp_val(data->range[sattr->index] & 0xf, 0,
864 ARRAY_SIZE(pwmfreq_table) - 1);
863
865
864 return sprintf(buf, "%d\n",
865 pwmfreq_table[data->range[sattr->index] & 7]);
866 return sprintf(buf, "%d\n", pwmfreq_table[i]);
866}
867
868static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
869 const char *buf, size_t count)
870{
871 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
872 struct i2c_client *client = to_i2c_client(dev);
873 struct adt7475_data *data = i2c_get_clientdata(client);

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

878 return -EINVAL;
879
880 out = find_closest(val, pwmfreq_table, ARRAY_SIZE(pwmfreq_table));
881
882 mutex_lock(&data->lock);
883
884 data->range[sattr->index] =
885 adt7475_read(TEMP_TRANGE_REG(sattr->index));
867}
868
869static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
870 const char *buf, size_t count)
871{
872 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
873 struct i2c_client *client = to_i2c_client(dev);
874 struct adt7475_data *data = i2c_get_clientdata(client);

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

879 return -EINVAL;
880
881 out = find_closest(val, pwmfreq_table, ARRAY_SIZE(pwmfreq_table));
882
883 mutex_lock(&data->lock);
884
885 data->range[sattr->index] =
886 adt7475_read(TEMP_TRANGE_REG(sattr->index));
886 data->range[sattr->index] &= ~7;
887 data->range[sattr->index] &= ~0xf;
887 data->range[sattr->index] |= out;
888
889 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
890 data->range[sattr->index]);
891
892 mutex_unlock(&data->lock);
893 return count;
894}

--- 801 unchanged lines hidden ---
888 data->range[sattr->index] |= out;
889
890 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
891 data->range[sattr->index]);
892
893 mutex_unlock(&data->lock);
894 return count;
895}

--- 801 unchanged lines hidden ---