diff options
Diffstat (limited to 'drivers/hwmon/adm1026.c')
-rw-r--r-- | drivers/hwmon/adm1026.c | 632 |
1 files changed, 360 insertions, 272 deletions
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 3e63c1486770..8002f68240c4 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c | |||
@@ -40,8 +40,8 @@ static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; | |||
40 | /* Insmod parameters */ | 40 | /* Insmod parameters */ |
41 | I2C_CLIENT_INSMOD_1(adm1026); | 41 | I2C_CLIENT_INSMOD_1(adm1026); |
42 | 42 | ||
43 | static int gpio_input[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | 43 | static int gpio_input[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, |
44 | -1, -1, -1, -1, -1, -1, -1, -1 }; | 44 | -1, -1, -1, -1, -1, -1, -1, -1 }; |
45 | static int gpio_output[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | 45 | static int gpio_output[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, |
46 | -1, -1, -1, -1, -1, -1, -1, -1 }; | 46 | -1, -1, -1, -1, -1, -1, -1, -1 }; |
47 | static int gpio_inverted[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | 47 | static int gpio_inverted[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, |
@@ -49,46 +49,49 @@ static int gpio_inverted[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | |||
49 | static int gpio_normal[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, | 49 | static int gpio_normal[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, |
50 | -1, -1, -1, -1, -1, -1, -1, -1 }; | 50 | -1, -1, -1, -1, -1, -1, -1, -1 }; |
51 | static int gpio_fan[8] = { -1, -1, -1, -1, -1, -1, -1, -1 }; | 51 | static int gpio_fan[8] = { -1, -1, -1, -1, -1, -1, -1, -1 }; |
52 | module_param_array(gpio_input,int,NULL,0); | 52 | module_param_array(gpio_input, int, NULL, 0); |
53 | MODULE_PARM_DESC(gpio_input,"List of GPIO pins (0-16) to program as inputs"); | 53 | MODULE_PARM_DESC(gpio_input, "List of GPIO pins (0-16) to program as inputs"); |
54 | module_param_array(gpio_output,int,NULL,0); | 54 | module_param_array(gpio_output, int, NULL, 0); |
55 | MODULE_PARM_DESC(gpio_output,"List of GPIO pins (0-16) to program as " | 55 | MODULE_PARM_DESC(gpio_output, "List of GPIO pins (0-16) to program as " |
56 | "outputs"); | 56 | "outputs"); |
57 | module_param_array(gpio_inverted,int,NULL,0); | 57 | module_param_array(gpio_inverted, int, NULL, 0); |
58 | MODULE_PARM_DESC(gpio_inverted,"List of GPIO pins (0-16) to program as " | 58 | MODULE_PARM_DESC(gpio_inverted, "List of GPIO pins (0-16) to program as " |
59 | "inverted"); | 59 | "inverted"); |
60 | module_param_array(gpio_normal,int,NULL,0); | 60 | module_param_array(gpio_normal, int, NULL, 0); |
61 | MODULE_PARM_DESC(gpio_normal,"List of GPIO pins (0-16) to program as " | 61 | MODULE_PARM_DESC(gpio_normal, "List of GPIO pins (0-16) to program as " |
62 | "normal/non-inverted"); | 62 | "normal/non-inverted"); |
63 | module_param_array(gpio_fan,int,NULL,0); | 63 | module_param_array(gpio_fan, int, NULL, 0); |
64 | MODULE_PARM_DESC(gpio_fan,"List of GPIO pins (0-7) to program as fan tachs"); | 64 | MODULE_PARM_DESC(gpio_fan, "List of GPIO pins (0-7) to program as fan tachs"); |
65 | 65 | ||
66 | /* Many ADM1026 constants specified below */ | 66 | /* Many ADM1026 constants specified below */ |
67 | 67 | ||
68 | /* The ADM1026 registers */ | 68 | /* The ADM1026 registers */ |
69 | #define ADM1026_REG_CONFIG1 0x00 | 69 | #define ADM1026_REG_CONFIG1 0x00 |
70 | #define CFG1_MONITOR 0x01 | 70 | #define CFG1_MONITOR 0x01 |
71 | #define CFG1_INT_ENABLE 0x02 | 71 | #define CFG1_INT_ENABLE 0x02 |
72 | #define CFG1_INT_CLEAR 0x04 | 72 | #define CFG1_INT_CLEAR 0x04 |
73 | #define CFG1_AIN8_9 0x08 | 73 | #define CFG1_AIN8_9 0x08 |
74 | #define CFG1_THERM_HOT 0x10 | 74 | #define CFG1_THERM_HOT 0x10 |
75 | #define CFG1_DAC_AFC 0x20 | 75 | #define CFG1_DAC_AFC 0x20 |
76 | #define CFG1_PWM_AFC 0x40 | 76 | #define CFG1_PWM_AFC 0x40 |
77 | #define CFG1_RESET 0x80 | 77 | #define CFG1_RESET 0x80 |
78 | #define ADM1026_REG_CONFIG2 0x01 | 78 | |
79 | #define ADM1026_REG_CONFIG2 0x01 | ||
79 | /* CONFIG2 controls FAN0/GPIO0 through FAN7/GPIO7 */ | 80 | /* CONFIG2 controls FAN0/GPIO0 through FAN7/GPIO7 */ |
80 | #define ADM1026_REG_CONFIG3 0x07 | 81 | |
81 | #define CFG3_GPIO16_ENABLE 0x01 | 82 | #define ADM1026_REG_CONFIG3 0x07 |
82 | #define CFG3_CI_CLEAR 0x02 | 83 | #define CFG3_GPIO16_ENABLE 0x01 |
83 | #define CFG3_VREF_250 0x04 | 84 | #define CFG3_CI_CLEAR 0x02 |
84 | #define CFG3_GPIO16_DIR 0x40 | 85 | #define CFG3_VREF_250 0x04 |
85 | #define CFG3_GPIO16_POL 0x80 | 86 | #define CFG3_GPIO16_DIR 0x40 |
86 | #define ADM1026_REG_E2CONFIG 0x13 | 87 | #define CFG3_GPIO16_POL 0x80 |
87 | #define E2CFG_READ 0x01 | 88 | |
88 | #define E2CFG_WRITE 0x02 | 89 | #define ADM1026_REG_E2CONFIG 0x13 |
89 | #define E2CFG_ERASE 0x04 | 90 | #define E2CFG_READ 0x01 |
90 | #define E2CFG_ROM 0x08 | 91 | #define E2CFG_WRITE 0x02 |
91 | #define E2CFG_CLK_EXT 0x80 | 92 | #define E2CFG_ERASE 0x04 |
93 | #define E2CFG_ROM 0x08 | ||
94 | #define E2CFG_CLK_EXT 0x80 | ||
92 | 95 | ||
93 | /* There are 10 general analog inputs and 7 dedicated inputs | 96 | /* There are 10 general analog inputs and 7 dedicated inputs |
94 | * They are: | 97 | * They are: |
@@ -129,48 +132,48 @@ static u16 ADM1026_REG_TEMP_TMIN[] = { 0x10, 0x11, 0x12 }; | |||
129 | static u16 ADM1026_REG_TEMP_THERM[] = { 0x0d, 0x0e, 0x0f }; | 132 | static u16 ADM1026_REG_TEMP_THERM[] = { 0x0d, 0x0e, 0x0f }; |
130 | static u16 ADM1026_REG_TEMP_OFFSET[] = { 0x1e, 0x6e, 0x6f }; | 133 | static u16 ADM1026_REG_TEMP_OFFSET[] = { 0x1e, 0x6e, 0x6f }; |
131 | 134 | ||
132 | #define ADM1026_REG_FAN(nr) (0x38 + (nr)) | 135 | #define ADM1026_REG_FAN(nr) (0x38 + (nr)) |
133 | #define ADM1026_REG_FAN_MIN(nr) (0x60 + (nr)) | 136 | #define ADM1026_REG_FAN_MIN(nr) (0x60 + (nr)) |
134 | #define ADM1026_REG_FAN_DIV_0_3 0x02 | 137 | #define ADM1026_REG_FAN_DIV_0_3 0x02 |
135 | #define ADM1026_REG_FAN_DIV_4_7 0x03 | 138 | #define ADM1026_REG_FAN_DIV_4_7 0x03 |
136 | 139 | ||
137 | #define ADM1026_REG_DAC 0x04 | 140 | #define ADM1026_REG_DAC 0x04 |
138 | #define ADM1026_REG_PWM 0x05 | 141 | #define ADM1026_REG_PWM 0x05 |
139 | 142 | ||
140 | #define ADM1026_REG_GPIO_CFG_0_3 0x08 | 143 | #define ADM1026_REG_GPIO_CFG_0_3 0x08 |
141 | #define ADM1026_REG_GPIO_CFG_4_7 0x09 | 144 | #define ADM1026_REG_GPIO_CFG_4_7 0x09 |
142 | #define ADM1026_REG_GPIO_CFG_8_11 0x0a | 145 | #define ADM1026_REG_GPIO_CFG_8_11 0x0a |
143 | #define ADM1026_REG_GPIO_CFG_12_15 0x0b | 146 | #define ADM1026_REG_GPIO_CFG_12_15 0x0b |
144 | /* CFG_16 in REG_CFG3 */ | 147 | /* CFG_16 in REG_CFG3 */ |
145 | #define ADM1026_REG_GPIO_STATUS_0_7 0x24 | 148 | #define ADM1026_REG_GPIO_STATUS_0_7 0x24 |
146 | #define ADM1026_REG_GPIO_STATUS_8_15 0x25 | 149 | #define ADM1026_REG_GPIO_STATUS_8_15 0x25 |
147 | /* STATUS_16 in REG_STATUS4 */ | 150 | /* STATUS_16 in REG_STATUS4 */ |
148 | #define ADM1026_REG_GPIO_MASK_0_7 0x1c | 151 | #define ADM1026_REG_GPIO_MASK_0_7 0x1c |
149 | #define ADM1026_REG_GPIO_MASK_8_15 0x1d | 152 | #define ADM1026_REG_GPIO_MASK_8_15 0x1d |
150 | /* MASK_16 in REG_MASK4 */ | 153 | /* MASK_16 in REG_MASK4 */ |
151 | 154 | ||
152 | #define ADM1026_REG_COMPANY 0x16 | 155 | #define ADM1026_REG_COMPANY 0x16 |
153 | #define ADM1026_REG_VERSTEP 0x17 | 156 | #define ADM1026_REG_VERSTEP 0x17 |
154 | /* These are the recognized values for the above regs */ | 157 | /* These are the recognized values for the above regs */ |
155 | #define ADM1026_COMPANY_ANALOG_DEV 0x41 | 158 | #define ADM1026_COMPANY_ANALOG_DEV 0x41 |
156 | #define ADM1026_VERSTEP_GENERIC 0x40 | 159 | #define ADM1026_VERSTEP_GENERIC 0x40 |
157 | #define ADM1026_VERSTEP_ADM1026 0x44 | 160 | #define ADM1026_VERSTEP_ADM1026 0x44 |
158 | 161 | ||
159 | #define ADM1026_REG_MASK1 0x18 | 162 | #define ADM1026_REG_MASK1 0x18 |
160 | #define ADM1026_REG_MASK2 0x19 | 163 | #define ADM1026_REG_MASK2 0x19 |
161 | #define ADM1026_REG_MASK3 0x1a | 164 | #define ADM1026_REG_MASK3 0x1a |
162 | #define ADM1026_REG_MASK4 0x1b | 165 | #define ADM1026_REG_MASK4 0x1b |
163 | 166 | ||
164 | #define ADM1026_REG_STATUS1 0x20 | 167 | #define ADM1026_REG_STATUS1 0x20 |
165 | #define ADM1026_REG_STATUS2 0x21 | 168 | #define ADM1026_REG_STATUS2 0x21 |
166 | #define ADM1026_REG_STATUS3 0x22 | 169 | #define ADM1026_REG_STATUS3 0x22 |
167 | #define ADM1026_REG_STATUS4 0x23 | 170 | #define ADM1026_REG_STATUS4 0x23 |
168 | 171 | ||
169 | #define ADM1026_FAN_ACTIVATION_TEMP_HYST -6 | 172 | #define ADM1026_FAN_ACTIVATION_TEMP_HYST -6 |
170 | #define ADM1026_FAN_CONTROL_TEMP_RANGE 20 | 173 | #define ADM1026_FAN_CONTROL_TEMP_RANGE 20 |
171 | #define ADM1026_PWM_MAX 255 | 174 | #define ADM1026_PWM_MAX 255 |
172 | 175 | ||
173 | /* Conversions. Rounding and limit checking is only done on the TO_REG | 176 | /* Conversions. Rounding and limit checking is only done on the TO_REG |
174 | * variants. Note that you should be a bit careful with which arguments | 177 | * variants. Note that you should be a bit careful with which arguments |
175 | * these macros are called: arguments may be evaluated more than once. | 178 | * these macros are called: arguments may be evaluated more than once. |
176 | */ | 179 | */ |
@@ -186,52 +189,49 @@ static u16 ADM1026_REG_TEMP_OFFSET[] = { 0x1e, 0x6e, 0x6f }; | |||
186 | * The values in this table are based on Table II, page 15 of the | 189 | * The values in this table are based on Table II, page 15 of the |
187 | * datasheet. | 190 | * datasheet. |
188 | */ | 191 | */ |
189 | static int adm1026_scaling[] = { /* .001 Volts */ | 192 | static int adm1026_scaling[] = { /* .001 Volts */ |
190 | 2250, 2250, 2250, 2250, 2250, 2250, | 193 | 2250, 2250, 2250, 2250, 2250, 2250, |
191 | 1875, 1875, 1875, 1875, 3000, 3330, | 194 | 1875, 1875, 1875, 1875, 3000, 3330, |
192 | 3330, 4995, 2250, 12000, 13875 | 195 | 3330, 4995, 2250, 12000, 13875 |
193 | }; | 196 | }; |
194 | #define NEG12_OFFSET 16000 | 197 | #define NEG12_OFFSET 16000 |
195 | #define SCALE(val,from,to) (((val)*(to) + ((from)/2))/(from)) | 198 | #define SCALE(val, from, to) (((val)*(to) + ((from)/2))/(from)) |
196 | #define INS_TO_REG(n,val) (SENSORS_LIMIT(SCALE(val,adm1026_scaling[n],192),\ | 199 | #define INS_TO_REG(n, val) (SENSORS_LIMIT(SCALE(val, adm1026_scaling[n], 192),\ |
197 | 0,255)) | 200 | 0, 255)) |
198 | #define INS_FROM_REG(n,val) (SCALE(val,192,adm1026_scaling[n])) | 201 | #define INS_FROM_REG(n, val) (SCALE(val, 192, adm1026_scaling[n])) |
199 | 202 | ||
200 | /* FAN speed is measured using 22.5kHz clock and counts for 2 pulses | 203 | /* FAN speed is measured using 22.5kHz clock and counts for 2 pulses |
201 | * and we assume a 2 pulse-per-rev fan tach signal | 204 | * and we assume a 2 pulse-per-rev fan tach signal |
202 | * 22500 kHz * 60 (sec/min) * 2 (pulse) / 2 (pulse/rev) == 1350000 | 205 | * 22500 kHz * 60 (sec/min) * 2 (pulse) / 2 (pulse/rev) == 1350000 |
203 | */ | 206 | */ |
204 | #define FAN_TO_REG(val,div) ((val)<=0 ? 0xff : SENSORS_LIMIT(1350000/((val)*\ | 207 | #define FAN_TO_REG(val, div) ((val) <= 0 ? 0xff : \ |
205 | (div)),1,254)) | 208 | SENSORS_LIMIT(1350000/((val)*(div)), 1, 254)) |
206 | #define FAN_FROM_REG(val,div) ((val)==0?-1:(val)==0xff ? 0 : 1350000/((val)*\ | 209 | #define FAN_FROM_REG(val, div) ((val) == 0 ? -1:(val) == 0xff ? 0 : \ |
207 | (div))) | 210 | 1350000/((val)*(div))) |
208 | #define DIV_FROM_REG(val) (1<<(val)) | 211 | #define DIV_FROM_REG(val) (1<<(val)) |
209 | #define DIV_TO_REG(val) ((val)>=8 ? 3 : (val)>=4 ? 2 : (val)>=2 ? 1 : 0) | 212 | #define DIV_TO_REG(val) ((val) >= 8 ? 3 : (val) >= 4 ? 2 : (val) >= 2 ? 1 : 0) |
210 | 213 | ||
211 | /* Temperature is reported in 1 degC increments */ | 214 | /* Temperature is reported in 1 degC increments */ |
212 | #define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)+((val)<0 ? -500 : 500))/1000,\ | 215 | #define TEMP_TO_REG(val) (SENSORS_LIMIT(((val)+((val)<0 ? -500 : 500))/1000,\ |
213 | -127,127)) | 216 | -127, 127)) |
214 | #define TEMP_FROM_REG(val) ((val) * 1000) | 217 | #define TEMP_FROM_REG(val) ((val) * 1000) |
215 | #define OFFSET_TO_REG(val) (SENSORS_LIMIT(((val)+((val)<0 ? -500 : 500))/1000,\ | 218 | #define OFFSET_TO_REG(val) (SENSORS_LIMIT(((val)+((val)<0 ? -500 : 500))/1000,\ |
216 | -127,127)) | 219 | -127, 127)) |
217 | #define OFFSET_FROM_REG(val) ((val) * 1000) | 220 | #define OFFSET_FROM_REG(val) ((val) * 1000) |
218 | 221 | ||
219 | #define PWM_TO_REG(val) (SENSORS_LIMIT(val,0,255)) | 222 | #define PWM_TO_REG(val) (SENSORS_LIMIT(val, 0, 255)) |
220 | #define PWM_FROM_REG(val) (val) | 223 | #define PWM_FROM_REG(val) (val) |
221 | 224 | ||
222 | #define PWM_MIN_TO_REG(val) ((val) & 0xf0) | 225 | #define PWM_MIN_TO_REG(val) ((val) & 0xf0) |
223 | #define PWM_MIN_FROM_REG(val) (((val) & 0xf0) + ((val) >> 4)) | 226 | #define PWM_MIN_FROM_REG(val) (((val) & 0xf0) + ((val) >> 4)) |
224 | 227 | ||
225 | /* Analog output is a voltage, and scaled to millivolts. The datasheet | 228 | /* Analog output is a voltage, and scaled to millivolts. The datasheet |
226 | * indicates that the DAC could be used to drive the fans, but in our | 229 | * indicates that the DAC could be used to drive the fans, but in our |
227 | * example board (Arima HDAMA) it isn't connected to the fans at all. | 230 | * example board (Arima HDAMA) it isn't connected to the fans at all. |
228 | */ | 231 | */ |
229 | #define DAC_TO_REG(val) (SENSORS_LIMIT(((((val)*255)+500)/2500),0,255)) | 232 | #define DAC_TO_REG(val) (SENSORS_LIMIT(((((val)*255)+500)/2500), 0, 255)) |
230 | #define DAC_FROM_REG(val) (((val)*2500)/255) | 233 | #define DAC_FROM_REG(val) (((val)*2500)/255) |
231 | 234 | ||
232 | /* Typically used with systems using a v9.1 VRM spec ? */ | ||
233 | #define ADM1026_INIT_VRM 91 | ||
234 | |||
235 | /* Chip sampling rates | 235 | /* Chip sampling rates |
236 | * | 236 | * |
237 | * Some sensors are not updated more frequently than once per second | 237 | * Some sensors are not updated more frequently than once per second |
@@ -243,8 +243,8 @@ static int adm1026_scaling[] = { /* .001 Volts */ | |||
243 | * So, we keep the config data up to date in the cache | 243 | * So, we keep the config data up to date in the cache |
244 | * when it is written and only sample it once every 5 *minutes* | 244 | * when it is written and only sample it once every 5 *minutes* |
245 | */ | 245 | */ |
246 | #define ADM1026_DATA_INTERVAL (1 * HZ) | 246 | #define ADM1026_DATA_INTERVAL (1 * HZ) |
247 | #define ADM1026_CONFIG_INTERVAL (5 * 60 * HZ) | 247 | #define ADM1026_CONFIG_INTERVAL (5 * 60 * HZ) |
248 | 248 | ||
249 | /* We allow for multiple chips in a single system. | 249 | /* We allow for multiple chips in a single system. |
250 | * | 250 | * |
@@ -261,37 +261,36 @@ struct pwm_data { | |||
261 | struct adm1026_data { | 261 | struct adm1026_data { |
262 | struct i2c_client client; | 262 | struct i2c_client client; |
263 | struct device *hwmon_dev; | 263 | struct device *hwmon_dev; |
264 | enum chips type; | ||
265 | 264 | ||
266 | struct mutex update_lock; | 265 | struct mutex update_lock; |
267 | int valid; /* !=0 if following fields are valid */ | 266 | int valid; /* !=0 if following fields are valid */ |
268 | unsigned long last_reading; /* In jiffies */ | 267 | unsigned long last_reading; /* In jiffies */ |
269 | unsigned long last_config; /* In jiffies */ | 268 | unsigned long last_config; /* In jiffies */ |
270 | 269 | ||
271 | u8 in[17]; /* Register value */ | 270 | u8 in[17]; /* Register value */ |
272 | u8 in_max[17]; /* Register value */ | 271 | u8 in_max[17]; /* Register value */ |
273 | u8 in_min[17]; /* Register value */ | 272 | u8 in_min[17]; /* Register value */ |
274 | s8 temp[3]; /* Register value */ | 273 | s8 temp[3]; /* Register value */ |
275 | s8 temp_min[3]; /* Register value */ | 274 | s8 temp_min[3]; /* Register value */ |
276 | s8 temp_max[3]; /* Register value */ | 275 | s8 temp_max[3]; /* Register value */ |
277 | s8 temp_tmin[3]; /* Register value */ | 276 | s8 temp_tmin[3]; /* Register value */ |
278 | s8 temp_crit[3]; /* Register value */ | 277 | s8 temp_crit[3]; /* Register value */ |
279 | s8 temp_offset[3]; /* Register value */ | 278 | s8 temp_offset[3]; /* Register value */ |
280 | u8 fan[8]; /* Register value */ | 279 | u8 fan[8]; /* Register value */ |
281 | u8 fan_min[8]; /* Register value */ | 280 | u8 fan_min[8]; /* Register value */ |
282 | u8 fan_div[8]; /* Decoded value */ | 281 | u8 fan_div[8]; /* Decoded value */ |
283 | struct pwm_data pwm1; /* Pwm control values */ | 282 | struct pwm_data pwm1; /* Pwm control values */ |
284 | int vid; /* Decoded value */ | 283 | int vid; /* Decoded value */ |
285 | u8 vrm; /* VRM version */ | 284 | u8 vrm; /* VRM version */ |
286 | u8 analog_out; /* Register value (DAC) */ | 285 | u8 analog_out; /* Register value (DAC) */ |
287 | long alarms; /* Register encoding, combined */ | 286 | long alarms; /* Register encoding, combined */ |
288 | long alarm_mask; /* Register encoding, combined */ | 287 | long alarm_mask; /* Register encoding, combined */ |
289 | long gpio; /* Register encoding, combined */ | 288 | long gpio; /* Register encoding, combined */ |
290 | long gpio_mask; /* Register encoding, combined */ | 289 | long gpio_mask; /* Register encoding, combined */ |
291 | u8 gpio_config[17]; /* Decoded value */ | 290 | u8 gpio_config[17]; /* Decoded value */ |
292 | u8 config1; /* Register value */ | 291 | u8 config1; /* Register value */ |
293 | u8 config2; /* Register value */ | 292 | u8 config2; /* Register value */ |
294 | u8 config3; /* Register value */ | 293 | u8 config3; /* Register value */ |
295 | }; | 294 | }; |
296 | 295 | ||
297 | static int adm1026_attach_adapter(struct i2c_adapter *adapter); | 296 | static int adm1026_attach_adapter(struct i2c_adapter *adapter); |
@@ -301,7 +300,7 @@ static int adm1026_detach_client(struct i2c_client *client); | |||
301 | static int adm1026_read_value(struct i2c_client *client, u8 reg); | 300 | static int adm1026_read_value(struct i2c_client *client, u8 reg); |
302 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value); | 301 | static int adm1026_write_value(struct i2c_client *client, u8 reg, int value); |
303 | static void adm1026_print_gpio(struct i2c_client *client); | 302 | static void adm1026_print_gpio(struct i2c_client *client); |
304 | static void adm1026_fixup_gpio(struct i2c_client *client); | 303 | static void adm1026_fixup_gpio(struct i2c_client *client); |
305 | static struct adm1026_data *adm1026_update_device(struct device *dev); | 304 | static struct adm1026_data *adm1026_update_device(struct device *dev); |
306 | static void adm1026_init_client(struct i2c_client *client); | 305 | static void adm1026_init_client(struct i2c_client *client); |
307 | 306 | ||
@@ -311,7 +310,7 @@ static struct i2c_driver adm1026_driver = { | |||
311 | .name = "adm1026", | 310 | .name = "adm1026", |
312 | }, | 311 | }, |
313 | .attach_adapter = adm1026_attach_adapter, | 312 | .attach_adapter = adm1026_attach_adapter, |
314 | .detach_client = adm1026_detach_client, | 313 | .detach_client = adm1026_detach_client, |
315 | }; | 314 | }; |
316 | 315 | ||
317 | static int adm1026_attach_adapter(struct i2c_adapter *adapter) | 316 | static int adm1026_attach_adapter(struct i2c_adapter *adapter) |
@@ -355,7 +354,7 @@ static void adm1026_init_client(struct i2c_client *client) | |||
355 | int value, i; | 354 | int value, i; |
356 | struct adm1026_data *data = i2c_get_clientdata(client); | 355 | struct adm1026_data *data = i2c_get_clientdata(client); |
357 | 356 | ||
358 | dev_dbg(&client->dev, "Initializing device\n"); | 357 | dev_dbg(&client->dev, "Initializing device\n"); |
359 | /* Read chip config */ | 358 | /* Read chip config */ |
360 | data->config1 = adm1026_read_value(client, ADM1026_REG_CONFIG1); | 359 | data->config1 = adm1026_read_value(client, ADM1026_REG_CONFIG1); |
361 | data->config2 = adm1026_read_value(client, ADM1026_REG_CONFIG2); | 360 | data->config2 = adm1026_read_value(client, ADM1026_REG_CONFIG2); |
@@ -384,7 +383,6 @@ static void adm1026_init_client(struct i2c_client *client) | |||
384 | "and temp limits enabled.\n"); | 383 | "and temp limits enabled.\n"); |
385 | } | 384 | } |
386 | 385 | ||
387 | value = data->config3; | ||
388 | if (data->config3 & CFG3_GPIO16_ENABLE) { | 386 | if (data->config3 & CFG3_GPIO16_ENABLE) { |
389 | dev_dbg(&client->dev, "GPIO16 enabled. THERM " | 387 | dev_dbg(&client->dev, "GPIO16 enabled. THERM " |
390 | "pin disabled.\n"); | 388 | "pin disabled.\n"); |
@@ -426,10 +424,10 @@ static void adm1026_init_client(struct i2c_client *client) | |||
426 | * configured, we don't want to mess with them. | 424 | * configured, we don't want to mess with them. |
427 | * If they weren't, the default is 100% PWM, no | 425 | * If they weren't, the default is 100% PWM, no |
428 | * control and will suffice until 'sensors -s' | 426 | * control and will suffice until 'sensors -s' |
429 | * can be run by the user. We DO set the default | 427 | * can be run by the user. We DO set the default |
430 | * value for pwm1.auto_pwm_min to its maximum | 428 | * value for pwm1.auto_pwm_min to its maximum |
431 | * so that enabling automatic pwm fan control | 429 | * so that enabling automatic pwm fan control |
432 | * without first setting a value for pwm1.auto_pwm_min | 430 | * without first setting a value for pwm1.auto_pwm_min |
433 | * will not result in potentially dangerous fan speed decrease. | 431 | * will not result in potentially dangerous fan speed decrease. |
434 | */ | 432 | */ |
435 | data->pwm1.auto_pwm_min=255; | 433 | data->pwm1.auto_pwm_min=255; |
@@ -453,7 +451,7 @@ static void adm1026_init_client(struct i2c_client *client) | |||
453 | static void adm1026_print_gpio(struct i2c_client *client) | 451 | static void adm1026_print_gpio(struct i2c_client *client) |
454 | { | 452 | { |
455 | struct adm1026_data *data = i2c_get_clientdata(client); | 453 | struct adm1026_data *data = i2c_get_clientdata(client); |
456 | int i; | 454 | int i; |
457 | 455 | ||
458 | dev_dbg(&client->dev, "GPIO config is:"); | 456 | dev_dbg(&client->dev, "GPIO config is:"); |
459 | for (i = 0;i <= 7;++i) { | 457 | for (i = 0;i <= 7;++i) { |
@@ -477,7 +475,7 @@ static void adm1026_print_gpio(struct i2c_client *client) | |||
477 | data->gpio_config[16] & 0x02 ? "" : "!", | 475 | data->gpio_config[16] & 0x02 ? "" : "!", |
478 | data->gpio_config[16] & 0x01 ? "OUT" : "IN"); | 476 | data->gpio_config[16] & 0x01 ? "OUT" : "IN"); |
479 | } else { | 477 | } else { |
480 | /* GPIO16 is THERM */ | 478 | /* GPIO16 is THERM */ |
481 | dev_dbg(&client->dev, "\tTHERM\n"); | 479 | dev_dbg(&client->dev, "\tTHERM\n"); |
482 | } | 480 | } |
483 | } | 481 | } |
@@ -485,8 +483,8 @@ static void adm1026_print_gpio(struct i2c_client *client) | |||
485 | static void adm1026_fixup_gpio(struct i2c_client *client) | 483 | static void adm1026_fixup_gpio(struct i2c_client *client) |
486 | { | 484 | { |
487 | struct adm1026_data *data = i2c_get_clientdata(client); | 485 | struct adm1026_data *data = i2c_get_clientdata(client); |
488 | int i; | 486 | int i; |
489 | int value; | 487 | int value; |
490 | 488 | ||
491 | /* Make the changes requested. */ | 489 | /* Make the changes requested. */ |
492 | /* We may need to unlock/stop monitoring or soft-reset the | 490 | /* We may need to unlock/stop monitoring or soft-reset the |
@@ -516,14 +514,14 @@ static void adm1026_fixup_gpio(struct i2c_client *client) | |||
516 | } | 514 | } |
517 | } | 515 | } |
518 | 516 | ||
519 | /* Inverted */ | 517 | /* Inverted */ |
520 | for (i = 0;i <= 16;++i) { | 518 | for (i = 0;i <= 16;++i) { |
521 | if (gpio_inverted[i] >= 0 && gpio_inverted[i] <= 16) { | 519 | if (gpio_inverted[i] >= 0 && gpio_inverted[i] <= 16) { |
522 | data->gpio_config[gpio_inverted[i]] &= ~ 0x02; | 520 | data->gpio_config[gpio_inverted[i]] &= ~ 0x02; |
523 | } | 521 | } |
524 | } | 522 | } |
525 | 523 | ||
526 | /* Normal overrides inverted */ | 524 | /* Normal overrides inverted */ |
527 | for (i = 0;i <= 16;++i) { | 525 | for (i = 0;i <= 16;++i) { |
528 | if (gpio_normal[i] >= 0 && gpio_normal[i] <= 16) { | 526 | if (gpio_normal[i] >= 0 && gpio_normal[i] <= 16) { |
529 | data->gpio_config[gpio_normal[i]] |= 0x02; | 527 | data->gpio_config[gpio_normal[i]] |= 0x02; |
@@ -569,7 +567,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
569 | if (!data->valid | 567 | if (!data->valid |
570 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { | 568 | || time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) { |
571 | /* Things that change quickly */ | 569 | /* Things that change quickly */ |
572 | dev_dbg(&client->dev,"Reading sensor values\n"); | 570 | dev_dbg(&client->dev, "Reading sensor values\n"); |
573 | for (i = 0;i <= 16;++i) { | 571 | for (i = 0;i <= 16;++i) { |
574 | data->in[i] = | 572 | data->in[i] = |
575 | adm1026_read_value(client, ADM1026_REG_IN[i]); | 573 | adm1026_read_value(client, ADM1026_REG_IN[i]); |
@@ -582,18 +580,18 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
582 | 580 | ||
583 | for (i = 0;i <= 2;++i) { | 581 | for (i = 0;i <= 2;++i) { |
584 | /* NOTE: temp[] is s8 and we assume 2's complement | 582 | /* NOTE: temp[] is s8 and we assume 2's complement |
585 | * "conversion" in the assignment */ | 583 | * "conversion" in the assignment */ |
586 | data->temp[i] = | 584 | data->temp[i] = |
587 | adm1026_read_value(client, ADM1026_REG_TEMP[i]); | 585 | adm1026_read_value(client, ADM1026_REG_TEMP[i]); |
588 | } | 586 | } |
589 | 587 | ||
590 | data->pwm1.pwm = adm1026_read_value(client, | 588 | data->pwm1.pwm = adm1026_read_value(client, |
591 | ADM1026_REG_PWM); | 589 | ADM1026_REG_PWM); |
592 | data->analog_out = adm1026_read_value(client, | 590 | data->analog_out = adm1026_read_value(client, |
593 | ADM1026_REG_DAC); | 591 | ADM1026_REG_DAC); |
594 | /* GPIO16 is MSbit of alarms, move it to gpio */ | 592 | /* GPIO16 is MSbit of alarms, move it to gpio */ |
595 | alarms = adm1026_read_value(client, ADM1026_REG_STATUS4); | 593 | alarms = adm1026_read_value(client, ADM1026_REG_STATUS4); |
596 | gpio = alarms & 0x80 ? 0x0100 : 0; /* GPIO16 */ | 594 | gpio = alarms & 0x80 ? 0x0100 : 0; /* GPIO16 */ |
597 | alarms &= 0x7f; | 595 | alarms &= 0x7f; |
598 | alarms <<= 8; | 596 | alarms <<= 8; |
599 | alarms |= adm1026_read_value(client, ADM1026_REG_STATUS3); | 597 | alarms |= adm1026_read_value(client, ADM1026_REG_STATUS3); |
@@ -604,24 +602,24 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
604 | data->alarms = alarms; | 602 | data->alarms = alarms; |
605 | 603 | ||
606 | /* Read the GPIO values */ | 604 | /* Read the GPIO values */ |
607 | gpio |= adm1026_read_value(client, | 605 | gpio |= adm1026_read_value(client, |
608 | ADM1026_REG_GPIO_STATUS_8_15); | 606 | ADM1026_REG_GPIO_STATUS_8_15); |
609 | gpio <<= 8; | 607 | gpio <<= 8; |
610 | gpio |= adm1026_read_value(client, | 608 | gpio |= adm1026_read_value(client, |
611 | ADM1026_REG_GPIO_STATUS_0_7); | 609 | ADM1026_REG_GPIO_STATUS_0_7); |
612 | data->gpio = gpio; | 610 | data->gpio = gpio; |
613 | 611 | ||
614 | data->last_reading = jiffies; | 612 | data->last_reading = jiffies; |
615 | }; /* last_reading */ | 613 | }; /* last_reading */ |
616 | 614 | ||
617 | if (!data->valid || | 615 | if (!data->valid || |
618 | time_after(jiffies, data->last_config + ADM1026_CONFIG_INTERVAL)) { | 616 | time_after(jiffies, data->last_config + ADM1026_CONFIG_INTERVAL)) { |
619 | /* Things that don't change often */ | 617 | /* Things that don't change often */ |
620 | dev_dbg(&client->dev, "Reading config values\n"); | 618 | dev_dbg(&client->dev, "Reading config values\n"); |
621 | for (i = 0;i <= 16;++i) { | 619 | for (i = 0;i <= 16;++i) { |
622 | data->in_min[i] = adm1026_read_value(client, | 620 | data->in_min[i] = adm1026_read_value(client, |
623 | ADM1026_REG_IN_MIN[i]); | 621 | ADM1026_REG_IN_MIN[i]); |
624 | data->in_max[i] = adm1026_read_value(client, | 622 | data->in_max[i] = adm1026_read_value(client, |
625 | ADM1026_REG_IN_MAX[i]); | 623 | ADM1026_REG_IN_MAX[i]); |
626 | } | 624 | } |
627 | 625 | ||
@@ -629,32 +627,32 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
629 | | (adm1026_read_value(client, ADM1026_REG_FAN_DIV_4_7) | 627 | | (adm1026_read_value(client, ADM1026_REG_FAN_DIV_4_7) |
630 | << 8); | 628 | << 8); |
631 | for (i = 0;i <= 7;++i) { | 629 | for (i = 0;i <= 7;++i) { |
632 | data->fan_min[i] = adm1026_read_value(client, | 630 | data->fan_min[i] = adm1026_read_value(client, |
633 | ADM1026_REG_FAN_MIN(i)); | 631 | ADM1026_REG_FAN_MIN(i)); |
634 | data->fan_div[i] = DIV_FROM_REG(value & 0x03); | 632 | data->fan_div[i] = DIV_FROM_REG(value & 0x03); |
635 | value >>= 2; | 633 | value >>= 2; |
636 | } | 634 | } |
637 | 635 | ||
638 | for (i = 0; i <= 2; ++i) { | 636 | for (i = 0; i <= 2; ++i) { |
639 | /* NOTE: temp_xxx[] are s8 and we assume 2's | 637 | /* NOTE: temp_xxx[] are s8 and we assume 2's |
640 | * complement "conversion" in the assignment | 638 | * complement "conversion" in the assignment |
641 | */ | 639 | */ |
642 | data->temp_min[i] = adm1026_read_value(client, | 640 | data->temp_min[i] = adm1026_read_value(client, |
643 | ADM1026_REG_TEMP_MIN[i]); | 641 | ADM1026_REG_TEMP_MIN[i]); |
644 | data->temp_max[i] = adm1026_read_value(client, | 642 | data->temp_max[i] = adm1026_read_value(client, |
645 | ADM1026_REG_TEMP_MAX[i]); | 643 | ADM1026_REG_TEMP_MAX[i]); |
646 | data->temp_tmin[i] = adm1026_read_value(client, | 644 | data->temp_tmin[i] = adm1026_read_value(client, |
647 | ADM1026_REG_TEMP_TMIN[i]); | 645 | ADM1026_REG_TEMP_TMIN[i]); |
648 | data->temp_crit[i] = adm1026_read_value(client, | 646 | data->temp_crit[i] = adm1026_read_value(client, |
649 | ADM1026_REG_TEMP_THERM[i]); | 647 | ADM1026_REG_TEMP_THERM[i]); |
650 | data->temp_offset[i] = adm1026_read_value(client, | 648 | data->temp_offset[i] = adm1026_read_value(client, |
651 | ADM1026_REG_TEMP_OFFSET[i]); | 649 | ADM1026_REG_TEMP_OFFSET[i]); |
652 | } | 650 | } |
653 | 651 | ||
654 | /* Read the STATUS/alarm masks */ | 652 | /* Read the STATUS/alarm masks */ |
655 | alarms = adm1026_read_value(client, ADM1026_REG_MASK4); | 653 | alarms = adm1026_read_value(client, ADM1026_REG_MASK4); |
656 | gpio = alarms & 0x80 ? 0x0100 : 0; /* GPIO16 */ | 654 | gpio = alarms & 0x80 ? 0x0100 : 0; /* GPIO16 */ |
657 | alarms = (alarms & 0x7f) << 8; | 655 | alarms = (alarms & 0x7f) << 8; |
658 | alarms |= adm1026_read_value(client, ADM1026_REG_MASK3); | 656 | alarms |= adm1026_read_value(client, ADM1026_REG_MASK3); |
659 | alarms <<= 8; | 657 | alarms <<= 8; |
660 | alarms |= adm1026_read_value(client, ADM1026_REG_MASK2); | 658 | alarms |= adm1026_read_value(client, ADM1026_REG_MASK2); |
@@ -663,24 +661,24 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
663 | data->alarm_mask = alarms; | 661 | data->alarm_mask = alarms; |
664 | 662 | ||
665 | /* Read the GPIO values */ | 663 | /* Read the GPIO values */ |
666 | gpio |= adm1026_read_value(client, | 664 | gpio |= adm1026_read_value(client, |
667 | ADM1026_REG_GPIO_MASK_8_15); | 665 | ADM1026_REG_GPIO_MASK_8_15); |
668 | gpio <<= 8; | 666 | gpio <<= 8; |
669 | gpio |= adm1026_read_value(client, ADM1026_REG_GPIO_MASK_0_7); | 667 | gpio |= adm1026_read_value(client, ADM1026_REG_GPIO_MASK_0_7); |
670 | data->gpio_mask = gpio; | 668 | data->gpio_mask = gpio; |
671 | 669 | ||
672 | /* Read various values from CONFIG1 */ | 670 | /* Read various values from CONFIG1 */ |
673 | data->config1 = adm1026_read_value(client, | 671 | data->config1 = adm1026_read_value(client, |
674 | ADM1026_REG_CONFIG1); | 672 | ADM1026_REG_CONFIG1); |
675 | if (data->config1 & CFG1_PWM_AFC) { | 673 | if (data->config1 & CFG1_PWM_AFC) { |
676 | data->pwm1.enable = 2; | 674 | data->pwm1.enable = 2; |
677 | data->pwm1.auto_pwm_min = | 675 | data->pwm1.auto_pwm_min = |
678 | PWM_MIN_FROM_REG(data->pwm1.pwm); | 676 | PWM_MIN_FROM_REG(data->pwm1.pwm); |
679 | } | 677 | } |
680 | /* Read the GPIO config */ | 678 | /* Read the GPIO config */ |
681 | data->config2 = adm1026_read_value(client, | 679 | data->config2 = adm1026_read_value(client, |
682 | ADM1026_REG_CONFIG2); | 680 | ADM1026_REG_CONFIG2); |
683 | data->config3 = adm1026_read_value(client, | 681 | data->config3 = adm1026_read_value(client, |
684 | ADM1026_REG_CONFIG3); | 682 | ADM1026_REG_CONFIG3); |
685 | data->gpio_config[16] = (data->config3 >> 6) & 0x03; | 683 | data->gpio_config[16] = (data->config3 >> 6) & 0x03; |
686 | 684 | ||
@@ -695,7 +693,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev) | |||
695 | } | 693 | } |
696 | 694 | ||
697 | data->last_config = jiffies; | 695 | data->last_config = jiffies; |
698 | }; /* last_config */ | 696 | }; /* last_config */ |
699 | 697 | ||
700 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); | 698 | dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n"); |
701 | data->vid = (data->gpio >> 11) & 0x1f; | 699 | data->vid = (data->gpio >> 11) & 0x1f; |
@@ -710,15 +708,15 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, | |||
710 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 708 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
711 | int nr = sensor_attr->index; | 709 | int nr = sensor_attr->index; |
712 | struct adm1026_data *data = adm1026_update_device(dev); | 710 | struct adm1026_data *data = adm1026_update_device(dev); |
713 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in[nr])); | 711 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in[nr])); |
714 | } | 712 | } |
715 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, | 713 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, |
716 | char *buf) | 714 | char *buf) |
717 | { | 715 | { |
718 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 716 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
719 | int nr = sensor_attr->index; | 717 | int nr = sensor_attr->index; |
720 | struct adm1026_data *data = adm1026_update_device(dev); | 718 | struct adm1026_data *data = adm1026_update_device(dev); |
721 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr])); | 719 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_min[nr])); |
722 | } | 720 | } |
723 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | 721 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
724 | const char *buf, size_t count) | 722 | const char *buf, size_t count) |
@@ -733,7 +731,7 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
733 | data->in_min[nr] = INS_TO_REG(nr, val); | 731 | data->in_min[nr] = INS_TO_REG(nr, val); |
734 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); | 732 | adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]); |
735 | mutex_unlock(&data->update_lock); | 733 | mutex_unlock(&data->update_lock); |
736 | return count; | 734 | return count; |
737 | } | 735 | } |
738 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, | 736 | static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
739 | char *buf) | 737 | char *buf) |
@@ -741,7 +739,7 @@ static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, | |||
741 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 739 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
742 | int nr = sensor_attr->index; | 740 | int nr = sensor_attr->index; |
743 | struct adm1026_data *data = adm1026_update_device(dev); | 741 | struct adm1026_data *data = adm1026_update_device(dev); |
744 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr])); | 742 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_max[nr])); |
745 | } | 743 | } |
746 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | 744 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
747 | const char *buf, size_t count) | 745 | const char *buf, size_t count) |
@@ -788,13 +786,13 @@ in_reg(15); | |||
788 | static ssize_t show_in16(struct device *dev, struct device_attribute *attr, char *buf) | 786 | static ssize_t show_in16(struct device *dev, struct device_attribute *attr, char *buf) |
789 | { | 787 | { |
790 | struct adm1026_data *data = adm1026_update_device(dev); | 788 | struct adm1026_data *data = adm1026_update_device(dev); |
791 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in[16]) - | 789 | return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in[16]) - |
792 | NEG12_OFFSET); | 790 | NEG12_OFFSET); |
793 | } | 791 | } |
794 | static ssize_t show_in16_min(struct device *dev, struct device_attribute *attr, char *buf) | 792 | static ssize_t show_in16_min(struct device *dev, struct device_attribute *attr, char *buf) |
795 | { | 793 | { |
796 | struct adm1026_data *data = adm1026_update_device(dev); | 794 | struct adm1026_data *data = adm1026_update_device(dev); |
797 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_min[16]) | 795 | return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in_min[16]) |
798 | - NEG12_OFFSET); | 796 | - NEG12_OFFSET); |
799 | } | 797 | } |
800 | static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 798 | static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
@@ -807,12 +805,12 @@ static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, c | |||
807 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); | 805 | data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET); |
808 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); | 806 | adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]); |
809 | mutex_unlock(&data->update_lock); | 807 | mutex_unlock(&data->update_lock); |
810 | return count; | 808 | return count; |
811 | } | 809 | } |
812 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) | 810 | static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf) |
813 | { | 811 | { |
814 | struct adm1026_data *data = adm1026_update_device(dev); | 812 | struct adm1026_data *data = adm1026_update_device(dev); |
815 | return sprintf(buf,"%d\n", INS_FROM_REG(16, data->in_max[16]) | 813 | return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in_max[16]) |
816 | - NEG12_OFFSET); | 814 | - NEG12_OFFSET); |
817 | } | 815 | } |
818 | static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 816 | static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
@@ -843,7 +841,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr, | |||
843 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 841 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
844 | int nr = sensor_attr->index; | 842 | int nr = sensor_attr->index; |
845 | struct adm1026_data *data = adm1026_update_device(dev); | 843 | struct adm1026_data *data = adm1026_update_device(dev); |
846 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr], | 844 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], |
847 | data->fan_div[nr])); | 845 | data->fan_div[nr])); |
848 | } | 846 | } |
849 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, | 847 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
@@ -852,7 +850,7 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, | |||
852 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 850 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
853 | int nr = sensor_attr->index; | 851 | int nr = sensor_attr->index; |
854 | struct adm1026_data *data = adm1026_update_device(dev); | 852 | struct adm1026_data *data = adm1026_update_device(dev); |
855 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr], | 853 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], |
856 | data->fan_div[nr])); | 854 | data->fan_div[nr])); |
857 | } | 855 | } |
858 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | 856 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
@@ -872,10 +870,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
872 | return count; | 870 | return count; |
873 | } | 871 | } |
874 | 872 | ||
875 | #define fan_offset(offset) \ | 873 | #define fan_offset(offset) \ |
876 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ | 874 | static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ |
877 | offset - 1); \ | 875 | offset - 1); \ |
878 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ | 876 | static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
879 | show_fan_min, set_fan_min, offset - 1); | 877 | show_fan_min, set_fan_min, offset - 1); |
880 | 878 | ||
881 | fan_offset(1); | 879 | fan_offset(1); |
@@ -892,8 +890,8 @@ static void fixup_fan_min(struct device *dev, int fan, int old_div) | |||
892 | { | 890 | { |
893 | struct i2c_client *client = to_i2c_client(dev); | 891 | struct i2c_client *client = to_i2c_client(dev); |
894 | struct adm1026_data *data = i2c_get_clientdata(client); | 892 | struct adm1026_data *data = i2c_get_clientdata(client); |
895 | int new_min; | 893 | int new_min; |
896 | int new_div = data->fan_div[fan]; | 894 | int new_div = data->fan_div[fan]; |
897 | 895 | ||
898 | /* 0 and 0xff are special. Don't adjust them */ | 896 | /* 0 and 0xff are special. Don't adjust them */ |
899 | if (data->fan_min[fan] == 0 || data->fan_min[fan] == 0xff) { | 897 | if (data->fan_min[fan] == 0 || data->fan_min[fan] == 0xff) { |
@@ -913,7 +911,7 @@ static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, | |||
913 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 911 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
914 | int nr = sensor_attr->index; | 912 | int nr = sensor_attr->index; |
915 | struct adm1026_data *data = adm1026_update_device(dev); | 913 | struct adm1026_data *data = adm1026_update_device(dev); |
916 | return sprintf(buf,"%d\n", data->fan_div[nr]); | 914 | return sprintf(buf, "%d\n", data->fan_div[nr]); |
917 | } | 915 | } |
918 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | 916 | static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
919 | const char *buf, size_t count) | 917 | const char *buf, size_t count) |
@@ -922,10 +920,10 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
922 | int nr = sensor_attr->index; | 920 | int nr = sensor_attr->index; |
923 | struct i2c_client *client = to_i2c_client(dev); | 921 | struct i2c_client *client = to_i2c_client(dev); |
924 | struct adm1026_data *data = i2c_get_clientdata(client); | 922 | struct adm1026_data *data = i2c_get_clientdata(client); |
925 | int val,orig_div,new_div,shift; | 923 | int val, orig_div, new_div, shift; |
926 | 924 | ||
927 | val = simple_strtol(buf, NULL, 10); | 925 | val = simple_strtol(buf, NULL, 10); |
928 | new_div = DIV_TO_REG(val); | 926 | new_div = DIV_TO_REG(val); |
929 | if (new_div == 0) { | 927 | if (new_div == 0) { |
930 | return -EINVAL; | 928 | return -EINVAL; |
931 | } | 929 | } |
@@ -946,14 +944,14 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
946 | } | 944 | } |
947 | 945 | ||
948 | if (data->fan_div[nr] != orig_div) { | 946 | if (data->fan_div[nr] != orig_div) { |
949 | fixup_fan_min(dev,nr,orig_div); | 947 | fixup_fan_min(dev, nr, orig_div); |
950 | } | 948 | } |
951 | mutex_unlock(&data->update_lock); | 949 | mutex_unlock(&data->update_lock); |
952 | return count; | 950 | return count; |
953 | } | 951 | } |
954 | 952 | ||
955 | #define fan_offset_div(offset) \ | 953 | #define fan_offset_div(offset) \ |
956 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ | 954 | static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ |
957 | show_fan_div, set_fan_div, offset - 1); | 955 | show_fan_div, set_fan_div, offset - 1); |
958 | 956 | ||
959 | fan_offset_div(1); | 957 | fan_offset_div(1); |
@@ -972,7 +970,7 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, | |||
972 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 970 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
973 | int nr = sensor_attr->index; | 971 | int nr = sensor_attr->index; |
974 | struct adm1026_data *data = adm1026_update_device(dev); | 972 | struct adm1026_data *data = adm1026_update_device(dev); |
975 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp[nr])); | 973 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); |
976 | } | 974 | } |
977 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, | 975 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, |
978 | char *buf) | 976 | char *buf) |
@@ -980,7 +978,7 @@ static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, | |||
980 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 978 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
981 | int nr = sensor_attr->index; | 979 | int nr = sensor_attr->index; |
982 | struct adm1026_data *data = adm1026_update_device(dev); | 980 | struct adm1026_data *data = adm1026_update_device(dev); |
983 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr])); | 981 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr])); |
984 | } | 982 | } |
985 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | 983 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
986 | const char *buf, size_t count) | 984 | const char *buf, size_t count) |
@@ -1004,7 +1002,7 @@ static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, | |||
1004 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1002 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1005 | int nr = sensor_attr->index; | 1003 | int nr = sensor_attr->index; |
1006 | struct adm1026_data *data = adm1026_update_device(dev); | 1004 | struct adm1026_data *data = adm1026_update_device(dev); |
1007 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr])); | 1005 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr])); |
1008 | } | 1006 | } |
1009 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | 1007 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
1010 | const char *buf, size_t count) | 1008 | const char *buf, size_t count) |
@@ -1024,7 +1022,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
1024 | } | 1022 | } |
1025 | 1023 | ||
1026 | #define temp_reg(offset) \ | 1024 | #define temp_reg(offset) \ |
1027 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \ | 1025 | static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \ |
1028 | NULL, offset - 1); \ | 1026 | NULL, offset - 1); \ |
1029 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ | 1027 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
1030 | show_temp_min, set_temp_min, offset - 1); \ | 1028 | show_temp_min, set_temp_min, offset - 1); \ |
@@ -1042,7 +1040,7 @@ static ssize_t show_temp_offset(struct device *dev, | |||
1042 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1040 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1043 | int nr = sensor_attr->index; | 1041 | int nr = sensor_attr->index; |
1044 | struct adm1026_data *data = adm1026_update_device(dev); | 1042 | struct adm1026_data *data = adm1026_update_device(dev); |
1045 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_offset[nr])); | 1043 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_offset[nr])); |
1046 | } | 1044 | } |
1047 | static ssize_t set_temp_offset(struct device *dev, | 1045 | static ssize_t set_temp_offset(struct device *dev, |
1048 | struct device_attribute *attr, const char *buf, | 1046 | struct device_attribute *attr, const char *buf, |
@@ -1076,7 +1074,7 @@ static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev, | |||
1076 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1074 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1077 | int nr = sensor_attr->index; | 1075 | int nr = sensor_attr->index; |
1078 | struct adm1026_data *data = adm1026_update_device(dev); | 1076 | struct adm1026_data *data = adm1026_update_device(dev); |
1079 | return sprintf(buf,"%d\n", TEMP_FROM_REG( | 1077 | return sprintf(buf, "%d\n", TEMP_FROM_REG( |
1080 | ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr])); | 1078 | ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr])); |
1081 | } | 1079 | } |
1082 | static ssize_t show_temp_auto_point2_temp(struct device *dev, | 1080 | static ssize_t show_temp_auto_point2_temp(struct device *dev, |
@@ -1085,7 +1083,7 @@ static ssize_t show_temp_auto_point2_temp(struct device *dev, | |||
1085 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1083 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1086 | int nr = sensor_attr->index; | 1084 | int nr = sensor_attr->index; |
1087 | struct adm1026_data *data = adm1026_update_device(dev); | 1085 | struct adm1026_data *data = adm1026_update_device(dev); |
1088 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr] + | 1086 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_tmin[nr] + |
1089 | ADM1026_FAN_CONTROL_TEMP_RANGE)); | 1087 | ADM1026_FAN_CONTROL_TEMP_RANGE)); |
1090 | } | 1088 | } |
1091 | static ssize_t show_temp_auto_point1_temp(struct device *dev, | 1089 | static ssize_t show_temp_auto_point1_temp(struct device *dev, |
@@ -1094,7 +1092,7 @@ static ssize_t show_temp_auto_point1_temp(struct device *dev, | |||
1094 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1092 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1095 | int nr = sensor_attr->index; | 1093 | int nr = sensor_attr->index; |
1096 | struct adm1026_data *data = adm1026_update_device(dev); | 1094 | struct adm1026_data *data = adm1026_update_device(dev); |
1097 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_tmin[nr])); | 1095 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_tmin[nr])); |
1098 | } | 1096 | } |
1099 | static ssize_t set_temp_auto_point1_temp(struct device *dev, | 1097 | static ssize_t set_temp_auto_point1_temp(struct device *dev, |
1100 | struct device_attribute *attr, const char *buf, size_t count) | 1098 | struct device_attribute *attr, const char *buf, size_t count) |
@@ -1113,13 +1111,13 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev, | |||
1113 | return count; | 1111 | return count; |
1114 | } | 1112 | } |
1115 | 1113 | ||
1116 | #define temp_auto_point(offset) \ | 1114 | #define temp_auto_point(offset) \ |
1117 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp, S_IRUGO | S_IWUSR, \ | 1115 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp, \ |
1118 | show_temp_auto_point1_temp, set_temp_auto_point1_temp, \ | 1116 | S_IRUGO | S_IWUSR, show_temp_auto_point1_temp, \ |
1119 | offset - 1); \ | 1117 | set_temp_auto_point1_temp, offset - 1); \ |
1120 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO, \ | 1118 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO,\ |
1121 | show_temp_auto_point1_temp_hyst, NULL, offset - 1); \ | 1119 | show_temp_auto_point1_temp_hyst, NULL, offset - 1); \ |
1122 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \ | 1120 | static SENSOR_DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \ |
1123 | show_temp_auto_point2_temp, NULL, offset - 1); | 1121 | show_temp_auto_point2_temp, NULL, offset - 1); |
1124 | 1122 | ||
1125 | temp_auto_point(1); | 1123 | temp_auto_point(1); |
@@ -1130,7 +1128,7 @@ static ssize_t show_temp_crit_enable(struct device *dev, | |||
1130 | struct device_attribute *attr, char *buf) | 1128 | struct device_attribute *attr, char *buf) |
1131 | { | 1129 | { |
1132 | struct adm1026_data *data = adm1026_update_device(dev); | 1130 | struct adm1026_data *data = adm1026_update_device(dev); |
1133 | return sprintf(buf,"%d\n", (data->config1 & CFG1_THERM_HOT) >> 4); | 1131 | return sprintf(buf, "%d\n", (data->config1 & CFG1_THERM_HOT) >> 4); |
1134 | } | 1132 | } |
1135 | static ssize_t set_temp_crit_enable(struct device *dev, | 1133 | static ssize_t set_temp_crit_enable(struct device *dev, |
1136 | struct device_attribute *attr, const char *buf, size_t count) | 1134 | struct device_attribute *attr, const char *buf, size_t count) |
@@ -1142,7 +1140,7 @@ static ssize_t set_temp_crit_enable(struct device *dev, | |||
1142 | if ((val == 1) || (val==0)) { | 1140 | if ((val == 1) || (val==0)) { |
1143 | mutex_lock(&data->update_lock); | 1141 | mutex_lock(&data->update_lock); |
1144 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); | 1142 | data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4); |
1145 | adm1026_write_value(client, ADM1026_REG_CONFIG1, | 1143 | adm1026_write_value(client, ADM1026_REG_CONFIG1, |
1146 | data->config1); | 1144 | data->config1); |
1147 | mutex_unlock(&data->update_lock); | 1145 | mutex_unlock(&data->update_lock); |
1148 | } | 1146 | } |
@@ -1163,7 +1161,7 @@ static ssize_t show_temp_crit(struct device *dev, | |||
1163 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 1161 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
1164 | int nr = sensor_attr->index; | 1162 | int nr = sensor_attr->index; |
1165 | struct adm1026_data *data = adm1026_update_device(dev); | 1163 | struct adm1026_data *data = adm1026_update_device(dev); |
1166 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_crit[nr])); | 1164 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[nr])); |
1167 | } | 1165 | } |
1168 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | 1166 | static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, |
1169 | const char *buf, size_t count) | 1167 | const char *buf, size_t count) |
@@ -1193,7 +1191,7 @@ temp_crit_reg(3); | |||
1193 | static ssize_t show_analog_out_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1191 | static ssize_t show_analog_out_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1194 | { | 1192 | { |
1195 | struct adm1026_data *data = adm1026_update_device(dev); | 1193 | struct adm1026_data *data = adm1026_update_device(dev); |
1196 | return sprintf(buf,"%d\n", DAC_FROM_REG(data->analog_out)); | 1194 | return sprintf(buf, "%d\n", DAC_FROM_REG(data->analog_out)); |
1197 | } | 1195 | } |
1198 | static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *attr, const char *buf, | 1196 | static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *attr, const char *buf, |
1199 | size_t count) | 1197 | size_t count) |
@@ -1209,26 +1207,25 @@ static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *a | |||
1209 | return count; | 1207 | return count; |
1210 | } | 1208 | } |
1211 | 1209 | ||
1212 | static DEVICE_ATTR(analog_out, S_IRUGO | S_IWUSR, show_analog_out_reg, | 1210 | static DEVICE_ATTR(analog_out, S_IRUGO | S_IWUSR, show_analog_out_reg, |
1213 | set_analog_out_reg); | 1211 | set_analog_out_reg); |
1214 | 1212 | ||
1215 | static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1213 | static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1216 | { | 1214 | { |
1217 | struct adm1026_data *data = adm1026_update_device(dev); | 1215 | struct adm1026_data *data = adm1026_update_device(dev); |
1218 | return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); | 1216 | return sprintf(buf, "%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); |
1219 | } | 1217 | } |
1220 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); | 1218 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); |
1221 | 1219 | ||
1222 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1220 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1223 | { | 1221 | { |
1224 | struct adm1026_data *data = dev_get_drvdata(dev); | 1222 | struct adm1026_data *data = dev_get_drvdata(dev); |
1225 | return sprintf(buf,"%d\n", data->vrm); | 1223 | return sprintf(buf, "%d\n", data->vrm); |
1226 | } | 1224 | } |
1227 | static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, | 1225 | static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, |
1228 | size_t count) | 1226 | size_t count) |
1229 | { | 1227 | { |
1230 | struct i2c_client *client = to_i2c_client(dev); | 1228 | struct adm1026_data *data = dev_get_drvdata(dev); |
1231 | struct adm1026_data *data = i2c_get_clientdata(client); | ||
1232 | 1229 | ||
1233 | data->vrm = simple_strtol(buf, NULL, 10); | 1230 | data->vrm = simple_strtol(buf, NULL, 10); |
1234 | return count; | 1231 | return count; |
@@ -1239,15 +1236,52 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); | |||
1239 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1236 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1240 | { | 1237 | { |
1241 | struct adm1026_data *data = adm1026_update_device(dev); | 1238 | struct adm1026_data *data = adm1026_update_device(dev); |
1242 | return sprintf(buf, "%ld\n", (long) (data->alarms)); | 1239 | return sprintf(buf, "%ld\n", data->alarms); |
1243 | } | 1240 | } |
1244 | 1241 | ||
1245 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); | 1242 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); |
1246 | 1243 | ||
1244 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | ||
1245 | char *buf) | ||
1246 | { | ||
1247 | struct adm1026_data *data = adm1026_update_device(dev); | ||
1248 | int bitnr = to_sensor_dev_attr(attr)->index; | ||
1249 | return sprintf(buf, "%ld\n", (data->alarms >> bitnr) & 1); | ||
1250 | } | ||
1251 | |||
1252 | static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 0); | ||
1253 | static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
1254 | static SENSOR_DEVICE_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, 1); | ||
1255 | static SENSOR_DEVICE_ATTR(in11_alarm, S_IRUGO, show_alarm, NULL, 2); | ||
1256 | static SENSOR_DEVICE_ATTR(in12_alarm, S_IRUGO, show_alarm, NULL, 3); | ||
1257 | static SENSOR_DEVICE_ATTR(in13_alarm, S_IRUGO, show_alarm, NULL, 4); | ||
1258 | static SENSOR_DEVICE_ATTR(in14_alarm, S_IRUGO, show_alarm, NULL, 5); | ||
1259 | static SENSOR_DEVICE_ATTR(in15_alarm, S_IRUGO, show_alarm, NULL, 6); | ||
1260 | static SENSOR_DEVICE_ATTR(in16_alarm, S_IRUGO, show_alarm, NULL, 7); | ||
1261 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 8); | ||
1262 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 9); | ||
1263 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 10); | ||
1264 | static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 11); | ||
1265 | static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 12); | ||
1266 | static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 13); | ||
1267 | static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 14); | ||
1268 | static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 15); | ||
1269 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 16); | ||
1270 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 17); | ||
1271 | static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 18); | ||
1272 | static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 19); | ||
1273 | static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, 20); | ||
1274 | static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 21); | ||
1275 | static SENSOR_DEVICE_ATTR(fan7_alarm, S_IRUGO, show_alarm, NULL, 22); | ||
1276 | static SENSOR_DEVICE_ATTR(fan8_alarm, S_IRUGO, show_alarm, NULL, 23); | ||
1277 | static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 24); | ||
1278 | static SENSOR_DEVICE_ATTR(in10_alarm, S_IRUGO, show_alarm, NULL, 25); | ||
1279 | static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 26); | ||
1280 | |||
1247 | static ssize_t show_alarm_mask(struct device *dev, struct device_attribute *attr, char *buf) | 1281 | static ssize_t show_alarm_mask(struct device *dev, struct device_attribute *attr, char *buf) |
1248 | { | 1282 | { |
1249 | struct adm1026_data *data = adm1026_update_device(dev); | 1283 | struct adm1026_data *data = adm1026_update_device(dev); |
1250 | return sprintf(buf,"%ld\n", data->alarm_mask); | 1284 | return sprintf(buf, "%ld\n", data->alarm_mask); |
1251 | } | 1285 | } |
1252 | static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, const char *buf, | 1286 | static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr, const char *buf, |
1253 | size_t count) | 1287 | size_t count) |
@@ -1283,7 +1317,7 @@ static DEVICE_ATTR(alarm_mask, S_IRUGO | S_IWUSR, show_alarm_mask, | |||
1283 | static ssize_t show_gpio(struct device *dev, struct device_attribute *attr, char *buf) | 1317 | static ssize_t show_gpio(struct device *dev, struct device_attribute *attr, char *buf) |
1284 | { | 1318 | { |
1285 | struct adm1026_data *data = adm1026_update_device(dev); | 1319 | struct adm1026_data *data = adm1026_update_device(dev); |
1286 | return sprintf(buf,"%ld\n", data->gpio); | 1320 | return sprintf(buf, "%ld\n", data->gpio); |
1287 | } | 1321 | } |
1288 | static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const char *buf, | 1322 | static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const char *buf, |
1289 | size_t count) | 1323 | size_t count) |
@@ -1291,16 +1325,16 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const | |||
1291 | struct i2c_client *client = to_i2c_client(dev); | 1325 | struct i2c_client *client = to_i2c_client(dev); |
1292 | struct adm1026_data *data = i2c_get_clientdata(client); | 1326 | struct adm1026_data *data = i2c_get_clientdata(client); |
1293 | int val = simple_strtol(buf, NULL, 10); | 1327 | int val = simple_strtol(buf, NULL, 10); |
1294 | long gpio; | 1328 | long gpio; |
1295 | 1329 | ||
1296 | mutex_lock(&data->update_lock); | 1330 | mutex_lock(&data->update_lock); |
1297 | data->gpio = val & 0x1ffff; | 1331 | data->gpio = val & 0x1ffff; |
1298 | gpio = data->gpio; | 1332 | gpio = data->gpio; |
1299 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff); | 1333 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7, gpio & 0xff); |
1300 | gpio >>= 8; | 1334 | gpio >>= 8; |
1301 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff); | 1335 | adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15, gpio & 0xff); |
1302 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); | 1336 | gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f); |
1303 | adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff); | 1337 | adm1026_write_value(client, ADM1026_REG_STATUS4, gpio & 0xff); |
1304 | mutex_unlock(&data->update_lock); | 1338 | mutex_unlock(&data->update_lock); |
1305 | return count; | 1339 | return count; |
1306 | } | 1340 | } |
@@ -1311,7 +1345,7 @@ static DEVICE_ATTR(gpio, S_IRUGO | S_IWUSR, show_gpio, set_gpio); | |||
1311 | static ssize_t show_gpio_mask(struct device *dev, struct device_attribute *attr, char *buf) | 1345 | static ssize_t show_gpio_mask(struct device *dev, struct device_attribute *attr, char *buf) |
1312 | { | 1346 | { |
1313 | struct adm1026_data *data = adm1026_update_device(dev); | 1347 | struct adm1026_data *data = adm1026_update_device(dev); |
1314 | return sprintf(buf,"%ld\n", data->gpio_mask); | 1348 | return sprintf(buf, "%ld\n", data->gpio_mask); |
1315 | } | 1349 | } |
1316 | static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, const char *buf, | 1350 | static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, const char *buf, |
1317 | size_t count) | 1351 | size_t count) |
@@ -1319,16 +1353,16 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr, | |||
1319 | struct i2c_client *client = to_i2c_client(dev); | 1353 | struct i2c_client *client = to_i2c_client(dev); |
1320 | struct adm1026_data *data = i2c_get_clientdata(client); | 1354 | struct adm1026_data *data = i2c_get_clientdata(client); |
1321 | int val = simple_strtol(buf, NULL, 10); | 1355 | int val = simple_strtol(buf, NULL, 10); |
1322 | long mask; | 1356 | long mask; |
1323 | 1357 | ||
1324 | mutex_lock(&data->update_lock); | 1358 | mutex_lock(&data->update_lock); |
1325 | data->gpio_mask = val & 0x1ffff; | 1359 | data->gpio_mask = val & 0x1ffff; |
1326 | mask = data->gpio_mask; | 1360 | mask = data->gpio_mask; |
1327 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff); | 1361 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7, mask & 0xff); |
1328 | mask >>= 8; | 1362 | mask >>= 8; |
1329 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff); | 1363 | adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15, mask & 0xff); |
1330 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); | 1364 | mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f); |
1331 | adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff); | 1365 | adm1026_write_value(client, ADM1026_REG_MASK1, mask & 0xff); |
1332 | mutex_unlock(&data->update_lock); | 1366 | mutex_unlock(&data->update_lock); |
1333 | return count; | 1367 | return count; |
1334 | } | 1368 | } |
@@ -1338,7 +1372,7 @@ static DEVICE_ATTR(gpio_mask, S_IRUGO | S_IWUSR, show_gpio_mask, set_gpio_mask); | |||
1338 | static ssize_t show_pwm_reg(struct device *dev, struct device_attribute *attr, char *buf) | 1372 | static ssize_t show_pwm_reg(struct device *dev, struct device_attribute *attr, char *buf) |
1339 | { | 1373 | { |
1340 | struct adm1026_data *data = adm1026_update_device(dev); | 1374 | struct adm1026_data *data = adm1026_update_device(dev); |
1341 | return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm1.pwm)); | 1375 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm1.pwm)); |
1342 | } | 1376 | } |
1343 | static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, const char *buf, | 1377 | static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, const char *buf, |
1344 | size_t count) | 1378 | size_t count) |
@@ -1359,7 +1393,7 @@ static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, co | |||
1359 | static ssize_t show_auto_pwm_min(struct device *dev, struct device_attribute *attr, char *buf) | 1393 | static ssize_t show_auto_pwm_min(struct device *dev, struct device_attribute *attr, char *buf) |
1360 | { | 1394 | { |
1361 | struct adm1026_data *data = adm1026_update_device(dev); | 1395 | struct adm1026_data *data = adm1026_update_device(dev); |
1362 | return sprintf(buf,"%d\n", data->pwm1.auto_pwm_min); | 1396 | return sprintf(buf, "%d\n", data->pwm1.auto_pwm_min); |
1363 | } | 1397 | } |
1364 | static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *attr, const char *buf, | 1398 | static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *attr, const char *buf, |
1365 | size_t count) | 1399 | size_t count) |
@@ -1369,10 +1403,10 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att | |||
1369 | int val = simple_strtol(buf, NULL, 10); | 1403 | int val = simple_strtol(buf, NULL, 10); |
1370 | 1404 | ||
1371 | mutex_lock(&data->update_lock); | 1405 | mutex_lock(&data->update_lock); |
1372 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255); | 1406 | data->pwm1.auto_pwm_min = SENSORS_LIMIT(val, 0, 255); |
1373 | if (data->pwm1.enable == 2) { /* apply immediately */ | 1407 | if (data->pwm1.enable == 2) { /* apply immediately */ |
1374 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | | 1408 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | |
1375 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); | 1409 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); |
1376 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); | 1410 | adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm); |
1377 | } | 1411 | } |
1378 | mutex_unlock(&data->update_lock); | 1412 | mutex_unlock(&data->update_lock); |
@@ -1380,12 +1414,12 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att | |||
1380 | } | 1414 | } |
1381 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) | 1415 | static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf) |
1382 | { | 1416 | { |
1383 | return sprintf(buf,"%d\n", ADM1026_PWM_MAX); | 1417 | return sprintf(buf, "%d\n", ADM1026_PWM_MAX); |
1384 | } | 1418 | } |
1385 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf) | 1419 | static ssize_t show_pwm_enable(struct device *dev, struct device_attribute *attr, char *buf) |
1386 | { | 1420 | { |
1387 | struct adm1026_data *data = adm1026_update_device(dev); | 1421 | struct adm1026_data *data = adm1026_update_device(dev); |
1388 | return sprintf(buf,"%d\n", data->pwm1.enable); | 1422 | return sprintf(buf, "%d\n", data->pwm1.enable); |
1389 | } | 1423 | } |
1390 | static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, const char *buf, | 1424 | static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, const char *buf, |
1391 | size_t count) | 1425 | size_t count) |
@@ -1393,7 +1427,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1393 | struct i2c_client *client = to_i2c_client(dev); | 1427 | struct i2c_client *client = to_i2c_client(dev); |
1394 | struct adm1026_data *data = i2c_get_clientdata(client); | 1428 | struct adm1026_data *data = i2c_get_clientdata(client); |
1395 | int val = simple_strtol(buf, NULL, 10); | 1429 | int val = simple_strtol(buf, NULL, 10); |
1396 | int old_enable; | 1430 | int old_enable; |
1397 | 1431 | ||
1398 | if ((val >= 0) && (val < 3)) { | 1432 | if ((val >= 0) && (val < 3)) { |
1399 | mutex_lock(&data->update_lock); | 1433 | mutex_lock(&data->update_lock); |
@@ -1403,15 +1437,15 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1403 | | ((val == 2) ? CFG1_PWM_AFC : 0); | 1437 | | ((val == 2) ? CFG1_PWM_AFC : 0); |
1404 | adm1026_write_value(client, ADM1026_REG_CONFIG1, | 1438 | adm1026_write_value(client, ADM1026_REG_CONFIG1, |
1405 | data->config1); | 1439 | data->config1); |
1406 | if (val == 2) { /* apply pwm1_auto_pwm_min to pwm1 */ | 1440 | if (val == 2) { /* apply pwm1_auto_pwm_min to pwm1 */ |
1407 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | | 1441 | data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) | |
1408 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); | 1442 | PWM_MIN_TO_REG(data->pwm1.auto_pwm_min)); |
1409 | adm1026_write_value(client, ADM1026_REG_PWM, | 1443 | adm1026_write_value(client, ADM1026_REG_PWM, |
1410 | data->pwm1.pwm); | 1444 | data->pwm1.pwm); |
1411 | } else if (!((old_enable == 1) && (val == 1))) { | 1445 | } else if (!((old_enable == 1) && (val == 1))) { |
1412 | /* set pwm to safe value */ | 1446 | /* set pwm to safe value */ |
1413 | data->pwm1.pwm = 255; | 1447 | data->pwm1.pwm = 255; |
1414 | adm1026_write_value(client, ADM1026_REG_PWM, | 1448 | adm1026_write_value(client, ADM1026_REG_PWM, |
1415 | data->pwm1.pwm); | 1449 | data->pwm1.pwm); |
1416 | } | 1450 | } |
1417 | mutex_unlock(&data->update_lock); | 1451 | mutex_unlock(&data->update_lock); |
@@ -1420,20 +1454,20 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr, | |||
1420 | } | 1454 | } |
1421 | 1455 | ||
1422 | /* enable PWM fan control */ | 1456 | /* enable PWM fan control */ |
1423 | static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); | 1457 | static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); |
1424 | static DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); | 1458 | static DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); |
1425 | static DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); | 1459 | static DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, show_pwm_reg, set_pwm_reg); |
1426 | static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, | 1460 | static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, |
1427 | set_pwm_enable); | 1461 | set_pwm_enable); |
1428 | static DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, show_pwm_enable, | 1462 | static DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, show_pwm_enable, |
1429 | set_pwm_enable); | 1463 | set_pwm_enable); |
1430 | static DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, show_pwm_enable, | 1464 | static DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, show_pwm_enable, |
1431 | set_pwm_enable); | 1465 | set_pwm_enable); |
1432 | static DEVICE_ATTR(temp1_auto_point1_pwm, S_IRUGO | S_IWUSR, | 1466 | static DEVICE_ATTR(temp1_auto_point1_pwm, S_IRUGO | S_IWUSR, |
1433 | show_auto_pwm_min, set_auto_pwm_min); | 1467 | show_auto_pwm_min, set_auto_pwm_min); |
1434 | static DEVICE_ATTR(temp2_auto_point1_pwm, S_IRUGO | S_IWUSR, | 1468 | static DEVICE_ATTR(temp2_auto_point1_pwm, S_IRUGO | S_IWUSR, |
1435 | show_auto_pwm_min, set_auto_pwm_min); | 1469 | show_auto_pwm_min, set_auto_pwm_min); |
1436 | static DEVICE_ATTR(temp3_auto_point1_pwm, S_IRUGO | S_IWUSR, | 1470 | static DEVICE_ATTR(temp3_auto_point1_pwm, S_IRUGO | S_IWUSR, |
1437 | show_auto_pwm_min, set_auto_pwm_min); | 1471 | show_auto_pwm_min, set_auto_pwm_min); |
1438 | 1472 | ||
1439 | static DEVICE_ATTR(temp1_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); | 1473 | static DEVICE_ATTR(temp1_auto_point2_pwm, S_IRUGO, show_auto_pwm_max, NULL); |
@@ -1444,105 +1478,115 @@ static struct attribute *adm1026_attributes[] = { | |||
1444 | &sensor_dev_attr_in0_input.dev_attr.attr, | 1478 | &sensor_dev_attr_in0_input.dev_attr.attr, |
1445 | &sensor_dev_attr_in0_max.dev_attr.attr, | 1479 | &sensor_dev_attr_in0_max.dev_attr.attr, |
1446 | &sensor_dev_attr_in0_min.dev_attr.attr, | 1480 | &sensor_dev_attr_in0_min.dev_attr.attr, |
1481 | &sensor_dev_attr_in0_alarm.dev_attr.attr, | ||
1447 | &sensor_dev_attr_in1_input.dev_attr.attr, | 1482 | &sensor_dev_attr_in1_input.dev_attr.attr, |
1448 | &sensor_dev_attr_in1_max.dev_attr.attr, | 1483 | &sensor_dev_attr_in1_max.dev_attr.attr, |
1449 | &sensor_dev_attr_in1_min.dev_attr.attr, | 1484 | &sensor_dev_attr_in1_min.dev_attr.attr, |
1485 | &sensor_dev_attr_in1_alarm.dev_attr.attr, | ||
1450 | &sensor_dev_attr_in2_input.dev_attr.attr, | 1486 | &sensor_dev_attr_in2_input.dev_attr.attr, |
1451 | &sensor_dev_attr_in2_max.dev_attr.attr, | 1487 | &sensor_dev_attr_in2_max.dev_attr.attr, |
1452 | &sensor_dev_attr_in2_min.dev_attr.attr, | 1488 | &sensor_dev_attr_in2_min.dev_attr.attr, |
1489 | &sensor_dev_attr_in2_alarm.dev_attr.attr, | ||
1453 | &sensor_dev_attr_in3_input.dev_attr.attr, | 1490 | &sensor_dev_attr_in3_input.dev_attr.attr, |
1454 | &sensor_dev_attr_in3_max.dev_attr.attr, | 1491 | &sensor_dev_attr_in3_max.dev_attr.attr, |
1455 | &sensor_dev_attr_in3_min.dev_attr.attr, | 1492 | &sensor_dev_attr_in3_min.dev_attr.attr, |
1493 | &sensor_dev_attr_in3_alarm.dev_attr.attr, | ||
1456 | &sensor_dev_attr_in4_input.dev_attr.attr, | 1494 | &sensor_dev_attr_in4_input.dev_attr.attr, |
1457 | &sensor_dev_attr_in4_max.dev_attr.attr, | 1495 | &sensor_dev_attr_in4_max.dev_attr.attr, |
1458 | &sensor_dev_attr_in4_min.dev_attr.attr, | 1496 | &sensor_dev_attr_in4_min.dev_attr.attr, |
1497 | &sensor_dev_attr_in4_alarm.dev_attr.attr, | ||
1459 | &sensor_dev_attr_in5_input.dev_attr.attr, | 1498 | &sensor_dev_attr_in5_input.dev_attr.attr, |
1460 | &sensor_dev_attr_in5_max.dev_attr.attr, | 1499 | &sensor_dev_attr_in5_max.dev_attr.attr, |
1461 | &sensor_dev_attr_in5_min.dev_attr.attr, | 1500 | &sensor_dev_attr_in5_min.dev_attr.attr, |
1501 | &sensor_dev_attr_in5_alarm.dev_attr.attr, | ||
1462 | &sensor_dev_attr_in6_input.dev_attr.attr, | 1502 | &sensor_dev_attr_in6_input.dev_attr.attr, |
1463 | &sensor_dev_attr_in6_max.dev_attr.attr, | 1503 | &sensor_dev_attr_in6_max.dev_attr.attr, |
1464 | &sensor_dev_attr_in6_min.dev_attr.attr, | 1504 | &sensor_dev_attr_in6_min.dev_attr.attr, |
1505 | &sensor_dev_attr_in6_alarm.dev_attr.attr, | ||
1465 | &sensor_dev_attr_in7_input.dev_attr.attr, | 1506 | &sensor_dev_attr_in7_input.dev_attr.attr, |
1466 | &sensor_dev_attr_in7_max.dev_attr.attr, | 1507 | &sensor_dev_attr_in7_max.dev_attr.attr, |
1467 | &sensor_dev_attr_in7_min.dev_attr.attr, | 1508 | &sensor_dev_attr_in7_min.dev_attr.attr, |
1468 | &sensor_dev_attr_in8_input.dev_attr.attr, | 1509 | &sensor_dev_attr_in7_alarm.dev_attr.attr, |
1469 | &sensor_dev_attr_in8_max.dev_attr.attr, | ||
1470 | &sensor_dev_attr_in8_min.dev_attr.attr, | ||
1471 | &sensor_dev_attr_in9_input.dev_attr.attr, | ||
1472 | &sensor_dev_attr_in9_max.dev_attr.attr, | ||
1473 | &sensor_dev_attr_in9_min.dev_attr.attr, | ||
1474 | &sensor_dev_attr_in10_input.dev_attr.attr, | 1510 | &sensor_dev_attr_in10_input.dev_attr.attr, |
1475 | &sensor_dev_attr_in10_max.dev_attr.attr, | 1511 | &sensor_dev_attr_in10_max.dev_attr.attr, |
1476 | &sensor_dev_attr_in10_min.dev_attr.attr, | 1512 | &sensor_dev_attr_in10_min.dev_attr.attr, |
1513 | &sensor_dev_attr_in10_alarm.dev_attr.attr, | ||
1477 | &sensor_dev_attr_in11_input.dev_attr.attr, | 1514 | &sensor_dev_attr_in11_input.dev_attr.attr, |
1478 | &sensor_dev_attr_in11_max.dev_attr.attr, | 1515 | &sensor_dev_attr_in11_max.dev_attr.attr, |
1479 | &sensor_dev_attr_in11_min.dev_attr.attr, | 1516 | &sensor_dev_attr_in11_min.dev_attr.attr, |
1517 | &sensor_dev_attr_in11_alarm.dev_attr.attr, | ||
1480 | &sensor_dev_attr_in12_input.dev_attr.attr, | 1518 | &sensor_dev_attr_in12_input.dev_attr.attr, |
1481 | &sensor_dev_attr_in12_max.dev_attr.attr, | 1519 | &sensor_dev_attr_in12_max.dev_attr.attr, |
1482 | &sensor_dev_attr_in12_min.dev_attr.attr, | 1520 | &sensor_dev_attr_in12_min.dev_attr.attr, |
1521 | &sensor_dev_attr_in12_alarm.dev_attr.attr, | ||
1483 | &sensor_dev_attr_in13_input.dev_attr.attr, | 1522 | &sensor_dev_attr_in13_input.dev_attr.attr, |
1484 | &sensor_dev_attr_in13_max.dev_attr.attr, | 1523 | &sensor_dev_attr_in13_max.dev_attr.attr, |
1485 | &sensor_dev_attr_in13_min.dev_attr.attr, | 1524 | &sensor_dev_attr_in13_min.dev_attr.attr, |
1525 | &sensor_dev_attr_in13_alarm.dev_attr.attr, | ||
1486 | &sensor_dev_attr_in14_input.dev_attr.attr, | 1526 | &sensor_dev_attr_in14_input.dev_attr.attr, |
1487 | &sensor_dev_attr_in14_max.dev_attr.attr, | 1527 | &sensor_dev_attr_in14_max.dev_attr.attr, |
1488 | &sensor_dev_attr_in14_min.dev_attr.attr, | 1528 | &sensor_dev_attr_in14_min.dev_attr.attr, |
1529 | &sensor_dev_attr_in14_alarm.dev_attr.attr, | ||
1489 | &sensor_dev_attr_in15_input.dev_attr.attr, | 1530 | &sensor_dev_attr_in15_input.dev_attr.attr, |
1490 | &sensor_dev_attr_in15_max.dev_attr.attr, | 1531 | &sensor_dev_attr_in15_max.dev_attr.attr, |
1491 | &sensor_dev_attr_in15_min.dev_attr.attr, | 1532 | &sensor_dev_attr_in15_min.dev_attr.attr, |
1533 | &sensor_dev_attr_in15_alarm.dev_attr.attr, | ||
1492 | &sensor_dev_attr_in16_input.dev_attr.attr, | 1534 | &sensor_dev_attr_in16_input.dev_attr.attr, |
1493 | &sensor_dev_attr_in16_max.dev_attr.attr, | 1535 | &sensor_dev_attr_in16_max.dev_attr.attr, |
1494 | &sensor_dev_attr_in16_min.dev_attr.attr, | 1536 | &sensor_dev_attr_in16_min.dev_attr.attr, |
1537 | &sensor_dev_attr_in16_alarm.dev_attr.attr, | ||
1495 | &sensor_dev_attr_fan1_input.dev_attr.attr, | 1538 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
1496 | &sensor_dev_attr_fan1_div.dev_attr.attr, | 1539 | &sensor_dev_attr_fan1_div.dev_attr.attr, |
1497 | &sensor_dev_attr_fan1_min.dev_attr.attr, | 1540 | &sensor_dev_attr_fan1_min.dev_attr.attr, |
1541 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
1498 | &sensor_dev_attr_fan2_input.dev_attr.attr, | 1542 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
1499 | &sensor_dev_attr_fan2_div.dev_attr.attr, | 1543 | &sensor_dev_attr_fan2_div.dev_attr.attr, |
1500 | &sensor_dev_attr_fan2_min.dev_attr.attr, | 1544 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
1545 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
1501 | &sensor_dev_attr_fan3_input.dev_attr.attr, | 1546 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
1502 | &sensor_dev_attr_fan3_div.dev_attr.attr, | 1547 | &sensor_dev_attr_fan3_div.dev_attr.attr, |
1503 | &sensor_dev_attr_fan3_min.dev_attr.attr, | 1548 | &sensor_dev_attr_fan3_min.dev_attr.attr, |
1549 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | ||
1504 | &sensor_dev_attr_fan4_input.dev_attr.attr, | 1550 | &sensor_dev_attr_fan4_input.dev_attr.attr, |
1505 | &sensor_dev_attr_fan4_div.dev_attr.attr, | 1551 | &sensor_dev_attr_fan4_div.dev_attr.attr, |
1506 | &sensor_dev_attr_fan4_min.dev_attr.attr, | 1552 | &sensor_dev_attr_fan4_min.dev_attr.attr, |
1553 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, | ||
1507 | &sensor_dev_attr_fan5_input.dev_attr.attr, | 1554 | &sensor_dev_attr_fan5_input.dev_attr.attr, |
1508 | &sensor_dev_attr_fan5_div.dev_attr.attr, | 1555 | &sensor_dev_attr_fan5_div.dev_attr.attr, |
1509 | &sensor_dev_attr_fan5_min.dev_attr.attr, | 1556 | &sensor_dev_attr_fan5_min.dev_attr.attr, |
1557 | &sensor_dev_attr_fan5_alarm.dev_attr.attr, | ||
1510 | &sensor_dev_attr_fan6_input.dev_attr.attr, | 1558 | &sensor_dev_attr_fan6_input.dev_attr.attr, |
1511 | &sensor_dev_attr_fan6_div.dev_attr.attr, | 1559 | &sensor_dev_attr_fan6_div.dev_attr.attr, |
1512 | &sensor_dev_attr_fan6_min.dev_attr.attr, | 1560 | &sensor_dev_attr_fan6_min.dev_attr.attr, |
1561 | &sensor_dev_attr_fan6_alarm.dev_attr.attr, | ||
1513 | &sensor_dev_attr_fan7_input.dev_attr.attr, | 1562 | &sensor_dev_attr_fan7_input.dev_attr.attr, |
1514 | &sensor_dev_attr_fan7_div.dev_attr.attr, | 1563 | &sensor_dev_attr_fan7_div.dev_attr.attr, |
1515 | &sensor_dev_attr_fan7_min.dev_attr.attr, | 1564 | &sensor_dev_attr_fan7_min.dev_attr.attr, |
1565 | &sensor_dev_attr_fan7_alarm.dev_attr.attr, | ||
1516 | &sensor_dev_attr_fan8_input.dev_attr.attr, | 1566 | &sensor_dev_attr_fan8_input.dev_attr.attr, |
1517 | &sensor_dev_attr_fan8_div.dev_attr.attr, | 1567 | &sensor_dev_attr_fan8_div.dev_attr.attr, |
1518 | &sensor_dev_attr_fan8_min.dev_attr.attr, | 1568 | &sensor_dev_attr_fan8_min.dev_attr.attr, |
1569 | &sensor_dev_attr_fan8_alarm.dev_attr.attr, | ||
1519 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 1570 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
1520 | &sensor_dev_attr_temp1_max.dev_attr.attr, | 1571 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
1521 | &sensor_dev_attr_temp1_min.dev_attr.attr, | 1572 | &sensor_dev_attr_temp1_min.dev_attr.attr, |
1573 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | ||
1522 | &sensor_dev_attr_temp2_input.dev_attr.attr, | 1574 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
1523 | &sensor_dev_attr_temp2_max.dev_attr.attr, | 1575 | &sensor_dev_attr_temp2_max.dev_attr.attr, |
1524 | &sensor_dev_attr_temp2_min.dev_attr.attr, | 1576 | &sensor_dev_attr_temp2_min.dev_attr.attr, |
1525 | &sensor_dev_attr_temp3_input.dev_attr.attr, | 1577 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, |
1526 | &sensor_dev_attr_temp3_max.dev_attr.attr, | ||
1527 | &sensor_dev_attr_temp3_min.dev_attr.attr, | ||
1528 | &sensor_dev_attr_temp1_offset.dev_attr.attr, | 1578 | &sensor_dev_attr_temp1_offset.dev_attr.attr, |
1529 | &sensor_dev_attr_temp2_offset.dev_attr.attr, | 1579 | &sensor_dev_attr_temp2_offset.dev_attr.attr, |
1530 | &sensor_dev_attr_temp3_offset.dev_attr.attr, | ||
1531 | &sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr, | 1580 | &sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr, |
1532 | &sensor_dev_attr_temp2_auto_point1_temp.dev_attr.attr, | 1581 | &sensor_dev_attr_temp2_auto_point1_temp.dev_attr.attr, |
1533 | &sensor_dev_attr_temp3_auto_point1_temp.dev_attr.attr, | ||
1534 | &sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr.attr, | 1582 | &sensor_dev_attr_temp1_auto_point1_temp_hyst.dev_attr.attr, |
1535 | &sensor_dev_attr_temp2_auto_point1_temp_hyst.dev_attr.attr, | 1583 | &sensor_dev_attr_temp2_auto_point1_temp_hyst.dev_attr.attr, |
1536 | &sensor_dev_attr_temp3_auto_point1_temp_hyst.dev_attr.attr, | ||
1537 | &sensor_dev_attr_temp1_auto_point2_temp.dev_attr.attr, | 1584 | &sensor_dev_attr_temp1_auto_point2_temp.dev_attr.attr, |
1538 | &sensor_dev_attr_temp2_auto_point2_temp.dev_attr.attr, | 1585 | &sensor_dev_attr_temp2_auto_point2_temp.dev_attr.attr, |
1539 | &sensor_dev_attr_temp3_auto_point2_temp.dev_attr.attr, | ||
1540 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | 1586 | &sensor_dev_attr_temp1_crit.dev_attr.attr, |
1541 | &sensor_dev_attr_temp2_crit.dev_attr.attr, | 1587 | &sensor_dev_attr_temp2_crit.dev_attr.attr, |
1542 | &sensor_dev_attr_temp3_crit.dev_attr.attr, | ||
1543 | &dev_attr_temp1_crit_enable.attr, | 1588 | &dev_attr_temp1_crit_enable.attr, |
1544 | &dev_attr_temp2_crit_enable.attr, | 1589 | &dev_attr_temp2_crit_enable.attr, |
1545 | &dev_attr_temp3_crit_enable.attr, | ||
1546 | &dev_attr_cpu0_vid.attr, | 1590 | &dev_attr_cpu0_vid.attr, |
1547 | &dev_attr_vrm.attr, | 1591 | &dev_attr_vrm.attr, |
1548 | &dev_attr_alarms.attr, | 1592 | &dev_attr_alarms.attr, |
@@ -1557,10 +1601,8 @@ static struct attribute *adm1026_attributes[] = { | |||
1557 | &dev_attr_pwm3_enable.attr, | 1601 | &dev_attr_pwm3_enable.attr, |
1558 | &dev_attr_temp1_auto_point1_pwm.attr, | 1602 | &dev_attr_temp1_auto_point1_pwm.attr, |
1559 | &dev_attr_temp2_auto_point1_pwm.attr, | 1603 | &dev_attr_temp2_auto_point1_pwm.attr, |
1560 | &dev_attr_temp3_auto_point1_pwm.attr, | ||
1561 | &dev_attr_temp1_auto_point2_pwm.attr, | 1604 | &dev_attr_temp1_auto_point2_pwm.attr, |
1562 | &dev_attr_temp2_auto_point2_pwm.attr, | 1605 | &dev_attr_temp2_auto_point2_pwm.attr, |
1563 | &dev_attr_temp3_auto_point2_pwm.attr, | ||
1564 | &dev_attr_analog_out.attr, | 1606 | &dev_attr_analog_out.attr, |
1565 | NULL | 1607 | NULL |
1566 | }; | 1608 | }; |
@@ -1569,11 +1611,45 @@ static const struct attribute_group adm1026_group = { | |||
1569 | .attrs = adm1026_attributes, | 1611 | .attrs = adm1026_attributes, |
1570 | }; | 1612 | }; |
1571 | 1613 | ||
1614 | static struct attribute *adm1026_attributes_temp3[] = { | ||
1615 | &sensor_dev_attr_temp3_input.dev_attr.attr, | ||
1616 | &sensor_dev_attr_temp3_max.dev_attr.attr, | ||
1617 | &sensor_dev_attr_temp3_min.dev_attr.attr, | ||
1618 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | ||
1619 | &sensor_dev_attr_temp3_offset.dev_attr.attr, | ||
1620 | &sensor_dev_attr_temp3_auto_point1_temp.dev_attr.attr, | ||
1621 | &sensor_dev_attr_temp3_auto_point1_temp_hyst.dev_attr.attr, | ||
1622 | &sensor_dev_attr_temp3_auto_point2_temp.dev_attr.attr, | ||
1623 | &sensor_dev_attr_temp3_crit.dev_attr.attr, | ||
1624 | &dev_attr_temp3_crit_enable.attr, | ||
1625 | &dev_attr_temp3_auto_point1_pwm.attr, | ||
1626 | &dev_attr_temp3_auto_point2_pwm.attr, | ||
1627 | }; | ||
1628 | |||
1629 | static const struct attribute_group adm1026_group_temp3 = { | ||
1630 | .attrs = adm1026_attributes_temp3, | ||
1631 | }; | ||
1632 | |||
1633 | static struct attribute *adm1026_attributes_in8_9[] = { | ||
1634 | &sensor_dev_attr_in8_input.dev_attr.attr, | ||
1635 | &sensor_dev_attr_in8_max.dev_attr.attr, | ||
1636 | &sensor_dev_attr_in8_min.dev_attr.attr, | ||
1637 | &sensor_dev_attr_in8_alarm.dev_attr.attr, | ||
1638 | &sensor_dev_attr_in9_input.dev_attr.attr, | ||
1639 | &sensor_dev_attr_in9_max.dev_attr.attr, | ||
1640 | &sensor_dev_attr_in9_min.dev_attr.attr, | ||
1641 | &sensor_dev_attr_in9_alarm.dev_attr.attr, | ||
1642 | }; | ||
1643 | |||
1644 | static const struct attribute_group adm1026_group_in8_9 = { | ||
1645 | .attrs = adm1026_attributes_in8_9, | ||
1646 | }; | ||
1647 | |||
1572 | static int adm1026_detect(struct i2c_adapter *adapter, int address, | 1648 | static int adm1026_detect(struct i2c_adapter *adapter, int address, |
1573 | int kind) | 1649 | int kind) |
1574 | { | 1650 | { |
1575 | int company, verstep; | 1651 | int company, verstep; |
1576 | struct i2c_client *new_client; | 1652 | struct i2c_client *client; |
1577 | struct adm1026_data *data; | 1653 | struct adm1026_data *data; |
1578 | int err = 0; | 1654 | int err = 0; |
1579 | const char *type_name = ""; | 1655 | const char *type_name = ""; |
@@ -1592,26 +1668,25 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1592 | goto exit; | 1668 | goto exit; |
1593 | } | 1669 | } |
1594 | 1670 | ||
1595 | new_client = &data->client; | 1671 | client = &data->client; |
1596 | i2c_set_clientdata(new_client, data); | 1672 | i2c_set_clientdata(client, data); |
1597 | new_client->addr = address; | 1673 | client->addr = address; |
1598 | new_client->adapter = adapter; | 1674 | client->adapter = adapter; |
1599 | new_client->driver = &adm1026_driver; | 1675 | client->driver = &adm1026_driver; |
1600 | new_client->flags = 0; | ||
1601 | 1676 | ||
1602 | /* Now, we do the remaining detection. */ | 1677 | /* Now, we do the remaining detection. */ |
1603 | 1678 | ||
1604 | company = adm1026_read_value(new_client, ADM1026_REG_COMPANY); | 1679 | company = adm1026_read_value(client, ADM1026_REG_COMPANY); |
1605 | verstep = adm1026_read_value(new_client, ADM1026_REG_VERSTEP); | 1680 | verstep = adm1026_read_value(client, ADM1026_REG_VERSTEP); |
1606 | 1681 | ||
1607 | dev_dbg(&new_client->dev, "Detecting device at %d,0x%02x with" | 1682 | dev_dbg(&client->dev, "Detecting device at %d,0x%02x with" |
1608 | " COMPANY: 0x%02x and VERSTEP: 0x%02x\n", | 1683 | " COMPANY: 0x%02x and VERSTEP: 0x%02x\n", |
1609 | i2c_adapter_id(new_client->adapter), new_client->addr, | 1684 | i2c_adapter_id(client->adapter), client->addr, |
1610 | company, verstep); | 1685 | company, verstep); |
1611 | 1686 | ||
1612 | /* If auto-detecting, Determine the chip type. */ | 1687 | /* If auto-detecting, Determine the chip type. */ |
1613 | if (kind <= 0) { | 1688 | if (kind <= 0) { |
1614 | dev_dbg(&new_client->dev, "Autodetecting device at %d,0x%02x " | 1689 | dev_dbg(&client->dev, "Autodetecting device at %d,0x%02x " |
1615 | "...\n", i2c_adapter_id(adapter), address); | 1690 | "...\n", i2c_adapter_id(adapter), address); |
1616 | if (company == ADM1026_COMPANY_ANALOG_DEV | 1691 | if (company == ADM1026_COMPANY_ANALOG_DEV |
1617 | && verstep == ADM1026_VERSTEP_ADM1026) { | 1692 | && verstep == ADM1026_VERSTEP_ADM1026) { |
@@ -1627,16 +1702,15 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1627 | verstep); | 1702 | verstep); |
1628 | kind = any_chip; | 1703 | kind = any_chip; |
1629 | } else { | 1704 | } else { |
1630 | dev_dbg(&new_client->dev, ": Autodetection " | 1705 | dev_dbg(&client->dev, ": Autodetection " |
1631 | "failed\n"); | 1706 | "failed\n"); |
1632 | /* Not an ADM1026 ... */ | 1707 | /* Not an ADM1026 ... */ |
1633 | if (kind == 0) { /* User used force=x,y */ | 1708 | if (kind == 0) { /* User used force=x,y */ |
1634 | dev_err(&adapter->dev, "Generic ADM1026 not " | 1709 | dev_err(&adapter->dev, "Generic ADM1026 not " |
1635 | "found at %d,0x%02x. Try " | 1710 | "found at %d,0x%02x. Try " |
1636 | "force_adm1026.\n", | 1711 | "force_adm1026.\n", |
1637 | i2c_adapter_id(adapter), address); | 1712 | i2c_adapter_id(adapter), address); |
1638 | } | 1713 | } |
1639 | err = 0; | ||
1640 | goto exitfree; | 1714 | goto exitfree; |
1641 | } | 1715 | } |
1642 | } | 1716 | } |
@@ -1655,28 +1729,34 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1655 | err = -EFAULT; | 1729 | err = -EFAULT; |
1656 | goto exitfree; | 1730 | goto exitfree; |
1657 | } | 1731 | } |
1658 | strlcpy(new_client->name, type_name, I2C_NAME_SIZE); | 1732 | strlcpy(client->name, type_name, I2C_NAME_SIZE); |
1659 | 1733 | ||
1660 | /* Fill in the remaining client fields */ | 1734 | /* Fill in the remaining client fields */ |
1661 | data->type = kind; | ||
1662 | data->valid = 0; | ||
1663 | mutex_init(&data->update_lock); | 1735 | mutex_init(&data->update_lock); |
1664 | 1736 | ||
1665 | /* Tell the I2C layer a new client has arrived */ | 1737 | /* Tell the I2C layer a new client has arrived */ |
1666 | if ((err = i2c_attach_client(new_client))) | 1738 | if ((err = i2c_attach_client(client))) |
1667 | goto exitfree; | 1739 | goto exitfree; |
1668 | 1740 | ||
1669 | /* Set the VRM version */ | 1741 | /* Set the VRM version */ |
1670 | data->vrm = vid_which_vrm(); | 1742 | data->vrm = vid_which_vrm(); |
1671 | 1743 | ||
1672 | /* Initialize the ADM1026 chip */ | 1744 | /* Initialize the ADM1026 chip */ |
1673 | adm1026_init_client(new_client); | 1745 | adm1026_init_client(client); |
1674 | 1746 | ||
1675 | /* Register sysfs hooks */ | 1747 | /* Register sysfs hooks */ |
1676 | if ((err = sysfs_create_group(&new_client->dev.kobj, &adm1026_group))) | 1748 | if ((err = sysfs_create_group(&client->dev.kobj, &adm1026_group))) |
1677 | goto exitdetach; | 1749 | goto exitdetach; |
1750 | if (data->config1 & CFG1_AIN8_9) | ||
1751 | err = sysfs_create_group(&client->dev.kobj, | ||
1752 | &adm1026_group_in8_9); | ||
1753 | else | ||
1754 | err = sysfs_create_group(&client->dev.kobj, | ||
1755 | &adm1026_group_temp3); | ||
1756 | if (err) | ||
1757 | goto exitremove; | ||
1678 | 1758 | ||
1679 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 1759 | data->hwmon_dev = hwmon_device_register(&client->dev); |
1680 | if (IS_ERR(data->hwmon_dev)) { | 1760 | if (IS_ERR(data->hwmon_dev)) { |
1681 | err = PTR_ERR(data->hwmon_dev); | 1761 | err = PTR_ERR(data->hwmon_dev); |
1682 | goto exitremove; | 1762 | goto exitremove; |
@@ -1686,9 +1766,13 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, | |||
1686 | 1766 | ||
1687 | /* Error out and cleanup code */ | 1767 | /* Error out and cleanup code */ |
1688 | exitremove: | 1768 | exitremove: |
1689 | sysfs_remove_group(&new_client->dev.kobj, &adm1026_group); | 1769 | sysfs_remove_group(&client->dev.kobj, &adm1026_group); |
1770 | if (data->config1 & CFG1_AIN8_9) | ||
1771 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_in8_9); | ||
1772 | else | ||
1773 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_temp3); | ||
1690 | exitdetach: | 1774 | exitdetach: |
1691 | i2c_detach_client(new_client); | 1775 | i2c_detach_client(client); |
1692 | exitfree: | 1776 | exitfree: |
1693 | kfree(data); | 1777 | kfree(data); |
1694 | exit: | 1778 | exit: |
@@ -1700,6 +1784,10 @@ static int adm1026_detach_client(struct i2c_client *client) | |||
1700 | struct adm1026_data *data = i2c_get_clientdata(client); | 1784 | struct adm1026_data *data = i2c_get_clientdata(client); |
1701 | hwmon_device_unregister(data->hwmon_dev); | 1785 | hwmon_device_unregister(data->hwmon_dev); |
1702 | sysfs_remove_group(&client->dev.kobj, &adm1026_group); | 1786 | sysfs_remove_group(&client->dev.kobj, &adm1026_group); |
1787 | if (data->config1 & CFG1_AIN8_9) | ||
1788 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_in8_9); | ||
1789 | else | ||
1790 | sysfs_remove_group(&client->dev.kobj, &adm1026_group_temp3); | ||
1703 | i2c_detach_client(client); | 1791 | i2c_detach_client(client); |
1704 | kfree(data); | 1792 | kfree(data); |
1705 | return 0; | 1793 | return 0; |
@@ -1710,14 +1798,14 @@ static int __init sm_adm1026_init(void) | |||
1710 | return i2c_add_driver(&adm1026_driver); | 1798 | return i2c_add_driver(&adm1026_driver); |
1711 | } | 1799 | } |
1712 | 1800 | ||
1713 | static void __exit sm_adm1026_exit(void) | 1801 | static void __exit sm_adm1026_exit(void) |
1714 | { | 1802 | { |
1715 | i2c_del_driver(&adm1026_driver); | 1803 | i2c_del_driver(&adm1026_driver); |
1716 | } | 1804 | } |
1717 | 1805 | ||
1718 | MODULE_LICENSE("GPL"); | 1806 | MODULE_LICENSE("GPL"); |
1719 | MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, " | 1807 | MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, " |
1720 | "Justin Thiessen <jthiessen@penguincomputing.com>"); | 1808 | "Justin Thiessen <jthiessen@penguincomputing.com>"); |
1721 | MODULE_DESCRIPTION("ADM1026 driver"); | 1809 | MODULE_DESCRIPTION("ADM1026 driver"); |
1722 | 1810 | ||
1723 | module_init(sm_adm1026_init); | 1811 | module_init(sm_adm1026_init); |