More i2c driver changes for 2.5.66
Subsystems (3)
PATCH 1/1 More i2c driver changes for 2.5.66
Hi,
Here are some more i2c driver changes for 2.5.66. It adds two i2c chip drivers, and converts all of them to the sysfs interface. In doing so, I've ripped out all of the old /proc and sysctl mess. A number of small bugfixes for some of the media i2c drivers are in here too.
I've also fixed up the bus_id of the i2c client devices, as the current code can cause duplicate bus_ids which didn't play nice on some systems.
Please pull from: bk://kernel.bkbits.net/gregkh/linux/i2c-2.5
thanks,
greg k-h
Documentation/i2c/proc-interface | 53 - drivers/i2c/i2c-proc.c | 187 --- include/linux/i2c-proc.h | 373 ------- Documentation/i2c/sysfs-interface | 177 +++ drivers/i2c/Kconfig | 11 drivers/i2c/Makefile | 2 drivers/i2c/busses/Kconfig | 13 drivers/i2c/chips/Kconfig | 70 + drivers/i2c/chips/Makefile | 2 drivers/i2c/chips/adm1021.c | 360 +++---- drivers/i2c/chips/lm75.c | 187 +-- drivers/i2c/chips/via686a.c | 1010 +++++++++++++++++++- drivers/i2c/chips/w83781d.c | 1892 +++++++++++++++++++++++++++++++++++++- drivers/i2c/i2c-core.c | 190 --- drivers/i2c/i2c-proc.c | 550 ----------- drivers/i2c/i2c-sensor.c | 182 +++ drivers/media/video/adv7175.c | 2 drivers/media/video/tvmixer.c | 20 include/linux/i2c-proc.h | 43 include/linux/i2c-sensor.h | 373 +++++++ include/linux/i2c-vid.h | 66 + 21 files changed, 3975 insertions(+), 1788 deletions(-)
-----
<[email protected]>:
o i2c: w83781d i2c driver updated for 2.5.66-bk4 (with sysfs support, empty tree)
<[email protected]>:
o i2c: add i2c-via686a driver
o i2c: fix compile bugs in tvmixer.c
Greg Kroah-Hartman <[email protected]>:
o i2c: remove old proc documentation and add sysfs file documentation
o i2c: fix up broken drivers/i2c/busses build due to I2C_PROC now being gone
o i2c: clean up previous w83781d patch due to changes I made to i2c core and build
o i2c: remove all proc code from the i2c core, as it's no longer needed
o i2c: move i2c-proc to i2c-sensor and clean up all usages of it
o i2c: remove unused paramater in found_proc callback function
o i2c: remove proc and sysctl code from i2c-proc as it is no longer used
o i2c: remove sysctl and proc functions from via686a.c driver
o i2c: convert adm1021 chip driver to use sysfs files
o i2c: convert lm75 chip driver to use sysfs files
o i2c: change the way i2c creates the bus ids to actually be unique now
o i2c: fix memleak caused by my last patch fo the adv7175.c driver
PATCH 1/1 More i2c driver changes for 2.5.66
ChangeSet 1.977.29.1, 2003/03/25 17:22:33-08:00, [email protected]
[PATCH] i2c: fix compile bugs in tvmixer.c
Additionally I need the following patch to tvmixer.c to compile properly with CONFIG_SOUND_TVMIXER=m. Just a /client->name/client->dev.name/g.
drivers/media/video/tvmixer.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
drivers/media/video/tvmixer.c +10 -10
@@ -87,7 +87,7 @@if (cmd ==SOUND_MIXER_INFO ) {mixer_info info;strncpy (info.id,"tv card" ,sizeof (info.id)); -strncpy (info.name, client->name,sizeof (info.name)); +strncpy (info.name, client->dev.name,sizeof (info.name)); info.modify_counter =42 /* FIXME */ ;if (copy_to_user ((void *)arg, &info,sizeof (info)))return -EFAULT ;
@@ -96,7 +96,7 @@if (cmd ==SOUND_OLD_MIXER_INFO ) {_old_mixer_info info;strncpy (info.id,"tv card" ,sizeof (info.id)); -strncpy (info.name, client->name,sizeof (info.name)); +strncpy (info.name, client->dev.name,sizeof (info.name));if (copy_to_user ((void *)arg, &info,sizeof (info)))return -EFAULT ;return 0 ;
@@ -237,7 +237,7 @@int i;if (debug) -printk ("tvmixer: adapter %s\n" ,adap->name); +printk ("tvmixer: adapter %s\n" ,adap->dev.name);for (i=0 ; i<I2C_CLIENT_MAX ; i++) {if (!adap->clients[i])continue ;
@@ -261,10 +261,10 @@/* ignore that one */ if (debug)printk ("tvmixer: %s is not a tv card\n" , - client->adapter->name); + client->adapter->dev.name);return -1 ; } -printk ("tvmixer: debug: %s\n" ,client->name); +printk ("tvmixer: debug: %s\n" ,client->dev.name);/* unregister ?? */ for (i =0 ; i <DEV_MAX ; i++) {
@@ -273,7 +273,7 @@unregister_sound_mixer (devices[i].minor); devices[i].dev =NULL ; devices[i].minor =-1 ; -printk ("tvmixer: %s unregistered (#1)\n" ,client->name); +printk ("tvmixer: %s unregistered (#1)\n" ,client->dev.name);return 0 ; } }
@@ -298,13 +298,13 @@if (0 != client->driver->command (client,VIDIOCGAUDIO ,&va)) {if (debug)printk ("tvmixer: %s: VIDIOCGAUDIO failed\n" , - client->name); + client->dev.name);return -1 ; }if (0 == (va.flags &VIDEO_AUDIO_VOLUME )) {if (debug)printk ("tvmixer: %s: has no volume control\n" , - client->name); + client->dev.name);return -1 ; }
@@ -318,7 +318,7 @@ devices[i].count =0 ; devices[i].dev = client;printk ("tvmixer: %s (%s) registered with minor %d\n" , - client->name,client->adapter->name,minor); + client->dev.name,client->adapter->dev.name,minor);return 0 ; }
@@ -344,7 +344,7 @@if (devices[i].minor !=-1 ) {unregister_sound_mixer (devices[i].minor);printk ("tvmixer: %s unregistered (#2)\n" , - devices[i].dev->name); + devices[i].dev->dev.name); } } }
ChangeSet 1.977.29.2, 2003/03/25 17:29:08-08:00, [email protected]
[PATCH] i2c: add i2c-via686a driver
drivers/i2c/chips/Kconfig | 13 drivers/i2c/chips/Makefile | 1 drivers/i2c/chips/via686a.c | 952 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 966 insertions(+)
drivers/i2c/chips/Kconfig +13 -0
@@ -37,4 +37,17 @@ in the lm_sensors package, which you can download at http://www.lm-sensors.nu +config SENSORS_VIA686A + tristate " VIA686A" + depends on I2C && I2C_PROC + help + support for via686a + If you say yes here you get support for the integrated sensors in + Via 686A/B South Bridges. This can also be built as a module + which can be inserted and removed while the kernel is running. + + You will also need the latest user-space utilties: you can find them + in the lm_sensors package, which you can download at + http://www.lm-sensors.nu + endmenu
drivers/i2c/chips/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o obj-$(CONFIG_SENSORS_LM75) += lm75.o +obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
drivers/i2c/chips/via686a.c new file +952 -0
952 lines not on this page · raw message
ChangeSet 1.977.29.3, 2003/03/31 15:25:48-08:00, [email protected]
[PATCH] i2c: fix memleak caused by my last patch fo the adv7175.c driver
drivers/media/video/adv7175.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/media/video/adv7175.c +1 -1
@@ -231,7 +231,7 @@static int adv717x_detach (struct i2c_client *client) {i2c_detach_client (client); -i2c_get_clientdata (client); +kfree (i2c_get_clientdata (client));kfree (client);return 0 ; }
ChangeSet 1.977.29.4, 2003/04/01 11:48:21-08:00, [email protected]
[PATCH] i2c: change the way i2c creates the bus ids to actually be unique now.
It also is much like the old naming scheme, to keep things consistent.
drivers/i2c/i2c-core.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletion(-)
drivers/i2c/i2c-core.c +2 -1
@@ -392,7 +392,8 @@ client->dev.driver = &client->driver->driver; client->dev.bus = &i2c_bus_type; -snprintf (&client->dev.bus_id[0 ],sizeof (client->dev.bus_id),"i2c_dev_%d" , i); +snprintf (&client->dev.bus_id[0 ],sizeof (client->dev.bus_id), +"%d-%04x" ,i2c_adapter_id (adapter), client->addr);printk ("registering %s\n" , client->dev.bus_id);device_register (&client->dev);
ChangeSet 1.977.29.5, 2003/04/02 11:29:55-08:00, [email protected]
i2c: convert lm75 chip driver to use sysfs files.
drivers/i2c/chips/lm75.c | 185 +++++++++++++++++++---------------------------- 1 files changed, 77 insertions(+), 108 deletions(-)
drivers/i2c/chips/lm75.c +77 -108
@@ -18,6 +18,8 @@Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* #define DEBUG 1 */ +#include <linux/module.h> #include <linux/init.h> #include <linux/slab.h>
@@ -25,8 +27,6 @@#include <linux/i2c-proc.h> -#define LM75_SYSCTL_TEMP 1200/* Degrees Celsius * 10 */ -/* Addresses to scan */ static unsigned short normal_i2c[] = {SENSORS_I2C_END };static unsigned short normal_i2c_range[] = {0x48 ,0x4f ,SENSORS_I2C_END };
@@ -39,97 +39,113 @@/* Many LM75 constants specified below */ /* The LM75 registers */ -#define LM75_REG_TEMP 0x00 -#define LM75_REG_CONF 0x01 -#define LM75_REG_TEMP_HYST 0x02 -#define LM75_REG_TEMP_OS 0x03 +#define LM75_REG_TEMP 0x00 +#define LM75_REG_CONF 0x01 +#define LM75_REG_TEMP_HYST 0x02 +#define LM75_REG_TEMP_OS 0x03/* Conversions. Rounding and limit checking is only done on the TO_REG variants. Note that you should be a bit careful with which arguments these macros are called: arguments may be evaluated more than once. Fixing this is just not worth it. */ -#define TEMP_FROM_REG (val) ((((val & 0x7fff) >> 7) * 5) | ((val & 0x8000)?-256:0)) -#define TEMP_TO_REG (val) (SENSORS_LIMIT((val<0?(0x200+((val)/5))<<7:(((val) + 2) / 5) << 7),0,0xffff)) +#define TEMP_FROM_REG (val) ((((val & 0x7fff) >> 7) * 5) | ((val & 0x8000)?-256:0)) +#define TEMP_TO_REG (val) (SENSORS_LIMIT((val<0?(0x200+((val)/5))<<7:(((val) + 2) / 5) << 7),0,0xffff))/* Initial values */ -#define LM75_INIT_TEMP_OS 600 -#define LM75_INIT_TEMP_HYST 500 +#define LM75_INIT_TEMP_OS 600 +#define LM75_INIT_TEMP_HYST 500/* Each client has this additional data */ struct lm75_data { -int sysctl_id; - -struct semaphore update_lock; -char valid;/* !=0 if following fields are valid */ -unsigned long last_updated;/* In jiffies */ - -u16 temp, temp_os, temp_hyst;/* Register values */ +struct semaphore update_lock; +char valid;/* !=0 if following fields are valid */ +unsigned long last_updated;/* In jiffies */ +u16 temp_input;/* Register values */ +u16 temp_max; +u16 temp_hyst; };static int lm75_attach_adapter (struct i2c_adapter *adapter); -static int lm75_detect (struct i2c_adapter *adapter,int address, -unsigned short flags,int kind); +static int lm75_detect (struct i2c_adapter *adapter,int address,int kind);static void lm75_init_client (struct i2c_client *client);static int lm75_detach_client (struct i2c_client *client); -static u16 swap_bytes (u16 val);static int lm75_read_value (struct i2c_client *client,u8 reg);static int lm75_write_value (struct i2c_client *client,u8 reg,u16 value); -static void lm75_temp (struct i2c_client *client,int operation, -int ctl_name,int *nrels_mag,long *results);static void lm75_update_client (struct i2c_client *client);/* This is the driver that will be inserted */ static struct i2c_driver lm75_driver = { .owner =THIS_MODULE , - .name ="LM75 sensor" , + .name ="lm75" , .id =I2C_DRIVERID_LM75 , .flags =I2C_DF_NOTIFY , .attach_adapter = lm75_attach_adapter, .detach_client = lm75_detach_client, }; -/* These files are created for each detected LM75. This is just a template; -though at first sight, you might think we could use a statically -allocated list, we need some way to get back to the parent - which -is done through one of the 'extra' fields which are initialized -when a new copy is allocated. */ -static ctl_table lm75_dir_table_template[] = { - {LM75_SYSCTL_TEMP ,"temp" ,NULL ,0 ,0644 ,NULL , &i2c_proc_real, - &i2c_sysctl_real,NULL , &lm75_temp}, - {0 } -}; -static int lm75_id =0 ; +#define show (value) \ +static ssize_t show_##value(struct device *dev, char *buf) \ +{ \ + struct i2c_client *client = to_i2c_client(dev); \ + struct lm75_data *data = i2c_get_clientdata(client); \ + int temp; \ + \ + lm75_update_client(client); \ + temp = TEMP_FROM_REG(data->value); \ + return sprintf(buf, "%d\n", temp * 100); \ +} +show (temp_max); +show (temp_hyst); +show (temp_input); + +#define set (value, reg) \ +static ssize_t set_##value(struct device *dev, const char *buf, size_t count) \ +{ \ + struct i2c_client *client = to_i2c_client(dev); \ + struct lm75_data *data = i2c_get_clientdata(client); \ + int temp = simple_strtoul(buf, NULL, 10) / 100; \ + \ + data->value = TEMP_TO_REG(temp); \ + lm75_write_value(client, reg, data->value); \ + return count; \ +} +set (temp_max,LM75_REG_TEMP_OS ); +set (temp_hyst,LM75_REG_TEMP_HYST ); + +static DEVICE_ATTR(temp_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max); +static DEVICE_ATTR(temp_min, S_IWUSR | S_IRUGO, show_temp_hyst, set_temp_hyst); +static DEVICE_ATTR(temp_input, S_IRUGO, show_temp_input, NULL); +static int lm75_attach_adapter (struct i2c_adapter *adapter) {return i2c_detect (adapter, &addr_data, lm75_detect); }/* This function is called by i2c_detect */ -static int lm75_detect (struct i2c_adapter *adapter,int address, -unsigned short flags,int kind) +static int lm75_detect (struct i2c_adapter *adapter,int address,int kind) {int i, cur, conf, hyst, os;struct i2c_client *new_client;struct lm75_data *data;int err =0 ; -const char *type_name, *client_name; +const char *name;/* Make sure we aren't probing the ISA bus!! This is just a safety check at this moment; i2c_detect really won't call us. */ #ifdef DEBUG if (i2c_is_isa_adapter (adapter)) { -printk - ("lm75.o: lm75_detect called for an ISA bus adapter?!?\n" ); -return 0 ; +dev_dbg (&adapter->dev, +"lm75_detect called for an ISA bus adapter?!?\n" ); + goto exit; }#endif if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA |I2C_FUNC_SMBUS_WORD_DATA )) - goto error0; + goto exit;/* OK. For now, we presume we have a valid client. We now create the client structure, even though we cannot fill it completely yet.
@@ -138,7 +154,7 @@ sizeof(struct lm75_data), GFP_KERNEL))) { err = -ENOMEM ; - goto error0; + goto exit; }memset (new_client,0x00 ,sizeof (struct i2c_client ) +sizeof (struct lm75_data ));
@@ -157,16 +173,10 @@ hyst =i2c_smbus_read_word_data (new_client,2 ); os =i2c_smbus_read_word_data (new_client,3 );for (i =0 ; i <=0x1f ; i++) -if ( - (i2c_smbus_read_byte_data - (new_client, i *8 +1 ) != conf) - || - (i2c_smbus_read_word_data - (new_client, i *8 +2 ) != hyst) - || - (i2c_smbus_read_word_data - (new_client, i *8 +3 ) != os)) - goto error1; +if ((i2c_smbus_read_byte_data (new_client, i *8 +1 ) != conf) || + (i2c_smbus_read_word_data (new_client, i *8 +2 ) != hyst) || + (i2c_smbus_read_word_data (new_client, i *8 +3 ) != os)) + goto exit_free; }/* Determine the chip type - only one kind supported! */
@@ -174,15 +184,15 @@ kind = lm75;if (kind == lm75) { - type_name ="lm75" ; - client_name ="LM75 chip" ; + name ="lm75" ; }else { -pr_debug ("lm75.o: Internal error: unknown kind (%d)?!?" , kind); - goto error1; +dev_dbg (&adapter->dev,"Internal error: unknown kind (%d)?!?" , + kind); + goto exit_free; }/* Fill in the remaining client fields and put it into the global list */ -strncpy (new_client->dev.name, client_name,DEVICE_NAME_SIZE ); +strncpy (new_client->dev.name, name,DEVICE_NAME_SIZE ); new_client->id = lm75_id++; data->valid =0 ;
@@ -190,36 +200,23 @@/* Tell the I2C layer a new client has arrived */ if ((err =i2c_attach_client (new_client))) - goto error3; + goto exit_free; -/* Register a new directory entry with module sensors */ - i =i2c_register_entry (new_client, type_name, lm75_dir_table_template); -if (i <0 ) { - err = i; - goto error4; - } - data->sysctl_id = i; +device_create_file (&new_client->dev, &dev_attr_temp_max); +device_create_file (&new_client->dev, &dev_attr_temp_min); +device_create_file (&new_client->dev, &dev_attr_temp_input);lm75_init_client (new_client);return 0 ; -/* OK, this is not exactly good programming practice, usually. But it is -very code-efficient in this case. */ - - error4: -i2c_detach_client (new_client); - error3: - error1: +exit_free:kfree (new_client); - error0: +exit:return err; }static int lm75_detach_client (struct i2c_client *client) { -struct lm75_data *data =i2c_get_clientdata (client); - -i2c_deregister_entry (data->sysctl_id);i2c_detach_client (client);kfree (client);return 0 ;
@@ -271,44 +268,16 @@if ((jiffies - data->last_updated >HZ +HZ /2 ) || (jiffies < data->last_updated) || !data->valid) { -pr_debug ("Starting lm75 update\n" ); +dev_dbg (&client->dev,"Starting lm75 update\n" ); - data->temp =lm75_read_value (client,LM75_REG_TEMP ); - data->temp_os =lm75_read_value (client,LM75_REG_TEMP_OS ); - data->temp_hyst = -lm75_read_value (client,LM75_REG_TEMP_HYST ); + data->temp_input =lm75_read_value (client,LM75_REG_TEMP ); + data->temp_max =lm75_read_value (client,LM75_REG_TEMP_OS ); + data->temp_hyst =lm75_read_value (client,LM75_REG_TEMP_HYST ); data->last_updated = jiffies; data->valid =1 ; }up (&data->update_lock); -} - - -static void lm75_temp (struct i2c_client *client,int operation,int ctl_name, -int *nrels_mag,long *results) -{ -struct lm75_data *data =i2c_get_clientdata (client); -if (operation ==SENSORS_PROC_REAL_INFO ) - *nrels_mag =1 ; -else if (operation ==SENSORS_PROC_REAL_READ ) { -lm75_update_client (client); - results[0 ] =TEMP_FROM_REG (data->temp_os); - results[1 ] =TEMP_FROM_REG (data->temp_hyst); - results[2 ] =TEMP_FROM_REG (data->temp); - *nrels_mag =3 ; - }else if (operation ==SENSORS_PROC_REAL_WRITE ) { -if (*nrels_mag >=1 ) { - data->temp_os =TEMP_TO_REG (results[0 ]); -lm75_write_value (client,LM75_REG_TEMP_OS , - data->temp_os); - } -if (*nrels_mag >=2 ) { - data->temp_hyst =TEMP_TO_REG (results[1 ]); -lm75_write_value (client,LM75_REG_TEMP_HYST , - data->temp_hyst); - } - } }static int __init sensors_lm75_init (void )
ChangeSet 1.977.29.6, 2003/04/02 11:32:24-08:00, [email protected]
i2c: convert adm1021 chip driver to use sysfs files.
Note, some data is not converted and will not be displayed. Someone with this hardware is going to have to finish the rest of this conversion.
drivers/i2c/chips/adm1021.c | 358 ++++++++++++++++++++------------------------ 1 files changed, 166 insertions(+), 192 deletions(-)
drivers/i2c/chips/adm1021.c +166 -192
@@ -53,34 +53,34 @@/* The adm1021 registers */ /* Read-only */ -#define ADM1021_REG_TEMP 0x00 -#define ADM1021_REG_REMOTE_TEMP 0x01 -#define ADM1021_REG_STATUS 0x02 -#define ADM1021_REG_MAN_ID 0x0FE/* 0x41 = AMD, 0x49 = TI, 0x4D = Maxim, 0x23 = Genesys , 0x54 = Onsemi*/ -#define ADM1021_REG_DEV_ID 0x0FF/* ADM1021 = 0x0X, ADM1023 = 0x3X */ -#define ADM1021_REG_DIE_CODE 0x0FF/* MAX1617A */ +#define ADM1021_REG_TEMP 0x00 +#define ADM1021_REG_REMOTE_TEMP 0x01 +#define ADM1021_REG_STATUS 0x02 +#define ADM1021_REG_MAN_ID 0x0FE/* 0x41 = AMD, 0x49 = TI, 0x4D = Maxim, 0x23 = Genesys , 0x54 = Onsemi*/ +#define ADM1021_REG_DEV_ID 0x0FF/* ADM1021 = 0x0X, ADM1023 = 0x3X */ +#define ADM1021_REG_DIE_CODE 0x0FF/* MAX1617A */ /* These use different addresses for reading/writing */ -#define ADM1021_REG_CONFIG_R 0x03 -#define ADM1021_REG_CONFIG_W 0x09 -#define ADM1021_REG_CONV_RATE_R 0x04 -#define ADM1021_REG_CONV_RATE_W 0x0A +#define ADM1021_REG_CONFIG_R 0x03 +#define ADM1021_REG_CONFIG_W 0x09 +#define ADM1021_REG_CONV_RATE_R 0x04 +#define ADM1021_REG_CONV_RATE_W 0x0A/* These are for the ADM1023's additional precision on the remote temp sensor */ -#define ADM1021_REG_REM_TEMP_PREC 0x010 -#define ADM1021_REG_REM_OFFSET 0x011 -#define ADM1021_REG_REM_OFFSET_PREC 0x012 -#define ADM1021_REG_REM_TOS_PREC 0x013 -#define ADM1021_REG_REM_THYST_PREC 0x014 +#define ADM1021_REG_REM_TEMP_PREC 0x010 +#define ADM1021_REG_REM_OFFSET 0x011 +#define ADM1021_REG_REM_OFFSET_PREC 0x012 +#define ADM1021_REG_REM_TOS_PREC 0x013 +#define ADM1021_REG_REM_THYST_PREC 0x014/* limits */ -#define ADM1021_REG_TOS_R 0x05 -#define ADM1021_REG_TOS_W 0x0B -#define ADM1021_REG_REMOTE_TOS_R 0x07 -#define ADM1021_REG_REMOTE_TOS_W 0x0D -#define ADM1021_REG_THYST_R 0x06 -#define ADM1021_REG_THYST_W 0x0C -#define ADM1021_REG_REMOTE_THYST_R 0x08 -#define ADM1021_REG_REMOTE_THYST_W 0x0E +#define ADM1021_REG_TOS_R 0x05 +#define ADM1021_REG_TOS_W 0x0B +#define ADM1021_REG_REMOTE_TOS_R 0x07 +#define ADM1021_REG_REMOTE_TOS_W 0x0D +#define ADM1021_REG_THYST_R 0x06 +#define ADM1021_REG_THYST_W 0x0C +#define ADM1021_REG_REMOTE_THYST_R 0x08 +#define ADM1021_REG_REMOTE_THYST_W 0x0E/* write-only */ -#define ADM1021_REG_ONESHOT 0x0F +#define ADM1021_REG_ONESHOT 0x0F/* Conversions. Rounding and limit checking is only done on the TO_REG
@@ -88,8 +88,8 @@these macros are called: arguments may be evaluated more than once. Fixing this is just not worth it. */ /* Conversions note: 1021 uses normal integer signed-byte format*/ -#define TEMP_FROM_REG (val) (val > 127 ? val-256 : val) -#define TEMP_TO_REG (val) (SENSORS_LIMIT((val < 0 ? val+256 : val),0,255)) +#define TEMP_FROM_REG (val) (val > 127 ? val-256 : val) +#define TEMP_TO_REG (val) (SENSORS_LIMIT((val < 0 ? val+256 : val),0,255))/* Initial values */
@@ -97,44 +97,43 @@they don't quite work like a thermostat the way the LM75 does. I.e., a lower temp than THYST actually triggers an alarm instead of clearing it. Weird, ey? --Phil */ -#define adm1021_INIT_TOS 60 -#define adm1021_INIT_THYST 20 -#define adm1021_INIT_REMOTE_TOS 60 -#define adm1021_INIT_REMOTE_THYST 20 +#define adm1021_INIT_TOS 60 +#define adm1021_INIT_THYST 20 +#define adm1021_INIT_REMOTE_TOS 60 +#define adm1021_INIT_REMOTE_THYST 20/* Each client has this additional data */ struct adm1021_data { -int sysctl_id;enum chips type;struct semaphore update_lock;char valid;/* !=0 if following fields are valid */ unsigned long last_updated;/* In jiffies */ -u8 temp, temp_os, temp_hyst;/* Register values */ -u8 remote_temp, remote_temp_os, remote_temp_hyst, alarms, die_code; +u8 temp_max;/* Register values */ +u8 temp_hyst; +u8 temp_input; +u8 remote_temp_max; +u8 remote_temp_hyst; +u8 remote_temp_input; +u8 alarms; +/* special values for ADM1021 only */ +u8 die_code;/* Special values for ADM1023 only */ -u8 remote_temp_prec, remote_temp_os_prec, remote_temp_hyst_prec, - remote_temp_offset, remote_temp_offset_prec; +u8 remote_temp_prec; +u8 remote_temp_os_prec; +u8 remote_temp_hyst_prec; +u8 remote_temp_offset; +u8 remote_temp_offset_prec; };static int adm1021_attach_adapter (struct i2c_adapter *adapter); -static int adm1021_detect (struct i2c_adapter *adapter,int address, -unsigned short flags,int kind); +static int adm1021_detect (struct i2c_adapter *adapter,int address,int kind);static void adm1021_init_client (struct i2c_client *client);static int adm1021_detach_client (struct i2c_client *client);static int adm1021_read_value (struct i2c_client *client,u8 reg);static int adm1021_write_value (struct i2c_client *client,u8 reg,u16 value); -static void adm1021_temp (struct i2c_client *client,int operation, -int ctl_name,int *nrels_mag,long *results); -static void adm1021_remote_temp (struct i2c_client *client,int operation, -int ctl_name,int *nrels_mag, -long *results); -static void adm1021_alarms (struct i2c_client *client,int operation, -int ctl_name,int *nrels_mag,long *results); -static void adm1021_die_code (struct i2c_client *client,int operation, -int ctl_name,int *nrels_mag,long *results);static void adm1021_update_client (struct i2c_client *client);/* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */
@@ -151,45 +150,63 @@ .detach_client = adm1021_detach_client, }; -/* These files are created for each detected adm1021. This is just a template; -though at first sight, you might think we could use a statically -allocated list, we need some way to get back to the parent - which -is done through one of the 'extra' fields which are initialized -when a new copy is allocated. */ -static ctl_table adm1021_dir_table_template[] = { - {ADM1021_SYSCTL_TEMP ,"temp1" ,NULL ,0 ,0644 ,NULL , &i2c_proc_real, - &i2c_sysctl_real,NULL , &adm1021_temp}, - {ADM1021_SYSCTL_REMOTE_TEMP ,"temp2" ,NULL ,0 ,0644 ,NULL , &i2c_proc_real, - &i2c_sysctl_real,NULL , &adm1021_remote_temp}, - {ADM1021_SYSCTL_DIE_CODE ,"die_code" ,NULL ,0 ,0444 ,NULL , &i2c_proc_real, - &i2c_sysctl_real,NULL , &adm1021_die_code}, - {ADM1021_SYSCTL_ALARMS ,"alarms" ,NULL ,0 ,0444 ,NULL , &i2c_proc_real, - &i2c_sysctl_real,NULL , &adm1021_alarms}, - {0 } -}; - -static ctl_table adm1021_max_dir_table_template[] = { - {ADM1021_SYSCTL_TEMP ,"temp1" ,NULL ,0 ,0644 ,NULL , &i2c_proc_real, - &i2c_sysctl_real,NULL , &adm1021_temp}, - {ADM1021_SYSCTL_REMOTE_TEMP ,"temp2" ,NULL ,0 ,0644 ,NULL , &i2c_proc_real, - &i2c_sysctl_real,NULL , &adm1021_remote_temp}, - {ADM1021_SYSCTL_ALARMS ,"alarms" ,NULL ,0 ,0444 ,NULL , &i2c_proc_real, - &i2c_sysctl_real,NULL , &adm1021_alarms}, - {0 } -}; -/* I choose here for semi-static allocation. Complete dynamic allocation could also be used; the code needed for this would probably take more memory than the datastructure takes now. */ static int adm1021_id =0 ; +#define show (value) \ +static ssize_t show_##value(struct device *dev, char *buf) \ +{ \ + struct i2c_client *client = to_i2c_client(dev); \ + struct adm1021_data *data = i2c_get_clientdata(client); \ + int temp; \ + \ + adm1021_update_client(client); \ + temp = TEMP_FROM_REG(data->value); \ + return sprintf(buf, "%d\n", temp); \ +} +show (temp_max); +show (temp_hyst); +show (temp_input); +show (remote_temp_max); +show (remote_temp_hyst); +show (remote_temp_input); +show (alarms); +show (die_code); + +#define set (value, reg) \ +static ssize_t set_##value(struct device *dev, const char *buf, size_t count) \ +{ \ + struct i2c_client *client = to_i2c_client(dev); \ + struct adm1021_data *data = i2c_get_clientdata(client); \ + int temp = simple_strtoul(buf, NULL, 10); \ + \ + data->value = TEMP_TO_REG(temp); \ + adm1021_write_value(client, reg, data->value); \ + return count; \ +} +set (temp_max,ADM1021_REG_TOS_W ); +set (temp_hyst,ADM1021_REG_THYST_W ); +set (remote_temp_max,ADM1021_REG_REMOTE_TOS_W ); +set (remote_temp_hyst,ADM1021_REG_REMOTE_THYST_W ); + +static DEVICE_ATTR(temp_max1, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max); +static DEVICE_ATTR(temp_min1, S_IWUSR | S_IRUGO, show_temp_hyst, set_temp_hyst); +static DEVICE_ATTR(temp_input1, S_IRUGO, show_temp_input, NULL); +static DEVICE_ATTR(temp_max2, S_IWUSR | S_IRUGO, show_remote_temp_max, set_remote_temp_max); +static DEVICE_ATTR(temp_min2, S_IWUSR | S_IRUGO, show_remote_temp_hyst, set_remote_temp_hyst); +static DEVICE_ATTR(temp_input2, S_IRUGO, show_remote_temp_input, NULL); +static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); +static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL); + +static int adm1021_attach_adapter (struct i2c_adapter *adapter) {return i2c_detect (adapter, &addr_data, adm1021_detect); } -static int adm1021_detect (struct i2c_adapter *adapter,int address, -unsigned short flags,int kind) +static int adm1021_detect (struct i2c_adapter *adapter,int address,int kind) {int i;struct i2c_client *new_client;
@@ -202,8 +219,7 @@at this moment; i2c_detect really won't call us. */ #ifdef DEBUG if (i2c_is_isa_adapter (adapter)) { -printk - ("adm1021.o: adm1021_detect called for an ISA bus adapter?!?\n" ); +dev_dbg (&adapter->dev,"adm1021_detect called for an ISA bus adapter?!?\n" );return 0 ; }#endif
@@ -232,35 +248,28 @@ new_client->flags =0 ;/* Now, we do the remaining detection. */ -if (kind <0 ) { -if ( - (adm1021_read_value (new_client,ADM1021_REG_STATUS ) & -0x03 ) !=0x00 ) +if ((adm1021_read_value (new_client,ADM1021_REG_STATUS ) &0x03 ) !=0x00 ) goto error1; }/* Determine the chip type. */ -if (kind <=0 ) { i =adm1021_read_value (new_client,ADM1021_REG_MAN_ID );if (i ==0x41 ) -if ((adm1021_read_value (new_client,ADM1021_REG_DEV_ID ) &0x0F0 ) ==0x030 ) - kind = adm1023; -else - kind = adm1021; +if ((adm1021_read_value (new_client,ADM1021_REG_DEV_ID ) &0x0F0 ) ==0x030 ) + kind = adm1023; +else + kind = adm1021;else if (i ==0x49 ) kind = thmc10;else if (i ==0x23 ) kind = gl523sm;else if ((i ==0x4d ) && - (adm1021_read_value - (new_client,ADM1021_REG_DEV_ID ) ==0x01 )) + (adm1021_read_value (new_client,ADM1021_REG_DEV_ID ) ==0x01 )) kind = max1617a;/* LM84 Mfr ID in a different place */ -else -if (adm1021_read_value - (new_client,ADM1021_REG_CONV_RATE_R ) ==0x00 ) +else if (adm1021_read_value (new_client,ADM1021_REG_CONV_RATE_R ) ==0x00 ) kind = lm84;else if (i ==0x54 ) kind = mc1066;
@@ -293,10 +302,8 @@ type_name ="mc1066" ; client_name ="MC1066 chip" ; }else { -#ifdef DEBUG -printk ("adm1021.o: Internal error: unknown kind (%d)?!?" , - kind); -#endif +dev_err (&adapter->dev,"Internal error: unknown kind (%d)?!?" , + kind); goto error1; }
@@ -312,25 +319,24 @@if ((err =i2c_attach_client (new_client))) goto error3; -/* Register a new directory entry with module sensors */ - err =i2c_register_entry (new_client, type_name, - (data->type == adm1021) ? - adm1021_dir_table_template : - adm1021_max_dir_table_template); -if (err <0 ) - goto error4; +device_create_file (&new_client->dev, &dev_attr_temp_max1); +device_create_file (&new_client->dev, &dev_attr_temp_min1); +device_create_file (&new_client->dev, &dev_attr_temp_input1); +device_create_file (&new_client->dev, &dev_attr_temp_max2); +device_create_file (&new_client->dev, &dev_attr_temp_min2); +device_create_file (&new_client->dev, &dev_attr_temp_input2); +device_create_file (&new_client->dev, &dev_attr_alarms); +if (data->type == adm1021) +device_create_file (&new_client->dev, &dev_attr_die_code); - data->sysctl_id = err;/* Initialize the ADM1021 chip */ adm1021_init_client (new_client);return 0 ; - error4: -i2c_detach_client (new_client); - error3: - error1: +error3: +error1:kfree (new_client); - error0: +error0:return err; }
@@ -353,21 +359,15 @@static int adm1021_detach_client (struct i2c_client *client) { -int err; -i2c_deregister_entry (((struct adm1021_data *) (i2c_get_clientdata (client)))->sysctl_id); -if ((err =i2c_detach_client (client))) { -printk - ("adm1021.o: Client deregistration failed, client not detached.\n" ); +dev_err (&client->dev,"Client deregistration failed, client not detached.\n" );return err; }kfree (client); -return 0 ; - }/* All registers are byte-sized */
@@ -391,39 +391,23 @@if ((jiffies - data->last_updated >HZ +HZ /2 ) || (jiffies < data->last_updated) || !data->valid) { +dev_dbg (&client->dev,"Starting adm1021 update\n" ); -#ifdef DEBUG -printk ("Starting adm1021 update\n" ); -#endif - - data->temp =adm1021_read_value (client,ADM1021_REG_TEMP ); - data->temp_os = -adm1021_read_value (client,ADM1021_REG_TOS_R ); - data->temp_hyst = -adm1021_read_value (client,ADM1021_REG_THYST_R ); - data->remote_temp = -adm1021_read_value (client,ADM1021_REG_REMOTE_TEMP ); - data->remote_temp_os = -adm1021_read_value (client,ADM1021_REG_REMOTE_TOS_R ); - data->remote_temp_hyst = -adm1021_read_value (client,ADM1021_REG_REMOTE_THYST_R ); - data->alarms = -adm1021_read_value (client,ADM1021_REG_STATUS ) &0xec ; + data->temp_input =adm1021_read_value (client,ADM1021_REG_TEMP ); + data->temp_max =adm1021_read_value (client,ADM1021_REG_TOS_R ); + data->temp_hyst =adm1021_read_value (client,ADM1021_REG_THYST_R ); + data->remote_temp_input =adm1021_read_value (client,ADM1021_REG_REMOTE_TEMP ); + data->remote_temp_max =adm1021_read_value (client,ADM1021_REG_REMOTE_TOS_R ); + data->remote_temp_hyst =adm1021_read_value (client,ADM1021_REG_REMOTE_THYST_R ); + data->alarms =adm1021_read_value (client,ADM1021_REG_STATUS ) &0xec ;if (data->type == adm1021) - data->die_code = -adm1021_read_value (client, -ADM1021_REG_DIE_CODE ); + data->die_code =adm1021_read_value (client,ADM1021_REG_DIE_CODE );if (data->type == adm1023) { - data->remote_temp_prec = -adm1021_read_value (client,ADM1021_REG_REM_TEMP_PREC ); - data->remote_temp_os_prec = -adm1021_read_value (client,ADM1021_REG_REM_TOS_PREC ); - data->remote_temp_hyst_prec = -adm1021_read_value (client,ADM1021_REG_REM_THYST_PREC ); - data->remote_temp_offset = -adm1021_read_value (client,ADM1021_REG_REM_OFFSET ); - data->remote_temp_offset_prec = -adm1021_read_value (client,ADM1021_REG_REM_OFFSET_PREC ); + data->remote_temp_prec =adm1021_read_value (client,ADM1021_REG_REM_TEMP_PREC ); + data->remote_temp_os_prec =adm1021_read_value (client,ADM1021_REG_REM_TOS_PREC ); + data->remote_temp_hyst_prec =adm1021_read_value (client,ADM1021_REG_REM_THYST_PREC ); + data->remote_temp_offset =adm1021_read_value (client,ADM1021_REG_REM_OFFSET ); + data->remote_temp_offset_prec =adm1021_read_value (client,ADM1021_REG_REM_OFFSET_PREC ); } data->last_updated = jiffies; data->valid =1 ;
@@ -433,6 +417,9 @@ } +/* FIXME, remove these four functions, they are here to verify the sysfs +* conversion is correct, or not */ +__attribute__((unused))static void adm1021_temp (struct i2c_client *client,int operation,int ctl_name,int *nrels_mag,long *results) {
@@ -442,15 +429,15 @@ *nrels_mag =0 ; else if (operation == SENSORS_PROC_REAL_READ) {adm1021_update_client (client); - results[0 ] =TEMP_FROM_REG (data->temp_os); + results[0 ] =TEMP_FROM_REG (data->temp_max); results[1 ] =TEMP_FROM_REG (data->temp_hyst); - results[2 ] =TEMP_FROM_REG (data->temp); + results[2 ] =TEMP_FROM_REG (data->temp_input); *nrels_mag =3 ; } else if (operation == SENSORS_PROC_REAL_WRITE) {if (*nrels_mag >=1 ) { - data->temp_os =TEMP_TO_REG (results[0 ]); + data->temp_max =TEMP_TO_REG (results[0 ]);adm1021_write_value (client,ADM1021_REG_TOS_W , - data->temp_os); + data->temp_max); }if (*nrels_mag >=2 ) { data->temp_hyst =TEMP_TO_REG (results[1 ]);
@@ -460,6 +447,7 @@ } } +__attribute__((unused))static void adm1021_remote_temp (struct i2c_client *client,int operation,int ctl_name,int *nrels_mag,long *results) {
@@ -471,68 +459,53 @@else { *nrels_mag =0 ; } else if (operation == SENSORS_PROC_REAL_READ) {adm1021_update_client (client); - results[0 ] =TEMP_FROM_REG (data->remote_temp_os); + results[0 ] =TEMP_FROM_REG (data->remote_temp_max); results[1 ] =TEMP_FROM_REG (data->remote_temp_hyst); - results[2 ] =TEMP_FROM_REG (data->remote_temp); + results[2 ] =TEMP_FROM_REG (data->remote_temp_input);if (data->type == adm1023) { - results[0 ]=results[0 ]*1000 + - ((data->remote_temp_os_prec >>5 ) *125 ); - results[1 ]=results[1 ]*1000 + - ((data->remote_temp_hyst_prec >>5 ) *125 ); - results[2 ]=(TEMP_FROM_REG (data->remote_temp_offset)*1000 ) + - ((data->remote_temp_offset_prec >>5 ) *125 ); - results[3 ]=TEMP_FROM_REG (data->remote_temp)*1000 + - ((data->remote_temp_prec >>5 ) *125 ); - *nrels_mag =4 ; + results[0 ] = results[0 ]*1000 + ((data->remote_temp_os_prec >>5 ) *125 ); + results[1 ] = results[1 ]*1000 + ((data->remote_temp_hyst_prec >>5 ) *125 ); + results[2 ] = (TEMP_FROM_REG (data->remote_temp_offset)*1000 ) + ((data->remote_temp_offset_prec >>5 ) *125 ); + results[3 ] = (TEMP_FROM_REG (data->remote_temp_input)*1000 ) + ((data->remote_temp_prec >>5 ) *125 ); + *nrels_mag =4 ; }else { - *nrels_mag =3 ; + *nrels_mag =3 ; } } else if (operation == SENSORS_PROC_REAL_WRITE) {if (*nrels_mag >=1 ) {if (data->type == adm1023) { - prec=((results[0 ]-((results[0 ]/1000 )*1000 ))/125 )<<5 ; -adm1021_write_value (client, -ADM1021_REG_REM_TOS_PREC , - prec); - results[0 ]=results[0 ]/1000 ; - data->remote_temp_os_prec=prec; + prec = ((results[0 ]-((results[0 ]/1000 )*1000 ))/125 )<<5 ; +adm1021_write_value (client,ADM1021_REG_REM_TOS_PREC , prec); + results[0 ] = results[0 ]/1000 ; + data->remote_temp_os_prec=prec; } - data->remote_temp_os =TEMP_TO_REG (results[0 ]); -adm1021_write_value (client, -ADM1021_REG_REMOTE_TOS_W , - data->remote_temp_os); + data->remote_temp_max =TEMP_TO_REG (results[0 ]); +adm1021_write_value (client,ADM1021_REG_REMOTE_TOS_W , data->remote_temp_max); }if (*nrels_mag >=2 ) {if (data->type == adm1023) { - prec=((results[1 ]-((results[1 ]/1000 )*1000 ))/125 )<<5 ; -adm1021_write_value (client, -ADM1021_REG_REM_THYST_PREC , - prec); - results[1 ]=results[1 ]/1000 ; - data->remote_temp_hyst_prec=prec; + prec = ((results[1 ]-((results[1 ]/1000 )*1000 ))/125 )<<5 ; +adm1021_write_value (client,ADM1021_REG_REM_THYST_PREC , prec); + results[1 ] = results[1 ]/1000 ; + data->remote_temp_hyst_prec=prec; } data->remote_temp_hyst =TEMP_TO_REG (results[1 ]); -adm1021_write_value (client, -ADM1021_REG_REMOTE_THYST_W , - data->remote_temp_hyst); +adm1021_write_value (client,ADM1021_REG_REMOTE_THYST_W , data->remote_temp_hyst); }if (*nrels_mag >=3 ) {if (data->type == adm1023) { - prec=((results[2 ]-((results[2 ]/1000 )*1000 ))/125 )<<5 ; -adm1021_write_value (client, -ADM1021_REG_REM_OFFSET_PREC , - prec); - results[2 ]=results[2 ]/1000 ; - data->remote_temp_offset_prec=prec; - data->remote_temp_offset=results[2 ]; -adm1021_write_value (client, -ADM1021_REG_REM_OFFSET , - data->remote_temp_offset); + prec = ((results[2 ]-((results[2 ]/1000 )*1000 ))/125 )<<5 ; +adm1021_write_value (client,ADM1021_REG_REM_OFFSET_PREC , prec); + results[2 ]=results[2 ]/1000 ; + data->remote_temp_offset_prec=prec; + data->remote_temp_offset=results[2 ]; +adm1021_write_value (client,ADM1021_REG_REM_OFFSET , data->remote_temp_offset); } } } } +__attribute__((unused))static void adm1021_die_code (struct i2c_client *client,int operation,int ctl_name,int *nrels_mag,long *results) {
@@ -549,6 +522,7 @@ } } +__attribute__((unused))static void adm1021_alarms (struct i2c_client *client,int operation,int ctl_name,int *nrels_mag,long *results) {
@@ -574,8 +548,8 @@i2c_del_driver (&adm1021_driver); } -MODULE_AUTHOR - ("Frodo Looijaard <[email protected]> and Philip Edelbrock <[email protected]>" ); +MODULE_AUTHOR ("Frodo Looijaard <[email protected]> and " +"Philip Edelbrock <[email protected]>" );MODULE_DESCRIPTION ("adm1021 driver" );MODULE_LICENSE ("GPL" );
ChangeSet 1.977.29.7, 2003/04/02 11:34:13-08:00, [email protected]
i2c: remove sysctl and proc functions from via686a.c driver
This still needs to be converted to use sysfs files, but due to lack of hardware, I can not do this. This change is necessary as the sysctl and proc interface is about to go away.
drivers/i2c/chips/via686a.c | 56 +++++++++++++------------------------------- 1 files changed, 17 insertions(+), 39 deletions(-)
drivers/i2c/chips/via686a.c +17 -39
@@ -369,8 +369,6 @@dynamically allocated, at the same time when a new via686a client is allocated. */ struct via686a_data { -int sysctl_id; -struct semaphore update_lock;char valid;/* !=0 if following fields are valid */ unsigned long last_updated;/* In jiffies */
@@ -390,8 +388,7 @@static struct pci_dev *s_bridge;/* pointer to the (only) via686a */ static int via686a_attach_adapter (struct i2c_adapter *adapter); -static int via686a_detect (struct i2c_adapter *adapter,int address, -unsigned short flags,int kind); +static int via686a_detect (struct i2c_adapter *adapter,int address,int kind);static int via686a_detach_client (struct i2c_client *client);static int via686a_read_value (struct i2c_client *client,u8 register);
@@ -400,18 +397,6 @@static void via686a_update_client (struct i2c_client *client);static void via686a_init_client (struct i2c_client *client); - -static void via686a_in (struct i2c_client *client,int operation, -int ctl_name,int *nrels_mag,long *results); -static void via686a_fan (struct i2c_client *client,int operation, -int ctl_name,int *nrels_mag,long *results); -static void via686a_temp (struct i2c_client *client,int operation, -int ctl_name,int *nrels_mag,long *results); -static void via686a_alarms (struct i2c_client *client,int operation, -int ctl_name,int *nrels_mag,long *results); -static void via686a_fan_div (struct i2c_client *client,int operation, -int ctl_name,int *nrels_mag,long *results); -static int via686a_id =0 ;/* The driver. I choose to use type i2c_driver, as at is identical to both
@@ -457,6 +442,7 @@/* -- SENSORS SYSCTL END -- */ +#if 0 /* These files are created for each detected VIA686A. This is just a template; though at first sight, you might think we could use a statically allocated list, we need some way to get back to the parent - which
@@ -489,6 +475,7 @@ &i2c_proc_real, &i2c_sysctl_real, NULL, &via686a_alarms}, {0} }; +#endif static inline int via686a_read_value (struct i2c_client *client,u8 reg) {
@@ -507,15 +494,12 @@return i2c_detect (adapter, &addr_data, via686a_detect); } -int via686a_detect (struct i2c_adapter *adapter,int address, -unsigned short flags,int kind) +static int via686a_detect (struct i2c_adapter *adapter,int address,int kind) { -int i;struct i2c_client *new_client;struct via686a_data *data;int err =0 ; -const char *type_name ="via686a" ; -const char client_name[] ="via686a chip" ; +const char *name ="via686a" ;u16 val;/* Make sure we are probing the ISA bus!! */
@@ -570,7 +554,7 @@ new_client->flags =0 ;/* Fill in the remaining client fields and put into the global list */ -snprintf (new_client->dev.name,DEVICE_NAME_SIZE , client_name); +snprintf (new_client->dev.name,DEVICE_NAME_SIZE , name); new_client->id = via686a_id++; data->valid =0 ;
@@ -579,21 +563,10 @@if ((err =i2c_attach_client (new_client))) goto ERROR3; -/* Register a new directory entry with module sensors */ -if ((i =i2c_register_entry ((struct i2c_client *) new_client, - type_name, - via686a_dir_table_template)) <0 ) { - err = i; - goto ERROR4; - } - data->sysctl_id = i; -/* Initialize the VIA686A chip */ via686a_init_client (new_client);return 0 ; - ERROR4: -i2c_detach_client (new_client); ERROR3:release_region (address,VIA686A_EXTENT );kfree (new_client);
@@ -604,8 +577,6 @@static int via686a_detach_client (struct i2c_client *client) {int err; -struct via686a_data *data =i2c_get_clientdata (client); -i2c_deregister_entry (data->sysctl_id);if ((err =i2c_detach_client (client))) { dev_err(&client->dev,
@@ -752,6 +723,9 @@large enough (by checking the incoming value of *nrels). This is not very good practice, but as long as you put less than about 5 values in results, you can assume it is large enough. */ +/* FIXME, remove these functions, they are here to verify the sysfs conversion +* is correct, or not */ +__attribute__((unused))static void via686a_in (struct i2c_client *client,int operation,int ctl_name,int *nrels_mag,long *results) {
@@ -780,7 +754,8 @@ } } -void via686a_fan (struct i2c_client *client,int operation,int ctl_name, +__attribute__((unused)) +static void via686a_fan (struct i2c_client *client,int operation,int ctl_name,int *nrels_mag,long *results) {struct via686a_data *data =i2c_get_clientdata (client);
@@ -808,7 +783,8 @@ } } -void via686a_temp (struct i2c_client *client,int operation,int ctl_name, +__attribute__((unused)) +static void via686a_temp (struct i2c_client *client,int operation,int ctl_name,int *nrels_mag,long *results) {struct via686a_data *data =i2c_get_clientdata (client);
@@ -838,7 +814,8 @@ } } -void via686a_alarms (struct i2c_client *client,int operation,int ctl_name, +__attribute__((unused)) +static void via686a_alarms (struct i2c_client *client,int operation,int ctl_name,int *nrels_mag,long *results) {struct via686a_data *data =i2c_get_clientdata (client);
@@ -851,7 +828,8 @@ } } -void via686a_fan_div (struct i2c_client *client,int operation, +__attribute__((unused)) +static void via686a_fan_div (struct i2c_client *client,int operation,int ctl_name,int *nrels_mag,long *results) {struct via686a_data *data =i2c_get_clientdata (client);
ChangeSet 1.977.29.8, 2003/04/02 11:45:21-08:00, [email protected]
i2c: remove proc and sysctl code from i2c-proc as it is no longer used.
drivers/i2c/i2c-proc.c | 546 ----------------------------------------------- include/linux/i2c-proc.h | 40 --- 2 files changed, 586 deletions(-)
drivers/i2c/i2c-proc.c +0 -546
@@ -37,539 +37,6 @@#include <linux/i2c-proc.h> #include <asm/uaccess.h> -static int i2c_parse_reals (int *nrels,void *buffer,int bufsize, -long *results,int magnitude); -static int i2c_write_reals (int nrels,void *buffer,size_t *bufsize, -long *results,int magnitude); -static int i2c_proc_chips (ctl_table * ctl,int write, -struct file *filp,void *buffer, -size_t * lenp); -static int i2c_sysctl_chips (ctl_table * table,int *name,int nlen, -void *oldval,size_t * oldlenp, -void *newval,size_t newlen, -void **context); - -#define SENSORS_ENTRY_MAX 20 -static struct ctl_table_header *i2c_entries[SENSORS_ENTRY_MAX ]; - -static struct i2c_client *i2c_clients[SENSORS_ENTRY_MAX ]; - -static ctl_table i2c_proc_dev_sensors[] = { - {SENSORS_CHIPS ,"chips" ,NULL ,0 ,0644 ,NULL , &i2c_proc_chips, - &i2c_sysctl_chips}, - {0 } -}; - -static ctl_table i2c_proc_dev[] = { - {DEV_SENSORS ,"sensors" ,NULL ,0 ,0555 , i2c_proc_dev_sensors}, - {0 }, -}; - - -static ctl_table i2c_proc[] = { - {CTL_DEV ,"dev" ,NULL ,0 ,0555 , i2c_proc_dev}, - {0 } -}; - - -static struct ctl_table_header *i2c_proc_header; - -/* This returns a nice name for a new directory; for example lm78-isa-0310 -(for a LM78 chip on the ISA bus at port 0x310), or lm75-i2c-3-4e (for -a LM75 chip on the third i2c bus at address 0x4e). -name is allocated first. */ -static char *generate_name (struct i2c_client *client,const char *prefix) -{ -struct i2c_adapter *adapter = client->adapter; -int addr = client->addr; -char name_buffer[50 ], *name; - -if (i2c_is_isa_adapter (adapter)) { -sprintf (name_buffer,"%s-isa-%04x" , prefix, addr); - }else if (adapter->algo->smbus_xfer || adapter->algo->master_xfer) { -int id =i2c_adapter_id (adapter); -if (id <0 ) -return ERR_PTR (-ENOENT ); -sprintf (name_buffer,"%s-i2c-%d-%02x" , prefix, id, addr); - }else {/* dummy adapter, generate prefix */ -int end, i; - -sprintf (name_buffer,"%s-" , prefix); - end =strlen (name_buffer); - -for (i =0 ; i <32 ; i++) { -if (adapter->algo->name[i] ==' ' ) -break ; - name_buffer[end++] =tolower (adapter->algo->name[i]); - } - - name_buffer[end] =0 ; -sprintf (name_buffer + end,"-%04x" , addr); - } - - name =kmalloc (strlen (name_buffer) +1 ,GFP_KERNEL ); -if (unlikely (!name)) -return ERR_PTR (-ENOMEM ); -strcpy (name, name_buffer); -return name; -} - -/* This rather complex function must be called when you want to add an entry -to /proc/sys/dev/sensors/chips. It also creates a new directory within -/proc/sys/dev/sensors/. -ctl_template should be a template of the newly created directory. It is -copied in memory. The extra2 field of each file is set to point to client. -If any driver wants subdirectories within the newly created directory, -this function must be updated! */ -int i2c_register_entry (struct i2c_client *client,const char *prefix, -struct ctl_table *leaf) -{ -struct {struct ctl_table root[2 ], dev[2 ], sensors[2 ]; } *tbl; -struct ctl_table_header *hdr; -struct ctl_table *tmp; -const char *name; -int id; - - name =generate_name (client, prefix); -if (IS_ERR (name)) -return PTR_ERR (name); - -for (id =0 ; id <SENSORS_ENTRY_MAX ; id++) { -if (!i2c_entries[id]) - goto free_slot; - } - - goto out_free_name; - - free_slot: - tbl =kmalloc (sizeof (*tbl),GFP_KERNEL ); -if (unlikely (!tbl)) - goto out_free_name; -memset (tbl,0 ,sizeof (*tbl)); - -for (tmp = leaf; tmp->ctl_name; tmp++) - tmp->extra2 = client; - - tbl->sensors->ctl_name = id+256 ; - tbl->sensors->procname = name; - tbl->sensors->mode =0555 ; - tbl->sensors->child = leaf; - - tbl->dev->ctl_name =DEV_SENSORS ; - tbl->dev->procname ="sensors" ; - tbl->dev->mode =0555 ; - tbl->dev->child = tbl->sensors; - - tbl->root->ctl_name =CTL_DEV ; - tbl->root->procname ="dev" ; - tbl->root->mode =0555 ; - tbl->root->child = tbl->dev; - - hdr =register_sysctl_table (tbl->root,0 ); -if (unlikely (!hdr)) - goto out_free_tbl; - - i2c_entries[id] = hdr; - i2c_clients[id] = client; - -return (id +256 );/* XXX(hch) why?? */ - - out_free_tbl: -kfree (tbl); - out_free_name: -kfree (name); -return -ENOMEM ; -} - -void i2c_deregister_entry (int id) -{ - id -=256 ; - -if (i2c_entries[id]) { -struct ctl_table_header *hdr = i2c_entries[id]; -struct ctl_table *tbl = hdr->ctl_table; - -unregister_sysctl_table (hdr); -kfree (tbl->child->child->procname); -kfree (tbl);/* actually the whole anonymous struct */ - } - - i2c_entries[id] =NULL ; - i2c_clients[id] =NULL ; -} - -static int i2c_proc_chips (ctl_table * ctl,int write,struct file *filp, -void *buffer,size_t * lenp) -{ -char BUF [SENSORS_PREFIX_MAX +30 ]; -int buflen, curbufsize, i; -struct ctl_table *client_tbl; - -if (write) -return 0 ; - -/* If buffer is size 0, or we try to read when not at the start, we -return nothing. Note that I think writing when not at the start -does not work either, but anyway, this is straight from the kernel -sources. */ -if (!*lenp || (filp->f_pos && !write)) { - *lenp =0 ; -return 0 ; - } - curbufsize =0 ; -for (i =0 ; i <SENSORS_ENTRY_MAX ; i++) -if (i2c_entries[i]) { - client_tbl = - i2c_entries[i]->ctl_table->child->child; - buflen = -sprintf (BUF ,"%d\t%s\n" , client_tbl->ctl_name, - client_tbl->procname); -if (buflen + curbufsize > *lenp) - buflen = *lenp - curbufsize; -if (copy_to_user (buffer,BUF , buflen)) -return -EFAULT ; - curbufsize += buflen; - (char *) buffer += buflen; - } - *lenp = curbufsize; - filp->f_pos += curbufsize; -return 0 ; -} - -static int i2c_sysctl_chips (ctl_table * table,int *name,int nlen, -void *oldval,size_t * oldlenp,void *newval, -size_t newlen,void **context) -{ -struct i2c_chips_data data; -int i, oldlen, nrels, maxels,ret=0 ; -struct ctl_table *client_tbl; - -if (oldval && oldlenp && !((ret =get_user (oldlen, oldlenp))) && - oldlen) { - maxels = oldlen /sizeof (struct i2c_chips_data ); - nrels =0 ; -for (i =0 ; (i <SENSORS_ENTRY_MAX ) && (nrels < maxels); - i++) -if (i2c_entries[i]) { - client_tbl = - i2c_entries[i]->ctl_table->child-> - child; - data.sysctl_id = client_tbl->ctl_name; -strcpy (data.name, client_tbl->procname); -if (copy_to_user (oldval, &data, -sizeof (struct -i2c_chips_data ))) -return -EFAULT ; - (char *) oldval += -sizeof (struct i2c_chips_data ); - nrels++; - } - oldlen = nrels *sizeof (struct i2c_chips_data ); -if (put_user (oldlen, oldlenp)) -return -EFAULT ; - } -return ret; -} - - -/* This function reads or writes a 'real' value (encoded by the combination -of an integer and a magnitude, the last is the power of ten the value -should be divided with) to a /proc/sys directory. To use this function, -you must (before registering the ctl_table) set the extra2 field to the -client, and the extra1 field to a function of the form: -void func(struct i2c_client *client, int operation, int ctl_name, -int *nrels_mag, long *results) -This function can be called for three values of operation. If operation -equals SENSORS_PROC_REAL_INFO, the magnitude should be returned in -nrels_mag. If operation equals SENSORS_PROC_REAL_READ, values should -be read into results. nrels_mag should return the number of elements -read; the maximum number is put in it on entry. Finally, if operation -equals SENSORS_PROC_REAL_WRITE, the values in results should be -written to the chip. nrels_mag contains on entry the number of elements -found. -In all cases, client points to the client we wish to interact with, -and ctl_name is the SYSCTL id of the file we are accessing. */ -int i2c_proc_real (ctl_table * ctl,int write,struct file *filp, -void *buffer,size_t * lenp) -{ -#define MAX_RESULTS 32 -int mag, nrels =MAX_RESULTS ; -long results[MAX_RESULTS ]; -i2c_real_callback callback = ctl->extra1; -struct i2c_client *client = ctl->extra2; -int res; - -/* If buffer is size 0, or we try to read when not at the start, we -return nothing. Note that I think writing when not at the start -does not work either, but anyway, this is straight from the kernel -sources. */ -if (!*lenp || (filp->f_pos && !write)) { - *lenp =0 ; -return 0 ; - } - -/* Get the magnitude */ -callback (client,SENSORS_PROC_REAL_INFO , ctl->ctl_name, &mag, -NULL ); - -if (write) { -/* Read the complete input into results, converting to longs */ - res =i2c_parse_reals (&nrels, buffer, *lenp, results, mag); -if (res) -return res; - -if (!nrels) -return 0 ; - -/* Now feed this information back to the client */ -callback (client,SENSORS_PROC_REAL_WRITE , ctl->ctl_name, - &nrels, results); - - filp->f_pos += *lenp; -return 0 ; - }else {/* read */ -/* Get the information from the client into results */ -callback (client,SENSORS_PROC_REAL_READ , ctl->ctl_name, - &nrels, results); - -/* And write them to buffer, converting to reals */ - res =i2c_write_reals (nrels, buffer, lenp, results, mag); -if (res) -return res; - filp->f_pos += *lenp; -return 0 ; - } -} - -/* This function is equivalent to i2c_proc_real, only it interacts with -the sysctl(2) syscall, and returns no reals, but integers */ -int i2c_sysctl_real (ctl_table * table,int *name,int nlen, -void *oldval,size_t * oldlenp,void *newval, -size_t newlen,void **context) -{ -long results[MAX_RESULTS ]; -int oldlen, nrels =MAX_RESULTS ,ret=0 ; -i2c_real_callback callback = table->extra1; -struct i2c_client *client = table->extra2; - -/* Check if we need to output the old values */ -if (oldval && oldlenp && !((ret=get_user (oldlen, oldlenp))) && oldlen) { -callback (client,SENSORS_PROC_REAL_READ , table->ctl_name, - &nrels, results); - -/* Note the rounding factor! */ -if (nrels *sizeof (long ) < oldlen) - oldlen = nrels *sizeof (long ); - oldlen = (oldlen /sizeof (long )) *sizeof (long ); -if (copy_to_user (oldval, results, oldlen)) -return -EFAULT ; -if (put_user (oldlen, oldlenp)) -return -EFAULT ; - } - -if (newval && newlen) { -/* Note the rounding factor! */ - newlen -= newlen %sizeof (long ); - nrels = newlen /sizeof (long ); -if (copy_from_user (results, newval, newlen)) -return -EFAULT ; - -/* Get the new values back to the client */ -callback (client,SENSORS_PROC_REAL_WRITE , table->ctl_name, - &nrels, results); - } -return ret; -} - - -/* nrels contains initially the maximum number of elements which can be -put in results, and finally the number of elements actually put there. -A magnitude of 1 will multiply everything with 10; etc. -buffer, bufsize is the character buffer we read from and its length. -results will finally contain the parsed integers. - -Buffer should contain several reals, separated by whitespace. A real -has the following syntax: -[ Minus ] Digit* [ Dot Digit* ] -(everything between [] is optional; * means zero or more). -When the next character is unparsable, everything is skipped until the -next whitespace. - -WARNING! This is tricky code. I have tested it, but there may still be -hidden bugs in it, even leading to crashes and things! -*/ -static int i2c_parse_reals (int *nrels,void *buffer,int bufsize, -long *results,int magnitude) -{ -int maxels, min, mag; -long res,ret=0 ; -char nextchar =0 ; - - maxels = *nrels; - *nrels =0 ; - -while (bufsize && (*nrels < maxels)) { - -/* Skip spaces at the start */ -while (bufsize && - !((ret=get_user (nextchar, (char *) buffer))) && -isspace ((int ) nextchar)) { - bufsize--; - ((char *) buffer)++; - } - -if (ret) -return -EFAULT ; -/* Well, we may be done now */ -if (!bufsize) -return 0 ; - -/* New defaults for our result */ - min =0 ; - res =0 ; - mag = magnitude; - -/* Check for a minus */ -if (!((ret=get_user (nextchar, (char *) buffer))) - && (nextchar =='-' )) { - min =1 ; - bufsize--; - ((char *) buffer)++; - } -if (ret) -return -EFAULT ; - -/* Digits before a decimal dot */ -while (bufsize && - !((ret=get_user (nextchar, (char *) buffer))) && -isdigit ((int ) nextchar)) { - res = res *10 + nextchar -'0' ; - bufsize--; - ((char *) buffer)++; - } -if (ret) -return -EFAULT ; - -/* If mag < 0, we must actually divide here! */ -while (mag <0 ) { - res = res /10 ; - mag++; - } - -if (bufsize && (nextchar =='.' )) { -/* Skip the dot */ - bufsize--; - ((char *) buffer)++; - -/* Read digits while they are significant */ -while (bufsize && (mag >0 ) && - !((ret=get_user (nextchar, (char *) buffer))) && -isdigit ((int ) nextchar)) { - res = res *10 + nextchar -'0' ; - mag--; - bufsize--; - ((char *) buffer)++; - } -if (ret) -return -EFAULT ; - } -/* If we are out of data, but mag > 0, we need to scale here */ -while (mag >0 ) { - res = res *10 ; - mag--; - } - -/* Skip everything until we hit whitespace */ -while (bufsize && - !((ret=get_user (nextchar, (char *) buffer))) && -isspace ((int ) nextchar)) { - bufsize--; - ((char *) buffer)++; - } -if (ret) -return -EFAULT ; - -/* Put res in results */ - results[*nrels] = (min ?-1 :1 ) * res; - (*nrels)++; - } - -/* Well, there may be more in the buffer, but we need no more data. -Ignore anything that is left. */ -return 0 ; -} - -static int i2c_write_reals (int nrels,void *buffer,size_t *bufsize, -long *results,int magnitude) -{ -#define BUFLEN 20 -char BUF [BUFLEN +1 ];/* An individual representation should fit! */ -char printfstr[10 ]; -int nr =0 ; -int buflen, mag, times; -int curbufsize =0 ; - -while ((nr < nrels) && (curbufsize < *bufsize)) { - mag = magnitude; - -if (nr !=0 ) { -if (put_user (' ' , (char *) buffer)) -return -EFAULT ; - curbufsize++; - ((char *) buffer)++; - } - -/* Fill BUF with the representation of the next string */ -if (mag <=0 ) { - buflen =sprintf (BUF ,"%ld" , results[nr]); -if (buflen <0 ) {/* Oops, a sprintf error! */ - *bufsize =0 ; -return -EINVAL ; - } -while ((mag <0 ) && (buflen <BUFLEN )) { -BUF [buflen++] ='0' ; - mag++; - } -BUF [buflen] =0 ; - }else { - times =1 ; -for (times =1 ; mag-- >0 ; times *=10 ); -if (results[nr] <0 ) { -BUF [0 ] ='-' ; - buflen =1 ; - }else - buflen =0 ; -strcpy (printfstr,"%ld.%0Xld" ); - printfstr[6 ] = magnitude +'0' ; - buflen += -sprintf (BUF + buflen, printfstr, -abs (results[nr]) / times, -abs (results[nr]) % times); -if (buflen <0 ) {/* Oops, a sprintf error! */ - *bufsize =0 ; -return -EINVAL ; - } - } - -/* Now copy it to the user-space buffer */ -if (buflen + curbufsize > *bufsize) - buflen = *bufsize - curbufsize; -if (copy_to_user (buffer,BUF , buflen)) -return -EFAULT ; - curbufsize += buflen; - (char *) buffer += buflen; - - nr++; - } -if (curbufsize < *bufsize) { -if (put_user ('\n' , (char *) buffer)) -return -EFAULT ; - curbufsize++; - } - *bufsize = curbufsize; -return 0 ; -} -/* Very inefficient for ISA detects, and won't work for 10-bit addresses! */ int i2c_detect(struct i2c_adapter *adapter,
@@ -703,26 +170,13 @@static int __init i2c_proc_init (void ) { -printk (KERN_INFO "i2c-proc.o version %s (%s)\n" ,I2C_VERSION ,I2C_DATE ); -if (! - (i2c_proc_header = -register_sysctl_table (i2c_proc,0 ))) { -printk (KERN_ERR "i2c-proc.o: error: sysctl interface not supported by kernel!\n" ); -return -EPERM ; - } - i2c_proc_header->ctl_table->child->de->owner =THIS_MODULE ;return 0 ; } static void __exit i2c_proc_exit(void) { -unregister_sysctl_table (i2c_proc_header); } -EXPORT_SYMBOL (i2c_register_entry); -EXPORT_SYMBOL (i2c_deregister_entry); -EXPORT_SYMBOL (i2c_proc_real); -EXPORT_SYMBOL (i2c_sysctl_real);EXPORT_SYMBOL (i2c_detect);MODULE_AUTHOR ("Frodo Looijaard <[email protected]>" );
include/linux/i2c-proc.h +0 -40
@@ -34,46 +34,6 @@#define SENSORS_PROC_REAL_READ 2#define SENSORS_PROC_REAL_WRITE 3 -/* These funcion reads or writes a 'real' value (encoded by the combination -of an integer and a magnitude, the last is the power of ten the value -should be divided with) to a /proc/sys directory. To use these functions, -you must (before registering the ctl_table) set the extra2 field to the -client, and the extra1 field to a function of the form: -void func(struct i2c_client *client, int operation, int ctl_name, -int *nrels_mag, long *results) -This last function can be called for three values of operation. If -operation equals SENSORS_PROC_REAL_INFO, the magnitude should be returned -in nrels_mag. If operation equals SENSORS_PROC_REAL_READ, values should -be read into results. nrels_mag should return the number of elements -read; the maximum number is put in it on entry. Finally, if operation -equals SENSORS_PROC_REAL_WRITE, the values in results should be -written to the chip. nrels_mag contains on entry the number of elements -found. -In all cases, client points to the client we wish to interact with, -and ctl_name is the SYSCTL id of the file we are accessing. */ -extern int i2c_sysctl_real (ctl_table * table,int *name,int nlen, -void *oldval,size_t * oldlenp, -void *newval,size_t newlen, -void **context); -extern int i2c_proc_real (ctl_table * ctl,int write,struct file *filp, -void *buffer,size_t * lenp); - - - -/* These rather complex functions must be called when you want to add or -delete an entry in /proc/sys/dev/sensors/chips (not yet implemented). It -also creates a new directory within /proc/sys/dev/sensors/. -ctl_template should be a template of the newly created directory. It is -copied in memory. The extra2 field of each file is set to point to client. -If any driver wants subdirectories within the newly created directory, -these functions must be updated! */ -extern int i2c_register_entry (struct i2c_client *client, -const char *prefix, -ctl_table * ctl_template); - -extern void i2c_deregister_entry (int id); - -/* A structure containing detect information. Force variables overrule all other variables; they force a detection on that place. If a specific chip is given, the module blindly assumes this
ChangeSet 1.977.29.9, 2003/04/02 11:48:13-08:00, [email protected]
i2c: remove unused paramater in found_proc callback function.
(the users of this function have already been changed in previous patches)
drivers/i2c/i2c-proc.c | 4 ++-- include/linux/i2c-proc.h | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/i2c/i2c-proc.c +2 -2
@@ -69,7 +69,7 @@ ((this_force->force[j] == SENSORS_ANY_I2C_BUS) && !is_isa)) && (addr == this_force->force[j + 1]) ) {dev_dbg (&adapter->dev,"found force parameter for adapter %d, addr %04x\n" , adapter_id, addr); -if ((err =found_proc (adapter, addr,0 , this_force->kind))) +if ((err =found_proc (adapter, addr, this_force->kind)))return err; found =1 ; }
@@ -162,7 +162,7 @@whether there is some client here at all! */ if (is_isa || (i2c_smbus_xfer (adapter, addr,0 ,0 ,0 ,I2C_SMBUS_QUICK ,NULL ) >=0 )) -if ((err =found_proc (adapter, addr,0 ,-1 ))) +if ((err =found_proc (adapter, addr,-1 )))return err; }return 0 ;
include/linux/i2c-proc.h +1 -2
@@ -328,8 +328,7 @@SENSORS_INSMOD typedef int i2c_found_addr_proc(struct i2c_adapter *adapter, -int addr,unsigned short flags, -int kind); +int addr,int kind);/* Detect function. It iterates over all possible addresses itself. For SMBus addresses, it will only call found_proc if some client is connected
ChangeSet 1.977.29.10, 2003/04/02 12:01:21-08:00, [email protected]
i2c: move i2c-proc to i2c-sensor and clean up all usages of it.
drivers/i2c/i2c-proc.c | 187 ---------------------- include/linux/i2c-proc.h | 373 -------------------------------------------- drivers/i2c/Kconfig | 11 - drivers/i2c/Makefile | 2 drivers/i2c/chips/Kconfig | 13 + drivers/i2c/chips/adm1021.c | 2 drivers/i2c/chips/lm75.c | 2 drivers/i2c/chips/via686a.c | 2 drivers/i2c/i2c-sensor.c | 182 +++++++++++++++++++++ include/linux/i2c-sensor.h | 373 ++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 568 insertions(+), 579 deletions(-)
drivers/i2c/Kconfig +0 -11
@@ -196,17 +196,6 @@ <file:Documentation/modules.txt>. The module will be called i2c-dev. -config I2C_PROC - tristate "I2C /proc interface (required for hardware sensors)" - depends on I2C && SYSCTL - help - This provides support for i2c device entries in the /proc filesystem. - The entries will be found in /proc/sys/dev/sensors. - - This code is also available as a module. If you want to compile - it as a module, say M here and read <file:Documentation/modules.txt>. - The module will be called i2c-proc. - source drivers/i2c/busses/Kconfig source drivers/i2c/chips/Kconfig
drivers/i2c/Makefile +1 -1
@@ -14,5 +14,5 @@ obj-$(CONFIG_ITE_I2C_ADAP) += i2c-adap-ite.o obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o obj-$(CONFIG_SCx200_ACB) += scx200_acb.o -obj-$(CONFIG_I2C_PROC) += i2c-proc.o +obj-$(CONFIG_I2C_SENSOR) += i2c-sensor.o obj-y += busses/ chips/
drivers/i2c/chips/Kconfig +9 -4
@@ -1,13 +1,13 @@ # # Sensor device configuration -# All depend on EXPERIMENTAL, I2C and I2C_PROC. +# All depend on EXPERIMENTAL and I2C # menu "I2C Hardware Sensors Chip support" config SENSORS_ADM1021 tristate " Analog Devices ADM1021 and compatibles" - depends on I2C && I2C_PROC + depends on I2C && EXPERIMENTAL help If you say yes here you get support for Analog Devices ADM1021 and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
@@ -24,7 +24,7 @@ config SENSORS_LM75 tristate " National Semiconductors LM75 and compatibles" - depends on I2C && I2C_PROC + depends on I2C && EXPERIMENTAL help If you say yes here you get support for National Semiconductor LM75 sensor chips and clones: Dallas Semi DS75 and DS1775, TelCon
@@ -39,7 +39,7 @@ config SENSORS_VIA686A tristate " VIA686A" - depends on I2C && I2C_PROC + depends on I2C && EXPERIMENTAL help support for via686a If you say yes here you get support for the integrated sensors in
@@ -49,5 +49,10 @@ You will also need the latest user-space utilties: you can find them in the lm_sensors package, which you can download at http://www.lm-sensors.nu + +config I2C_SENSOR + tristate + depends on SENSORS_ADM1021 || SENSORS_LM75 || SENSORS_VIA686A + default m endmenu
drivers/i2c/chips/adm1021.c +1 -1
@@ -23,7 +23,7 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-proc.h> +#include <linux/i2c-sensor.h> /* Registers */
drivers/i2c/chips/lm75.c +1 -1
@@ -24,7 +24,7 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-proc.h> +#include <linux/i2c-sensor.h> /* Addresses to scan */
drivers/i2c/chips/via686a.c +1 -1
@@ -36,7 +36,7 @@#include <linux/pci.h> #include <linux/delay.h> #include <linux/i2c.h> -#include <linux/i2c-proc.h> +#include <linux/i2c-sensor.h> #include <linux/init.h> #include <asm/io.h>
drivers/i2c/i2c-proc.c deleted +0 -187
187 lines not on this page · raw message
drivers/i2c/i2c-sensor.c new file +182 -0
182 lines not on this page · raw message
include/linux/i2c-proc.h deleted +0 -373
373 lines not on this page · raw message
include/linux/i2c-sensor.h new file +373 -0
373 lines not on this page · raw message
ChangeSet 1.977.29.11, 2003/04/02 13:54:45-08:00, [email protected]
i2c: remove all proc code from the i2c core, as it's no longer needed.
drivers/i2c/i2c-core.c | 187 ------------------------------------------------- 1 files changed, 1 insertion(+), 186 deletions(-)
drivers/i2c/i2c-core.c +1 -186
@@ -29,7 +29,6 @@#include <linux/kernel.h> #include <linux/errno.h> #include <linux/slab.h> -#include <linux/proc_fs.h> #include <linux/i2c.h> #include <linux/init.h> #include <linux/seq_file.h>
@@ -46,15 +45,6 @@/**** debug level */ static int i2c_debug; -#ifdef CONFIG_PROC_FS -static int i2cproc_register (struct i2c_adapter *adap,int bus); -static void i2cproc_remove (int bus); -#else -# define i2cproc_register (adap, bus) 0 -# define i2cproc_remove (bus) do { } while (0) -#endif /* CONFIG_PROC_FS */ - -int i2c_device_probe (struct device *dev) {return -ENODEV ;
@@ -98,10 +88,6 @@ goto out_unlock; } - res =i2cproc_register (adap, i); -if (res) - goto out_unlock; - adapters[i] = adap;init_MUTEX (&adap->bus);
@@ -180,8 +166,6 @@ } } -i2cproc_remove (i); -/* clean up the sysfs representation */ device_unregister (&adap->dev);
@@ -495,173 +479,6 @@return 0 ; } -#ifdef CONFIG_PROC_FS -/* This function generates the output for /proc/bus/i2c-? */ -static ssize_t i2cproc_bus_read (struct file *file,char *buf, -size_t count,loff_t *ppos) -{ -struct inode *inode = file->f_dentry->d_inode; -char *kbuf; -struct i2c_client *client; -int i,j,k,order_nr,len=0 ; -size_t len_total; -int order[I2C_CLIENT_MAX ]; -#define OUTPUT_LENGTH_PER_LINE 70 - - len_total = file->f_pos + count; -if (len_total > (I2C_CLIENT_MAX *OUTPUT_LENGTH_PER_LINE ) ) -/* adjust to maximum file size */ - len_total = (I2C_CLIENT_MAX *OUTPUT_LENGTH_PER_LINE ); -for (i =0 ; i <I2C_ADAP_MAX ; i++) -if (adapters[i]->inode == inode->i_ino) { -/* We need a bit of slack in the kernel buffer; this makes the -sprintf safe. */ -if (! (kbuf =kmalloc (len_total + -OUTPUT_LENGTH_PER_LINE , -GFP_KERNEL ))) -return -ENOMEM ; -/* Order will hold the indexes of the clients -sorted by address */ - order_nr=0 ; -for (j =0 ; j <I2C_CLIENT_MAX ; j++) { -if ((client = adapters[i]->clients[j]) && - (client->driver->id !=I2C_DRIVERID_I2CDEV )) { -for (k = order_nr; - (k >0 ) && - adapters[i]->clients[order[k-1 ]]-> - addr > client->addr; - k--) - order[k] = order[k-1 ]; - order[k] = j; - order_nr++; - } - } - - -for (j =0 ; (j < order_nr) && (len < len_total); j++) { - client = adapters[i]->clients[order[j]]; - len +=sprintf (kbuf+len,"%02x\t%-32s\t%-32s\n" , - client->addr, - client->dev.name, - client->driver->name); - } - len = len - file->f_pos; -if (len > count) - len = count; -if (len <0 ) - len =0 ; -if (copy_to_user (buf,kbuf+file->f_pos, len)) { -kfree (kbuf); -return -EFAULT ; - } - file->f_pos += len; -kfree (kbuf); -return len; - } -return -ENOENT ; -} - -static struct file_operations i2cproc_operations = { - .read = i2cproc_bus_read, -}; - -/* This function generates the output for /proc/bus/i2c */ -static int bus_i2c_show (struct seq_file *s,void *p) -{ -int i; - -down (&core_lists); -for (i =0 ; i <I2C_ADAP_MAX ; i++) { -struct i2c_adapter *adapter = adapters[i]; - -if (!adapter) -continue ; - -seq_printf (s,"i2c-%d\t" , i); - -if (adapter->algo->smbus_xfer) { -if (adapter->algo->master_xfer) -seq_printf (s,"smbus/i2c" ); -else -seq_printf (s,"smbus " ); - }else if (adapter->algo->master_xfer) -seq_printf (s ,"i2c " ); -else -seq_printf (s,"dummy " ); - -seq_printf (s,"\t%-32s\t%-32s\n" , - adapter->dev.name, adapter->algo->name); - } -up (&core_lists); - -return 0 ; -} - -static int bus_i2c_open (struct inode *inode,struct file *file) -{ -return single_open (file, bus_i2c_show,NULL ); -} - -static struct file_operations bus_i2c_fops = { - .open = bus_i2c_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - }; - -static int i2cproc_register (struct i2c_adapter *adap,int bus) -{ -struct proc_dir_entry *proc_entry; -char name[8 ]; - -sprintf (name,"i2c-%d" , bus); - - proc_entry =create_proc_entry (name,0 , proc_bus); -if (!proc_entry) - goto fail; - - proc_entry->proc_fops = &i2cproc_operations; - proc_entry->owner = adap->owner; - adap->inode = proc_entry->low_ino; -return 0 ; - fail: -printk (KERN_ERR "i2c-core.o: Could not create /proc/bus/%s\n" , name); -return -ENOENT ; -} - -static void i2cproc_remove (int bus) -{ -char name[8 ]; - -sprintf (name,"i2c-%d" , bus); -remove_proc_entry (name, proc_bus); -} - -static int __init i2cproc_init (void ) -{ -struct proc_dir_entry *proc_bus_i2c; - - proc_bus_i2c =create_proc_entry ("i2c" ,0 , proc_bus); -if (!proc_bus_i2c) - goto fail; - proc_bus_i2c->proc_fops = &bus_i2c_fops; - proc_bus_i2c->owner =THIS_MODULE ; -return 0 ; - - fail: -printk (KERN_ERR "i2c-core.o: Could not create /proc/bus/i2c" ); -return -ENOENT ; -} - -static void __exit i2cproc_cleanup(void) -{ -remove_proc_entry ("i2c" ,proc_bus); -} -#else -static int __init i2cproc_init (void ) {return 0 ; } -static void __exit i2cproc_cleanup(void) { } -#endif /* CONFIG_PROC_FS */ -/* match always succeeds, as we want the probe() to tell if we really accept this match */ static int i2c_device_match (struct device *dev,struct device_driver *drv) {
@@ -676,13 +493,11 @@static int __init i2c_init (void ) { -bus_register (&i2c_bus_type); -return i2cproc_init (); +return bus_register (&i2c_bus_type); } static void __exit i2c_exit(void) { -i2cproc_cleanup ();bus_unregister (&i2c_bus_type); }
ChangeSet 1.977.29.12, 2003/04/02 14:07:40-08:00, [email protected]
[PATCH] i2c: w83781d i2c driver updated for 2.5.66-bk4 (with sysfs support, empty tree)
This should have a working w83781d driver updated for 2.5.66-bk4. Currently sysfs support is working, and are according to the spec (sensors-sysfs) in the 'lm sensors sysfs file structure' thread. Thus I used 'temp_input[1-3]', as there was not final decision on having them temp_input[0-2] as well, for example.
drivers/i2c/chips/Kconfig | 14 drivers/i2c/chips/w83781d.c | 1884 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/i2c-vid.h | 62 + 3 files changed, 1960 insertions(+)
drivers/i2c/chips/Kconfig +14 -0
@@ -36,6 +36,20 @@ You will also need the latest user-space utilties: you can find them in the lm_sensors package, which you can download at http://www.lm-sensors.nu + +config SENSORS_W83781D + tristate " Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" + depends on I2C && I2C_PROC + help + If you say yes here you get support for the Winbond W8378x series + of sensor chips: the W83781D, W83782D, W83783S and W83682HF, + and the similar Asus AS99127F. This + can also be built as a module which can be inserted and removed + while the kernel is running. + + You will also need the latest user-space utilties: you can find them + in the lm_sensors package, which you can download at + http://www.lm-sensors.nu config SENSORS_VIA686A tristate " VIA686A"
drivers/i2c/chips/w83781d.c new file +1884 -0
1,884 lines not on this page · raw message
include/linux/i2c-vid.h new file +62 -0
62 lines not on this page · raw message
ChangeSet 1.977.29.13, 2003/04/02 14:18:09-08:00, [email protected]
i2c: clean up previous w83781d patch due to changes I made to i2c core and build.
drivers/i2c/chips/Kconfig | 30 +++++++++++++++--------------- drivers/i2c/chips/Makefile | 1 + drivers/i2c/chips/w83781d.c | 8 +++----- include/linux/i2c-vid.h | 4 ++-- 4 files changed, 21 insertions(+), 22 deletions(-)
drivers/i2c/chips/Kconfig +15 -15
@@ -37,20 +37,6 @@ in the lm_sensors package, which you can download at http://www.lm-sensors.nu -config SENSORS_W83781D - tristate " Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" - depends on I2C && I2C_PROC - help - If you say yes here you get support for the Winbond W8378x series - of sensor chips: the W83781D, W83782D, W83783S and W83682HF, - and the similar Asus AS99127F. This - can also be built as a module which can be inserted and removed - while the kernel is running. - - You will also need the latest user-space utilties: you can find them - in the lm_sensors package, which you can download at - http://www.lm-sensors.nu - config SENSORS_VIA686A tristate " VIA686A" depends on I2C && EXPERIMENTAL
@@ -64,9 +50,23 @@ in the lm_sensors package, which you can download at http://www.lm-sensors.nu +config SENSORS_W83781D + tristate " Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" + depends on I2C && EXPERIMENTAL + help + If you say yes here you get support for the Winbond W8378x series + of sensor chips: the W83781D, W83782D, W83783S and W83682HF, + and the similar Asus AS99127F. This + can also be built as a module which can be inserted and removed + while the kernel is running. + + You will also need the latest user-space utilties: you can find them + in the lm_sensors package, which you can download at + http://www.lm-sensors.nu + config I2C_SENSOR tristate - depends on SENSORS_ADM1021 || SENSORS_LM75 || SENSORS_VIA686A + depends on SENSORS_ADM1021 || SENSORS_LM75 || SENSORS_VIA686A || SENSORS_W83781D default m endmenu
drivers/i2c/chips/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o obj-$(CONFIG_SENSORS_LM75) += lm75.o obj-$(CONFIG_SENSORS_VIA686A) += via686a.o +obj-$(CONFIG_SENSORS_W83781D) += w83781d.o
drivers/i2c/chips/w83781d.c +3 -5
@@ -38,7 +38,7 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> -#include <linux/i2c-proc.h> +#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <asm/io.h>
@@ -332,8 +332,7 @@ };static int w83781d_attach_adapter (struct i2c_adapter *adapter); -static int w83781d_detect (struct i2c_adapter *adapter,int address, -unsigned short flags,int kind); +static int w83781d_detect (struct i2c_adapter *adapter,int address,int kind);static int w83781d_detach_client (struct i2c_client *client);static int w83781d_read_value (struct i2c_client *client,u16 register);
@@ -1031,8 +1030,7 @@ }static int -w83781d_detect (struct i2c_adapter *adapter,int address, -unsigned short flags,int kind) +w83781d_detect (struct i2c_adapter *adapter,int address,int kind) {int i =0 , val1 =0 , val2, id;struct i2c_client *new_client;
include/linux/i2c-vid.h +2 -2
@@ -1,6 +1,6 @@/* -vrm.c - Part of lm_sensors, Linux kernel modules for hardware -monitoring +i2c-vid.h - Part of lm_sensors, Linux kernel modules for hardware +monitoring Copyright (c) 2002 Mark D. Studebaker <[email protected]> With assistance from Trent Piepho <[email protected]>
ChangeSet 1.1009, 2003/04/02 15:36:11-08:00, [email protected]
i2c: fix up broken drivers/i2c/busses build due to I2C_PROC now being gone.
drivers/i2c/busses/Kconfig | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-)
drivers/i2c/busses/Kconfig +6 -7
@@ -1,13 +1,12 @@ # # Sensor device configuration -# All depend on EXPERIMENTAL, I2C and I2C_PROC. # menu "I2C Hardware Sensors Mainboard support" config I2C_ALI15X3 tristate " ALI 15x3" - depends on I2C && I2C_PROC && PCI && EXPERIMENTAL + depends on I2C && PCI && EXPERIMENTAL help If you say yes to this option, support will be included for the Acer Labs Inc. (ALI) M1514 and M1543 motherboard I2C interfaces.
@@ -21,7 +20,7 @@ config I2C_AMD756 tristate " AMD 756/766" - depends on I2C && I2C_PROC + depends on I2C && EXPERIMENTAL help If you say yes to this option, support will be included for the AMD 756/766/768 mainboard I2C interfaces.
@@ -38,7 +37,7 @@ config I2C_AMD8111 tristate " AMD 8111" - depends on I2C && I2C_PROC + depends on I2C && EXPERIMENTAL help If you say yes to this option, support will be included for the AMD 8111 mainboard I2C interfaces.
@@ -55,7 +54,7 @@ config I2C_I801 tristate " Intel 801" - depends on I2C && I2C_PROC && PCI && EXPERIMENTAL + depends on I2C && PCI && EXPERIMENTAL help If you say yes to this option, support will be included for the Intel 801 family of mainboard I2C interfaces. Specifically, the following
@@ -78,7 +77,7 @@ config I2C_ISA tristate " ISA Bus support" - depends on I2C && I2C_PROC && ISA && EXPERIMENTAL + depends on I2C && ISA && EXPERIMENTAL help If you say yes to this option, support will be included for i2c interfaces that are on the ISA bus.
@@ -96,7 +95,7 @@ config I2C_PIIX4 tristate " Intel PIIX4" - depends on I2C && I2C_PROC && PCI && EXPERIMENTAL + depends on I2C && PCI && EXPERIMENTAL help If you say yes to this option, support will be included for the Intel PIIX4 family of mainboard I2C interfaces. Specifically, the following
ChangeSet 1.1010, 2003/04/02 15:39:28-08:00, [email protected]
i2c: remove old proc documentation and add sysfs file documentation
Documentation/i2c/proc-interface | 53 ----------- Documentation/i2c/sysfs-interface | 177 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 53 deletions(-)
Documentation/i2c/proc-interface deleted +0 -53
@@ -1,53 +0,0 @@ -i2c-core is the core i2c module (surprise!) which offers general routines on -which other modules build. You will find that all i2c-related modules depend -on this module, so it will (need to) be loaded whenever another i2c-related -module is loaded. Seen from the outside, the most interesting is the /proc -interface. Note that there is no corresponding sysctl interface! - -/proc/bus/i2c -============= - -Whenever i2c-core is loaded, you will find a file /proc/bus/i2c, which lists -all currently registered I2C adapters. Each line contains exactly one -I2C adapter. Each line has the following format: "i2c-%d\t%9s\t%-32s't%-32s\n", -which works out to four columns separated by tabs. Note that the file -will be empty, if no adapters are registered at all. - -Adapters are numbered from 0 upwards. The first column contains the number -of the adapter, for example "i2c-4" for adapter 4. The name listed is also -the name of the /proc file which lists all devices attached to it, and -of the /dev file which corresponds to this adapter. - -The second column documents what kind of adapter this is. Some adapters -understand the full I2C protocol, others only a subset called SMBus, -and yet others are some kind of pseudo-adapters that do not understand -i2c at all. Possible values in here are "i2c", "smbus", "i2c/smbus" -and "dummy". Because the SMBus protocol can be fully emulated by i2c -adapters, if you see "i2c" here, SMBus is supported too. There may -be some future adapters which support both specific SMBus commands and -general I2C, and they will display "i2c/smbus". - -The third and fourth column are respectively the algorithm and adapter -name of this adapter. Each adapter is associated with an algorithm, -and several adapters can share the same algorithm. The combination of -algorithm name and adapter name should be unique for an adapter, but -you can't really count on that yet. - - -/proc/bus/i2c-* -=============== - -Each registered adapter gets its own file in /proc/bus/, which lists -the devices registered to the adapter. Each line in such a file contains -one registered device. Each line has the following format: -"%02x\t%-32s\t%-32s\n", which works out to three columns separated by -tabs. Note that this file can be empty, if no devices are found on -the adapter. - -The first column contains the (hexadecimal) address of the client. As -only 7-bit addresses are supported at this moment, two digits are -enough. - -The second and third column are respectively the client name and the -driver name of this client. Each client is associated with a driver, -and several clients can share the same driver.
Documentation/i2c/sysfs-interface new file +177 -0
177 lines not on this page · raw message
I read the thread concerning the removal of proc.c & proc.h but hope that this does not go to Linus until the interface between i2c & sensors to application is somewhat defined.
At the moment we have a sysctl API used by sensors, video and other i2c kernel applications that is working.
Our desire to switch the sensors to sysfs interface should not break other applications. At least until we have a model/api to propose to these other drivers.
In my personal home systems I use it87 driver and have been somewhat successful in switching to sysfs. A big blocking point is there is no application to read/set/monitor the driver, so it is basically unverified. I would hate to put other i2c applications in the same boat.
Your thoughts?
Albert
Quoted 4 lines · Greg KH
ChangeSet 1.977.29.8, 2003/04/02 11:45:21-08:00, [email protected]
i2c: remove proc and sysctl code from i2c-proc as it is no longer used.
Quoted 6 lines · Albert Cranford
I read the thread concerning the removal of
proc.c&proc.hbut hope that this does not go to Linus until the interface between i2c & sensors to application is somewhat defined.At the moment we have a sysctl API used by sensors, video and other i2c kernel applications that is working.
The only in-kernel drivers that were using the sysctl/proc interface was the lm75 and adm1021 drivers. The video and other i2c kernel drivers do not use this interface at all.
Those two drivers, and the two other chip drivers that I added to the kernel in this set of patches were converted over to the sysfs interface (well one of the new ones were, the other one will build and run, but doesn't export any sysfs files yet, that will change soon.)
Quoted 3 lines
Our desire to switch the sensors to sysfs interface should not break other applications. At least until we have a model/api to propose to these other drivers.
Yes, any applications that used the sysctl interface to get data from those two driver will break. However we have to switch at some point in time, and the userspace library can't be worked on very well if the kernel can't support it yet :)
So I'm choosing to update the kernel first, and will be working on the library in the coming weeks. As there is no real sensors support besides those two drivers in the main kernel, I didn't break much :)
Quoted 4 lines
In my personal home systems I use it87 driver and have been somewhat successful in switching to sysfs. A big blocking point is there is no application to read/set/monitor the driver, so it is basically unverified.
I tested the changes I did by using echo and cat, no library or other applications are needed just yet.
thanks,
greg k-h
Your right, nobody outside of sensors uses i2c-proc, but why not create a new i2c-sysfs.h in drivers/i2c locally and and adjust the couple of existing drivers. We all know the application library is not going to have access to include/linux/include/i2c-xxxx.h anyhow.
Later we can completely remove linux/include/linux/i2c-proc.h which the existing application library relies upon. ALbert
Quoted 49 lines · Greg KH
Quoted 6 lines · Albert Cranford
I read the thread concerning the removal of
proc.c&proc.hbut hope that this does not go to Linus until the interface between i2c & sensors to application is somewhat defined.At the moment we have a sysctl API used by sensors, video and other i2c kernel applications that is working.
The only in-kernel drivers that were using the sysctl/proc interface was the lm75 and adm1021 drivers. The video and other i2c kernel drivers do not use this interface at all.
Those two drivers, and the two other chip drivers that I added to the kernel in this set of patches were converted over to the sysfs interface (well one of the new ones were, the other one will build and run, but doesn't export any sysfs files yet, that will change soon.)
Quoted 3 lines
Our desire to switch the sensors to sysfs interface should not break other applications. At least until we have a model/api to propose to these other drivers.
Yes, any applications that used the sysctl interface to get data from those two driver will break. However we have to switch at some point in time, and the userspace library can't be worked on very well if the kernel can't support it yet :)
So I'm choosing to update the kernel first, and will be working on the library in the coming weeks. As there is no real sensors support besides those two drivers in the main kernel, I didn't break much :)
Quoted 4 lines
In my personal home systems I use it87 driver and have been somewhat successful in switching to sysfs. A big blocking point is there is no application to read/set/monitor the driver, so it is basically unverified.
I tested the changes I did by using echo and cat, no library or other applications are needed just yet.
thanks,
greg k-h
Quoted 3 lines · Albert Cranford
Your right, nobody outside of sensors uses i2c-proc, but why not create a new
i2c-sysfs.hindrivers/i2clocally and and adjust the couple of existing drivers.
What would i2c-sysfs.h be needed for? All of the needed sysfs prototype functions are already in device.h.
Quoted 2 lines
We all know the application library is not going to have access to
include/linux/include/i2c-xxxx.hanyhow.
It never did :)
Quoted 2 lines
Later we can completely remove
linux/include/linux/i2c-proc.hwhich the existing application library relies upon.
No userspace program should rely on kernel header files. And I didn't take away the functionality that i2c-proc.h provided with the list of devices supported and such. Just the unused function prototypes that dealt with the proc and sysctl interface.
thanks,
greg k-h