asc7621.c (dca3a783400a18e2bf4503b1d4a85c4d0ca1a7e4) | asc7621.c (088ce2ac9ebac5c74faf4d39083627875fa6f0f0) |
---|---|
1/* 2 * asc7621.c - Part of lm_sensors, Linux kernel modules for hardware monitoring 3 * Copyright (c) 2007, 2010 George Joseph <george.joseph@fairview5.com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 145 unchanged lines hidden (view full) --- 154} 155 156/* 157 * Data Handlers 158 * Each function handles the formatting, storage 159 * and retrieval of like parameters. 160 */ 161 | 1/* 2 * asc7621.c - Part of lm_sensors, Linux kernel modules for hardware monitoring 3 * Copyright (c) 2007, 2010 George Joseph <george.joseph@fairview5.com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. --- 145 unchanged lines hidden (view full) --- 154} 155 156/* 157 * Data Handlers 158 * Each function handles the formatting, storage 159 * and retrieval of like parameters. 160 */ 161 |
162#define SETUP_SHOW_data_param(d, a) \ | 162#define SETUP_SHOW_DATA_PARAM(d, a) \ |
163 struct sensor_device_attribute *sda = to_sensor_dev_attr(a); \ 164 struct asc7621_data *data = asc7621_update_device(d); \ 165 struct asc7621_param *param = to_asc7621_param(sda) 166 | 163 struct sensor_device_attribute *sda = to_sensor_dev_attr(a); \ 164 struct asc7621_data *data = asc7621_update_device(d); \ 165 struct asc7621_param *param = to_asc7621_param(sda) 166 |
167#define SETUP_STORE_data_param(d, a) \ | 167#define SETUP_STORE_DATA_PARAM(d, a) \ |
168 struct sensor_device_attribute *sda = to_sensor_dev_attr(a); \ 169 struct i2c_client *client = to_i2c_client(d); \ 170 struct asc7621_data *data = i2c_get_clientdata(client); \ 171 struct asc7621_param *param = to_asc7621_param(sda) 172 173/* 174 * u8 is just what it sounds like...an unsigned byte with no 175 * special formatting. 176 */ 177static ssize_t show_u8(struct device *dev, struct device_attribute *attr, 178 char *buf) 179{ | 168 struct sensor_device_attribute *sda = to_sensor_dev_attr(a); \ 169 struct i2c_client *client = to_i2c_client(d); \ 170 struct asc7621_data *data = i2c_get_clientdata(client); \ 171 struct asc7621_param *param = to_asc7621_param(sda) 172 173/* 174 * u8 is just what it sounds like...an unsigned byte with no 175 * special formatting. 176 */ 177static ssize_t show_u8(struct device *dev, struct device_attribute *attr, 178 char *buf) 179{ |
180 SETUP_SHOW_data_param(dev, attr); | 180 SETUP_SHOW_DATA_PARAM(dev, attr); |
181 182 return sprintf(buf, "%u\n", data->reg[param->msb[0]]); 183} 184 185static ssize_t store_u8(struct device *dev, struct device_attribute *attr, 186 const char *buf, size_t count) 187{ | 181 182 return sprintf(buf, "%u\n", data->reg[param->msb[0]]); 183} 184 185static ssize_t store_u8(struct device *dev, struct device_attribute *attr, 186 const char *buf, size_t count) 187{ |
188 SETUP_STORE_data_param(dev, attr); | 188 SETUP_STORE_DATA_PARAM(dev, attr); |
189 long reqval; 190 191 if (kstrtol(buf, 10, &reqval)) 192 return -EINVAL; 193 194 reqval = clamp_val(reqval, 0, 255); 195 196 mutex_lock(&data->update_lock); --- 4 unchanged lines hidden (view full) --- 201} 202 203/* 204 * Many of the config values occupy only a few bits of a register. 205 */ 206static ssize_t show_bitmask(struct device *dev, 207 struct device_attribute *attr, char *buf) 208{ | 189 long reqval; 190 191 if (kstrtol(buf, 10, &reqval)) 192 return -EINVAL; 193 194 reqval = clamp_val(reqval, 0, 255); 195 196 mutex_lock(&data->update_lock); --- 4 unchanged lines hidden (view full) --- 201} 202 203/* 204 * Many of the config values occupy only a few bits of a register. 205 */ 206static ssize_t show_bitmask(struct device *dev, 207 struct device_attribute *attr, char *buf) 208{ |
209 SETUP_SHOW_data_param(dev, attr); | 209 SETUP_SHOW_DATA_PARAM(dev, attr); |
210 211 return sprintf(buf, "%u\n", 212 (data->reg[param->msb[0]] >> param-> 213 shift[0]) & param->mask[0]); 214} 215 216static ssize_t store_bitmask(struct device *dev, 217 struct device_attribute *attr, 218 const char *buf, size_t count) 219{ | 210 211 return sprintf(buf, "%u\n", 212 (data->reg[param->msb[0]] >> param-> 213 shift[0]) & param->mask[0]); 214} 215 216static ssize_t store_bitmask(struct device *dev, 217 struct device_attribute *attr, 218 const char *buf, size_t count) 219{ |
220 SETUP_STORE_data_param(dev, attr); | 220 SETUP_STORE_DATA_PARAM(dev, attr); |
221 long reqval; 222 u8 currval; 223 224 if (kstrtol(buf, 10, &reqval)) 225 return -EINVAL; 226 227 reqval = clamp_val(reqval, 0, param->mask[0]); 228 --- 12 unchanged lines hidden (view full) --- 241 * 16 bit fan rpm values 242 * reported by the device as the number of 11.111us periods (90khz) 243 * between full fan rotations. Therefore... 244 * RPM = (90000 * 60) / register value 245 */ 246static ssize_t show_fan16(struct device *dev, 247 struct device_attribute *attr, char *buf) 248{ | 221 long reqval; 222 u8 currval; 223 224 if (kstrtol(buf, 10, &reqval)) 225 return -EINVAL; 226 227 reqval = clamp_val(reqval, 0, param->mask[0]); 228 --- 12 unchanged lines hidden (view full) --- 241 * 16 bit fan rpm values 242 * reported by the device as the number of 11.111us periods (90khz) 243 * between full fan rotations. Therefore... 244 * RPM = (90000 * 60) / register value 245 */ 246static ssize_t show_fan16(struct device *dev, 247 struct device_attribute *attr, char *buf) 248{ |
249 SETUP_SHOW_data_param(dev, attr); | 249 SETUP_SHOW_DATA_PARAM(dev, attr); |
250 u16 regval; 251 252 mutex_lock(&data->update_lock); 253 regval = (data->reg[param->msb[0]] << 8) | data->reg[param->lsb[0]]; 254 mutex_unlock(&data->update_lock); 255 256 return sprintf(buf, "%u\n", 257 (regval == 0 ? -1 : (regval) == 258 0xffff ? 0 : 5400000 / regval)); 259} 260 261static ssize_t store_fan16(struct device *dev, 262 struct device_attribute *attr, const char *buf, 263 size_t count) 264{ | 250 u16 regval; 251 252 mutex_lock(&data->update_lock); 253 regval = (data->reg[param->msb[0]] << 8) | data->reg[param->lsb[0]]; 254 mutex_unlock(&data->update_lock); 255 256 return sprintf(buf, "%u\n", 257 (regval == 0 ? -1 : (regval) == 258 0xffff ? 0 : 5400000 / regval)); 259} 260 261static ssize_t store_fan16(struct device *dev, 262 struct device_attribute *attr, const char *buf, 263 size_t count) 264{ |
265 SETUP_STORE_data_param(dev, attr); | 265 SETUP_STORE_DATA_PARAM(dev, attr); |
266 long reqval; 267 268 if (kstrtol(buf, 10, &reqval)) 269 return -EINVAL; 270 271 /* 272 * If a minimum RPM of zero is requested, then we set the register to 273 * 0xffff. This value allows the fan to be stopped completely without --- 28 unchanged lines hidden (view full) --- 302 303static int asc7621_in_scaling[] = { 304 2500, 2250, 3300, 5000, 12000 305}; 306 307static ssize_t show_in10(struct device *dev, struct device_attribute *attr, 308 char *buf) 309{ | 266 long reqval; 267 268 if (kstrtol(buf, 10, &reqval)) 269 return -EINVAL; 270 271 /* 272 * If a minimum RPM of zero is requested, then we set the register to 273 * 0xffff. This value allows the fan to be stopped completely without --- 28 unchanged lines hidden (view full) --- 302 303static int asc7621_in_scaling[] = { 304 2500, 2250, 3300, 5000, 12000 305}; 306 307static ssize_t show_in10(struct device *dev, struct device_attribute *attr, 308 char *buf) 309{ |
310 SETUP_SHOW_data_param(dev, attr); | 310 SETUP_SHOW_DATA_PARAM(dev, attr); |
311 u16 regval; 312 u8 nr = sda->index; 313 314 mutex_lock(&data->update_lock); 315 regval = (data->reg[param->msb[0]] << 8) | (data->reg[param->lsb[0]]); 316 mutex_unlock(&data->update_lock); 317 318 /* The LSB value is a 2-bit scaling of the MSB's LSbit value. */ 319 regval = (regval >> 6) * asc7621_in_scaling[nr] / (0xc0 << 2); 320 321 return sprintf(buf, "%u\n", regval); 322} 323 324/* 8 bit voltage values (the mins and maxs) */ 325static ssize_t show_in8(struct device *dev, struct device_attribute *attr, 326 char *buf) 327{ | 311 u16 regval; 312 u8 nr = sda->index; 313 314 mutex_lock(&data->update_lock); 315 regval = (data->reg[param->msb[0]] << 8) | (data->reg[param->lsb[0]]); 316 mutex_unlock(&data->update_lock); 317 318 /* The LSB value is a 2-bit scaling of the MSB's LSbit value. */ 319 regval = (regval >> 6) * asc7621_in_scaling[nr] / (0xc0 << 2); 320 321 return sprintf(buf, "%u\n", regval); 322} 323 324/* 8 bit voltage values (the mins and maxs) */ 325static ssize_t show_in8(struct device *dev, struct device_attribute *attr, 326 char *buf) 327{ |
328 SETUP_SHOW_data_param(dev, attr); | 328 SETUP_SHOW_DATA_PARAM(dev, attr); |
329 u8 nr = sda->index; 330 331 return sprintf(buf, "%u\n", 332 ((data->reg[param->msb[0]] * 333 asc7621_in_scaling[nr]) / 0xc0)); 334} 335 336static ssize_t store_in8(struct device *dev, struct device_attribute *attr, 337 const char *buf, size_t count) 338{ | 329 u8 nr = sda->index; 330 331 return sprintf(buf, "%u\n", 332 ((data->reg[param->msb[0]] * 333 asc7621_in_scaling[nr]) / 0xc0)); 334} 335 336static ssize_t store_in8(struct device *dev, struct device_attribute *attr, 337 const char *buf, size_t count) 338{ |
339 SETUP_STORE_data_param(dev, attr); | 339 SETUP_STORE_DATA_PARAM(dev, attr); |
340 long reqval; 341 u8 nr = sda->index; 342 343 if (kstrtol(buf, 10, &reqval)) 344 return -EINVAL; 345 346 reqval = clamp_val(reqval, 0, 0xffff); 347 --- 7 unchanged lines hidden (view full) --- 355 mutex_unlock(&data->update_lock); 356 357 return count; 358} 359 360static ssize_t show_temp8(struct device *dev, 361 struct device_attribute *attr, char *buf) 362{ | 340 long reqval; 341 u8 nr = sda->index; 342 343 if (kstrtol(buf, 10, &reqval)) 344 return -EINVAL; 345 346 reqval = clamp_val(reqval, 0, 0xffff); 347 --- 7 unchanged lines hidden (view full) --- 355 mutex_unlock(&data->update_lock); 356 357 return count; 358} 359 360static ssize_t show_temp8(struct device *dev, 361 struct device_attribute *attr, char *buf) 362{ |
363 SETUP_SHOW_data_param(dev, attr); | 363 SETUP_SHOW_DATA_PARAM(dev, attr); |
364 365 return sprintf(buf, "%d\n", ((s8) data->reg[param->msb[0]]) * 1000); 366} 367 368static ssize_t store_temp8(struct device *dev, 369 struct device_attribute *attr, const char *buf, 370 size_t count) 371{ | 364 365 return sprintf(buf, "%d\n", ((s8) data->reg[param->msb[0]]) * 1000); 366} 367 368static ssize_t store_temp8(struct device *dev, 369 struct device_attribute *attr, const char *buf, 370 size_t count) 371{ |
372 SETUP_STORE_data_param(dev, attr); | 372 SETUP_STORE_DATA_PARAM(dev, attr); |
373 long reqval; 374 s8 temp; 375 376 if (kstrtol(buf, 10, &reqval)) 377 return -EINVAL; 378 379 reqval = clamp_val(reqval, -127000, 127000); 380 --- 11 unchanged lines hidden (view full) --- 392 * number of degrees in the MSB with some part of the LSB 393 * indicating fractional degrees. 394 */ 395 396/* mmmmmmmm.llxxxxxx */ 397static ssize_t show_temp10(struct device *dev, 398 struct device_attribute *attr, char *buf) 399{ | 373 long reqval; 374 s8 temp; 375 376 if (kstrtol(buf, 10, &reqval)) 377 return -EINVAL; 378 379 reqval = clamp_val(reqval, -127000, 127000); 380 --- 11 unchanged lines hidden (view full) --- 392 * number of degrees in the MSB with some part of the LSB 393 * indicating fractional degrees. 394 */ 395 396/* mmmmmmmm.llxxxxxx */ 397static ssize_t show_temp10(struct device *dev, 398 struct device_attribute *attr, char *buf) 399{ |
400 SETUP_SHOW_data_param(dev, attr); | 400 SETUP_SHOW_DATA_PARAM(dev, attr); |
401 u8 msb, lsb; 402 int temp; 403 404 mutex_lock(&data->update_lock); 405 msb = data->reg[param->msb[0]]; 406 lsb = (data->reg[param->lsb[0]] >> 6) & 0x03; 407 temp = (((s8) msb) * 1000) + (lsb * 250); 408 mutex_unlock(&data->update_lock); 409 410 return sprintf(buf, "%d\n", temp); 411} 412 413/* mmmmmm.ll */ 414static ssize_t show_temp62(struct device *dev, 415 struct device_attribute *attr, char *buf) 416{ | 401 u8 msb, lsb; 402 int temp; 403 404 mutex_lock(&data->update_lock); 405 msb = data->reg[param->msb[0]]; 406 lsb = (data->reg[param->lsb[0]] >> 6) & 0x03; 407 temp = (((s8) msb) * 1000) + (lsb * 250); 408 mutex_unlock(&data->update_lock); 409 410 return sprintf(buf, "%d\n", temp); 411} 412 413/* mmmmmm.ll */ 414static ssize_t show_temp62(struct device *dev, 415 struct device_attribute *attr, char *buf) 416{ |
417 SETUP_SHOW_data_param(dev, attr); | 417 SETUP_SHOW_DATA_PARAM(dev, attr); |
418 u8 regval = data->reg[param->msb[0]]; 419 int temp = ((s8) (regval & 0xfc) * 1000) + ((regval & 0x03) * 250); 420 421 return sprintf(buf, "%d\n", temp); 422} 423 424static ssize_t store_temp62(struct device *dev, 425 struct device_attribute *attr, const char *buf, 426 size_t count) 427{ | 418 u8 regval = data->reg[param->msb[0]]; 419 int temp = ((s8) (regval & 0xfc) * 1000) + ((regval & 0x03) * 250); 420 421 return sprintf(buf, "%d\n", temp); 422} 423 424static ssize_t store_temp62(struct device *dev, 425 struct device_attribute *attr, const char *buf, 426 size_t count) 427{ |
428 SETUP_STORE_data_param(dev, attr); | 428 SETUP_STORE_DATA_PARAM(dev, attr); |
429 long reqval, i, f; 430 s8 temp; 431 432 if (kstrtol(buf, 10, &reqval)) 433 return -EINVAL; 434 435 reqval = clamp_val(reqval, -32000, 31750); 436 i = reqval / 1000; --- 17 unchanged lines hidden (view full) --- 454static u32 asc7621_range_map[] = { 455 2000, 2500, 3330, 4000, 5000, 6670, 8000, 10000, 456 13330, 16000, 20000, 26670, 32000, 40000, 53330, 80000, 457}; 458 459static ssize_t show_ap2_temp(struct device *dev, 460 struct device_attribute *attr, char *buf) 461{ | 429 long reqval, i, f; 430 s8 temp; 431 432 if (kstrtol(buf, 10, &reqval)) 433 return -EINVAL; 434 435 reqval = clamp_val(reqval, -32000, 31750); 436 i = reqval / 1000; --- 17 unchanged lines hidden (view full) --- 454static u32 asc7621_range_map[] = { 455 2000, 2500, 3330, 4000, 5000, 6670, 8000, 10000, 456 13330, 16000, 20000, 26670, 32000, 40000, 53330, 80000, 457}; 458 459static ssize_t show_ap2_temp(struct device *dev, 460 struct device_attribute *attr, char *buf) 461{ |
462 SETUP_SHOW_data_param(dev, attr); | 462 SETUP_SHOW_DATA_PARAM(dev, attr); |
463 long auto_point1; 464 u8 regval; 465 int temp; 466 467 mutex_lock(&data->update_lock); 468 auto_point1 = ((s8) data->reg[param->msb[1]]) * 1000; 469 regval = 470 ((data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]); 471 temp = auto_point1 + asc7621_range_map[clamp_val(regval, 0, 15)]; 472 mutex_unlock(&data->update_lock); 473 474 return sprintf(buf, "%d\n", temp); 475 476} 477 478static ssize_t store_ap2_temp(struct device *dev, 479 struct device_attribute *attr, 480 const char *buf, size_t count) 481{ | 463 long auto_point1; 464 u8 regval; 465 int temp; 466 467 mutex_lock(&data->update_lock); 468 auto_point1 = ((s8) data->reg[param->msb[1]]) * 1000; 469 regval = 470 ((data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]); 471 temp = auto_point1 + asc7621_range_map[clamp_val(regval, 0, 15)]; 472 mutex_unlock(&data->update_lock); 473 474 return sprintf(buf, "%d\n", temp); 475 476} 477 478static ssize_t store_ap2_temp(struct device *dev, 479 struct device_attribute *attr, 480 const char *buf, size_t count) 481{ |
482 SETUP_STORE_data_param(dev, attr); | 482 SETUP_STORE_DATA_PARAM(dev, attr); |
483 long reqval, auto_point1; 484 int i; 485 u8 currval, newval = 0; 486 487 if (kstrtol(buf, 10, &reqval)) 488 return -EINVAL; 489 490 mutex_lock(&data->update_lock); --- 14 unchanged lines hidden (view full) --- 505 write_byte(client, param->msb[0], newval); 506 mutex_unlock(&data->update_lock); 507 return count; 508} 509 510static ssize_t show_pwm_ac(struct device *dev, 511 struct device_attribute *attr, char *buf) 512{ | 483 long reqval, auto_point1; 484 int i; 485 u8 currval, newval = 0; 486 487 if (kstrtol(buf, 10, &reqval)) 488 return -EINVAL; 489 490 mutex_lock(&data->update_lock); --- 14 unchanged lines hidden (view full) --- 505 write_byte(client, param->msb[0], newval); 506 mutex_unlock(&data->update_lock); 507 return count; 508} 509 510static ssize_t show_pwm_ac(struct device *dev, 511 struct device_attribute *attr, char *buf) 512{ |
513 SETUP_SHOW_data_param(dev, attr); | 513 SETUP_SHOW_DATA_PARAM(dev, attr); |
514 u8 config, altbit, regval; 515 u8 map[] = { 516 0x01, 0x02, 0x04, 0x1f, 0x00, 0x06, 0x07, 0x10, 517 0x08, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f 518 }; 519 520 mutex_lock(&data->update_lock); 521 config = (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; 522 altbit = (data->reg[param->msb[1]] >> param->shift[1]) & param->mask[1]; 523 regval = config | (altbit << 3); 524 mutex_unlock(&data->update_lock); 525 526 return sprintf(buf, "%u\n", map[clamp_val(regval, 0, 15)]); 527} 528 529static ssize_t store_pwm_ac(struct device *dev, 530 struct device_attribute *attr, 531 const char *buf, size_t count) 532{ | 514 u8 config, altbit, regval; 515 u8 map[] = { 516 0x01, 0x02, 0x04, 0x1f, 0x00, 0x06, 0x07, 0x10, 517 0x08, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f 518 }; 519 520 mutex_lock(&data->update_lock); 521 config = (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; 522 altbit = (data->reg[param->msb[1]] >> param->shift[1]) & param->mask[1]; 523 regval = config | (altbit << 3); 524 mutex_unlock(&data->update_lock); 525 526 return sprintf(buf, "%u\n", map[clamp_val(regval, 0, 15)]); 527} 528 529static ssize_t store_pwm_ac(struct device *dev, 530 struct device_attribute *attr, 531 const char *buf, size_t count) 532{ |
533 SETUP_STORE_data_param(dev, attr); | 533 SETUP_STORE_DATA_PARAM(dev, attr); |
534 unsigned long reqval; 535 u8 currval, config, altbit, newval; 536 u16 map[] = { 537 0x04, 0x00, 0x01, 0xff, 0x02, 0xff, 0x05, 0x06, 538 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 539 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 540 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 541 }; --- 22 unchanged lines hidden (view full) --- 564 write_byte(client, param->msb[0], newval); 565 mutex_unlock(&data->update_lock); 566 return count; 567} 568 569static ssize_t show_pwm_enable(struct device *dev, 570 struct device_attribute *attr, char *buf) 571{ | 534 unsigned long reqval; 535 u8 currval, config, altbit, newval; 536 u16 map[] = { 537 0x04, 0x00, 0x01, 0xff, 0x02, 0xff, 0x05, 0x06, 538 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 539 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 540 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 541 }; --- 22 unchanged lines hidden (view full) --- 564 write_byte(client, param->msb[0], newval); 565 mutex_unlock(&data->update_lock); 566 return count; 567} 568 569static ssize_t show_pwm_enable(struct device *dev, 570 struct device_attribute *attr, char *buf) 571{ |
572 SETUP_SHOW_data_param(dev, attr); | 572 SETUP_SHOW_DATA_PARAM(dev, attr); |
573 u8 config, altbit, minoff, val, newval; 574 575 mutex_lock(&data->update_lock); 576 config = (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; 577 altbit = (data->reg[param->msb[1]] >> param->shift[1]) & param->mask[1]; 578 minoff = (data->reg[param->msb[2]] >> param->shift[2]) & param->mask[2]; 579 mutex_unlock(&data->update_lock); 580 --- 13 unchanged lines hidden (view full) --- 594 595 return sprintf(buf, "%u\n", newval); 596} 597 598static ssize_t store_pwm_enable(struct device *dev, 599 struct device_attribute *attr, 600 const char *buf, size_t count) 601{ | 573 u8 config, altbit, minoff, val, newval; 574 575 mutex_lock(&data->update_lock); 576 config = (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; 577 altbit = (data->reg[param->msb[1]] >> param->shift[1]) & param->mask[1]; 578 minoff = (data->reg[param->msb[2]] >> param->shift[2]) & param->mask[2]; 579 mutex_unlock(&data->update_lock); 580 --- 13 unchanged lines hidden (view full) --- 594 595 return sprintf(buf, "%u\n", newval); 596} 597 598static ssize_t store_pwm_enable(struct device *dev, 599 struct device_attribute *attr, 600 const char *buf, size_t count) 601{ |
602 SETUP_STORE_data_param(dev, attr); | 602 SETUP_STORE_DATA_PARAM(dev, attr); |
603 long reqval; 604 u8 currval, config, altbit, newval, minoff = 255; 605 606 if (kstrtol(buf, 10, &reqval)) 607 return -EINVAL; 608 609 switch (reqval) { 610 case 0: --- 43 unchanged lines hidden (view full) --- 654static u32 asc7621_pwm_freq_map[] = { 655 10, 15, 23, 30, 38, 47, 62, 94, 656 23000, 24000, 25000, 26000, 27000, 28000, 29000, 30000 657}; 658 659static ssize_t show_pwm_freq(struct device *dev, 660 struct device_attribute *attr, char *buf) 661{ | 603 long reqval; 604 u8 currval, config, altbit, newval, minoff = 255; 605 606 if (kstrtol(buf, 10, &reqval)) 607 return -EINVAL; 608 609 switch (reqval) { 610 case 0: --- 43 unchanged lines hidden (view full) --- 654static u32 asc7621_pwm_freq_map[] = { 655 10, 15, 23, 30, 38, 47, 62, 94, 656 23000, 24000, 25000, 26000, 27000, 28000, 29000, 30000 657}; 658 659static ssize_t show_pwm_freq(struct device *dev, 660 struct device_attribute *attr, char *buf) 661{ |
662 SETUP_SHOW_data_param(dev, attr); | 662 SETUP_SHOW_DATA_PARAM(dev, attr); |
663 u8 regval = 664 (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; 665 666 regval = clamp_val(regval, 0, 15); 667 668 return sprintf(buf, "%u\n", asc7621_pwm_freq_map[regval]); 669} 670 671static ssize_t store_pwm_freq(struct device *dev, 672 struct device_attribute *attr, 673 const char *buf, size_t count) 674{ | 663 u8 regval = 664 (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; 665 666 regval = clamp_val(regval, 0, 15); 667 668 return sprintf(buf, "%u\n", asc7621_pwm_freq_map[regval]); 669} 670 671static ssize_t store_pwm_freq(struct device *dev, 672 struct device_attribute *attr, 673 const char *buf, size_t count) 674{ |
675 SETUP_STORE_data_param(dev, attr); | 675 SETUP_STORE_DATA_PARAM(dev, attr); |
676 unsigned long reqval; 677 u8 currval, newval = 255; 678 int i; 679 680 if (kstrtoul(buf, 10, &reqval)) 681 return -EINVAL; 682 683 for (i = 0; i < ARRAY_SIZE(asc7621_pwm_freq_map); i++) { --- 18 unchanged lines hidden (view full) --- 702 703static u32 asc7621_pwm_auto_spinup_map[] = { 704 0, 100, 250, 400, 700, 1000, 2000, 4000 705}; 706 707static ssize_t show_pwm_ast(struct device *dev, 708 struct device_attribute *attr, char *buf) 709{ | 676 unsigned long reqval; 677 u8 currval, newval = 255; 678 int i; 679 680 if (kstrtoul(buf, 10, &reqval)) 681 return -EINVAL; 682 683 for (i = 0; i < ARRAY_SIZE(asc7621_pwm_freq_map); i++) { --- 18 unchanged lines hidden (view full) --- 702 703static u32 asc7621_pwm_auto_spinup_map[] = { 704 0, 100, 250, 400, 700, 1000, 2000, 4000 705}; 706 707static ssize_t show_pwm_ast(struct device *dev, 708 struct device_attribute *attr, char *buf) 709{ |
710 SETUP_SHOW_data_param(dev, attr); | 710 SETUP_SHOW_DATA_PARAM(dev, attr); |
711 u8 regval = 712 (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; 713 714 regval = clamp_val(regval, 0, 7); 715 716 return sprintf(buf, "%u\n", asc7621_pwm_auto_spinup_map[regval]); 717 718} 719 720static ssize_t store_pwm_ast(struct device *dev, 721 struct device_attribute *attr, 722 const char *buf, size_t count) 723{ | 711 u8 regval = 712 (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; 713 714 regval = clamp_val(regval, 0, 7); 715 716 return sprintf(buf, "%u\n", asc7621_pwm_auto_spinup_map[regval]); 717 718} 719 720static ssize_t store_pwm_ast(struct device *dev, 721 struct device_attribute *attr, 722 const char *buf, size_t count) 723{ |
724 SETUP_STORE_data_param(dev, attr); | 724 SETUP_STORE_DATA_PARAM(dev, attr); |
725 long reqval; 726 u8 currval, newval = 255; 727 u32 i; 728 729 if (kstrtol(buf, 10, &reqval)) 730 return -EINVAL; 731 732 for (i = 0; i < ARRAY_SIZE(asc7621_pwm_auto_spinup_map); i++) { --- 18 unchanged lines hidden (view full) --- 751 752static u32 asc7621_temp_smoothing_time_map[] = { 753 35000, 17600, 11800, 7000, 4400, 3000, 1600, 800 754}; 755 756static ssize_t show_temp_st(struct device *dev, 757 struct device_attribute *attr, char *buf) 758{ | 725 long reqval; 726 u8 currval, newval = 255; 727 u32 i; 728 729 if (kstrtol(buf, 10, &reqval)) 730 return -EINVAL; 731 732 for (i = 0; i < ARRAY_SIZE(asc7621_pwm_auto_spinup_map); i++) { --- 18 unchanged lines hidden (view full) --- 751 752static u32 asc7621_temp_smoothing_time_map[] = { 753 35000, 17600, 11800, 7000, 4400, 3000, 1600, 800 754}; 755 756static ssize_t show_temp_st(struct device *dev, 757 struct device_attribute *attr, char *buf) 758{ |
759 SETUP_SHOW_data_param(dev, attr); | 759 SETUP_SHOW_DATA_PARAM(dev, attr); |
760 u8 regval = 761 (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; 762 regval = clamp_val(regval, 0, 7); 763 764 return sprintf(buf, "%u\n", asc7621_temp_smoothing_time_map[regval]); 765} 766 767static ssize_t store_temp_st(struct device *dev, 768 struct device_attribute *attr, 769 const char *buf, size_t count) 770{ | 760 u8 regval = 761 (data->reg[param->msb[0]] >> param->shift[0]) & param->mask[0]; 762 regval = clamp_val(regval, 0, 7); 763 764 return sprintf(buf, "%u\n", asc7621_temp_smoothing_time_map[regval]); 765} 766 767static ssize_t store_temp_st(struct device *dev, 768 struct device_attribute *attr, 769 const char *buf, size_t count) 770{ |
771 SETUP_STORE_data_param(dev, attr); | 771 SETUP_STORE_DATA_PARAM(dev, attr); |
772 long reqval; 773 u8 currval, newval = 255; 774 u32 i; 775 776 if (kstrtol(buf, 10, &reqval)) 777 return -EINVAL; 778 779 for (i = 0; i < ARRAY_SIZE(asc7621_temp_smoothing_time_map); i++) { --- 469 unchanged lines hidden --- | 772 long reqval; 773 u8 currval, newval = 255; 774 u32 i; 775 776 if (kstrtol(buf, 10, &reqval)) 777 return -EINVAL; 778 779 for (i = 0; i < ARRAY_SIZE(asc7621_temp_smoothing_time_map); i++) { --- 469 unchanged lines hidden --- |