* [lm-sensors] [PATCH] hwmon: (adm1021) Avoid forward declaration
@ 2014-07-03 13:45 Axel Lin
2014-07-03 14:12 ` Guenter Roeck
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Axel Lin @ 2014-07-03 13:45 UTC (permalink / raw)
To: lm-sensors
Reorder functions to avoid forward declaration.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/hwmon/adm1021.c | 175 +++++++++++++++++++++++-------------------------
1 file changed, 83 insertions(+), 92 deletions(-)
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index 3eb4281..7f7635b 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -98,41 +98,63 @@ struct adm1021_data {
u8 remote_temp_offset_prec;
};
-static int adm1021_probe(struct i2c_client *client,
- const struct i2c_device_id *id);
-static int adm1021_detect(struct i2c_client *client,
- struct i2c_board_info *info);
-static void adm1021_init_client(struct i2c_client *client);
-static struct adm1021_data *adm1021_update_device(struct device *dev);
-
/* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */
static bool read_only;
+static struct adm1021_data *adm1021_update_device(struct device *dev)
+{
+ struct adm1021_data *data = dev_get_drvdata(dev);
+ struct i2c_client *client = data->client;
-static const struct i2c_device_id adm1021_id[] = {
- { "adm1021", adm1021 },
- { "adm1023", adm1023 },
- { "max1617", max1617 },
- { "max1617a", max1617a },
- { "thmc10", thmc10 },
- { "lm84", lm84 },
- { "gl523sm", gl523sm },
- { "mc1066", mc1066 },
- { }
-};
-MODULE_DEVICE_TABLE(i2c, adm1021_id);
+ mutex_lock(&data->update_lock);
-/* This is the driver that will be inserted */
-static struct i2c_driver adm1021_driver = {
- .class = I2C_CLASS_HWMON,
- .driver = {
- .name = "adm1021",
- },
- .probe = adm1021_probe,
- .id_table = adm1021_id,
- .detect = adm1021_detect,
- .address_list = normal_i2c,
-};
+ if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
+ || !data->valid) {
+ int i;
+
+ dev_dbg(dev, "Starting adm1021 update\n");
+
+ for (i = 0; i < 2; i++) {
+ data->temp[i] = 1000 *
+ (s8) i2c_smbus_read_byte_data(
+ client, ADM1021_REG_TEMP(i));
+ data->temp_max[i] = 1000 *
+ (s8) i2c_smbus_read_byte_data(
+ client, ADM1021_REG_TOS_R(i));
+ if (data->type != lm84) {
+ data->temp_min[i] = 1000 *
+ (s8) i2c_smbus_read_byte_data(client,
+ ADM1021_REG_THYST_R(i));
+ }
+ }
+ data->alarms = i2c_smbus_read_byte_data(client,
+ ADM1021_REG_STATUS) & 0x7c;
+ if (data->type = adm1023) {
+ /*
+ * The ADM1023 provides 3 extra bits of precision for
+ * the remote sensor in extra registers.
+ */
+ data->temp[1] += 125 * (i2c_smbus_read_byte_data(
+ client, ADM1023_REG_REM_TEMP_PREC) >> 5);
+ data->temp_max[1] += 125 * (i2c_smbus_read_byte_data(
+ client, ADM1023_REG_REM_TOS_PREC) >> 5);
+ data->temp_min[1] += 125 * (i2c_smbus_read_byte_data(
+ client, ADM1023_REG_REM_THYST_PREC) >> 5);
+ data->remote_temp_offset + i2c_smbus_read_byte_data(client,
+ ADM1023_REG_REM_OFFSET);
+ data->remote_temp_offset_prec + i2c_smbus_read_byte_data(client,
+ ADM1023_REG_REM_OFFSET_PREC);
+ }
+ data->last_updated = jiffies;
+ data->valid = 1;
+ }
+
+ mutex_unlock(&data->update_lock);
+
+ return data;
+}
static ssize_t show_temp(struct device *dev,
struct device_attribute *devattr, char *buf)
@@ -409,6 +431,15 @@ static int adm1021_detect(struct i2c_client *client,
return 0;
}
+static void adm1021_init_client(struct i2c_client *client)
+{
+ /* Enable ADC and disable suspend mode */
+ i2c_smbus_write_byte_data(client, ADM1021_REG_CONFIG_W,
+ i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R) & 0xBF);
+ /* Set Conversion rate to 1/sec (this can be tinkered with) */
+ i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04);
+}
+
static int adm1021_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -438,69 +469,29 @@ static int adm1021_probe(struct i2c_client *client,
return PTR_ERR_OR_ZERO(hwmon_dev);
}
-static void adm1021_init_client(struct i2c_client *client)
-{
- /* Enable ADC and disable suspend mode */
- i2c_smbus_write_byte_data(client, ADM1021_REG_CONFIG_W,
- i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R) & 0xBF);
- /* Set Conversion rate to 1/sec (this can be tinkered with) */
- i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04);
-}
-
-static struct adm1021_data *adm1021_update_device(struct device *dev)
-{
- struct adm1021_data *data = dev_get_drvdata(dev);
- struct i2c_client *client = data->client;
-
- mutex_lock(&data->update_lock);
-
- if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
- || !data->valid) {
- int i;
-
- dev_dbg(dev, "Starting adm1021 update\n");
-
- for (i = 0; i < 2; i++) {
- data->temp[i] = 1000 *
- (s8) i2c_smbus_read_byte_data(
- client, ADM1021_REG_TEMP(i));
- data->temp_max[i] = 1000 *
- (s8) i2c_smbus_read_byte_data(
- client, ADM1021_REG_TOS_R(i));
- if (data->type != lm84) {
- data->temp_min[i] = 1000 *
- (s8) i2c_smbus_read_byte_data(client,
- ADM1021_REG_THYST_R(i));
- }
- }
- data->alarms = i2c_smbus_read_byte_data(client,
- ADM1021_REG_STATUS) & 0x7c;
- if (data->type = adm1023) {
- /*
- * The ADM1023 provides 3 extra bits of precision for
- * the remote sensor in extra registers.
- */
- data->temp[1] += 125 * (i2c_smbus_read_byte_data(
- client, ADM1023_REG_REM_TEMP_PREC) >> 5);
- data->temp_max[1] += 125 * (i2c_smbus_read_byte_data(
- client, ADM1023_REG_REM_TOS_PREC) >> 5);
- data->temp_min[1] += 125 * (i2c_smbus_read_byte_data(
- client, ADM1023_REG_REM_THYST_PREC) >> 5);
- data->remote_temp_offset - i2c_smbus_read_byte_data(client,
- ADM1023_REG_REM_OFFSET);
- data->remote_temp_offset_prec - i2c_smbus_read_byte_data(client,
- ADM1023_REG_REM_OFFSET_PREC);
- }
- data->last_updated = jiffies;
- data->valid = 1;
- }
-
- mutex_unlock(&data->update_lock);
+static const struct i2c_device_id adm1021_id[] = {
+ { "adm1021", adm1021 },
+ { "adm1023", adm1023 },
+ { "max1617", max1617 },
+ { "max1617a", max1617a },
+ { "thmc10", thmc10 },
+ { "lm84", lm84 },
+ { "gl523sm", gl523sm },
+ { "mc1066", mc1066 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, adm1021_id);
- return data;
-}
+static struct i2c_driver adm1021_driver = {
+ .class = I2C_CLASS_HWMON,
+ .driver = {
+ .name = "adm1021",
+ },
+ .probe = adm1021_probe,
+ .id_table = adm1021_id,
+ .detect = adm1021_detect,
+ .address_list = normal_i2c,
+};
module_i2c_driver(adm1021_driver);
--
1.9.1
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (adm1021) Avoid forward declaration
2014-07-03 13:45 [lm-sensors] [PATCH] hwmon: (adm1021) Avoid forward declaration Axel Lin
@ 2014-07-03 14:12 ` Guenter Roeck
2014-07-03 14:21 ` Axel Lin
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2014-07-03 14:12 UTC (permalink / raw)
To: lm-sensors
On 07/03/2014 06:45 AM, Axel Lin wrote:
> Reorder functions to avoid forward declaration.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Hi Axel,
did you write module test scripts for any of those by any chance ?
Just asking, since it would save me some time.
The module test script for the adm1021 driver exposes a cache problem
when writing temperature limits. temp_min and temp_max are expected
to be stored in milli-degrees C but are stored in degrees C.
Feel free to send a patch to fix the problem if you have time.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (adm1021) Avoid forward declaration
2014-07-03 13:45 [lm-sensors] [PATCH] hwmon: (adm1021) Avoid forward declaration Axel Lin
2014-07-03 14:12 ` Guenter Roeck
@ 2014-07-03 14:21 ` Axel Lin
2014-07-03 14:25 ` Guenter Roeck
2014-07-03 14:27 ` Guenter Roeck
3 siblings, 0 replies; 5+ messages in thread
From: Axel Lin @ 2014-07-03 14:21 UTC (permalink / raw)
To: lm-sensors
2014-07-03 22:12 GMT+08:00 Guenter Roeck <linux@roeck-us.net>:
> On 07/03/2014 06:45 AM, Axel Lin wrote:
>>
>> Reorder functions to avoid forward declaration.
>>
>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>
>
> Hi Axel,
>
> did you write module test scripts for any of those by any chance ?
> Just asking, since it would save me some time.
No, not yet.
I need to study how to write the module test scripts first.
>
> The module test script for the adm1021 driver exposes a cache problem
> when writing temperature limits. temp_min and temp_max are expected
> to be stored in milli-degrees C but are stored in degrees C.
> Feel free to send a patch to fix the problem if you have time.
Ok. Thanks for the report and the nice test tool.
Regards,
Axel
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (adm1021) Avoid forward declaration
2014-07-03 13:45 [lm-sensors] [PATCH] hwmon: (adm1021) Avoid forward declaration Axel Lin
2014-07-03 14:12 ` Guenter Roeck
2014-07-03 14:21 ` Axel Lin
@ 2014-07-03 14:25 ` Guenter Roeck
2014-07-03 14:27 ` Guenter Roeck
3 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2014-07-03 14:25 UTC (permalink / raw)
To: lm-sensors
On 07/03/2014 06:45 AM, Axel Lin wrote:
> Reorder functions to avoid forward declaration.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Applied to -next.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [lm-sensors] [PATCH] hwmon: (adm1021) Avoid forward declaration
2014-07-03 13:45 [lm-sensors] [PATCH] hwmon: (adm1021) Avoid forward declaration Axel Lin
` (2 preceding siblings ...)
2014-07-03 14:25 ` Guenter Roeck
@ 2014-07-03 14:27 ` Guenter Roeck
3 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2014-07-03 14:27 UTC (permalink / raw)
To: lm-sensors
On 07/03/2014 07:21 AM, Axel Lin wrote:
> 2014-07-03 22:12 GMT+08:00 Guenter Roeck <linux@roeck-us.net>:
>> On 07/03/2014 06:45 AM, Axel Lin wrote:
>>>
>>> Reorder functions to avoid forward declaration.
>>>
>>> Signed-off-by: Axel Lin <axel.lin@ingics.com>
>>
>>
>> Hi Axel,
>>
>> did you write module test scripts for any of those by any chance ?
>> Just asking, since it would save me some time.
> No, not yet.
> I need to study how to write the module test scripts first.
>
No problem, just asking.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-07-03 14:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-03 13:45 [lm-sensors] [PATCH] hwmon: (adm1021) Avoid forward declaration Axel Lin
2014-07-03 14:12 ` Guenter Roeck
2014-07-03 14:21 ` Axel Lin
2014-07-03 14:25 ` Guenter Roeck
2014-07-03 14:27 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.