Source
91
91
return max1111_read(&the_max1111->spi->dev, channel);
92
92
}
93
93
EXPORT_SYMBOL(max1111_read_channel);
94
94
#endif
95
95
96
96
/*
97
97
* NOTE: SPI devices do not have a default 'name' attribute, which is
98
98
* likely to be used by hwmon applications to distinguish between
99
99
* different devices, explicitly add a name attribute here.
100
100
*/
101
-
static ssize_t show_name(struct device *dev,
101
+
static ssize_t name_show(struct device *dev,
102
102
struct device_attribute *attr, char *buf)
103
103
{
104
104
return sprintf(buf, "%s\n", to_spi_device(dev)->modalias);
105
105
}
106
106
107
107
static ssize_t show_adc(struct device *dev,
108
108
struct device_attribute *attr, char *buf)
109
109
{
110
110
struct max1111_data *data = dev_get_drvdata(dev);
111
111
int channel = to_sensor_dev_attr(attr)->index;
118
118
/*
119
119
* Assume the reference voltage to be 2.048V or 4.096V, with an 8-bit
120
120
* sample. The LSB weight is 8mV or 16mV depending on the chip type.
121
121
*/
122
122
return sprintf(buf, "%d\n", ret * data->lsb);
123
123
}
124
124
125
125
#define MAX1111_ADC_ATTR(_id) \
126
126
SENSOR_DEVICE_ATTR(in##_id##_input, S_IRUGO, show_adc, NULL, _id)
127
127
128
-
static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
128
+
static DEVICE_ATTR_RO(name);
129
129
static MAX1111_ADC_ATTR(0);
130
130
static MAX1111_ADC_ATTR(1);
131
131
static MAX1111_ADC_ATTR(2);
132
132
static MAX1111_ADC_ATTR(3);
133
133
static MAX1111_ADC_ATTR(4);
134
134
static MAX1111_ADC_ATTR(5);
135
135
static MAX1111_ADC_ATTR(6);
136
136
static MAX1111_ADC_ATTR(7);
137
137
138
138
static struct attribute *max1111_attributes[] = {