i2c: modify sensors
This patch modifies sensors chip drivers to make use of the new sysfs class "hwmon".
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/adm1021.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/adm1021.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/adm1021.c
@@ -25,6 +25,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* Addresses to scan */
@@ -37,6 +39,8 @@ static unsigned int normal_isa[] = { I2C
/* Insmod parameters */
SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066);
+static int id; /* increment once for every chip found */
+
/* adm1021 constants specified below */
/* The adm1021 registers */
@@ -295,6 +299,13 @@ static int adm1021_detect(struct i2c_ada
adm1021_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto error2;
+ }
+
device_create_file(&new_client->dev, &dev_attr_temp1_max); device_create_file(&new_client->dev, &dev_attr_temp1_min); device_create_file(&new_client->dev, &dev_attr_temp1_input);
@@ -305,6 +316,8 @@ static int adm1021_detect(struct i2c_ada
return 0;
+error2:
+ i2c_detach_client(new_client);
error1:
kfree(data);
error0:
@@ -324,6 +337,8 @@ static int adm1021_detach_client(struct
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, client not detached.\n"); return err;
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/adm1025.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/adm1025.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/adm1025.c
@@ -52,6 +52,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/*
* Addresses to scan
@@ -68,6 +70,8 @@ static unsigned int normal_isa[] = { I2C
SENSORS_INSMOD_2(adm1025, ne1619);
+static int id; /* increment once for every chip found */
+
/*
* The ADM1025 registers
*/
@@ -416,6 +420,13 @@ static int adm1025_detect(struct i2c_ada
adm1025_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -452,6 +463,8 @@ static int adm1025_detect(struct i2c_ada
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -504,6 +517,8 @@ static int adm1025_detach_client(struct
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/adm1026.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/adm1026.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/adm1026.c
@@ -31,6 +31,8 @@
#include <linux/i2c-sensor.h>
#include <linux/i2c-sysfs.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -62,6 +64,8 @@ MODULE_PARM_DESC(gpio_normal,"List of GP
module_param_array(gpio_fan,int,NULL,0); MODULE_PARM_DESC(gpio_fan,"List of GPIO pins (0-7) to program as fan tachs");
+static int id; /* increment once for every chip found */
+
/* Many ADM1026 constants specified below */
/* The ADM1026 registers */
@@ -324,6 +328,7 @@ int adm1026_attach_adapter(struct i2c_ad
int adm1026_detach_client(struct i2c_client *client) {
+ hwmon_device_unregister(client->class_dev);
i2c_detach_client(client);
kfree(client);
return 0;
@@ -1555,6 +1560,13 @@ int adm1026_detect(struct i2c_adapter *a
adm1026_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exitdetach;
+ }
+
device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr); device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr); device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
@@ -1690,6 +1702,8 @@ int adm1026_detect(struct i2c_adapter *a
return 0;
/* Error out and cleanup code */
+exitdetach:
+ i2c_detach_client(new_client);
exitfree:
kfree(new_client);
exit:
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/adm1031.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/adm1031.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/adm1031.c
@@ -27,6 +27,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* Following macros takes channel parameter starting from 0 to 2 */
#define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr))
@@ -64,6 +66,8 @@ static unsigned int normal_isa[] = { I2C
/* Insmod parameters */
SENSORS_INSMOD_2(adm1030, adm1031);
+static int id; /* increment once for every chip found */
+
typedef u8 auto_chan_table_t[8][2];
/* Each client has this additional data */
@@ -788,6 +792,13 @@ static int adm1031_detect(struct i2c_ada
adm1031_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_fan1_input); device_create_file(&new_client->dev, &dev_attr_fan1_div); device_create_file(&new_client->dev, &dev_attr_fan1_min);
@@ -833,6 +844,8 @@ static int adm1031_detect(struct i2c_ada
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(new_client);
exit:
@@ -842,6 +855,8 @@ exit:
static int adm1031_detach_client(struct i2c_client *client)
{
int ret;
+
+ hwmon_device_unregister(client->class_dev);
if ((ret = i2c_detach_client(client)) != 0) {
return ret;
}
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/adm9240.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/adm9240.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/adm9240.c
@@ -47,6 +47,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
@@ -57,6 +59,8 @@ static unsigned int normal_isa[] = { I2C
/* Insmod parameters */
SENSORS_INSMOD_3(adm9240, ds1780, lm81);
+static int id; /* increment once for every chip found */
+
/* ADM9240 registers */
#define ADM9240_REG_MAN_ID 0x3e
#define ADM9240_REG_DIE_REV 0x3f
@@ -582,6 +586,13 @@ static int adm9240_detect(struct i2c_ada
adm9240_init_client(new_client);
/* populate sysfs filesystem */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -615,6 +626,9 @@ static int adm9240_detect(struct i2c_ada
device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
return 0;
+
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(new_client);
exit:
@@ -632,6 +646,8 @@ static int adm9240_detach_client(struct
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/asb100.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/asb100.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/asb100.c
@@ -41,6 +41,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <linux/init.h>
#include <linux/jiffies.h>
#include "lm75.h"
@@ -62,6 +64,8 @@ SENSORS_INSMOD_1(asb100);
I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
"{bus, clientaddr, subclientaddr1, subclientaddr2}");
+static int id; /* increment once for every chip found */
+
/* Voltage IN registers 0-6 */
#define ASB100_REG_IN(nr) (0x20 + (nr))
#define ASB100_REG_IN_MAX(nr) (0x2b + (nr * 2))
@@ -821,6 +825,13 @@ static int asb100_detect(struct i2c_adap
data->fan_min[2] = asb100_read_value(new_client, ASB100_REG_FAN_MIN(2));
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto ERROR3;
+ }
+
device_create_file_in(new_client, 0); device_create_file_in(new_client, 1); device_create_file_in(new_client, 2);
@@ -847,6 +858,10 @@ static int asb100_detect(struct i2c_adap
return 0;
+ERROR3:
+ i2c_detach_client(data->lm75[0]);
+ kfree(data->lm75[1]);
+ kfree(data->lm75[0]);
ERROR2:
i2c_detach_client(new_client);
ERROR1:
@@ -859,6 +874,8 @@ static int asb100_detach_client(struct i
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "client deregistration failed; "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/ds1621.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/ds1621.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/ds1621.c
@@ -27,6 +27,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include "lm75.h"
/* Addresses to scan */
@@ -40,6 +42,8 @@ static int polarity = -1;
module_param(polarity, int, 0);
MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low");
+static int id; /* increment once for every chip found */
+
/* Many DS1621 constants specified below */
/* Config register used for detection */
/* 7 6 5 4 3 2 1 0 */
@@ -250,6 +254,13 @@ int ds1621_detect(struct i2c_adapter *ad
ds1621_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_alarms); device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -259,6 +270,8 @@ int ds1621_detect(struct i2c_adapter *ad
/* OK, this is not exactly good programming practice, usually. But it is
very code-efficient in this case. */
+ exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -269,6 +282,8 @@ static int ds1621_detach_client(struct i
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/fscher.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/fscher.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/fscher.c
@@ -32,6 +32,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/*
* Addresses to scan
@@ -46,6 +48,8 @@ static unsigned int normal_isa[] = { I2C
SENSORS_INSMOD_1(fscher);
+static int id; /* increment once for every chip found */
+
/*
* The FSCHER registers
*/
@@ -341,6 +345,13 @@ static int fscher_detect(struct i2c_adap
fscher_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file_revision(new_client); device_create_file_alarms(new_client); device_create_file_control(new_client);
@@ -360,6 +371,8 @@ static int fscher_detect(struct i2c_adap
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -370,6 +383,8 @@ static int fscher_detach_client(struct i
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/fscpos.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/fscpos.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/fscpos.c
@@ -35,6 +35,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/init.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/*
* Addresses to scan
@@ -47,6 +49,8 @@ static unsigned int normal_isa[] = { I2C
*/
SENSORS_INSMOD_1(fscpos);
+static int id; /* increment once for every chip found */
+
/*
* The FSCPOS registers
*/
@@ -495,6 +499,13 @@ int fscpos_detect(struct i2c_adapter *ad
dev_info(&new_client->dev, "Found fscpos chip, rev %u\n", data->revision);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_event); device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input);
@@ -525,6 +536,8 @@ int fscpos_detect(struct i2c_adapter *ad
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -535,6 +548,8 @@ static int fscpos_detach_client(struct i
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, client"
" not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/gl518sm.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/gl518sm.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/gl518sm.c
@@ -42,6 +42,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
@@ -50,6 +52,8 @@ static unsigned int normal_isa[] = { I2C
/* Insmod parameters */
SENSORS_INSMOD_2(gl518sm_r00, gl518sm_r80);
+static int id; /* increment once for every chip found */
+
/* Many GL518 constants specified below */
/* The GL518 registers */
@@ -419,6 +423,13 @@ static int gl518_detect(struct i2c_adapt
gl518_init_client((struct i2c_client *) new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -450,6 +461,8 @@ static int gl518_detect(struct i2c_adapt
/* OK, this is not exactly good programming practice, usually. But it is
very code-efficient in this case. */
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -479,6 +492,8 @@ static int gl518_detach_client(struct i2
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/gl520sm.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/gl520sm.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/gl520sm.c
@@ -27,6 +27,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* Type of the extra sensor */
static unsigned short extra_sensor_type;
@@ -40,6 +42,8 @@ static unsigned int normal_isa[] = { I2C
/* Insmod parameters */ SENSORS_INSMOD_1(gl520sm);
+static int id; /* increment once for each chip found */
+
/* Many GL520 constants specified below
One of the inputs can be configured as either temp or voltage. That's why _TEMP2 and _IN4 access the same register
@@ -570,6 +574,13 @@ static int gl520_detect(struct i2c_adapt
gl520_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file_vid(new_client, 0);
device_create_file_in(new_client, 0);
@@ -591,6 +602,8 @@ static int gl520_detect(struct i2c_adapt
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -640,6 +653,8 @@ static int gl520_detach_client(struct i2
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/it87.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/it87.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/it87.c
@@ -38,9 +38,10 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <asm/io.h>
-
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
0x2e, 0x2f, I2C_CLIENT_END };
@@ -49,6 +50,8 @@ static unsigned int normal_isa[] = { 0x0
/* Insmod parameters */
SENSORS_INSMOD_2(it87, it8712);
+static int id; /* increment once for every chip found */
+
#define REG 0x2e /* The register to read/write */
#define DEV 0x07 /* Register: Logical device select */
#define VAL 0x2f /* The value to read/write */
@@ -861,6 +864,13 @@ int it87_detect(struct i2c_adapter *adap
it87_init_client(new_client, data);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto ERROR3;
+ }
+
device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -925,6 +935,8 @@ int it87_detect(struct i2c_adapter *adap
return 0;
+ERROR3:
+ i2c_detach_client(new_client);
ERROR2:
kfree(data);
ERROR1:
@@ -938,6 +950,8 @@ static int it87_detach_client(struct i2c
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm63.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/lm63.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm63.c
@@ -43,6 +43,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/*
* Addresses to scan
@@ -58,6 +60,8 @@ static unsigned int normal_isa[] = { I2C
SENSORS_INSMOD_1(lm63);
+static int id; /* increment once for each chip found */
+
/*
* The LM63 registers
*/
@@ -428,6 +432,13 @@ static int lm63_detect(struct i2c_adapte
lm63_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
if (data->config & 0x04) { /* tachometer enabled */
device_create_file(&new_client->dev, &dev_attr_fan1_input); device_create_file(&new_client->dev, &dev_attr_fan1_min);
@@ -445,6 +456,8 @@ static int lm63_detect(struct i2c_adapte
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -490,6 +503,8 @@ static int lm63_detach_client(struct i2c
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm75.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/lm75.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm75.c
@@ -24,6 +24,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include "lm75.h"
@@ -35,6 +37,8 @@ static unsigned int normal_isa[] = { I2C
/* Insmod parameters */
SENSORS_INSMOD_1(lm75);
+static int id; /* increment once for every chip found */
+
/* Many LM75 constants specified below */
/* The LM75 registers */
@@ -208,12 +212,21 @@ static int lm75_detect(struct i2c_adapte
lm75_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_temp1_max); device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); device_create_file(&new_client->dev, &dev_attr_temp1_input);
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -222,6 +235,7 @@ exit:
static int lm75_detach_client(struct i2c_client *client)
{
+ hwmon_device_unregister(client->class_dev);
i2c_detach_client(client);
kfree(i2c_get_clientdata(client));
return 0;
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm77.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/lm77.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm77.c
@@ -31,7 +31,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
-
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END };
@@ -40,6 +41,8 @@ static unsigned int normal_isa[] = { I2C
/* Insmod parameters */
SENSORS_INSMOD_1(lm77);
+static int id; /* increment once for every chip found */
+
/* The LM77 registers */
#define LM77_REG_TEMP 0x00
#define LM77_REG_CONF 0x01
@@ -317,6 +320,13 @@ static int lm77_detect(struct i2c_adapte
lm77_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp1_crit); device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -327,6 +337,8 @@ static int lm77_detect(struct i2c_adapte
device_create_file(&new_client->dev, &dev_attr_alarms); return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -335,6 +347,7 @@ exit:
static int lm77_detach_client(struct i2c_client *client)
{
+ hwmon_device_unregister(client->class_dev);
i2c_detach_client(client);
kfree(i2c_get_clientdata(client));
return 0;
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm78.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/lm78.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm78.c
@@ -24,6 +24,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <asm/io.h>
/* Addresses to scan */
@@ -36,6 +38,8 @@ static unsigned int normal_isa[] = { 0x0
/* Insmod parameters */
SENSORS_INSMOD_3(lm78, lm78j, lm79);
+static int id; /* increment once for every chip found */
+
/* Many LM78 constants specified below */
/* Length of ISA address segment */
@@ -605,6 +609,13 @@ int lm78_detect(struct i2c_adapter *adap
}
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto ERROR3;
+ }
+
device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -643,6 +654,8 @@ int lm78_detect(struct i2c_adapter *adap
return 0;
+ERROR3:
+ i2c_detach_client(new_client);
ERROR2:
kfree(data);
ERROR1:
@@ -656,6 +669,8 @@ static int lm78_detach_client(struct i2c
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm80.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/lm80.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm80.c
@@ -27,6 +27,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
@@ -36,6 +38,8 @@ static unsigned int normal_isa[] = { I2C
/* Insmod parameters */
SENSORS_INSMOD_1(lm80);
+static int id; /* increment once for every chip found */
+
/* Many LM80 constants specified below */
/* The LM80 registers */
@@ -451,6 +455,13 @@ int lm80_detect(struct i2c_adapter *adap
data->fan_min[1] = lm80_read_value(new_client, LM80_REG_FAN_MIN(2));
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto error_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in1_min); device_create_file(&new_client->dev, &dev_attr_in2_min);
@@ -487,6 +498,8 @@ int lm80_detect(struct i2c_adapter *adap
return 0;
+error_detach:
+ i2c_detach_client(new_client);
error_free:
kfree(data);
exit:
@@ -497,6 +510,8 @@ static int lm80_detach_client(struct i2c
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm83.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/lm83.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm83.c
@@ -33,6 +33,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/*
* Addresses to scan
@@ -52,6 +54,8 @@ static unsigned int normal_isa[] = { I2C
SENSORS_INSMOD_1(lm83);
+static int id; /* increment once for every chip found */
+
/*
* The LM83 registers
* Manufacturer ID is 0x01 for National Semiconductor.
@@ -322,6 +326,13 @@ static int lm83_detect(struct i2c_adapte
*/
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp2_input); device_create_file(&new_client->dev, &dev_attr_temp3_input);
@@ -338,6 +349,8 @@ static int lm83_detect(struct i2c_adapte
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -348,6 +361,8 @@ static int lm83_detach_client(struct i2c
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm85.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/lm85.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm85.c
@@ -30,6 +30,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -38,6 +40,8 @@ static unsigned int normal_isa[] = { I2C
/* Insmod parameters */
SENSORS_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);
+static int id; /* increment once for every chip found */
+
/* The LM85 registers */
#define LM85_REG_IN(nr) (0x20 + (nr))
@@ -1166,6 +1170,13 @@ int lm85_detect(struct i2c_adapter *adap
lm85_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto ERROR2;
+ }
+
device_create_file(&new_client->dev, &dev_attr_fan1_input); device_create_file(&new_client->dev, &dev_attr_fan2_input); device_create_file(&new_client->dev, &dev_attr_fan3_input);
@@ -1235,6 +1246,8 @@ int lm85_detect(struct i2c_adapter *adap
return 0;
/* Error out and cleanup code */
+ ERROR2:
+ i2c_detach_client(new_client);
ERROR1:
kfree(data);
ERROR0:@@ -1243,6 +1256,7 @@ int lm85_detect(struct i2c_adapter *adap
int lm85_detach_client(struct i2c_client *client)
{
+ hwmon_device_unregister(client->class_dev);
i2c_detach_client(client);
kfree(i2c_get_clientdata(client));
return 0;
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm87.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/lm87.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm87.c
@@ -59,6 +59,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/*
* Addresses to scan
@@ -74,6 +76,8 @@ static unsigned int normal_isa[] = { I2C
SENSORS_INSMOD_1(lm87);
+static int id; /* increment once for every chip found */
+
/*
* The LM87 registers
*/
@@ -608,6 +612,13 @@ static int lm87_detect(struct i2c_adapte
data->in_scale[7] = 1875;
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in1_min); device_create_file(&new_client->dev, &dev_attr_in1_max);
@@ -673,6 +684,8 @@ static int lm87_detect(struct i2c_adapte
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -721,6 +734,8 @@ static int lm87_detach_client(struct i2c
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm90.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/lm90.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm90.c
@@ -76,6 +76,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/*
* Addresses to scan
@@ -96,6 +98,8 @@ static unsigned int normal_isa[] = { I2C
SENSORS_INSMOD_6(lm90, adm1032, lm99, lm86, max6657, adt7461);
+static int id; /* increment once for every chip found */
+
/*
* The LM90 registers
*/
@@ -480,6 +484,13 @@ static int lm90_detect(struct i2c_adapte
lm90_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp2_input); device_create_file(&new_client->dev, &dev_attr_temp1_min);
@@ -494,6 +505,8 @@ static int lm90_detect(struct i2c_adapte
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -519,6 +532,8 @@ static int lm90_detach_client(struct i2c
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm92.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/lm92.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/lm92.c
@@ -45,7 +45,8 @@
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
-
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* The LM92 and MAX6635 have 2 two-state pins for address selection,
resulting in 4 possible addresses. */
@@ -56,6 +57,8 @@ static unsigned int normal_isa[] = { I2C
/* Insmod parameters */
SENSORS_INSMOD_1(lm92);
+static int id; /* increment once for every chip found */
+
/* The LM92 registers */
#define LM92_REG_CONFIG 0x01 /* 8-bit, RW */
#define LM92_REG_TEMP 0x00 /* 16-bit, RO */
@@ -359,6 +362,13 @@ static int lm92_detect(struct i2c_adapte
lm92_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp1_crit); device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst);
@@ -370,6 +380,8 @@ static int lm92_detect(struct i2c_adapte
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -387,6 +399,8 @@ static int lm92_detach_client(struct i2c
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/max1619.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/max1619.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/max1619.c
@@ -32,7 +32,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
-
+#include <linux/hwmon.h>
+#include <linux/err.h>
static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
0x29, 0x2a, 0x2b,
@@ -46,6 +47,8 @@ static unsigned int normal_isa[] = { I2C
SENSORS_INSMOD_1(max1619);
+static int id; /* increment once for every chip found */
+
/*
* The MAX1619 registers
*/
@@ -275,6 +278,13 @@ static int max1619_detect(struct i2c_ada
max1619_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp2_input); device_create_file(&new_client->dev, &dev_attr_temp2_min);
@@ -285,6 +295,8 @@ static int max1619_detect(struct i2c_ada
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -310,6 +322,8 @@ static int max1619_detach_client(struct
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/pc87360.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/pc87360.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/pc87360.c
@@ -40,6 +40,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <asm/io.h>
static unsigned short normal_i2c[] = { I2C_CLIENT_END };
@@ -65,6 +67,8 @@ MODULE_PARM_DESC(init,
" 2: Forcibly enable all voltage and temperature channels, except in9\n" " 3: Forcibly enable all voltage and temperature channels, including in9");
+static int id; /* increment once for every chip found */
+
/*
* Super-I/O registers and operations
*/
@@ -838,6 +842,13 @@ int pc87360_detect(struct i2c_adapter *a
}
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto ERROR3;
+ }
+
if (data->innr) {
device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input);
@@ -974,6 +985,8 @@ int pc87360_detect(struct i2c_adapter *a
return 0;
+ERROR3:
+ i2c_detach_client(new_client);
ERROR2:
for (i = 0; i < 3; i++) {
if (data->address[i]) {
@@ -990,6 +1003,8 @@ static int pc87360_detach_client(struct
struct pc87360_data *data = i2c_get_clientdata(client); int i;
+ hwmon_device_unregister(client->class_dev);
+
if ((i = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/sis5595.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/sis5595.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/sis5595.c
@@ -56,6 +56,8 @@
#include <linux/pci.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <linux/init.h>
#include <linux/jiffies.h>
#include <asm/io.h>
@@ -77,6 +79,8 @@ static unsigned int normal_isa[] = { 0x0
/* Insmod parameters */
SENSORS_INSMOD_1(sis5595);
+static int id; /* increment once for every chip found */
+
/* Many SIS5595 constants specified below */
/* Length of ISA address segment */
@@ -578,6 +582,13 @@ int sis5595_detect(struct i2c_adapter *a
}
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in0_max);
@@ -608,7 +619,9 @@ int sis5595_detect(struct i2c_adapter *a
device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst);
}
return 0;
-
+
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit_release:
@@ -621,6 +634,8 @@ static int sis5595_detach_client(struct
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/smsc47b397.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/smsc47b397.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/smsc47b397.c
@@ -32,6 +32,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <linux/init.h>
#include <asm/io.h>
@@ -49,6 +51,8 @@ static struct i2c_address_data addr_data
.forces = forces,
};
+static int id; /* increment once for every chip found */
+
/* Super-I/0 registers and commands */
#define REG 0x2e /* The register to read/write */
@@ -228,6 +232,8 @@ static int smsc47b397_detach_client(stru
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
@@ -285,6 +291,13 @@ static int smsc47b397_detect(struct i2c_
if ((err = i2c_attach_client(new_client)))
goto error_free;
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto error_detach;
+ }
+
device_create_file_temp(new_client, 1); device_create_file_temp(new_client, 2); device_create_file_temp(new_client, 3);
@@ -297,6 +310,8 @@ static int smsc47b397_detect(struct i2c_
return 0;
+error_detach:
+ i2c_detach_client(new_client);
error_free:
kfree(new_client);
error_release:
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/smsc47m1.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/smsc47m1.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/smsc47m1.c
@@ -31,6 +31,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <linux/init.h>
#include <asm/io.h>
@@ -46,6 +48,8 @@ static struct i2c_address_data addr_data
.forces = forces,
};
+static int id; /* increment once for every chip found */
+
/* Super-I/0 registers and commands */
#define REG 0x2e /* The register to read/write */
@@ -461,6 +465,14 @@ static int smsc47m1_detect(struct i2c_ad
function. */
smsc47m1_update_device(&new_client->dev, 1);
+ /* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto error_detach;
+ }
+
if (fan1) {
device_create_file(&new_client->dev, &dev_attr_fan1_input); device_create_file(&new_client->dev, &dev_attr_fan1_min);
@@ -494,6 +506,8 @@ static int smsc47m1_detect(struct i2c_ad
return 0;
+error_detach:
+ i2c_detach_client(new_client);
error_free:
kfree(new_client);
error_release:
@@ -505,6 +519,8 @@ static int smsc47m1_detach_client(struct
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/via686a.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/via686a.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/via686a.c
@@ -36,6 +36,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <linux/init.h>
#include <asm/io.h>
@@ -56,6 +58,8 @@ static unsigned int normal_isa[] = { 0x0
/* Insmod parameters */ SENSORS_INSMOD_1(via686a);
+static int id; /* increment once for every chip found */
+
/*
The Via 686a southbridge has a LM78-like chip integrated on the same IC. This driver is a customized copy of lm78.c
@@ -637,7 +641,7 @@ static int via686a_detect(struct i2c_ada
if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) {
err = -ENOMEM;
- goto ERROR0;
+ goto exit_release;
}
memset(data, 0, sizeof(struct via686a_data));
@@ -655,12 +659,19 @@ static int via686a_detect(struct i2c_ada
init_MUTEX(&data->update_lock);
/* Tell the I2C layer a new client has arrived */ if ((err = i2c_attach_client(new_client)))
- goto ERROR3;
+ goto exit_free;
/* Initialize the VIA686A chip */
via686a_init_client(new_client);
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in2_input);
@@ -695,9 +706,11 @@ static int via686a_detect(struct i2c_ada
return 0;
-ERROR3:
+exit_detach:
+ i2c_detach_client(new_client);
+exit_free:
kfree(data);-ERROR0:
+exit_release:
release_region(address, VIA686A_EXTENT); return err;
}
@@ -706,6 +719,8 @@ static int via686a_detach_client(struct
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/w83627ehf.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/w83627ehf.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/w83627ehf.c
@@ -38,6 +38,8 @@
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <asm/io.h>
#include "lm75.h"
@@ -49,6 +51,8 @@ static unsigned int normal_isa[] = { 0,
/* Insmod parameters */ SENSORS_INSMOD_1(w83627ehf);
+static int id; /* increment once for every chip found */
+
/*
* Super-I/O constants and functions
*/
@@ -720,6 +724,13 @@ static int w83627ehf_detect(struct i2c_a
data->has_fan |= (1 << 4);
/* Register sysfs hooks */
+ client->class_dev = hwmon_device_register(&client->dev,
+ "%s-%d", client->name, id++);
+ if (IS_ERR(client->class_dev)) {
+ err = PTR_ERR(client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&client->dev, &dev_attr_fan1_input); device_create_file(&client->dev, &dev_attr_fan1_min); device_create_file(&client->dev, &dev_attr_fan1_div);
@@ -753,6 +764,8 @@ static int w83627ehf_detect(struct i2c_a
return 0;
+exit_detach:
+ i2c_detach_client(client);
exit_free:
kfree(data);
exit_release:
@@ -772,6 +785,8 @@ static int w83627ehf_detach_client(struc
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/w83627hf.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/w83627hf.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/w83627hf.c
@@ -44,6 +44,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <asm/io.h>
#include "lm75.h"
@@ -67,6 +69,8 @@ static int init = 1;
module_param(init, bool, 0);
MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization");
+static int id; /* increment once for every chip found */
+
/* modified from kernel/include/traps.c */
static int REG; /* The register to read/write */
#define DEV 0x07 /* Register: Logical device select */
@@ -1102,6 +1106,13 @@ int w83627hf_detect(struct i2c_adapter *
data->fan_min[2] = w83627hf_read_value(new_client, W83781D_REG_FAN_MIN(3));
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto ERROR3;
+ }
+
device_create_file_in(new_client, 0);
if (kind != w83697hf)
device_create_file_in(new_client, 1);
@@ -1152,6 +1163,8 @@ int w83627hf_detect(struct i2c_adapter *
return 0;
+ ERROR3:
+ i2c_detach_client(new_client);
ERROR2:
kfree(data);
ERROR1:@@ -1164,6 +1177,8 @@ static int w83627hf_detach_client(struct
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev,
"Client deregistration failed, client not detached.\n");
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/w83781d.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/w83781d.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/w83781d.c
@@ -42,6 +42,8 @@
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
#include <asm/io.h>
#include "lm75.h"
@@ -60,6 +62,8 @@ static int init = 1;
module_param(init, bool, 0);
MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization");
+static int id; /* increment once for every chip found */
+
/* Constants specified below */
/* Length of ISA address segment */
@@ -1205,6 +1209,13 @@ w83781d_detect(struct i2c_adapter *adapt
data->pwmenable[i] = 1;
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto ERROR4;
+ }
+
device_create_file_in(new_client, 0);
if (kind != w83783s && kind != w83697hf)
device_create_file_in(new_client, 1);
@@ -1262,6 +1273,15 @@ w83781d_detect(struct i2c_adapter *adapt
return 0;
+ERROR4:
+ if (NULL != data->lm75[1]) {
+ i2c_detach_client(data->lm75[1]);
+ kfree(data->lm75[1]);
+ }
+ if (NULL != data->lm75[0]) {
+ i2c_detach_client(data->lm75[0]);
+ kfree(data->lm75[0]);
+ }
ERROR3:
i2c_detach_client(new_client);
ERROR2:
@@ -1278,6 +1298,9 @@ w83781d_detach_client(struct i2c_client
{
int err;
+ if (client->class_dev)
+ hwmon_device_unregister(client->class_dev);
+
if (i2c_is_isa_client(client))
release_region(client->addr, W83781D_EXTENT);
Index: linux-2.6.12-rc5-mm1/drivers/i2c/chips/w83l785ts.c =================================--- linux-2.6.12-rc5-mm1.orig/drivers/i2c/chips/w83l785ts.c +++ linux-2.6.12-rc5-mm1/drivers/i2c/chips/w83l785ts.c
@@ -37,6 +37,8 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
+#include <linux/hwmon.h>
+#include <linux/err.h>
/* How many retries on register read error */
#define MAX_RETRIES 5
@@ -55,6 +57,8 @@ static unsigned int normal_isa[] = { I2C
SENSORS_INSMOD_1(w83l785ts);
+static int id; /* increment once for every chip found */
+
/*
* The W83L785TS-S registers
* Manufacturer ID is 0x5CA3 for Winbond.
@@ -239,11 +243,20 @@ static int w83l785ts_detect(struct i2c_a
*/
/* Register sysfs hooks */
+ new_client->class_dev = hwmon_device_register(&new_client->dev,
+ "%s-%d", new_client->name, id++);
+ if (IS_ERR(new_client->class_dev)) {
+ err = PTR_ERR(new_client->class_dev);
+ goto exit_detach;
+ }
+
device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp1_max);
return 0;
+exit_detach:
+ i2c_detach_client(new_client);
exit_free:
kfree(data);
exit:
@@ -254,6 +267,8 @@ static int w83l785ts_detach_client(struc
{
int err;
+ hwmon_device_unregister(client->class_dev);
+
if ((err = i2c_detach_client(client))) {
dev_err(&client->dev, "Client deregistration failed, "
"client not detached.\n");
Index: linux-2.6.12-rc5-mm1/include/linux/i2c.h =================================--- linux-2.6.12-rc5-mm1.orig/include/linux/i2c.h +++ linux-2.6.12-rc5-mm1/include/linux/i2c.h
@@ -154,6 +154,7 @@ struct i2c_client {
int usage_count; /* How many accesses currently */
/* to the client */
struct device dev; /* the device structure */
+ struct class_device *class_dev;
struct list_head list;
char name[I2C_NAME_SIZE];
struct completion released;
Signature · 2 lines
Mark M. Hoffman [email protected]
Review static unsigned int normal_isa[] = { I2C · line 43
Quoted 6 lines · Mark M. Hoffman
(quoted diff) +2
-0@@ -37,6 +39,8 @@ static unsigned int normal_isa[] = { I2C /* Insmod parameters */ SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066); +static int id; /* increment once for every chip found */ +
You duplicate this logic in every driver. Is it really needed? How about having the "bus id" be unique for all hwmon devices? That way, no id varible is needed, and just the name of the device. Then, in the hwmon core, you add the unique number to the front of the name. Something like:
01-adm1021 02-adm1025
and so on.
Any thoughts?
thanks,
greg k-h
Hi Greg:
Quoted 13 lines · Greg KH
Review static unsigned int normal_isa[] = { I2C · line 43
Quoted 6 lines · Mark M. Hoffman
(quoted diff) +2
-0@@ -37,6 +39,8 @@ static unsigned int normal_isa[] = { I2C /* Insmod parameters */ SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066); +static int id; /* increment once for every chip found */ +You duplicate this logic in every driver. Is it really needed? How about having the "bus id" be unique for all hwmon devices? That way, no id varible is needed, and just the name of the device. Then, in the hwmon core, you add the unique number to the front of the name. Something like:
Quoted 5 lines
01-adm1021 02-adm1025and so on.
Any thoughts?
Yeah, that looks reasonable [1]. Ultimately, libsensors isn't going to care about that name; it will grab all the info it needs through the device link. It also renders the first patch in the set unnecessary - you can apply that seperately if you want it at all.
Again, hold up on sending through to -mm and I'll fix this up.
[1] I personally prefer more leading zeros, or better yet none at all.
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
Quoted 20 lines · Mark M. Hoffman
Hi Greg:
Quoted 17 lines · Greg KH
Review static unsigned int normal_isa[] = { I2C · line 43
Quoted 6 lines · Mark M. Hoffman
(quoted diff) +2
-0@@ -37,6 +39,8 @@ static unsigned int normal_isa[] = { I2C /* Insmod parameters */ SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066); +static int id; /* increment once for every chip found */ +You duplicate this logic in every driver. Is it really needed? How about having the "bus id" be unique for all hwmon devices? That way, no id varible is needed, and just the name of the device. Then, in the hwmon core, you add the unique number to the front of the name. Something like:
01-adm1021 02-adm1025and so on.
Quoted 6 lines
Quoted 1 line
Any thoughts?
Yeah, that looks reasonable [1]. Ultimately, libsensors isn't going to care about that name; it will grab all the info it needs through the device link. It also renders the first patch in the set unnecessary - you can apply that seperately if you want it at all.
Well, things are in a quilt tree, so it's quite easy to drop any one patch if needed. I'll keep it around for a while, it's a nice function to have :)
Quoted 1 line
Again, hold up on sending through to -mm and I'll fix this up.
Heh, the fun thing about -mm release is, we never know when they will happen... My stuff is public and Andrew pulls it in when he wants to update. As he just released one last night, we might have a day or so before the next one, so it should be fine.
Quoted 1 line
[1] I personally prefer more leading zeros, or better yet none at all.
Sure, just an example, use what you want. More is always nice to keep things sorted sanely.
thanks,
greg k-h
Hi Mark,
I'm trying to implement the hwmon interface in ipmi_sensors (the re-written driver based on bmcsensors w/o i2c-ipmi), but I can't find any device struct that I could pass when registering the hwmon class, the ipmi system simply doesn't seem to define any, I thought that perhaps the bmc interfaces would have an associated one at least.
The problem essentially is, unlike the i2c/isa sensor chip drivers, ipmi_sensors isn't a device driver as such, it is an lm-sensors interface to the sensors available to an IPMI BMC.
I just come back to my previous line of thought that we really should be using class_device_attributes for hwmon class sensor attributes rather than assuming that every hwmon class_device has an associated device...
Yani
Quoted 11 lines · Yani Ioannou
Hi Mark,
I'm trying to implement the hwmon interface in
ipmi_sensors(the re-written driver based on bmcsensors w/o i2c-ipmi), but I can't find any device struct that I could pass when registering the hwmon class, the ipmi system simply doesn't seem to define any, I thought that perhaps the bmc interfaces would have an associated one at least.The problem essentially is, unlike the i2c/isa sensor chip drivers,
ipmi_sensorsisn't a device driver as such, it is an lm-sensors interface to the sensors available to an IPMI BMC.
Which is a platform device. Or if not, it should be. There is your struct device.
Quoted 4 lines
I just come back to my previous line of thought that we really should be using
class_device_attributesfor hwmon class sensor attributes rather than assuming that every hwmonclass_devicehas an associated device...
No, every hwmon class_device should have a struct device associated with it. If not, it needs to be fixed :)
thanks,
greg k-h
Hi Greg,
Quoted 6 lines
Quoted 3 lines
The problem essentially is, unlike the i2c/isa sensor chip drivers,
ipmi_sensorsisn't a device driver as such, it is an lm-sensors interface to the sensors available to an IPMI BMC.Which is a platform device. Or if not, it should be. There is your struct device.
Yes, I agree, I'm going to have to see if I can find away to make the low level device (assuming that exists..) for each IPMI interface type available at a higher level, without annoying Corey too much :-).
Quoted 7 lines
Quoted 4 lines
I just come back to my previous line of thought that we really should be using
class_device_attributesfor hwmon class sensor attributes rather than assuming that every hwmonclass_devicehas an associated device...No, every hwmon
class_deviceshould have a struct device associated with it. If not, it needs to be fixed :)
Well even assuming that every hwmon class_device does have a device associated with it, it still makes sense to me to be using class_device_attributes.
First of all they are attributes of the hwmon class, not that neccessarily that device, for example assuming I add the sensor device_attributes to the ipmi low level interface device, now I have a device entry with a whole load of sensor attributes when that low level interface hasn't actually got sensors hanging off it, it is just a way of accessing the IPMI BMC (which by the way can be accessed through more than one interface). It simply doesn't make sense in the way that the sysfs tree should IMHO.
Furthermore I've added attributes for the device from a hwmon class, shouldn't the device be responsible for device_attributes?
Thanks,
Yani
Hi Greg,
Quoted 5 lines
Quoted 2 lines
[1] I personally prefer more leading zeros, or better yet none at all.
Sure, just an example, use what you want. More is always nice to keep things sorted sanely.
ls -v is nice for that purpose too. I would better improve sorting algorithms were needed than add arbitrary limits were not needed.
That being said, I'd be curious to see a system with more than 10 hardware monitoring chips (record so far is 6 on the Tyan S4882 board).
Thanks,
Signature · 1 line
Jean Delvare
Hi Mark, Greg,
Quoted 14 lines · Mark M. Hoffman
Review static unsigned int normal_isa[] = { I2C · line 44
Quoted 7 lines
(quoted diff) +2
-0@@ -37,6 +39,8 @@ static unsigned int normal_isa[] = { I2C /* Insmod parameters */ SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066); +static int id; /* increment once for every chip found */ +You duplicate this logic in every driver. Is it really needed? How about having the "bus id" be unique for all hwmon devices? That way, no id varible is needed, and just the name of the device. Then, in the hwmon core, you add the unique number to the front of the name. Something like:
Quoted 5 lines
01-adm1021 02-adm1025and so on.
Any thoughts?
I totally second Greg on that. I have been working hard to get the i2c_client.id mess out of each i2c chip driver, let's not reintroduce it again here.
Also, this original approach was dangerous, as it relied on the cooperation of each driver for uniqueness of the IDs. This can easily fail. We want the uniqueness guaranted by the hwmon class itself.
I am not even sure we want to display the name of the chips here, as it is redundant with the "name" file in the target directory. I would go with a simple number, this is the easiest and does the job.
Last, it would be nice if the IDs were reused on driver cycling, just like the i2c bus IDs are. You should be able to pick the code in i2c-dev and reuse it in the hwmon class.
Thanks,
Signature · 1 line
Jean Delvare
Quoted 5 lines · Jean Delvare
Hi Greg,
Quoted 3 lines
Quoted 2 lines
[1] I personally prefer more leading zeros, or better yet none at all.
Quoted 8 lines
Quoted 2 lines
Sure, just an example, use what you want. More is always nice to keep things sorted sanely.
ls -v is nice for that purpose too. I would better improve sorting algorithms were needed than add arbitrary limits were not needed.
That being said, I'd be curious to see a system with more than 10 hardware monitoring chips (record so far is 6 on the Tyan S4882 board).
Actually record is 60 if you include bmcsensors :-), some server IPMI BMCs seem to have an insane number of sensors.
Yani
Hi Yani,
Quoted 6 lines
Quoted 3 lines
That being said, I'd be curious to see a system with more than 10 hardware monitoring chips (record so far is 6 on the Tyan S4882 board).
Actually record is 60 if you include bmcsensors :-), some server IPMI BMCs seem to have an insane number of sensors.
Hm, I really mean sensor chips, not channels. bmcsensors will still show as a single chip, with many sensor channels, right?
Signature · 1 line
Jean Delvare
Quoted 11 lines · Jean Delvare
Hi Yani,
Quoted 6 lines
Quoted 3 lines
That being said, I'd be curious to see a system with more than 10 hardware monitoring chips (record so far is 6 on the Tyan S4882 board).
Actually record is 60 if you include bmcsensors :-), some server IPMI BMCs seem to have an insane number of sensors.
Hm, I really mean sensor chips, not channels. bmcsensors will still show as a single chip, with many sensor channels, right?
Ah yes, sorry, I read that wrong. Each BMC will show as a single 'chip'/hwmon device with many sensors, although it is really interfacing to many chips itself.
Yani
Hi Jean et. al.
Quoted 26 lines · Jean Delvare
Hi Mark, Greg,
Quoted 14 lines · Mark M. Hoffman
Review static unsigned int normal_isa[] = { I2C · line 44
Quoted 7 lines
(quoted diff) +2
-0@@ -37,6 +39,8 @@ static unsigned int normal_isa[] = { I2C /* Insmod parameters */ SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066); +static int id; /* increment once for every chip found */ +You duplicate this logic in every driver. Is it really needed? How about having the "bus id" be unique for all hwmon devices? That way, no id varible is needed, and just the name of the device. Then, in the hwmon core, you add the unique number to the front of the name. Something like:
Quoted 5 lines
01-adm1021 02-adm1025and so on.
Any thoughts?
I totally second Greg on that. I have been working hard to get the i2c_client.id mess out of each i2c chip driver, let's not reintroduce it again here.
Quoted 7 lines
Also, this original approach was dangerous, as it relied on the cooperation of each driver for uniqueness of the IDs. This can easily fail. We want the uniqueness guaranted by the hwmon class itself.
I am not even sure we want to display the name of the chips here, as it is redundant with the "name" file in the target directory. I would go with a simple number, this is the easiest and does the job.
It would be easy enough to do hwmon1, hwmon2, etc. just like the usb_host class does. Everyone OK with that?
Quoted 3 lines
Last, it would be nice if the IDs were reused on driver cycling, just like the i2c bus IDs are. You should be able to pick the code in i2c-dev and reuse it in the hwmon class.
It would be nice... I'll look into it.
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
Hi Mark,
Quoted 2 lines
It would be easy enough to do hwmon1, hwmon2, etc. just like the
usb_hostclass does. Everyone OK with that?
Yes, sounds good.
Thanks,
Signature · 1 line
Jean Delvare
Quoted 11 lines · Yani Ioannou
Quoted 7 lines
Quoted 4 lines
I just come back to my previous line of thought that we really should be using
class_device_attributesfor hwmon class sensor attributes rather than assuming that every hwmonclass_devicehas an associated device...No, every hwmon
class_deviceshould have a struct device associated with it. If not, it needs to be fixed :)Well even assuming that every hwmon
class_devicedoes have a device associated with it, it still makes sense to me to be usingclass_device_attributes.
It does, over time. I can see the sensor files moving to be class attributes instead of device attributes. But we need to do that so we don't break all of the userspace code at the same time :)
thanks,
greg k-h
Quoted 3 lines
It does, over time. I can see the sensor files moving to be class attributes instead of device attributes. But we need to do that so we don't break all of the userspace code at the same time :)
Yes, fair enough :). That's basically the point Mark made too, and I can understand, the userspace interface hasn't exactly been stable for lm-sensors 2.6. I really like the hwmon direction overall though, and hopefully the ipmi sensors driver will be an ideal example of what the hwmon patch is all about. I keep encountering little hurdles to jump over though on the way..
Thanks,
Yani
Hi all,
Quoted 3 lines
It does, over time. I can see the sensor files moving to be class attributes instead of device attributes. But we need to do that so we don't break all of the userspace code at the same time :)
I am not sure what attributes are typically found in classes (pointers to existing implementations would be welcome), but please keep in mind that no single sysfs file will ever be found in all hwmon clients. The sysfs interface we defined is about how the files should be named for present features, but no part of this interface is required for any given driver (this wouldn't make sense).
Thanks,
--
Jean Delvare
Hi Jean:
Quoted 2 lines · Mark M. Hoffman
It would be easy enough to do hwmon1, hwmon2, etc. just like the
usb_hostclass does. Everyone OK with that?
Quoted 3 lines · Jean Delvare
Quoted 3 lines
Last, it would be nice if the IDs were reused on driver cycling, just like the i2c bus IDs are. You should be able to pick the code in i2c-dev and reuse it in the hwmon class.
Quoted 1 line · Mark M. Hoffman
It would be nice... I'll look into it.
Actually, the bus IDs are assigned in i2c-core. The i2c-dev ID is just a copy of that. The mechanism for the ID recycling is from lib/idr.c.
AFAICT, the ID recycling is a mere side-effect of that (idr.c) modules's real purpose. The way it's used in i2c-core.c feels like bloat to me. I'm not certain I want to duplicate that in hwmon.c. Opinions?
* * * * *
Well, i2c_get_adapter() could actually use i2c_adapter_idr properly:
(untested, not signed off, may eet ur branes, /me needs sleep)
Index: linux-2.6.12-rc6-mm1/drivers/i2c/i2c-core.c =================================--- linux-2.6.12-rc6-mm1.orig/drivers/i2c/i2c-core.c +++ linux-2.6.12-rc6-mm1/drivers/i2c/i2c-core.c
@@ -156,7 +156,7 @@ int i2c_add_adapter(struct i2c_adapter *
goto out_unlock;
}
- res = idr_get_new(&i2c_adapter_idr, NULL, &id);
+ res = idr_get_new(&i2c_adapter_idr, adap, &id);
if (res < 0) {
if (res = -EAGAIN)
res = -ENOMEM;
@@ -765,20 +765,15 @@ int i2c_adapter_id(struct i2c_adapter *a
struct i2c_adapter* i2c_get_adapter(int id)
{
- struct list_head *item;
struct i2c_adapter *adapter;
down(&core_lists);
- list_for_each(item,&adapters) {
- adapter = list_entry(item, struct i2c_adapter, list);
- if (id = adapter->nr &&
- try_module_get(adapter->owner)) {
- up(&core_lists);
- return adapter;
- }
- }
+ adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
+ if (adapter && !try_module_get(adapter->owner))
+ adapter = NULL;
+
up(&core_lists);
- return NULL;
+ return adapter;
}
void i2c_put_adapter(struct i2c_adapter *adap)
Signature · 2 lines
Mark M. Hoffman [email protected]
Quoted 12 lines · Mark M. Hoffman
Hi Jean:
Quoted 2 lines · Mark M. Hoffman
It would be easy enough to do hwmon1, hwmon2, etc. just like the
usb_hostclass does. Everyone OK with that?Quoted 3 lines · Jean Delvare
Quoted 3 lines
Last, it would be nice if the IDs were reused on driver cycling, just like the i2c bus IDs are. You should be able to pick the code in i2c-dev and reuse it in the hwmon class.
* Mark M. Hoffman <[email protected]> [2005-06-04 23:41:37 -0400]:
Quoted 8 lines
Quoted 1 line
It would be nice... I'll look into it.
Actually, the bus IDs are assigned in i2c-core. The i2c-dev ID is just a copy of that. The mechanism for the ID recycling is from
lib/idr.c.AFAICT, the ID recycling is a mere side-effect of that (
idr.c) modules's real purpose. The way it's used ini2c-core.cfeels like bloat to me. I'm not certain I want to duplicate that inhwmon.c. Opinions?
Hm, idr.c is used to generate unique ids, that's what it is there for.
Quoted 2 lines
Well,
i2c_get_adapter()could actually usei2c_adapter_idrproperly:
(untested, not signed off, may eet ur branes, /me needs sleep)
Yeah, this looks probably right. Anyone want to test it out? :)
thanks,
greg k-h
Hi Greg, Mark, all,
Quoted 4 lines
Quoted 2 lines
Well,
i2c_get_adapter()could actually usei2c_adapter_idrproperly:
(untested, not signed off, may eet ur branes, /me needs sleep)Yeah, this looks probably right. Anyone want to test it out? :)
Applied to my local tree, let's see what happens. So far so good. I think I understand I'm only supposed to verify that nothing breaks?
Thanks,
Signature · 1 line
Jean Delvare