* [BK PATCH] More i2c driver changes for 2.5.69 @ 2003-05-09 23:55 Greg KH 2003-05-09 23:56 ` [PATCH] " Greg KH 0 siblings, 1 reply; 7+ messages in thread From: Greg KH @ 2003-05-09 23:55 UTC (permalink / raw) To: torvalds; +Cc: linux-kernel, sensors Hi, Here are some more minor i2c fixups for 2.5.69. They are basically a bunch of fixes for the it87 driver, and a few other minor changes. Please pull from: bk://kernel.bkbits.net/gregkh/linux/i2c-2.5 thanks, greg k-h drivers/i2c/chips/it87.c | 195 +++++++++++++++++++++++------------------------ drivers/i2c/i2c-core.c | 33 ++++++- include/linux/i2c.h | 13 +-- 3 files changed, 133 insertions(+), 108 deletions(-) ----- <warp:mercury.d2dc.net>: o I2C: And another it87 patch o I2C: Yet another it87 patch o I2C: Another it87 patch Greg Kroah-Hartman: o i2c: register the i2c_adapter_driver so things link up properly in sysfs o i2c: add i2c_adapter class support Mark W. McClelland: o I2C: add more classes ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] More i2c driver changes for 2.5.69 2003-05-09 23:55 [BK PATCH] More i2c driver changes for 2.5.69 Greg KH @ 2003-05-09 23:56 ` Greg KH 2003-05-09 23:56 ` Greg KH 0 siblings, 1 reply; 7+ messages in thread From: Greg KH @ 2003-05-09 23:56 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1083.2.1, 2003/05/09 13:53:57-07:00, greg@kroah.com [PATCH] i2c: add i2c_adapter class support drivers/i2c/i2c-core.c | 23 ++++++++++++++++++++--- include/linux/i2c.h | 3 ++- 2 files changed, 22 insertions(+), 4 deletions(-) diff -Nru a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c --- a/drivers/i2c/i2c-core.c Fri May 9 16:48:30 2003 +++ b/drivers/i2c/i2c-core.c Fri May 9 16:48:30 2003 @@ -62,6 +62,10 @@ .remove = i2c_device_remove, }; +static struct class i2c_adapter_class = { + .name = "i2c-adapter" +}; + /* --------------------------------------------------- * registering functions @@ -97,6 +101,13 @@ adap->dev.driver = &i2c_generic_driver; device_register(&adap->dev); + /* Add this adapter to the i2c_adapter class */ + memset(&adap->class_dev, 0x00, sizeof(struct class_device)); + adap->class_dev.dev = &adap->dev; + adap->class_dev.class = &i2c_adapter_class; + strncpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE); + class_device_register(&adap->class_dev); + /* inform drivers of new adapters */ list_for_each(item,&drivers) { driver = list_entry(item, struct i2c_driver, list); @@ -150,6 +161,7 @@ } /* clean up the sysfs representation */ + class_device_unregister(&adap->class_dev); device_unregister(&adap->dev); list_del(&adap->list); @@ -443,14 +455,19 @@ .match = i2c_device_match, }; - static int __init i2c_init(void) { - return bus_register(&i2c_bus_type); + int retval; + + retval = bus_register(&i2c_bus_type); + if (retval) + return retval; + return class_register(&i2c_adapter_class); } static void __exit i2c_exit(void) { + class_unregister(&i2c_adapter_class); bus_unregister(&i2c_bus_type); } @@ -475,7 +492,7 @@ return ret; } else { - dev_err(&adap->dev, "I2C level transfers not supported\n"); + DEB2(dev_dbg(&adap->dev, "I2C level transfers not supported\n")); return -ENOSYS; } } diff -Nru a/include/linux/i2c.h b/include/linux/i2c.h --- a/include/linux/i2c.h Fri May 9 16:48:30 2003 +++ b/include/linux/i2c.h Fri May 9 16:48:30 2003 @@ -240,7 +240,8 @@ int timeout; int retries; - struct device dev; /* the adapter device */ + struct device dev; /* the adapter device */ + struct class_device class_dev; /* the class device */ #ifdef CONFIG_PROC_FS /* No need to set this when you initialize the adapter */ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] More i2c driver changes for 2.5.69 2003-05-09 23:56 ` [PATCH] " Greg KH @ 2003-05-09 23:56 ` Greg KH 2003-05-09 23:56 ` Greg KH 0 siblings, 1 reply; 7+ messages in thread From: Greg KH @ 2003-05-09 23:56 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1083.2.2, 2003/05/09 13:58:10-07:00, mark@alpha.dyndns.org [PATCH] I2C: add more classes Add I2C classes for analog and digital cameras, and fix a typo. include/linux/i2c.h | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff -Nru a/include/linux/i2c.h b/include/linux/i2c.h --- a/include/linux/i2c.h Fri May 9 16:48:20 2003 +++ b/include/linux/i2c.h Fri May 9 16:48:20 2003 @@ -281,10 +281,12 @@ /* Must equal I2C_M_TEN below */ /* i2c adapter classes (bitmask) */ -#define I2C_ADAP_CLASS_SMBUS (1<<0) /* lm_sensors, ... */ -#define I2C_ADAP_CLASS_TV_ANALOG (1<<1) /* bttv + friends */ -#define I2C_ADAP_CLASS_TV_DIGINAL (1<<2) /* dbv cards */ -#define I2C_ADAP_CLASS_DDC (1<<3) /* i2c-matroxfb ? */ +#define I2C_ADAP_CLASS_SMBUS (1<<0) /* lm_sensors, ... */ +#define I2C_ADAP_CLASS_TV_ANALOG (1<<1) /* bttv + friends */ +#define I2C_ADAP_CLASS_TV_DIGITAL (1<<2) /* dbv cards */ +#define I2C_ADAP_CLASS_DDC (1<<3) /* i2c-matroxfb ? */ +#define I2C_ADAP_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */ +#define I2C_ADAP_CLASS_CAM_DIGITAL (1<<5) /* most webcams */ /* i2c_client_address_data is the struct for holding default client * addresses for a driver and for the parameters supplied on the ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] More i2c driver changes for 2.5.69 2003-05-09 23:56 ` Greg KH @ 2003-05-09 23:56 ` Greg KH 2003-05-09 23:56 ` Greg KH 0 siblings, 1 reply; 7+ messages in thread From: Greg KH @ 2003-05-09 23:56 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1083.2.3, 2003/05/09 14:54:04-07:00, warp@mercury.d2dc.net [PATCH] I2C: Another it87 patch. This is against my last. While the old code most definitely did /something/ to the register for setting the fan div, the 'what' is a more interesting question. To be honest I could not figure out what it was trying to do, because the way it was inserting values disagreed with not only the data sheet, but how it parsed the very same register. This corrects the issue, and allows one to properly control the divisor on all 3 fans, including the (much more limited) 3rd fan. drivers/i2c/chips/it87.c | 34 ++++++++++++++++++++++++++++------ 1 files changed, 28 insertions(+), 6 deletions(-) diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c --- a/drivers/i2c/chips/it87.c Fri May 9 16:48:09 2003 +++ b/drivers/i2c/chips/it87.c Fri May 9 16:48:09 2003 @@ -159,7 +159,14 @@ 205-(val)*5) #define ALARMS_FROM_REG(val) (val) -#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) +static int log2(int val) +{ + int answer = 0; + while ((val >>= 1)) + answer++; + return answer; +} +#define DIV_TO_REG(val) log2(val) #define DIV_FROM_REG(val) (1 << (val)) /* Initial limits. Use the config file to set better limits. */ @@ -520,10 +527,25 @@ struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); int val = simple_strtol(buf, NULL, 10); - int old = it87_read_value(client, IT87_REG_FAN_DIV); - data->fan_div[nr] = DIV_TO_REG(val); - old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); - it87_write_value(client, IT87_REG_FAN_DIV, old); + u8 old = it87_read_value(client, IT87_REG_FAN_DIV); + + switch (nr) { + case 0: + case 1: + data->fan_div[nr] = DIV_TO_REG(val); + break; + case 2: + if (val < 8) + data->fan_div[nr] = 1; + else + data->fan_div[nr] = 3; + } + val = old & 0x100; + val |= (data->fan_div[0] & 0x07); + val |= (data->fan_div[1] & 0x07) << 3; + if (data->fan_div[2] == 3) + val |= 0x1 << 6; + it87_write_value(client, IT87_REG_FAN_DIV, val); return count; } @@ -961,7 +983,7 @@ i = it87_read_value(client, IT87_REG_FAN_DIV); data->fan_div[0] = i & 0x07; data->fan_div[1] = (i >> 3) & 0x07; - data->fan_div[2] = 1; + data->fan_div[2] = (i & 0x40) ? 3 : 1; data->alarms = it87_read_value(client, IT87_REG_ALARM1) | ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] More i2c driver changes for 2.5.69 2003-05-09 23:56 ` Greg KH @ 2003-05-09 23:56 ` Greg KH 2003-05-09 23:56 ` Greg KH 0 siblings, 1 reply; 7+ messages in thread From: Greg KH @ 2003-05-09 23:56 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1083.2.4, 2003/05/09 14:54:15-07:00, warp@mercury.d2dc.net [PATCH] I2C: Yet another it87 patch. Ok, after writing up something in the way of a perl script to make some sense of the data for voltages, and finding that there is no sense to make, I took a longer look at things. The it87 driver in 2.5.x is doing some, down right /odd/ math on the numbers for the in_input* readings, and the 2.4.x driver is doing something quite different. And while it might be possible to get sane numbers out of the 2.5.x driver, people /expect/ to get the numbers that they were getting from 2.4.x. So this patch puts things back to the simpler calculations done by the 2.4.x lm-sensors drivers, and my script confirms that the numbers come out right. drivers/i2c/chips/it87.c | 84 ++++++++++++----------------------------------- 1 files changed, 23 insertions(+), 61 deletions(-) diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c --- a/drivers/i2c/chips/it87.c Fri May 9 16:47:59 2003 +++ b/drivers/i2c/chips/it87.c Fri May 9 16:47:59 2003 @@ -99,46 +99,8 @@ #define IT87_REG_CHIPID 0x58 -static inline u8 IN_TO_REG(long val, int inNum) -{ - /* to avoid floating point, we multiply everything by 100. - val is guaranteed to be positive, so we can achieve the effect of - rounding by (...*10+5)/10. Note that the *10 is hidden in the - /250 (which should really be /2500). - At the end, we need to /100 because we *100 everything and we need - to /10 because of the rounding thing, so we /1000. */ - if (inNum <= 1) - return (u8) - SENSORS_LIMIT(((val * 210240 - 13300) / 250 + 5) / 1000, - 0, 255); - else if (inNum == 2) - return (u8) - SENSORS_LIMIT(((val * 157370 - 13300) / 250 + 5) / 1000, - 0, 255); - else if (inNum == 3) - return (u8) - SENSORS_LIMIT(((val * 101080 - 13300) / 250 + 5) / 1000, - 0, 255); - else - return (u8) SENSORS_LIMIT(((val * 41714 - 13300) / 250 + 5) - / 1000, 0, 255); -} - -static inline long IN_FROM_REG(u8 val, int inNum) -{ - /* to avoid floating point, we multiply everything by 100. - val is guaranteed to be positive, so we can achieve the effect of - rounding by adding 0.5. Or, to avoid fp math, we do (...*10+5)/10. - We need to scale with *100 anyway, so no need to /100 at the end. */ - if (inNum <= 1) - return (long) (((250000 * val + 13300) / 210240 * 10 + 5) /10); - else if (inNum == 2) - return (long) (((250000 * val + 13300) / 157370 * 10 + 5) /10); - else if (inNum == 3) - return (long) (((250000 * val + 13300) / 101080 * 10 + 5) /10); - else - return (long) (((250000 * val + 13300) / 41714 * 10 + 5) /10); -} +#define IN_TO_REG(val) (SENSORS_LIMIT((((val) * 10 + 8)/16),0,255)) +#define IN_FROM_REG(val) (((val) * 16) / 10) static inline u8 FAN_TO_REG(long rpm, int div) { @@ -279,7 +241,7 @@ struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); it87_update_client(client); - return sprintf(buf, "%ld\n", IN_FROM_REG(data->in[nr], nr)*10 ); + return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr])*10 ); } static ssize_t show_in_min(struct device *dev, char *buf, int nr) @@ -287,7 +249,7 @@ struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); it87_update_client(client); - return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_min[nr], nr)*10 ); + return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr])*10 ); } static ssize_t show_in_max(struct device *dev, char *buf, int nr) @@ -295,7 +257,7 @@ struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); it87_update_client(client); - return sprintf(buf, "%ld\n", IN_FROM_REG(data->in_max[nr], nr)*10 ); + return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr])*10 ); } static ssize_t set_in_min(struct device *dev, const char *buf, @@ -304,7 +266,7 @@ struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); unsigned long val = simple_strtoul(buf, NULL, 10)/10; - data->in_min[nr] = IN_TO_REG(val,nr); + data->in_min[nr] = IN_TO_REG(val); it87_write_value(client, IT87_REG_VIN_MIN(nr), data->in_min[nr]); return count; @@ -315,7 +277,7 @@ struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); unsigned long val = simple_strtoul(buf, NULL, 10)/10; - data->in_max[nr] = IN_TO_REG(val,nr); + data->in_max[nr] = IN_TO_REG(val); it87_write_value(client, IT87_REG_VIN_MAX(nr), data->in_max[nr]); return count; @@ -855,37 +817,37 @@ This sets fan-divs to 2, among others */ it87_write_value(client, IT87_REG_CONFIG, 0x80); it87_write_value(client, IT87_REG_VIN_MIN(0), - IN_TO_REG(IT87_INIT_IN_MIN_0, 0)); + IN_TO_REG(IT87_INIT_IN_MIN_0)); it87_write_value(client, IT87_REG_VIN_MAX(0), - IN_TO_REG(IT87_INIT_IN_MAX_0, 0)); + IN_TO_REG(IT87_INIT_IN_MAX_0)); it87_write_value(client, IT87_REG_VIN_MIN(1), - IN_TO_REG(IT87_INIT_IN_MIN_1, 1)); + IN_TO_REG(IT87_INIT_IN_MIN_1)); it87_write_value(client, IT87_REG_VIN_MAX(1), - IN_TO_REG(IT87_INIT_IN_MAX_1, 1)); + IN_TO_REG(IT87_INIT_IN_MAX_1)); it87_write_value(client, IT87_REG_VIN_MIN(2), - IN_TO_REG(IT87_INIT_IN_MIN_2, 2)); + IN_TO_REG(IT87_INIT_IN_MIN_2)); it87_write_value(client, IT87_REG_VIN_MAX(2), - IN_TO_REG(IT87_INIT_IN_MAX_2, 2)); + IN_TO_REG(IT87_INIT_IN_MAX_2)); it87_write_value(client, IT87_REG_VIN_MIN(3), - IN_TO_REG(IT87_INIT_IN_MIN_3, 3)); + IN_TO_REG(IT87_INIT_IN_MIN_3)); it87_write_value(client, IT87_REG_VIN_MAX(3), - IN_TO_REG(IT87_INIT_IN_MAX_3, 3)); + IN_TO_REG(IT87_INIT_IN_MAX_3)); it87_write_value(client, IT87_REG_VIN_MIN(4), - IN_TO_REG(IT87_INIT_IN_MIN_4, 4)); + IN_TO_REG(IT87_INIT_IN_MIN_4)); it87_write_value(client, IT87_REG_VIN_MAX(4), - IN_TO_REG(IT87_INIT_IN_MAX_4, 4)); + IN_TO_REG(IT87_INIT_IN_MAX_4)); it87_write_value(client, IT87_REG_VIN_MIN(5), - IN_TO_REG(IT87_INIT_IN_MIN_5, 5)); + IN_TO_REG(IT87_INIT_IN_MIN_5)); it87_write_value(client, IT87_REG_VIN_MAX(5), - IN_TO_REG(IT87_INIT_IN_MAX_5, 5)); + IN_TO_REG(IT87_INIT_IN_MAX_5)); it87_write_value(client, IT87_REG_VIN_MIN(6), - IN_TO_REG(IT87_INIT_IN_MIN_6, 6)); + IN_TO_REG(IT87_INIT_IN_MIN_6)); it87_write_value(client, IT87_REG_VIN_MAX(6), - IN_TO_REG(IT87_INIT_IN_MAX_6, 6)); + IN_TO_REG(IT87_INIT_IN_MAX_6)); it87_write_value(client, IT87_REG_VIN_MIN(7), - IN_TO_REG(IT87_INIT_IN_MIN_7, 7)); + IN_TO_REG(IT87_INIT_IN_MIN_7)); it87_write_value(client, IT87_REG_VIN_MAX(7), - IN_TO_REG(IT87_INIT_IN_MAX_7, 7)); + IN_TO_REG(IT87_INIT_IN_MAX_7)); /* Note: Battery voltage does not have limit registers */ it87_write_value(client, IT87_REG_FAN_MIN(1), FAN_TO_REG(IT87_INIT_FAN_MIN_1, 2)); ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] More i2c driver changes for 2.5.69 2003-05-09 23:56 ` Greg KH @ 2003-05-09 23:56 ` Greg KH 2003-05-09 23:56 ` Greg KH 0 siblings, 1 reply; 7+ messages in thread From: Greg KH @ 2003-05-09 23:56 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1083.2.5, 2003/05/09 14:54:25-07:00, warp@mercury.d2dc.net [PATCH] I2C: And another it87 patch. Don't provide min/max for in8, which allowed one to scribble on registers one should not be messing with. (My fault, oops.) The setting of the temp high/low registers was off by one, not mine this time. While I was at it, I reordered a few other register accesses to be base 0 instead of base 1. The temp interface was slightly incorrect, degrees * 100 instead of degrees * 1000, also fixed. And lastly, when changing the fan count divisor, fix up the min setting to still be roughly the same. (Previously the meaning of the value in the register changed, but not the value itself, resulting in, undesired surprises.) drivers/i2c/chips/it87.c | 77 ++++++++++++++++++++++++++++------------------- 1 files changed, 47 insertions(+), 30 deletions(-) diff -Nru a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c --- a/drivers/i2c/chips/it87.c Fri May 9 16:47:47 2003 +++ b/drivers/i2c/chips/it87.c Fri May 9 16:47:47 2003 @@ -80,17 +80,17 @@ /* Monitors: 9 voltage (0 to 7, battery), 3 temp (1 to 3), 3 fan (1 to 3) */ -#define IT87_REG_FAN(nr) (0x0c + (nr)) -#define IT87_REG_FAN_MIN(nr) (0x0f + (nr)) +#define IT87_REG_FAN(nr) (0x0d + (nr)) +#define IT87_REG_FAN_MIN(nr) (0x10 + (nr)) #define IT87_REG_FAN_CTRL 0x13 #define IT87_REG_VIN(nr) (0x20 + (nr)) -#define IT87_REG_TEMP(nr) (0x28 + (nr)) +#define IT87_REG_TEMP(nr) (0x29 + (nr)) #define IT87_REG_VIN_MAX(nr) (0x30 + (nr) * 2) #define IT87_REG_VIN_MIN(nr) (0x31 + (nr) * 2) -#define IT87_REG_TEMP_HIGH(nr) (0x3e + (nr) * 2) -#define IT87_REG_TEMP_LOW(nr) (0x3f + (nr) * 2) +#define IT87_REG_TEMP_HIGH(nr) (0x40 + ((nr) * 2)) +#define IT87_REG_TEMP_LOW(nr) (0x41 + ((nr) * 2)) #define IT87_REG_I2C_ADDR 0x48 @@ -289,6 +289,9 @@ { \ return show_in(dev, buf, 0x##offset); \ } \ +static DEVICE_ATTR(in_input##offset, S_IRUGO, show_in##offset, NULL) + +#define limit_in_offset(offset) \ static ssize_t \ show_in##offset##_min (struct device *dev, char *buf) \ { \ @@ -309,20 +312,27 @@ { \ return set_in_max(dev, buf, count, 0x##offset); \ } \ -static DEVICE_ATTR(in_input##offset, S_IRUGO, show_in##offset, NULL) \ static DEVICE_ATTR(in_min##offset, S_IRUGO | S_IWUSR, \ show_in##offset##_min, set_in##offset##_min) \ static DEVICE_ATTR(in_max##offset, S_IRUGO | S_IWUSR, \ show_in##offset##_max, set_in##offset##_max) show_in_offset(0); +limit_in_offset(0); show_in_offset(1); +limit_in_offset(1); show_in_offset(2); +limit_in_offset(2); show_in_offset(3); +limit_in_offset(3); show_in_offset(4); +limit_in_offset(4); show_in_offset(5); +limit_in_offset(5); show_in_offset(6); +limit_in_offset(6); show_in_offset(7); +limit_in_offset(7); show_in_offset(8); /* 3 temperatures */ @@ -331,7 +341,7 @@ struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); it87_update_client(client); - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])*10 ); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])*100 ); } /* more like overshoot temperature */ static ssize_t show_temp_max(struct device *dev, char *buf, int nr) @@ -339,7 +349,7 @@ struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); it87_update_client(client); - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])*10); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_high[nr])*100); } /* more like hysteresis temperature */ static ssize_t show_temp_min(struct device *dev, char *buf, int nr) @@ -347,14 +357,14 @@ struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); it87_update_client(client); - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])*10); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_low[nr])*100); } static ssize_t set_temp_max(struct device *dev, const char *buf, size_t count, int nr) { struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); - int val = simple_strtol(buf, NULL, 10)/10; + int val = simple_strtol(buf, NULL, 10)/100; data->temp_high[nr] = TEMP_TO_REG(val); it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]); return count; @@ -364,7 +374,7 @@ { struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); - int val = simple_strtol(buf, NULL, 10)/10; + int val = simple_strtol(buf, NULL, 10)/100; data->temp_low[nr] = TEMP_TO_REG(val); it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]); return count; @@ -480,7 +490,7 @@ struct it87_data *data = i2c_get_clientdata(client); int val = simple_strtol(buf, NULL, 10); data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); - it87_write_value(client, IT87_REG_FAN_MIN(nr+1), data->fan_min[nr]); + it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); return count; } static ssize_t set_fan_div(struct device *dev, const char *buf, @@ -489,8 +499,12 @@ struct i2c_client *client = to_i2c_client(dev); struct it87_data *data = i2c_get_clientdata(client); int val = simple_strtol(buf, NULL, 10); + int i, min[3]; u8 old = it87_read_value(client, IT87_REG_FAN_DIV); + for (i = 0; i < 3; i++) + min[i] = FAN_FROM_REG(data->fan_min[i], DIV_FROM_REG(data->fan_div[i])); + switch (nr) { case 0: case 1: @@ -508,6 +522,11 @@ if (data->fan_div[2] == 3) val |= 0x1 << 6; it87_write_value(client, IT87_REG_FAN_DIV, val); + + for (i = 0; i < 3; i++) { + data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i])); + it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]); + } return count; } @@ -704,7 +723,6 @@ device_create_file(&new_client->dev, &dev_attr_in_min5); device_create_file(&new_client->dev, &dev_attr_in_min6); device_create_file(&new_client->dev, &dev_attr_in_min7); - device_create_file(&new_client->dev, &dev_attr_in_min8); device_create_file(&new_client->dev, &dev_attr_in_max0); device_create_file(&new_client->dev, &dev_attr_in_max1); device_create_file(&new_client->dev, &dev_attr_in_max2); @@ -713,7 +731,6 @@ device_create_file(&new_client->dev, &dev_attr_in_max5); device_create_file(&new_client->dev, &dev_attr_in_max6); device_create_file(&new_client->dev, &dev_attr_in_max7); - device_create_file(&new_client->dev, &dev_attr_in_max8); device_create_file(&new_client->dev, &dev_attr_temp_input1); device_create_file(&new_client->dev, &dev_attr_temp_input2); device_create_file(&new_client->dev, &dev_attr_temp_input3); @@ -849,23 +866,23 @@ it87_write_value(client, IT87_REG_VIN_MAX(7), IN_TO_REG(IT87_INIT_IN_MAX_7)); /* Note: Battery voltage does not have limit registers */ - it87_write_value(client, IT87_REG_FAN_MIN(1), + it87_write_value(client, IT87_REG_FAN_MIN(0), FAN_TO_REG(IT87_INIT_FAN_MIN_1, 2)); - it87_write_value(client, IT87_REG_FAN_MIN(2), + it87_write_value(client, IT87_REG_FAN_MIN(1), FAN_TO_REG(IT87_INIT_FAN_MIN_2, 2)); - it87_write_value(client, IT87_REG_FAN_MIN(3), + it87_write_value(client, IT87_REG_FAN_MIN(2), FAN_TO_REG(IT87_INIT_FAN_MIN_3, 2)); - it87_write_value(client, IT87_REG_TEMP_HIGH(1), + it87_write_value(client, IT87_REG_TEMP_HIGH(0), TEMP_TO_REG(IT87_INIT_TEMP_HIGH_1)); - it87_write_value(client, IT87_REG_TEMP_LOW(1), + it87_write_value(client, IT87_REG_TEMP_LOW(0), TEMP_TO_REG(IT87_INIT_TEMP_LOW_1)); - it87_write_value(client, IT87_REG_TEMP_HIGH(2), + it87_write_value(client, IT87_REG_TEMP_HIGH(1), TEMP_TO_REG(IT87_INIT_TEMP_HIGH_2)); - it87_write_value(client, IT87_REG_TEMP_LOW(2), + it87_write_value(client, IT87_REG_TEMP_LOW(1), TEMP_TO_REG(IT87_INIT_TEMP_LOW_2)); - it87_write_value(client, IT87_REG_TEMP_HIGH(3), + it87_write_value(client, IT87_REG_TEMP_HIGH(2), TEMP_TO_REG(IT87_INIT_TEMP_HIGH_3)); - it87_write_value(client, IT87_REG_TEMP_LOW(3), + it87_write_value(client, IT87_REG_TEMP_LOW(2), TEMP_TO_REG(IT87_INIT_TEMP_LOW_3)); /* Enable voltage monitors */ @@ -918,18 +935,18 @@ data->in_min[8] = 0; data->in_max[8] = 255; - for (i = 1; i <= 3; i++) { - data->fan[i - 1] = + for (i = 0; i < 3; i++) { + data->fan[i] = it87_read_value(client, IT87_REG_FAN(i)); - data->fan_min[i - 1] = + data->fan_min[i] = it87_read_value(client, IT87_REG_FAN_MIN(i)); } - for (i = 1; i <= 3; i++) { - data->temp[i - 1] = + for (i = 0; i < 3; i++) { + data->temp[i] = it87_read_value(client, IT87_REG_TEMP(i)); - data->temp_high[i - 1] = + data->temp_high[i] = it87_read_value(client, IT87_REG_TEMP_HIGH(i)); - data->temp_low[i - 1] = + data->temp_low[i] = it87_read_value(client, IT87_REG_TEMP_LOW(i)); } ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] More i2c driver changes for 2.5.69 2003-05-09 23:56 ` Greg KH @ 2003-05-09 23:56 ` Greg KH 0 siblings, 0 replies; 7+ messages in thread From: Greg KH @ 2003-05-09 23:56 UTC (permalink / raw) To: linux-kernel, sensors ChangeSet 1.1083.2.6, 2003/05/09 16:12:53-07:00, greg@kroah.com [PATCH] i2c: register the i2c_adapter_driver so things link up properly in sysfs drivers/i2c/i2c-core.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff -Nru a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c --- a/drivers/i2c/i2c-core.c Fri May 9 16:47:36 2003 +++ b/drivers/i2c/i2c-core.c Fri May 9 16:47:36 2003 @@ -55,8 +55,8 @@ return 0; } -static struct device_driver i2c_generic_driver = { - .name = "i2c", +static struct device_driver i2c_adapter_driver = { + .name = "i2c_adapter", .bus = &i2c_bus_type, .probe = i2c_device_probe, .remove = i2c_device_remove, @@ -98,7 +98,7 @@ if (adap->dev.parent == NULL) adap->dev.parent = &legacy_bus; sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); - adap->dev.driver = &i2c_generic_driver; + adap->dev.driver = &i2c_adapter_driver; device_register(&adap->dev); /* Add this adapter to the i2c_adapter class */ @@ -462,12 +462,16 @@ retval = bus_register(&i2c_bus_type); if (retval) return retval; + retval = driver_register(&i2c_adapter_driver); + if (retval) + return retval; return class_register(&i2c_adapter_class); } static void __exit i2c_exit(void) { class_unregister(&i2c_adapter_class); + driver_unregister(&i2c_adapter_driver); bus_unregister(&i2c_bus_type); } ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-05-09 23:46 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-05-09 23:55 [BK PATCH] More i2c driver changes for 2.5.69 Greg KH 2003-05-09 23:56 ` [PATCH] " Greg KH 2003-05-09 23:56 ` Greg KH 2003-05-09 23:56 ` Greg KH 2003-05-09 23:56 ` Greg KH 2003-05-09 23:56 ` Greg KH 2003-05-09 23:56 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox