diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-07-03 09:45:33 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-08-04 10:01:36 -0400 |
commit | 48995bc4bb9446b81ddf32ee56be0e47aab50557 (patch) | |
tree | 5252a0e0d1ecf4067e2c936bf71635d3c7185ae5 /drivers/hwmon | |
parent | d1b9c3f50304376f365e305ff61c3ae9a358e2f9 (diff) |
hwmon: (adm1021) Avoid forward declaration
Reorder functions to avoid forward declaration.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/adm1021.c | 175 |
1 files changed, 83 insertions, 92 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index d74241bb278c..1fdcc3e703b9 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -98,41 +98,63 @@ struct adm1021_data { | |||
98 | u8 remote_temp_offset_prec; | 98 | u8 remote_temp_offset_prec; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | static int adm1021_probe(struct i2c_client *client, | ||
102 | const struct i2c_device_id *id); | ||
103 | static int adm1021_detect(struct i2c_client *client, | ||
104 | struct i2c_board_info *info); | ||
105 | static void adm1021_init_client(struct i2c_client *client); | ||
106 | static struct adm1021_data *adm1021_update_device(struct device *dev); | ||
107 | |||
108 | /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ | 101 | /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ |
109 | static bool read_only; | 102 | static bool read_only; |
110 | 103 | ||
104 | static struct adm1021_data *adm1021_update_device(struct device *dev) | ||
105 | { | ||
106 | struct adm1021_data *data = dev_get_drvdata(dev); | ||
107 | struct i2c_client *client = data->client; | ||
111 | 108 | ||
112 | static const struct i2c_device_id adm1021_id[] = { | 109 | mutex_lock(&data->update_lock); |
113 | { "adm1021", adm1021 }, | ||
114 | { "adm1023", adm1023 }, | ||
115 | { "max1617", max1617 }, | ||
116 | { "max1617a", max1617a }, | ||
117 | { "thmc10", thmc10 }, | ||
118 | { "lm84", lm84 }, | ||
119 | { "gl523sm", gl523sm }, | ||
120 | { "mc1066", mc1066 }, | ||
121 | { } | ||
122 | }; | ||
123 | MODULE_DEVICE_TABLE(i2c, adm1021_id); | ||
124 | 110 | ||
125 | /* This is the driver that will be inserted */ | 111 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) |
126 | static struct i2c_driver adm1021_driver = { | 112 | || !data->valid) { |
127 | .class = I2C_CLASS_HWMON, | 113 | int i; |
128 | .driver = { | 114 | |
129 | .name = "adm1021", | 115 | dev_dbg(dev, "Starting adm1021 update\n"); |
130 | }, | 116 | |
131 | .probe = adm1021_probe, | 117 | for (i = 0; i < 2; i++) { |
132 | .id_table = adm1021_id, | 118 | data->temp[i] = 1000 * |
133 | .detect = adm1021_detect, | 119 | (s8) i2c_smbus_read_byte_data( |
134 | .address_list = normal_i2c, | 120 | client, ADM1021_REG_TEMP(i)); |
135 | }; | 121 | data->temp_max[i] = 1000 * |
122 | (s8) i2c_smbus_read_byte_data( | ||
123 | client, ADM1021_REG_TOS_R(i)); | ||
124 | if (data->type != lm84) { | ||
125 | data->temp_min[i] = 1000 * | ||
126 | (s8) i2c_smbus_read_byte_data(client, | ||
127 | ADM1021_REG_THYST_R(i)); | ||
128 | } | ||
129 | } | ||
130 | data->alarms = i2c_smbus_read_byte_data(client, | ||
131 | ADM1021_REG_STATUS) & 0x7c; | ||
132 | if (data->type == adm1023) { | ||
133 | /* | ||
134 | * The ADM1023 provides 3 extra bits of precision for | ||
135 | * the remote sensor in extra registers. | ||
136 | */ | ||
137 | data->temp[1] += 125 * (i2c_smbus_read_byte_data( | ||
138 | client, ADM1023_REG_REM_TEMP_PREC) >> 5); | ||
139 | data->temp_max[1] += 125 * (i2c_smbus_read_byte_data( | ||
140 | client, ADM1023_REG_REM_TOS_PREC) >> 5); | ||
141 | data->temp_min[1] += 125 * (i2c_smbus_read_byte_data( | ||
142 | client, ADM1023_REG_REM_THYST_PREC) >> 5); | ||
143 | data->remote_temp_offset = | ||
144 | i2c_smbus_read_byte_data(client, | ||
145 | ADM1023_REG_REM_OFFSET); | ||
146 | data->remote_temp_offset_prec = | ||
147 | i2c_smbus_read_byte_data(client, | ||
148 | ADM1023_REG_REM_OFFSET_PREC); | ||
149 | } | ||
150 | data->last_updated = jiffies; | ||
151 | data->valid = 1; | ||
152 | } | ||
153 | |||
154 | mutex_unlock(&data->update_lock); | ||
155 | |||
156 | return data; | ||
157 | } | ||
136 | 158 | ||
137 | static ssize_t show_temp(struct device *dev, | 159 | static ssize_t show_temp(struct device *dev, |
138 | struct device_attribute *devattr, char *buf) | 160 | struct device_attribute *devattr, char *buf) |
@@ -411,6 +433,15 @@ static int adm1021_detect(struct i2c_client *client, | |||
411 | return 0; | 433 | return 0; |
412 | } | 434 | } |
413 | 435 | ||
436 | static void adm1021_init_client(struct i2c_client *client) | ||
437 | { | ||
438 | /* Enable ADC and disable suspend mode */ | ||
439 | i2c_smbus_write_byte_data(client, ADM1021_REG_CONFIG_W, | ||
440 | i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R) & 0xBF); | ||
441 | /* Set Conversion rate to 1/sec (this can be tinkered with) */ | ||
442 | i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04); | ||
443 | } | ||
444 | |||
414 | static int adm1021_probe(struct i2c_client *client, | 445 | static int adm1021_probe(struct i2c_client *client, |
415 | const struct i2c_device_id *id) | 446 | const struct i2c_device_id *id) |
416 | { | 447 | { |
@@ -440,69 +471,29 @@ static int adm1021_probe(struct i2c_client *client, | |||
440 | return PTR_ERR_OR_ZERO(hwmon_dev); | 471 | return PTR_ERR_OR_ZERO(hwmon_dev); |
441 | } | 472 | } |
442 | 473 | ||
443 | static void adm1021_init_client(struct i2c_client *client) | 474 | static const struct i2c_device_id adm1021_id[] = { |
444 | { | 475 | { "adm1021", adm1021 }, |
445 | /* Enable ADC and disable suspend mode */ | 476 | { "adm1023", adm1023 }, |
446 | i2c_smbus_write_byte_data(client, ADM1021_REG_CONFIG_W, | 477 | { "max1617", max1617 }, |
447 | i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R) & 0xBF); | 478 | { "max1617a", max1617a }, |
448 | /* Set Conversion rate to 1/sec (this can be tinkered with) */ | 479 | { "thmc10", thmc10 }, |
449 | i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04); | 480 | { "lm84", lm84 }, |
450 | } | 481 | { "gl523sm", gl523sm }, |
451 | 482 | { "mc1066", mc1066 }, | |
452 | static struct adm1021_data *adm1021_update_device(struct device *dev) | 483 | { } |
453 | { | 484 | }; |
454 | struct adm1021_data *data = dev_get_drvdata(dev); | 485 | MODULE_DEVICE_TABLE(i2c, adm1021_id); |
455 | struct i2c_client *client = data->client; | ||
456 | |||
457 | mutex_lock(&data->update_lock); | ||
458 | |||
459 | if (time_after(jiffies, data->last_updated + HZ + HZ / 2) | ||
460 | || !data->valid) { | ||
461 | int i; | ||
462 | |||
463 | dev_dbg(dev, "Starting adm1021 update\n"); | ||
464 | |||
465 | for (i = 0; i < 2; i++) { | ||
466 | data->temp[i] = 1000 * | ||
467 | (s8) i2c_smbus_read_byte_data( | ||
468 | client, ADM1021_REG_TEMP(i)); | ||
469 | data->temp_max[i] = 1000 * | ||
470 | (s8) i2c_smbus_read_byte_data( | ||
471 | client, ADM1021_REG_TOS_R(i)); | ||
472 | if (data->type != lm84) { | ||
473 | data->temp_min[i] = 1000 * | ||
474 | (s8) i2c_smbus_read_byte_data(client, | ||
475 | ADM1021_REG_THYST_R(i)); | ||
476 | } | ||
477 | } | ||
478 | data->alarms = i2c_smbus_read_byte_data(client, | ||
479 | ADM1021_REG_STATUS) & 0x7c; | ||
480 | if (data->type == adm1023) { | ||
481 | /* | ||
482 | * The ADM1023 provides 3 extra bits of precision for | ||
483 | * the remote sensor in extra registers. | ||
484 | */ | ||
485 | data->temp[1] += 125 * (i2c_smbus_read_byte_data( | ||
486 | client, ADM1023_REG_REM_TEMP_PREC) >> 5); | ||
487 | data->temp_max[1] += 125 * (i2c_smbus_read_byte_data( | ||
488 | client, ADM1023_REG_REM_TOS_PREC) >> 5); | ||
489 | data->temp_min[1] += 125 * (i2c_smbus_read_byte_data( | ||
490 | client, ADM1023_REG_REM_THYST_PREC) >> 5); | ||
491 | data->remote_temp_offset = | ||
492 | i2c_smbus_read_byte_data(client, | ||
493 | ADM1023_REG_REM_OFFSET); | ||
494 | data->remote_temp_offset_prec = | ||
495 | i2c_smbus_read_byte_data(client, | ||
496 | ADM1023_REG_REM_OFFSET_PREC); | ||
497 | } | ||
498 | data->last_updated = jiffies; | ||
499 | data->valid = 1; | ||
500 | } | ||
501 | |||
502 | mutex_unlock(&data->update_lock); | ||
503 | 486 | ||
504 | return data; | 487 | static struct i2c_driver adm1021_driver = { |
505 | } | 488 | .class = I2C_CLASS_HWMON, |
489 | .driver = { | ||
490 | .name = "adm1021", | ||
491 | }, | ||
492 | .probe = adm1021_probe, | ||
493 | .id_table = adm1021_id, | ||
494 | .detect = adm1021_detect, | ||
495 | .address_list = normal_i2c, | ||
496 | }; | ||
506 | 497 | ||
507 | module_i2c_driver(adm1021_driver); | 498 | module_i2c_driver(adm1021_driver); |
508 | 499 | ||