diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-07-03 09:48:15 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-08-04 10:01:36 -0400 |
commit | 851a7afa82c9cbbfa2f85151872a29db0a3f6cbf (patch) | |
tree | f0938016043cae6099033a16436a47ddaf108b94 /drivers/hwmon/adm1025.c | |
parent | 48995bc4bb9446b81ddf32ee56be0e47aab50557 (diff) |
hwmon: (adm1025) 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/adm1025.c')
-rw-r--r-- | drivers/hwmon/adm1025.c | 224 |
1 files changed, 104 insertions, 120 deletions
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 9ffc4c8ca8b5..0533c2c679f6 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c | |||
@@ -103,41 +103,6 @@ static const int in_scale[6] = { 2500, 2250, 3300, 5000, 12000, 3300 }; | |||
103 | (val) + 500) / 1000)) | 103 | (val) + 500) / 1000)) |
104 | 104 | ||
105 | /* | 105 | /* |
106 | * Functions declaration | ||
107 | */ | ||
108 | |||
109 | static int adm1025_probe(struct i2c_client *client, | ||
110 | const struct i2c_device_id *id); | ||
111 | static int adm1025_detect(struct i2c_client *client, | ||
112 | struct i2c_board_info *info); | ||
113 | static void adm1025_init_client(struct i2c_client *client); | ||
114 | static int adm1025_remove(struct i2c_client *client); | ||
115 | static struct adm1025_data *adm1025_update_device(struct device *dev); | ||
116 | |||
117 | /* | ||
118 | * Driver data (common to all clients) | ||
119 | */ | ||
120 | |||
121 | static const struct i2c_device_id adm1025_id[] = { | ||
122 | { "adm1025", adm1025 }, | ||
123 | { "ne1619", ne1619 }, | ||
124 | { } | ||
125 | }; | ||
126 | MODULE_DEVICE_TABLE(i2c, adm1025_id); | ||
127 | |||
128 | static struct i2c_driver adm1025_driver = { | ||
129 | .class = I2C_CLASS_HWMON, | ||
130 | .driver = { | ||
131 | .name = "adm1025", | ||
132 | }, | ||
133 | .probe = adm1025_probe, | ||
134 | .remove = adm1025_remove, | ||
135 | .id_table = adm1025_id, | ||
136 | .detect = adm1025_detect, | ||
137 | .address_list = normal_i2c, | ||
138 | }; | ||
139 | |||
140 | /* | ||
141 | * Client data (each client gets its own) | 106 | * Client data (each client gets its own) |
142 | */ | 107 | */ |
143 | 108 | ||
@@ -158,6 +123,51 @@ struct adm1025_data { | |||
158 | u8 vrm; | 123 | u8 vrm; |
159 | }; | 124 | }; |
160 | 125 | ||
126 | static struct adm1025_data *adm1025_update_device(struct device *dev) | ||
127 | { | ||
128 | struct i2c_client *client = to_i2c_client(dev); | ||
129 | struct adm1025_data *data = i2c_get_clientdata(client); | ||
130 | |||
131 | mutex_lock(&data->update_lock); | ||
132 | |||
133 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | ||
134 | int i; | ||
135 | |||
136 | dev_dbg(&client->dev, "Updating data.\n"); | ||
137 | for (i = 0; i < 6; i++) { | ||
138 | data->in[i] = i2c_smbus_read_byte_data(client, | ||
139 | ADM1025_REG_IN(i)); | ||
140 | data->in_min[i] = i2c_smbus_read_byte_data(client, | ||
141 | ADM1025_REG_IN_MIN(i)); | ||
142 | data->in_max[i] = i2c_smbus_read_byte_data(client, | ||
143 | ADM1025_REG_IN_MAX(i)); | ||
144 | } | ||
145 | for (i = 0; i < 2; i++) { | ||
146 | data->temp[i] = i2c_smbus_read_byte_data(client, | ||
147 | ADM1025_REG_TEMP(i)); | ||
148 | data->temp_min[i] = i2c_smbus_read_byte_data(client, | ||
149 | ADM1025_REG_TEMP_LOW(i)); | ||
150 | data->temp_max[i] = i2c_smbus_read_byte_data(client, | ||
151 | ADM1025_REG_TEMP_HIGH(i)); | ||
152 | } | ||
153 | data->alarms = i2c_smbus_read_byte_data(client, | ||
154 | ADM1025_REG_STATUS1) | ||
155 | | (i2c_smbus_read_byte_data(client, | ||
156 | ADM1025_REG_STATUS2) << 8); | ||
157 | data->vid = (i2c_smbus_read_byte_data(client, | ||
158 | ADM1025_REG_VID) & 0x0f) | ||
159 | | ((i2c_smbus_read_byte_data(client, | ||
160 | ADM1025_REG_VID4) & 0x01) << 4); | ||
161 | |||
162 | data->last_updated = jiffies; | ||
163 | data->valid = 1; | ||
164 | } | ||
165 | |||
166 | mutex_unlock(&data->update_lock); | ||
167 | |||
168 | return data; | ||
169 | } | ||
170 | |||
161 | /* | 171 | /* |
162 | * Sysfs stuff | 172 | * Sysfs stuff |
163 | */ | 173 | */ |
@@ -470,6 +480,48 @@ static int adm1025_detect(struct i2c_client *client, | |||
470 | return 0; | 480 | return 0; |
471 | } | 481 | } |
472 | 482 | ||
483 | static void adm1025_init_client(struct i2c_client *client) | ||
484 | { | ||
485 | u8 reg; | ||
486 | struct adm1025_data *data = i2c_get_clientdata(client); | ||
487 | int i; | ||
488 | |||
489 | data->vrm = vid_which_vrm(); | ||
490 | |||
491 | /* | ||
492 | * Set high limits | ||
493 | * Usually we avoid setting limits on driver init, but it happens | ||
494 | * that the ADM1025 comes with stupid default limits (all registers | ||
495 | * set to 0). In case the chip has not gone through any limit | ||
496 | * setting yet, we better set the high limits to the max so that | ||
497 | * no alarm triggers. | ||
498 | */ | ||
499 | for (i = 0; i < 6; i++) { | ||
500 | reg = i2c_smbus_read_byte_data(client, | ||
501 | ADM1025_REG_IN_MAX(i)); | ||
502 | if (reg == 0) | ||
503 | i2c_smbus_write_byte_data(client, | ||
504 | ADM1025_REG_IN_MAX(i), | ||
505 | 0xFF); | ||
506 | } | ||
507 | for (i = 0; i < 2; i++) { | ||
508 | reg = i2c_smbus_read_byte_data(client, | ||
509 | ADM1025_REG_TEMP_HIGH(i)); | ||
510 | if (reg == 0) | ||
511 | i2c_smbus_write_byte_data(client, | ||
512 | ADM1025_REG_TEMP_HIGH(i), | ||
513 | 0x7F); | ||
514 | } | ||
515 | |||
516 | /* | ||
517 | * Start the conversions | ||
518 | */ | ||
519 | reg = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG); | ||
520 | if (!(reg & 0x01)) | ||
521 | i2c_smbus_write_byte_data(client, ADM1025_REG_CONFIG, | ||
522 | (reg&0x7E)|0x01); | ||
523 | } | ||
524 | |||
473 | static int adm1025_probe(struct i2c_client *client, | 525 | static int adm1025_probe(struct i2c_client *client, |
474 | const struct i2c_device_id *id) | 526 | const struct i2c_device_id *id) |
475 | { | 527 | { |
@@ -515,48 +567,6 @@ exit_remove: | |||
515 | return err; | 567 | return err; |
516 | } | 568 | } |
517 | 569 | ||
518 | static void adm1025_init_client(struct i2c_client *client) | ||
519 | { | ||
520 | u8 reg; | ||
521 | struct adm1025_data *data = i2c_get_clientdata(client); | ||
522 | int i; | ||
523 | |||
524 | data->vrm = vid_which_vrm(); | ||
525 | |||
526 | /* | ||
527 | * Set high limits | ||
528 | * Usually we avoid setting limits on driver init, but it happens | ||
529 | * that the ADM1025 comes with stupid default limits (all registers | ||
530 | * set to 0). In case the chip has not gone through any limit | ||
531 | * setting yet, we better set the high limits to the max so that | ||
532 | * no alarm triggers. | ||
533 | */ | ||
534 | for (i = 0; i < 6; i++) { | ||
535 | reg = i2c_smbus_read_byte_data(client, | ||
536 | ADM1025_REG_IN_MAX(i)); | ||
537 | if (reg == 0) | ||
538 | i2c_smbus_write_byte_data(client, | ||
539 | ADM1025_REG_IN_MAX(i), | ||
540 | 0xFF); | ||
541 | } | ||
542 | for (i = 0; i < 2; i++) { | ||
543 | reg = i2c_smbus_read_byte_data(client, | ||
544 | ADM1025_REG_TEMP_HIGH(i)); | ||
545 | if (reg == 0) | ||
546 | i2c_smbus_write_byte_data(client, | ||
547 | ADM1025_REG_TEMP_HIGH(i), | ||
548 | 0x7F); | ||
549 | } | ||
550 | |||
551 | /* | ||
552 | * Start the conversions | ||
553 | */ | ||
554 | reg = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG); | ||
555 | if (!(reg & 0x01)) | ||
556 | i2c_smbus_write_byte_data(client, ADM1025_REG_CONFIG, | ||
557 | (reg&0x7E)|0x01); | ||
558 | } | ||
559 | |||
560 | static int adm1025_remove(struct i2c_client *client) | 570 | static int adm1025_remove(struct i2c_client *client) |
561 | { | 571 | { |
562 | struct adm1025_data *data = i2c_get_clientdata(client); | 572 | struct adm1025_data *data = i2c_get_clientdata(client); |
@@ -568,50 +578,24 @@ static int adm1025_remove(struct i2c_client *client) | |||
568 | return 0; | 578 | return 0; |
569 | } | 579 | } |
570 | 580 | ||
571 | static struct adm1025_data *adm1025_update_device(struct device *dev) | 581 | static const struct i2c_device_id adm1025_id[] = { |
572 | { | 582 | { "adm1025", adm1025 }, |
573 | struct i2c_client *client = to_i2c_client(dev); | 583 | { "ne1619", ne1619 }, |
574 | struct adm1025_data *data = i2c_get_clientdata(client); | 584 | { } |
575 | 585 | }; | |
576 | mutex_lock(&data->update_lock); | 586 | MODULE_DEVICE_TABLE(i2c, adm1025_id); |
577 | |||
578 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { | ||
579 | int i; | ||
580 | |||
581 | dev_dbg(&client->dev, "Updating data.\n"); | ||
582 | for (i = 0; i < 6; i++) { | ||
583 | data->in[i] = i2c_smbus_read_byte_data(client, | ||
584 | ADM1025_REG_IN(i)); | ||
585 | data->in_min[i] = i2c_smbus_read_byte_data(client, | ||
586 | ADM1025_REG_IN_MIN(i)); | ||
587 | data->in_max[i] = i2c_smbus_read_byte_data(client, | ||
588 | ADM1025_REG_IN_MAX(i)); | ||
589 | } | ||
590 | for (i = 0; i < 2; i++) { | ||
591 | data->temp[i] = i2c_smbus_read_byte_data(client, | ||
592 | ADM1025_REG_TEMP(i)); | ||
593 | data->temp_min[i] = i2c_smbus_read_byte_data(client, | ||
594 | ADM1025_REG_TEMP_LOW(i)); | ||
595 | data->temp_max[i] = i2c_smbus_read_byte_data(client, | ||
596 | ADM1025_REG_TEMP_HIGH(i)); | ||
597 | } | ||
598 | data->alarms = i2c_smbus_read_byte_data(client, | ||
599 | ADM1025_REG_STATUS1) | ||
600 | | (i2c_smbus_read_byte_data(client, | ||
601 | ADM1025_REG_STATUS2) << 8); | ||
602 | data->vid = (i2c_smbus_read_byte_data(client, | ||
603 | ADM1025_REG_VID) & 0x0f) | ||
604 | | ((i2c_smbus_read_byte_data(client, | ||
605 | ADM1025_REG_VID4) & 0x01) << 4); | ||
606 | |||
607 | data->last_updated = jiffies; | ||
608 | data->valid = 1; | ||
609 | } | ||
610 | |||
611 | mutex_unlock(&data->update_lock); | ||
612 | 587 | ||
613 | return data; | 588 | static struct i2c_driver adm1025_driver = { |
614 | } | 589 | .class = I2C_CLASS_HWMON, |
590 | .driver = { | ||
591 | .name = "adm1025", | ||
592 | }, | ||
593 | .probe = adm1025_probe, | ||
594 | .remove = adm1025_remove, | ||
595 | .id_table = adm1025_id, | ||
596 | .detect = adm1025_detect, | ||
597 | .address_list = normal_i2c, | ||
598 | }; | ||
615 | 599 | ||
616 | module_i2c_driver(adm1025_driver); | 600 | module_i2c_driver(adm1025_driver); |
617 | 601 | ||