I2C: Separate non-i2c hwmon drivers from i2c-core (0/9)
Subsystems (10)
PATCH 1/1 I2C: Separate non-i2c hwmon drivers from i2c-core (0/9)
Hi all,
This is a set of patches for review and comments. The aim is to start separating a number of hardware monitoring drivers from the i2c subsystem. Hardware monitoring (or sensors) have a long history of being registered with the i2c subsystem even when they are not I2C (nor SMBus) devices. This adds artificial dependencies between various kernel drivers, is reponsible for some weird code, and prevents us from cleaning up some code in the i2c subsystem. For all these reasons, I would like to separate non-I2C hardware monitoring drivers from the i2c core.
This will be a multistep process, as we need to keep all the drivers working and to preserve user-space compatibility (most notably with libsensors) while cleaning up the various parts which need be.
This patchset constitutes the first big step, and is made up of 9 patches, to be applied in order. Individual patches follow, each with comments and diffstat.
Andrew, please don't pick this for -mm yet. It'll hopefully come to you through Greg's i2c tree when it is ready.
Additional notes:
* Stats (debugging disabled)
before after diff
# I2C-only drivers
drivers/hwmon/adm1021.ko 16855 16820 -35 drivers/hwmon/adm1025.ko 21677 21642 -35 drivers/hwmon/adm1026.ko 41379 41344 -35 drivers/hwmon/adm1031.ko 23071 23036 -35 drivers/hwmon/adm9240.ko 21338 21303 -35 drivers/hwmon/asb100.ko 27512 27445 -67 drivers/hwmon/atxp1.ko 10410 10375 -35 drivers/hwmon/ds1621.ko 9970 9903 -67 drivers/hwmon/fscher.ko 19333 19298 -35 drivers/hwmon/fscpos.ko 19192 19157 -35 drivers/hwmon/gl518sm.ko 21011 20976 -35 drivers/hwmon/gl520sm.ko 23552 23517 -35 drivers/hwmon/lm63.ko 12532 12497 -35 drivers/hwmon/lm75.ko 9382 9347 -35 drivers/hwmon/lm77.ko 11666 11631 -35 drivers/hwmon/lm80.ko 22552 22517 -35 drivers/hwmon/lm83.ko 10146 10111 -35 drivers/hwmon/lm85.ko 41069 41034 -35 drivers/hwmon/lm87.ko 25868 25833 -35 drivers/hwmon/lm90.ko 15511 15458 -53 drivers/hwmon/lm92.ko 12072 12037 -35 drivers/hwmon/max1619.ko 10995 10960 -35 drivers/hwmon/w83l785ts.ko 8513 8478 -35 drivers/i2c/chips/ds1337.ko 8800 8765 -35 drivers/i2c/chips/eeprom.ko 8331 8296 -35 drivers/i2c/chips/max6875.ko 10460 10425 -35 drivers/i2c/chips/pca9539.ko 7981 7946 -35 drivers/i2c/chips/pcf8574.ko 8260 8225 -35 drivers/i2c/chips/pcf8591.ko 9798 9763 -35
# hybrid drivers drivers/hwmon/it87.ko 25924 26563 +639 drivers/hwmon/lm78.ko 21781 22420 +639 drivers/hwmon/w83781d.ko 39132 39745 +613
# ISA-only drivers
drivers/hwmon/pc87360.ko 48007 47734 -273 drivers/hwmon/sis5595.ko 20257 17401 -2856 drivers/hwmon/smsc47b397.ko 7422 7122 -300 drivers/hwmon/smsc47m1.ko 11330 11080 -250 drivers/hwmon/via686a.ko 22922 20066 -2856 drivers/hwmon/w83627ehf.ko 19155 16255 -2900 drivers/hwmon/w83627hf.ko 35861 30955 -4906
# core modules drivers/i2c/busses/i2c-isa.ko 2991 5685 +2694 drivers/i2c/i2c-core.ko 21257 21805 +548 drivers/i2c/i2c-sensor.ko 4057 3767 -290
total -10595
Documentation/i2c/porting-clients | 7 - Documentation/i2c/writing-clients | 46 ++++------- drivers/hwmon/Kconfig | 3 drivers/hwmon/adm1021.c | 10 -- drivers/hwmon/adm1025.c | 1 drivers/hwmon/adm1026.c | 1 drivers/hwmon/adm1031.c | 1 drivers/hwmon/adm9240.c | 2 drivers/hwmon/asb100.c | 11 -- drivers/hwmon/atxp1.c | 1 drivers/hwmon/ds1621.c | 1 drivers/hwmon/fscher.c | 1 drivers/hwmon/fscpos.c | 1 drivers/hwmon/gl518sm.c | 1 drivers/hwmon/gl520sm.c | 1 drivers/hwmon/it87.c | 42 ++++++++-- drivers/hwmon/lm63.c | 1 drivers/hwmon/lm75.c | 11 -- drivers/hwmon/lm77.c | 1 drivers/hwmon/lm78.c | 37 +++++++- drivers/hwmon/lm80.c | 1 drivers/hwmon/lm83.c | 1 drivers/hwmon/lm85.c | 6 - drivers/hwmon/lm87.c | 1 drivers/hwmon/lm90.c | 1 drivers/hwmon/lm92.c | 1 drivers/hwmon/max1619.c | 1 drivers/hwmon/pc87360.c | 43 ++-------- drivers/hwmon/sis5595.c | 46 ++--------- drivers/hwmon/smsc47b397.c | 53 +++--------- drivers/hwmon/smsc47m1.c | 47 ++--------- drivers/hwmon/via686a.c | 46 ++--------- drivers/hwmon/w83627ehf.c | 40 ++------- drivers/hwmon/w83627hf.c | 54 +++--------- drivers/hwmon/w83781d.c | 37 +++++++- drivers/hwmon/w83l785ts.c | 1 drivers/i2c/busses/Kconfig | 8 - drivers/i2c/busses/i2c-isa.c | 158 +++++++++++++++++++++++++++++++++++--- drivers/i2c/chips/ds1337.c | 1 drivers/i2c/chips/eeprom.c | 1 drivers/i2c/chips/max6875.c | 1 drivers/i2c/chips/pca9539.c | 1 drivers/i2c/chips/pcf8574.c | 1 drivers/i2c/chips/pcf8591.c | 1 drivers/i2c/i2c-core.c | 14 ++- drivers/i2c/i2c-sensor-detect.c | 45 +++------- include/linux/i2c-isa.h | 36 ++++++++ include/linux/i2c-sensor.h | 36 +++----- include/linux/i2c.h | 22 ++--- 49 files changed, 448 insertions(+), 436 deletions(-)
These stats are not necessarily very impressive by themselves, as i2c-isa and i2c-core both increase in size quite significantly, and so do the hybrid drivers. However this changeset opens possibilities to many other cleanups in the future, including dropping i2c-isa altogether (which will revert all the losses on i2c-core and i2c-isa), merging i2c_probe and i2c_detect (100 lines of code) and reworking the way i2c module parameters are handled (150 lines of ugly macros).
The size shrink of the ISA-only drivers is nice already. The loss on hybrid drivers isn't very significant as this is a rare case, and even it87 may become an ISA-only driver in the long run.
* ISA drivers are still registered with the i2c subsystem at the moment, even if not as directly as before. This is a requirement as long as user-space tools (libsensors) are not taught to search for hardware monitoring drivers in /sys/class/hwmon rather than /sys/bus/i2c. I'll work on that in parallel. In the long run, we really want these drivers to be completely independant from the i2c subsystem, and this patchset is a step in this direction, even if it might not be obvious at first sight.
* Each hybrid driver could be split in three parts, one I2C part, one ISA part and one common part. This would make things cleaner and would suppress some artificial dependencies. There is little value in doing so right now though, as the ISA part would still depend on i2c-core. Doing so would also break compatibility with user-space (not by much but still). Not sure what we want to do here as there are only three (or even two) such drivers and there is a significant work to split them.
* i2c-isa could have been moved to drivers/hwmon or drivers/i2c as it is no more an i2c bus driver (it never really has been), but I chose not to do it because in the long run this module will disappear anyway - so why bother?
Thanks,
Signature · 1 line
Jean Delvare
PATCH 1/1 I2C: Separate non-i2c hwmon drivers from i2c-core (1/9)
Temporarily export a few structures and functions from i2c-core, because we will soon need them in i2c-isa.
drivers/i2c/i2c-core.c | 14 ++++++++++---- include/linux/i2c.h | 7 +++++++ 2 files changed, 17 insertions(+), 4 deletions(-)
drivers/i2c/i2c-core.c +10 -4
@@ -61,7 +61,7 @@return rc; } -static struct bus_type i2c_bus_type = { +struct bus_type i2c_bus_type = { .name ="i2c" , .match = i2c_device_match, .suspend = i2c_bus_suspend,
@@ -78,13 +78,13 @@return 0 ; } -static void i2c_adapter_dev_release (struct device *dev) +void i2c_adapter_dev_release (struct device *dev) {struct i2c_adapter *adap =dev_to_i2c_adapter (dev);complete (&adap->dev_released); } -static struct device_driver i2c_adapter_driver = { +struct device_driver i2c_adapter_driver = { .name ="i2c_adapter" , .bus = &i2c_bus_type, .probe = i2c_device_probe,
@@ -97,7 +97,7 @@complete (&adap->class_dev_released); } -static struct class i2c_adapter_class = { +struct class i2c_adapter_class = { .name ="i2c-adapter" , .release = &i2c_adapter_class_dev_release, };
@@ -1171,6 +1171,12 @@ } +/* Next four are needed by i2c-isa */ +EXPORT_SYMBOL (i2c_adapter_dev_release); +EXPORT_SYMBOL (i2c_adapter_driver); +EXPORT_SYMBOL (i2c_adapter_class); +EXPORT_SYMBOL (i2c_bus_type); +EXPORT_SYMBOL (i2c_add_adapter);EXPORT_SYMBOL (i2c_del_adapter);EXPORT_SYMBOL (i2c_add_driver);
include/linux/i2c.h +7 -0
@@ -34,6 +34,13 @@#include <linux/device.h> /* for struct device */ #include <asm/semaphore.h> +/* --- For i2c-isa ---------------------------------------------------- */ + +extern void i2c_adapter_dev_release (struct device *dev); +extern struct device_driver i2c_adapter_driver; +extern struct class i2c_adapter_class; +extern struct bus_type i2c_bus_type; +/* --- General options ------------------------------------------------ */ struct i2c_msg ;
Signature · 1 line
Jean Delvare
Re: [PATCH 2.6] I2C: Separate non-i2c hwmon drivers from i2c-core (1/9)
drivers/i2c/i2c-core.c line 1178
Quoted 5 lines · Jean Delvare
drivers/i2c/i2c-core.c +5
-0+/* Next four are needed by i2c-isa */ +EXPORT_SYMBOL (i2c_adapter_dev_release); +EXPORT_SYMBOL (i2c_adapter_driver); +EXPORT_SYMBOL (i2c_adapter_class); +EXPORT_SYMBOL (i2c_bus_type);
EXPORT_SYMBOL_GPL() instead? As these were, core, GPL only symbols before you exported them.
thanks,
greg k-h
Re: [PATCH 2.6] I2C: Separate non-i2c hwmon drivers from i2c-core (1/9)
Hi Greg,
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+/* Next four are needed by i2c-isa */ +EXPORT_SYMBOL(i2c_adapter_dev_release); +EXPORT_SYMBOL(i2c_adapter_driver); +EXPORT_SYMBOL(i2c_adapter_class); +EXPORT_SYMBOL(i2c_bus_type);
EXPORT_SYMBOL_GPL()instead? As these were, core, GPL only symbols before you exported them.
Sure, no problem. I would even use EXPORT_SYMBOL_I2C_ISA_ONLY() if it happened to exist ;)
Updated patch follows, thanks.
Temporarily export a few structures and functions from i2c-core, because we will soon need them in i2c-isa.
drivers/i2c/i2c-core.c | 14 ++++++++++---- include/linux/i2c.h | 7 +++++++ 2 files changed, 17 insertions(+), 4 deletions(-)
drivers/i2c/i2c-core.c +10 -4
@@ -61,7 +61,7 @@return rc; } -static struct bus_type i2c_bus_type = { +struct bus_type i2c_bus_type = { .name ="i2c" , .match = i2c_device_match, .suspend = i2c_bus_suspend,
@@ -78,13 +78,13 @@return 0 ; } -static void i2c_adapter_dev_release (struct device *dev) +void i2c_adapter_dev_release (struct device *dev) {struct i2c_adapter *adap =dev_to_i2c_adapter (dev);complete (&adap->dev_released); } -static struct device_driver i2c_adapter_driver = { +struct device_driver i2c_adapter_driver = { .name ="i2c_adapter" , .bus = &i2c_bus_type, .probe = i2c_device_probe,
@@ -97,7 +97,7 @@complete (&adap->class_dev_released); } -static struct class i2c_adapter_class = { +struct class i2c_adapter_class = { .name ="i2c-adapter" , .release = &i2c_adapter_class_dev_release, };
@@ -1171,6 +1171,12 @@ } +/* Next four are needed by i2c-isa */ +EXPORT_SYMBOL_GPL (i2c_adapter_dev_release); +EXPORT_SYMBOL_GPL (i2c_adapter_driver); +EXPORT_SYMBOL_GPL (i2c_adapter_class); +EXPORT_SYMBOL_GPL (i2c_bus_type); +EXPORT_SYMBOL (i2c_add_adapter);EXPORT_SYMBOL (i2c_del_adapter);EXPORT_SYMBOL (i2c_add_driver);
include/linux/i2c.h +7 -0
@@ -34,6 +34,13 @@#include <linux/device.h> /* for struct device */ #include <asm/semaphore.h> +/* --- For i2c-isa ---------------------------------------------------- */ + +extern void i2c_adapter_dev_release (struct device *dev); +extern struct device_driver i2c_adapter_driver; +extern struct class i2c_adapter_class; +extern struct bus_type i2c_bus_type; +/* --- General options ------------------------------------------------ */ struct i2c_msg ;
Signature · 1 line
Jean Delvare
PATCH 1/1 I2C: Separate non-i2c hwmon drivers from i2c-core (2/9)
In reply to Jean DelvareConvert i2c-isa from a dumb i2c_adapter into a pseudo i2c-core for ISA hardware monitoring drivers. The isa i2c_adapter is no more registered with i2c-core, drivers have to explicitely connect to it using the new i2c_isa_{add,del}_driver interface.
At this point, all ISA chip drivers are useless, because they still register with i2c-core in the hope i2c-isa is registered there as well, but it isn't anymore.
The fake bus will be named i2c-9191 in sysfs. This is the number it already had internally in various places, so it's not exactly new, except that now the number is seen in userspace as well. This shouldn't be a problem until someone really has 9192 I2C busses in a given system ;)
The fake bus will no more show in "i2cdetect -l", as it won't be seen by i2c-dev anymore (not being registered with i2c-core), which is a good thing, as i2cdetect/i2cdump/i2cset cannot operate on this fake bus anyway.
drivers/i2c/busses/i2c-isa.c | 158 ++++++++++++++++++++++++++++++++++++++++--- include/linux/i2c-isa.h | 29 +++++++ 2 files changed, 177 insertions(+), 10 deletions(-)
drivers/i2c/busses/i2c-isa.c +148 -10
@@ -1,6 +1,8 @@/* -i2c-isa.c - Part of lm_sensors, Linux kernel modules for hardware -monitoring +i2c-isa.c - an i2c-core-like thing for ISA hardware monitoring chips +Copyright (C) 2005 Jean Delvare <[email protected]> + +Based on the i2c-isa pseudo-adapter from the lm_sensors project Copyright (c) 1998, 1999 Frodo Looijaard <[email protected]> This program is free software; you can redistribute it and/or modify
@@ -18,17 +20,24 @@Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* This implements an i2c algorithm/adapter for ISA bus. Not that this is -on first sight very useful; almost no functionality is preserved. -Except that it makes writing drivers for chips which can be on both -the SMBus and the ISA bus very much easier. See lm78.c for an example -of this. */ +/* This implements an i2c-core-like thing for ISA hardware monitoring +chips. Such chips are linked to the i2c subsystem for historical +reasons (because the early ISA hardware monitoring chips such as the +LM78 had both an I2C and an ISA interface). They used to be +registered with the main i2c-core, but as a first step in the +direction of a clean separation between I2C and ISA chip drivers, +we now have this separate core for ISA ones. It is significantly +more simple than the real one, of course, because we don't have to +handle multiple busses: there is only one (fake) ISA adapter. +It is worth noting that we still rely on i2c-core for some things +at the moment - but hopefully this won't last. */ #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> static u32 isa_func (struct i2c_adapter *adapter);
@@ -53,17 +62,146 @@return 0 ; } + +/* Copied from i2c-core */ +static ssize_t show_adapter_name (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct i2c_adapter *adap =dev_to_i2c_adapter (dev); +return sprintf (buf,"%s\n" , adap->name); +} +static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); + +static int i2c_isa_device_probe (struct device *dev) +{ +return -ENODEV ; +} + +static int i2c_isa_device_remove (struct device *dev) +{ +return 0 ; +} + + +/* We implement an interface which resembles i2c_{add,del}_driver, +but for i2c-isa drivers. We don't have to remember and handle lists +of drivers and adapters so this is much more simple, of course. */ + +int i2c_isa_add_driver (struct i2c_driver *driver) +{ +int res; + +/* Add the driver to the list of i2c drivers in the driver core */ + driver->driver.name = driver->name; + driver->driver.bus = &i2c_bus_type; + driver->driver.probe = i2c_isa_device_probe; + driver->driver.remove = i2c_isa_device_remove; + res =driver_register (&driver->driver); +if (res) +return res; +dev_dbg (&isa_adapter.dev,"Driver %s registered\n" , driver->name); + +/* Now look for clients */ + driver->attach_adapter (&isa_adapter); + +return 0 ; +} + +int i2c_isa_del_driver (struct i2c_driver *driver) +{ +struct list_head *item, *_n; +struct i2c_client *client; +int res; + +/* Detach all clients belonging to this one driver */ +list_for_each_safe (item, _n, &isa_adapter.clients) { + client = list_entry(item, struct i2c_client, list); +if (client->driver != driver) +continue ; +dev_dbg (&isa_adapter.dev,"Detaching client %s at 0x%x\n" , + client->name, client->addr); +if ((res = driver->detach_client (client))) { +dev_err (&isa_adapter.dev,"Failed, driver " +"%s not unregistered!\n" , + driver->name); +return res; + } + } + +/* Get the driver off the core list */ +driver_unregister (&driver->driver); +dev_dbg (&isa_adapter.dev,"Driver %s unregistered\n" , driver->name); + +return 0 ; +} + +static int __init i2c_isa_init (void ) { -return i2c_add_adapter (&isa_adapter); +init_MUTEX (&isa_adapter.clist_lock); +INIT_LIST_HEAD (&isa_adapter.clients); + + isa_adapter.nr =ANY_I2C_ISA_BUS ; + isa_adapter.dev.parent = &platform_bus; +sprintf (isa_adapter.dev.bus_id,"i2c-%d" , isa_adapter.nr); + isa_adapter.dev.driver = &i2c_adapter_driver; + isa_adapter.dev.release = &i2c_adapter_dev_release; +device_register (&isa_adapter.dev); +device_create_file (&isa_adapter.dev, &dev_attr_name); + +/* Add this adapter to the i2c_adapter class */ +memset (&isa_adapter.class_dev,0x00 ,sizeof (struct class_device )); + isa_adapter.class_dev.dev = &isa_adapter.dev; + isa_adapter.class_dev.class = &i2c_adapter_class; +strlcpy (isa_adapter.class_dev.class_id, isa_adapter.dev.bus_id, +BUS_ID_SIZE ); +class_device_register (&isa_adapter.class_dev); + +dev_dbg (&isa_adapter.dev,"%s registered\n" , isa_adapter.name); + +return 0 ; } static void __exit i2c_isa_exit(void) { -i2c_del_adapter (&isa_adapter); +#ifdef DEBUG +struct list_head *item, *_n; +struct i2c_client *client =NULL ; +#endif + +/* There should be no more active client */ +#ifdef DEBUG +dev_dbg (&isa_adapter.dev,"Looking for clients\n" ); +list_for_each_safe (item, _n, &isa_adapter.clients) { + client = list_entry(item, struct i2c_client, list); +dev_err (&isa_adapter.dev,"Driver %s still has an active " +"ISA client at 0x%x\n" , client->driver->name, + client->addr); + } +if (client !=NULL ) +return ; +#endif + +/* Clean up the sysfs representation */ +dev_dbg (&isa_adapter.dev,"Unregistering from sysfs\n" ); +init_completion (&isa_adapter.dev_released); +init_completion (&isa_adapter.class_dev_released); +class_device_unregister (&isa_adapter.class_dev); +device_remove_file (&isa_adapter.dev, &dev_attr_name); +device_unregister (&isa_adapter.dev); + +/* Wait for sysfs to drop all references */ +dev_dbg (&isa_adapter.dev,"Waiting for sysfs completion\n" ); +wait_for_completion (&isa_adapter.dev_released); +wait_for_completion (&isa_adapter.class_dev_released); + +dev_dbg (&isa_adapter.dev,"%s unregistered\n" , isa_adapter.name); } -MODULE_AUTHOR ("Frodo Looijaard <[email protected]>" ); +EXPORT_SYMBOL (i2c_isa_add_driver); +EXPORT_SYMBOL (i2c_isa_del_driver); + +MODULE_AUTHOR ("Jean Delvare <[email protected]>" );MODULE_DESCRIPTION ("ISA bus access through i2c" );MODULE_LICENSE ("GPL" );
include/linux/i2c-isa.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* i2c-isa.h - definitions for the i2c-isa pseudo-i2c-adapter interface +* +* Copyright (C) 2005 Jean Delvare <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _LINUX_I2C_ISA_H +#define _LINUX_I2C_ISA_H + +#include <linux/i2c.h> + +extern int i2c_isa_add_driver (struct i2c_driver *driver); +extern int i2c_isa_del_driver (struct i2c_driver *driver); + +#endif /* _LINUX_I2C_ISA_H */
Signature · 1 line
Jean Delvare
Re: [PATCH 2.6] I2C: Separate non-i2c hwmon drivers from i2c-core (2/9)
Quoted 4 lines · Jean Delvare
Convert i2c-isa from a dumb
i2c_adapterinto a pseudo i2c-core for ISA hardware monitoring drivers. The isai2c_adapteris no more registered with i2c-core, drivers have to explicitely connect to it using the new i2c_isa_{add,del}_driver interface.
Ick, when I did this originally it was a hack, and it's still a hack. It's sad to see it spreading around, but that's proably my fault...
Anyway, what are your plans for after this? How long will this code stay around? What do you want to do next?
I don't have any real objections to this patch series at all, just very curious as to your proposed roadmap after this.
thanks,
greg k-h
Re: [PATCH 2.6] I2C: Separate non-i2c hwmon drivers from i2c-core (2/9)
Hi Greg,
Quoted 7 lines
Quoted 4 lines
Convert i2c-isa from a dumb
i2c_adapterinto a pseudo i2c-core for ISA hardware monitoring drivers. The isai2c_adapteris no more registered with i2c-core, drivers have to explicitely connect to it using the new i2c_isa_{add,del}_driver interface.Ick, when I did this originally it was a hack, and it's still a hack. It's sad to see it spreading around, but that's proably my fault...
I didn't know that, I'm sorry. As I don't really know how the driver core works, I just copied from the nearest working driver, which happened to be i2c-core. If this isn't good and you want me to do it differently, just tell me how and I'll tackle this. Actually it might be more important for i2c-core than i2c-isa, as i2c-isa will die in the long run.
Quoted 5 lines
Anyway, what are your plans for after this? How long will this code stay around? What do you want to do next?
I don't have any real objections to this patch series at all, just very curious as to your proposed roadmap after this.
I'm sorry, I thought I had explained it in the first post of the set, but now I realize that I explained in detail *what* I am doing, not *why* nor the whole picture.
The whole point is to end with the current state where i2c and hardware monitoring are the same subsystem. There are more and more non-i2c hardware monitoring chip, in particular Super-I/O integrated sensors (IT8712F, W83627HF, PC87366 and all their variants), which have a very high overhead currently due to being linked to the i2c core for no reason but historical.
The positive side effect is that there are a few ugly hooks in the i2c-core (expecially the sensors part) to handle the non-i2c chips, and we will be able to get rid of them and clean up a few things - as details in my original post.
The reason why I am going into this now is that a totally different hardware monitoring driver is in the process of being added to the Linux
kernel: bmcsensors, which is IPMI based. This would be yet another driver articifially linked to the i2c subsystem, requiring yet other hooks. So I wanted to clean up the mess first.
Another reason is that I now have a Super-I/O chip with integrated sensors on one of my systems, as well as a legacy ISA hardware monitoring chip on another one, so I should be able to test my changes more efficiently than before in that field (although more hardware would be even better, as usual).
The major steps in the process are:
1* Define a hardware monitoring class, which all hardware monitoring drivers would register with. Mark M. Hoffman just did that a few weeks ago.
2* Separate the non-i2c hardware monitoring drivers from the i2c-core. This is what I am doing right now.
3* Have the user-space tools (libsensors) search for hardware monitoring drivers through /sys/class/hwmon rather than (or, for the time being, additionally to) /sys/bus/i2c. Next on my list.
4* Clean up the i2c core. This isn't directly related, but needs to be done, and will be much easier now that the isa hooks are gone. This includes a full rewrite of the way the i2c chip driver module parameters are handled, and a merge of i2c_probe and i2c_detect, to name only the two major ones. We might also get rid of some IDs that don't seem to be strictly needed (in i2c_algorithm and i2c_driver). And maybe split the SMBus 1 and 2 implementations away from i2c-core, not too sure what it would take.
5* Really attach the non-i2c drivers to their right location in the sysfs tree. I don't know exactly where the correct location is, but we'll have to find. Once the hwmon class is in use, moving the drivers around in the sysfs tree will not break the user-space compatibility.
Note that 3* depends on 1* and 4* depends on 2*. Also, we will need to wait some time (6 months? 1 year?) between 3* and 5* so as to not break user-space compatibility too much. This is the reason why I made 2* and 5* different points even though it would sound saner to do them in a single step. This approach also lets me parallelize with 4*, which I want to do now rather than wait for 5* to happen.
So, the approximate timeline would be 1* to 3* right now, 4* after that as time permits, and 5* when we estimate that 3* happened long enough ago (roughly 1st half of 2006?)
I hope I explained it correctly this time. If not, just complain ;)
Thanks,
Signature · 1 line
Jean Delvare
Re: [PATCH 2.6] I2C: Separate non-i2c hwmon drivers from i2c-core (2/9)
Quoted 6 lines · Jean Delvare
So, the approximate timeline would be 1* to 3* right now, 4* after that as time permits, and 5* when we estimate that 3* happened long enough ago (roughly 1st half of 2006?)
I hope I explained it correctly this time. If not, just complain ;)
Ah, much better, thanks. Sounds like a great plan, I'll go apply your patches in a day or so when I catch up from my travels.
thanks,
greg k-h
Re: [PATCH 2.6] I2C: Separate non-i2c hwmon drivers from i2c-core (2/9)
Hi Greg,
Quoted 2 lines
Ah, much better, thanks. Sounds like a great plan, I'll go apply your patches in a day or so when I catch up from my travels.
OK, thanks.
Note that there are a few patches which you should apply before this series, in particular Mark Hoffman's 3 hwmon class patches. There are no hard dependencies between both series but applying them in order is likely to ease your work.
You can take a look at my current stack here for reference:
http://khali.linux-fr.org/devel/i2c/linux-2.6/series
Not everything is i2c or hwmon related, but that should give you an idea of which order you should apply them in to keep the noise to a minimum level. There might be a number of individual patches that I did not post yet, because I was waiting for you to apply Mark's stuff first. Just let me know when you're done with the hwmon class patches and everything else you might have on your end, and I'll post all other patches - after I checked that they properly apply on top of what you have.
Thanks,
Signature · 1 line
Jean Delvare
Re: [PATCH 2.6] I2C: Separate non-i2c hwmon drivers from i2c-core (2/9)
Quoted 7 lines · Jean Delvare
Hi Greg,
Quoted 2 lines
Ah, much better, thanks. Sounds like a great plan, I'll go apply your patches in a day or so when I catch up from my travels.
OK, thanks.
Quoted 7 lines
Note that there are a few patches which you should apply before this series, in particular Mark Hoffman's 3 hwmon class patches. There are no hard dependencies between both series but applying them in order is likely to ease your work.
You can take a look at my current stack here for reference:
http://khali.linux-fr.org/devel/i2c/linux-2.6/series
Ok, should be caught up now. I have a pci patch or two still left to apply that i know you were also tracking.
thanks,
greg k-h
Re: [PATCH 2.6] I2C: Separate non-i2c hwmon drivers from i2c-core (2/9)
Hi Greg,
Quoted 5 lines
Quoted 2 lines
You can take a look at my current stack here for reference:
http://khali.linux-fr.org/devel/i2c/linux-2.6/seriesOk, should be caught up now. I have a pci patch or two still left to apply that i know you were also tracking.
I've picked up the few i2c patches you have and I didn't, and just posted the ones I had and you didn't to the the sensors list, so we should be sync'd again soon now.
As for PCI, I only have one patch pending and it seems you have it already, so it's OK.
Thanks,
Signature · 1 line
Jean Delvare
PATCH 1/1 I2C: Separate non-i2c hwmon drivers from i2c-core (3/9)
In reply to Jean DelvareConvert the 10 ISA hardware monitoring drivers (it87, lm78, pc87360, sis5595, smsc47b397, smsc47m1, via686a, w83627hf, w83627ehf, w83781d) to explicitely register with i2c-isa. For hybrid drivers (it87, lm78, w83781d), we now have two separate instances of i2c_driver, one for the I2C interface of the chip, and one for ISA interface. In the long run, the one for ISA will be replaced with a different driver type.
At this point, all drivers are working again, except for missing dependencies in Kconfig.
drivers/hwmon/it87.c | 29 +++++++++++++++++++++++++---- drivers/hwmon/lm78.c | 29 ++++++++++++++++++++++++++--- drivers/hwmon/pc87360.c | 5 +++-- drivers/hwmon/sis5595.c | 5 +++-- drivers/hwmon/smsc47b397.c | 5 +++-- drivers/hwmon/smsc47m1.c | 5 +++-- drivers/hwmon/via686a.c | 5 +++-- drivers/hwmon/w83627ehf.c | 5 +++-- drivers/hwmon/w83627hf.c | 5 +++-- drivers/hwmon/w83781d.c | 28 +++++++++++++++++++++++++--- 10 files changed, 97 insertions(+), 24 deletions(-)
drivers/hwmon/it87.c +25 -4
@@ -36,6 +36,7 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> #include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon-sysfs.h>
@@ -242,6 +243,14 @@ .detach_client = it87_detach_client, }; +static struct i2c_driver it87_isa_driver = { + .owner =THIS_MODULE , + .name ="it87-isa" , + .attach_adapter = it87_attach_adapter, + .detach_client = it87_detach_client, +}; + +static ssize_t show_in (struct device *dev,struct device_attribute *attr,char *buf) {
@@ -741,7 +750,7 @@/* Reserve the ISA region */ if (is_isa) -if (!request_region (address,IT87_EXTENT , it87_driver.name)) +if (!request_region (address,IT87_EXTENT , it87_isa_driver.name)) goto ERROR0;/* Probe whether there is anything available on this address. Already
@@ -787,7 +796,7 @@i2c_set_clientdata (new_client, data); new_client->addr = address; new_client->adapter = adapter; - new_client->driver = &it87_driver; + new_client->driver = is_isa ? &it87_isa_driver : &it87_driver; new_client->flags =0 ;/* Now, we do the remaining detection. */
@@ -1172,16 +1181,28 @@static int __init sm_it87_init (void ) { -int addr; +int addr, res;if (!it87_find (&addr)) { normal_isa[0 ] = addr; } -return i2c_add_driver (&it87_driver); + + res =i2c_add_driver (&it87_driver); +if (res) +return res; + + res =i2c_isa_add_driver (&it87_isa_driver); +if (res) { +i2c_del_driver (&it87_driver); +return res; + } + +return 0 ; } static void __exit sm_it87_exit(void) { +i2c_isa_del_driver (&it87_isa_driver);i2c_del_driver (&it87_driver); }
drivers/hwmon/lm78.c +26 -3
@@ -23,6 +23,7 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> #include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -177,6 +178,14 @@ .detach_client = lm78_detach_client, }; +static struct i2c_driver lm78_isa_driver = { + .owner =THIS_MODULE , + .name ="lm78-isa" , + .attach_adapter = lm78_attach_adapter, + .detach_client = lm78_detach_client, +}; + +/* 7 Voltages */ static ssize_t show_in (struct device *dev,char *buf,int nr) {
@@ -488,7 +497,8 @@/* Reserve the ISA region */ if (is_isa) -if (!request_region (address,LM78_EXTENT , lm78_driver.name)) { +if (!request_region (address,LM78_EXTENT , + lm78_isa_driver.name)) { err = -EBUSY ; goto ERROR0; }
@@ -543,7 +553,7 @@i2c_set_clientdata (new_client, data); new_client->addr = address; new_client->adapter = adapter; - new_client->driver = &lm78_driver; + new_client->driver = is_isa ? &lm78_isa_driver : &lm78_driver; new_client->flags =0 ;/* Now, we do the remaining detection. */
@@ -791,11 +801,24 @@static int __init sm_lm78_init (void ) { -return i2c_add_driver (&lm78_driver); +int res; + + res =i2c_add_driver (&lm78_driver); +if (res) +return res; + + res =i2c_isa_add_driver (&lm78_isa_driver); +if (res) { +i2c_del_driver (&lm78_driver); +return res; + } + +return 0 ; } static void __exit sm_lm78_exit(void) { +i2c_isa_del_driver (&lm78_isa_driver);i2c_del_driver (&lm78_driver); }
drivers/hwmon/pc87360.c +3 -2
@@ -38,6 +38,7 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> #include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h>
@@ -1344,12 +1345,12 @@return -ENODEV ; } -return i2c_add_driver (&pc87360_driver); +return i2c_isa_add_driver (&pc87360_driver); } static void __exit pc87360_exit(void) { -i2c_del_driver (&pc87360_driver); +i2c_isa_del_driver (&pc87360_driver); }
drivers/hwmon/sis5595.c +3 -2
@@ -55,6 +55,7 @@#include <linux/ioport.h> #include <linux/pci.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> #include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -790,7 +791,7 @@ normal_isa[0 ] = addr; s_bridge =pci_dev_get (dev); -if (i2c_add_driver (&sis5595_driver)) { +if (i2c_isa_add_driver (&sis5595_driver)) {pci_dev_put (s_bridge); s_bridge =NULL ; }
@@ -817,7 +818,7 @@ {pci_unregister_driver (&sis5595_pci_driver);if (s_bridge !=NULL ) { -i2c_del_driver (&sis5595_driver); +i2c_isa_del_driver (&sis5595_driver);pci_dev_put (s_bridge); s_bridge =NULL ; }
drivers/hwmon/smsc47b397.c +3 -2
@@ -31,6 +31,7 @@#include <linux/ioport.h> #include <linux/jiffies.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> #include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -350,12 +351,12 @@if ((ret =smsc47b397_find (normal_isa)))return ret; -return i2c_add_driver (&smsc47b397_driver); +return i2c_isa_add_driver (&smsc47b397_driver); } static void __exit smsc47b397_exit(void) { -i2c_del_driver (&smsc47b397_driver); +i2c_isa_del_driver (&smsc47b397_driver); }MODULE_AUTHOR ("Mark M. Hoffman <[email protected]>" );
drivers/hwmon/smsc47m1.c +3 -2
@@ -30,6 +30,7 @@#include <linux/ioport.h> #include <linux/jiffies.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> #include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -592,12 +593,12 @@return -ENODEV ; } -return i2c_add_driver (&smsc47m1_driver); +return i2c_isa_add_driver (&smsc47m1_driver); } static void __exit sm_smsc47m1_exit(void) { -i2c_del_driver (&smsc47m1_driver); +i2c_isa_del_driver (&smsc47m1_driver); }MODULE_AUTHOR ("Mark D. Studebaker <[email protected]>" );
drivers/hwmon/via686a.c +3 -2
@@ -35,6 +35,7 @@#include <linux/pci.h> #include <linux/jiffies.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> #include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -846,7 +847,7 @@ normal_isa[0 ] = addr; s_bridge =pci_dev_get (dev); -if (i2c_add_driver (&via686a_driver)) { +if (i2c_isa_add_driver (&via686a_driver)) {pci_dev_put (s_bridge); s_bridge =NULL ; }
@@ -873,7 +874,7 @@ {pci_unregister_driver (&via686a_pci_driver);if (s_bridge !=NULL ) { -i2c_del_driver (&via686a_driver); +i2c_isa_del_driver (&via686a_driver);pci_dev_put (s_bridge); s_bridge =NULL ; }
drivers/hwmon/w83627hf.c +3 -2
@@ -42,6 +42,7 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> #include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h>
@@ -1507,12 +1508,12 @@ } normal_isa[0 ] = addr; -return i2c_add_driver (&w83627hf_driver); +return i2c_isa_add_driver (&w83627hf_driver); } static void __exit sensors_w83627hf_exit(void) { -i2c_del_driver (&w83627hf_driver); +i2c_isa_del_driver (&w83627hf_driver); } MODULE_AUTHOR("Frodo Looijaard <[email protected]>, "
drivers/hwmon/w83781d.c +25 -3
@@ -38,6 +38,7 @@#include <linux/slab.h> #include <linux/jiffies.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> #include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h>
@@ -276,6 +277,14 @@ .detach_client = w83781d_detach_client, }; +static struct i2c_driver w83781d_isa_driver = { + .owner =THIS_MODULE , + .name ="w83781d-isa" , + .attach_adapter = w83781d_attach_adapter, + .detach_client = w83781d_detach_client, +}; + +/* following are the sysfs callback functions */ #define show_in_reg (reg) \ static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
@@ -1002,7 +1011,7 @@if (is_isa)if (!request_region (address,W83781D_EXTENT , - w83781d_driver.name)) { + w83781d_isa_driver.name)) {dev_dbg (&adapter->dev,"Request of region " "0x%x-0x%x for w83781d failed\n" , address, address +W83781D_EXTENT -1 );
@@ -1060,7 +1069,7 @@ new_client->addr = address;init_MUTEX (&data->lock); new_client->adapter = adapter; - new_client->driver = &w83781d_driver; + new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver; new_client->flags =0 ;/* Now, we do the remaining detection. */
@@ -1636,12 +1645,25 @@static int __init sensors_w83781d_init (void ) { -return i2c_add_driver (&w83781d_driver); +int res; + + res =i2c_add_driver (&w83781d_driver); +if (res) +return res; + + res =i2c_isa_add_driver (&w83781d_isa_driver); +if (res) { +i2c_del_driver (&w83781d_driver); +return res; + } + +return 0 ; } static void __exitsensors_w83781d_exit (void ) { +i2c_isa_del_driver (&w83781d_isa_driver);i2c_del_driver (&w83781d_driver); }
drivers/hwmon/w83627ehf.c +3 -2
@@ -37,6 +37,7 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/i2c.h> +#include <linux/i2c-isa.h> #include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h>
@@ -844,12 +845,12 @@ && w83627ehf_find(0x4e, &normal_isa[0]))return -ENODEV ; -return i2c_add_driver (&w83627ehf_driver); +return i2c_isa_add_driver (&w83627ehf_driver); } static void __exit sensors_w83627ehf_exit(void) { -i2c_del_driver (&w83627ehf_driver); +i2c_isa_del_driver (&w83627ehf_driver); }MODULE_AUTHOR ("Jean Delvare <[email protected]>" );
Signature · 1 line
Jean Delvare
PATCH 1/1 I2C: Separate non-i2c hwmon drivers from i2c-core (4/9)
In reply to Jean DelvareAll ISA hardware monitoring drivers (including hybrid drivers) now have a hard dependency on i2c-isa, so they must select I2C_ISA. As a result, CONFIG_I2C_ISA doesn't need to be left visible to the user. The good thing here is that users will stop complaining that some driver doesn't work just because they forgot to compile or load i2c-isa.
At this point, all drivers are working again and the cleanup phase can begin.
drivers/hwmon/Kconfig | 3 +++ drivers/i2c/busses/Kconfig | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-)
drivers/hwmon/Kconfig +3 -0
@@ -160,6 +160,7 @@ tristate "ITE IT87xx and compatibles" depends on HWMON && I2C select I2C_SENSOR + select I2C_ISA help If you say yes here you get support for ITE IT87xx sensor chips and clones: SiS960.
@@ -211,6 +212,7 @@ tristate "National Semiconductor LM78 and compatibles" depends on HWMON && I2C && EXPERIMENTAL select I2C_SENSOR + select I2C_ISA help If you say yes here you get support for National Semiconductor LM78, LM78-J and LM79.
@@ -366,6 +368,7 @@ tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" depends on HWMON && I2C select I2C_SENSOR + select I2C_ISA help If you say yes here you get support for the Winbond W8378x series of sensor chips: the W83781D, W83782D, W83783S and W83627HF,
drivers/i2c/busses/Kconfig +1 -7
@@ -182,14 +182,8 @@ will be called i2c-iop3xx. config I2C_ISA - tristate "ISA Bus support" + tristate depends on I2C - help - If you say yes to this option, support will be included for i2c - interfaces that are on the ISA bus. - - This driver can also be built as a module. If so, the module - will be called i2c-isa. config I2C_ITE tristate "ITE I2C Adapter"
Signature · 1 line
Jean Delvare
PATCH 1/1 I2C: Separate non-i2c hwmon drivers from i2c-core (5/9)
In reply to Jean DelvareCall the ISA chip drivers detection function directly instead of relying on i2c_detect. The net effect is that address lists won't be handled anymore, but they were mostly useless in the ISA case anyway (pc87360, smsc47m1, smsc47b397 had already dropped them).
We don't need to handle multiple devices, all we may need is a way to force a given address instead of the original one (some drivers already
do: sis5595, via686a, w83627hf), and, for drivers supporting multiple chips, a way to force one given kind. All this may be added later on demand, but I actually don't think there will be much demand.
drivers/hwmon/it87.c | 16 ++++++++++---- drivers/hwmon/lm78.c | 11 ++++++++-- drivers/hwmon/pc87360.c | 38 ++++++++-------------------------- drivers/hwmon/sis5595.c | 41 ++++++++----------------------------- drivers/hwmon/smsc47b397.c | 48 +++++++++++--------------------------------- drivers/hwmon/smsc47m1.c | 42 ++++++++------------------------------ drivers/hwmon/via686a.c | 41 +++++++------------------------------ drivers/hwmon/w83627ehf.c | 35 ++++++++------------------------ drivers/hwmon/w83627hf.c | 49 +++++++++++---------------------------------- drivers/hwmon/w83781d.c | 12 +++++++++-- 10 files changed, 98 insertions(+), 235 deletions(-)
drivers/hwmon/pc87360.c +9 -29
@@ -39,25 +39,17 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h> #include <asm/io.h> -static unsigned short normal_i2c[] = {I2C_CLIENT_END }; -static unsigned int normal_isa[] = {0 ,I2C_CLIENT_ISA_END }; -static struct i2c_force_data forces[] = {{NULL }};static u8 devid; -static unsigned int extra_isa[3 ]; +static unsigned short address; +static unsigned short extra_isa[3 ];static u8 confreg[4 ];enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 }; -static struct i2c_address_data addr_data = { - .normal_i2c = normal_i2c, - .normal_isa = normal_isa, - .forces = forces, -};static int init =1 ;module_param (init, int,0 );
@@ -228,8 +220,7 @@* Functions declaration */ -static int pc87360_attach_adapter (struct i2c_adapter *adapter); -static int pc87360_detect (struct i2c_adapter *adapter,int address,int kind); +static int pc87360_detect (struct i2c_adapter *adapter);static int pc87360_detach_client (struct i2c_client *client); static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
@@ -246,8 +237,7 @@static struct i2c_driver pc87360_driver = { .owner =THIS_MODULE , .name ="pc87360" , - .flags =I2C_DF_NOTIFY , - .attach_adapter = pc87360_attach_adapter, + .attach_adapter = pc87360_detect, .detach_client = pc87360_detach_client, };
@@ -636,12 +626,7 @@* Device detection, registration and update */ -static int pc87360_attach_adapter (struct i2c_adapter *adapter) -{ -return i2c_detect (adapter, &addr_data, pc87360_detect); -} - -static int pc87360_find (int sioaddr,u8 *devid,int *address) +static int pc87360_find (int sioaddr,u8 *devid,unsigned short *addresses) {u16 val;int i;
@@ -687,7 +672,7 @@continue ; } - address[i] = val; + addresses[i] = val;if (i==0 ) {/* Fans */ confreg[0 ] =superio_inb (sioaddr,0xF0 );
@@ -731,9 +716,7 @@return 0 ; } -/* We don't really care about the address. -Read from extra_isa instead. */ -int pc87360_detect (struct i2c_adapter *adapter,int address,int kind) +static int pc87360_detect (struct i2c_adapter *adapter) {int i;struct i2c_client *new_client;
@@ -742,9 +725,6 @@const char *name ="pc87360" ;int use_thermistors =0 ; -if (!i2c_is_isa_adapter (adapter)) -return -ENODEV ; -if (!(data =kmalloc (sizeof (struct pc87360_data ),GFP_KERNEL )))return -ENOMEM ;memset (data,0x00 ,sizeof (struct pc87360_data ));
@@ -1334,12 +1314,12 @@/* Arbitrarily pick one of the addresses */ for (i =0 ; i <3 ; i++) {if (extra_isa[i] !=0x0000 ) { - normal_isa[0 ] = extra_isa[i]; + address = extra_isa[i];break ; } } -if (normal_isa[0 ] ==0x0000 ) { +if (address ==0x0000 ) {printk (KERN_WARNING "pc87360: No active logical device, " "module not inserted.\n" );return -ENODEV ;
drivers/hwmon/sis5595.c +9 -32
98 lines not on this page · raw message
drivers/hwmon/via686a.c +8 -33
91 lines not on this page · raw message
drivers/hwmon/it87.c +11 -5
@@ -48,7 +48,8 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e ,0x2f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {0x0290 ,I2C_CLIENT_ISA_END }; +static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END }; +static unsigned short isa_address =0x290 ;/* Insmod parameters */ SENSORS_INSMOD_2 (it87, it8712);
@@ -222,7 +223,7 @@static int it87_attach_adapter (struct i2c_adapter *adapter); -static int it87_find (int *address); +static int it87_isa_attach_adapter (struct i2c_adapter *adapter);static int it87_detect (struct i2c_adapter *adapter,int address,int kind);static int it87_detach_client (struct i2c_client *client);
@@ -246,7 +247,7 @@static struct i2c_driver it87_isa_driver = { .owner =THIS_MODULE , .name ="it87-isa" , - .attach_adapter = it87_attach_adapter, + .attach_adapter = it87_isa_attach_adapter, .detach_client = it87_detach_client, };
@@ -701,7 +702,12 @@return i2c_detect (adapter, &addr_data, it87_detect); } -/* SuperIO detection - will change normal_isa[0] if a chip is found */ +static int it87_isa_attach_adapter (struct i2c_adapter *adapter) +{ +return it87_detect (adapter, isa_address,-1 ); +} + +/* SuperIO detection - will change isa_address if a chip is found */ static int it87_find (int *address) {int err = -ENODEV ;
@@ -1184,7 +1190,7 @@int addr, res;if (!it87_find (&addr)) { - normal_isa[0 ] = addr; + isa_address = addr; } res =i2c_add_driver (&it87_driver);
drivers/hwmon/lm78.c +9 -2
@@ -34,7 +34,8 @@0x25 ,0x26 ,0x27 ,0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e , 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = {0x0290 ,I2C_CLIENT_ISA_END }; +static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END }; +static unsigned short isa_address =0x290 ;/* Insmod parameters */ SENSORS_INSMOD_3 (lm78, lm78j, lm79);
@@ -160,6 +161,7 @@static int lm78_attach_adapter (struct i2c_adapter *adapter); +static int lm78_isa_attach_adapter (struct i2c_adapter *adapter);static int lm78_detect (struct i2c_adapter *adapter,int address,int kind);static int lm78_detach_client (struct i2c_client *client);
@@ -181,7 +183,7 @@static struct i2c_driver lm78_isa_driver = { .owner =THIS_MODULE , .name ="lm78-isa" , - .attach_adapter = lm78_attach_adapter, + .attach_adapter = lm78_isa_attach_adapter, .detach_client = lm78_detach_client, };
@@ -480,6 +482,11 @@return i2c_detect (adapter, &addr_data, lm78_detect); } +static int lm78_isa_attach_adapter (struct i2c_adapter *adapter) +{ +return lm78_detect (adapter, isa_address,-1 ); +} +/* This function is called by i2c_detect */ int lm78_detect (struct i2c_adapter *adapter,int address,int kind) {
drivers/hwmon/w83781d.c +10 -2
@@ -50,7 +50,8 @@static unsigned short normal_i2c[] = {0x20 ,0x21 ,0x22 ,0x23 ,0x24 ,0x25 ,0x26 ,0x27 ,0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e ,0x2f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {0x0290 ,I2C_CLIENT_ISA_END }; +static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END }; +static unsigned short isa_address =0x290 ;/* Insmod parameters */ SENSORS_INSMOD_5 (w83781d, w83782d, w83783s, w83627hf, as99127f);
@@ -259,6 +260,7 @@ };static int w83781d_attach_adapter (struct i2c_adapter *adapter); +static int w83781d_isa_attach_adapter (struct i2c_adapter *adapter);static int w83781d_detect (struct i2c_adapter *adapter,int address,int kind);static int w83781d_detach_client (struct i2c_client *client);
@@ -280,7 +282,7 @@static struct i2c_driver w83781d_isa_driver = { .owner =THIS_MODULE , .name ="w83781d-isa" , - .attach_adapter = w83781d_attach_adapter, + .attach_adapter = w83781d_isa_attach_adapter, .detach_client = w83781d_detach_client, };
@@ -871,6 +873,12 @@return i2c_detect (adapter, &addr_data, w83781d_detect); } +static int +w83781d_isa_attach_adapter (struct i2c_adapter *adapter) +{ +return w83781d_detect (adapter, isa_address,-1 ); +} +/* Assumes that adapter is of I2C, not ISA variety. * OTHERWISE DON'T CALL THIS */
drivers/hwmon/smsc47b397.c +12 -36
104 lines not on this page · raw message
drivers/hwmon/smsc47m1.c +9 -33
92 lines not on this page · raw message
drivers/hwmon/w83627ehf.c +9 -26
@@ -38,19 +38,13 @@#include <linux/slab.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h> #include <asm/io.h> #include "lm75.h" -/* Addresses to scan -The actual ISA address is read from Super-I/O configuration space */ -static unsigned short normal_i2c[] = {I2C_CLIENT_END }; -static unsigned int normal_isa[] = {0 ,I2C_CLIENT_ISA_END }; - -/* Insmod parameters */ -SENSORS_INSMOD_1 (w83627ehf); +/* The actual ISA address is read from Super-I/O configuration space */ +static unsigned short address;/* * Super-I/O constants and functions
@@ -670,15 +664,12 @@ } } -static int w83627ehf_detect (struct i2c_adapter *adapter,int address,int kind) +static int w83627ehf_detect (struct i2c_adapter *adapter) {struct i2c_client *client;struct w83627ehf_data *data;int i, err =0 ; -if (!i2c_is_isa_adapter (adapter)) -return 0 ; -if (!request_region (address,REGION_LENGTH , w83627ehf_driver.name)) { err = -EBUSY ; goto exit;
@@ -773,13 +764,6 @@return err; } -static int w83627ehf_attach_adapter (struct i2c_adapter *adapter) -{ -if (!(adapter->class &I2C_CLASS_HWMON )) -return 0 ; -return i2c_detect (adapter, &addr_data, w83627ehf_detect); -} -static int w83627ehf_detach_client (struct i2c_client *client) {struct w83627ehf_data *data =i2c_get_clientdata (client);
@@ -801,12 +785,11 @@static struct i2c_driver w83627ehf_driver = { .owner =THIS_MODULE , .name ="w83627ehf" , - .flags =I2C_DF_NOTIFY , - .attach_adapter = w83627ehf_attach_adapter, + .attach_adapter = w83627ehf_detect, .detach_client = w83627ehf_detach_client, }; -static int __init w83627ehf_find (int sioaddr,int *address) +static int __init w83627ehf_find (int sioaddr,unsigned short *addr) {u16 val;
@@ -824,8 +807,8 @@superio_select (W83627EHF_LD_HWM ); val = (superio_inb (SIO_REG_ADDR ) <<8 ) |superio_inb (SIO_REG_ADDR +1 ); - *address = val & ~(REGION_LENGTH -1 ); -if (*address ==0 ) { + *addr = val & ~(REGION_LENGTH -1 ); +if (*addr ==0 ) {superio_exit ();return -ENODEV ; }
@@ -841,8 +824,8 @@static int __init sensors_w83627ehf_init (void ) { -if (w83627ehf_find (0x2e , &normal_isa[0 ]) - &&w83627ehf_find (0x4e , &normal_isa[0 ])) +if (w83627ehf_find (0x2e , &address) + &&w83627ehf_find (0x4e , &address))return -ENODEV ;return i2c_isa_add_driver (&w83627ehf_driver);
drivers/hwmon/w83627hf.c +12 -37
103 lines not on this page · raw message
Signature · 1 line
Jean Delvare
[email protected]
Appliedpatch i2c-hwmon-split-05.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled
Subject: I2C: Separate non-i2c hwmon drivers from i2c-core (5/9)
to my gregkh-2.6 tree. Its filename is
i2c-hwmon-split-05.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Patches currently in gregkh-2.6 which might be from [email protected] are
i2c/i2c-max6875-documentation-update.patchi2c/i2c-max6875-simplify.patchi2c/i2c-hwmon-class-01.patchi2c/i2c-hwmon-class-02.patchi2c/i2c-hwmon-class-03.patchi2c/i2c-missing-space.patchi2c/i2c-nforce2-cleanup.patchi2c/i2c-hwmon-split-01.patchi2c/i2c-hwmon-split-02.patchi2c/i2c-hwmon-split-03.patchi2c/i2c-hwmon-split-04.patchi2c/i2c-hwmon-split-05.patchi2c/i2c-hwmon-split-06.patchi2c/i2c-hwmon-split-07.patchi2c/i2c-hwmon-split-08.patchi2c/i2c-hwmon-split-09.patch
Quoted 1 line
From [email protected] Tue Jul 19 18:00:07 2005
Date: Tue, 19 Jul 2005 23:56:35 +0200
From: Jean Delvare <[email protected]>
To: LKML <[email protected]>, LM Sensors
<[email protected]>
Cc: Greg KH <[email protected]>
Subject: I2C: Separate non-i2c hwmon drivers from i2c-core (5/9)
Message-Id: <[email protected]>
Call the ISA chip drivers detection function directly instead of relying on i2c_detect. The net effect is that address lists won't be handled anymore, but they were mostly useless in the ISA case anyway (pc87360, smsc47m1, smsc47b397 had already dropped them).
We don't need to handle multiple devices, all we may need is a way to force a given address instead of the original one (some drivers already
do: sis5595, via686a, w83627hf), and, for drivers supporting multiple chips, a way to force one given kind. All this may be added later on demand, but I actually don't think there will be much demand.
--- drivers/hwmon/it87.c | 16 ++++++++++---- drivers/hwmon/lm78.c | 11 ++++++++-- drivers/hwmon/pc87360.c | 38 ++++++++-------------------------- drivers/hwmon/sis5595.c | 41 ++++++++----------------------------- drivers/hwmon/smsc47b397.c | 48 +++++++++++--------------------------------- drivers/hwmon/smsc47m1.c | 42 ++++++++------------------------------ drivers/hwmon/via686a.c | 41 +++++++------------------------------ drivers/hwmon/w83627ehf.c | 35 ++++++++------------------------ drivers/hwmon/w83627hf.c | 49 +++++++++++---------------------------------- drivers/hwmon/w83781d.c | 12 +++++++++-- 10 files changed, 98 insertions(+), 235 deletions(-)
drivers/hwmon/pc87360.c +9 -29
@@ -39,25 +39,17 @@#include <linux/jiffies.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/i2c-vid.h> #include <linux/hwmon.h> #include <linux/err.h> #include <asm/io.h> -static unsigned short normal_i2c[] = {I2C_CLIENT_END }; -static unsigned int normal_isa[] = {0 ,I2C_CLIENT_ISA_END }; -static struct i2c_force_data forces[] = {{NULL }};static u8 devid; -static unsigned int extra_isa[3 ]; +static unsigned short address; +static unsigned short extra_isa[3 ];static u8 confreg[4 ];enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 }; -static struct i2c_address_data addr_data = { - .normal_i2c = normal_i2c, - .normal_isa = normal_isa, - .forces = forces, -};static int init =1 ;module_param (init, int,0 );
@@ -228,8 +220,7 @@* Functions declaration */ -static int pc87360_attach_adapter (struct i2c_adapter *adapter); -static int pc87360_detect (struct i2c_adapter *adapter,int address,int kind); +static int pc87360_detect (struct i2c_adapter *adapter);static int pc87360_detach_client (struct i2c_client *client); static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
@@ -246,8 +237,7 @@static struct i2c_driver pc87360_driver = { .owner =THIS_MODULE , .name ="pc87360" , - .flags =I2C_DF_NOTIFY , - .attach_adapter = pc87360_attach_adapter, + .attach_adapter = pc87360_detect, .detach_client = pc87360_detach_client, };
@@ -636,12 +626,7 @@* Device detection, registration and update */ -static int pc87360_attach_adapter (struct i2c_adapter *adapter) -{ -return i2c_detect (adapter, &addr_data, pc87360_detect); -} - -static int pc87360_find (int sioaddr,u8 *devid,int *address) +static int pc87360_find (int sioaddr,u8 *devid,unsigned short *addresses) {u16 val;int i;
@@ -687,7 +672,7 @@continue ; } - address[i] = val; + addresses[i] = val;if (i==0 ) {/* Fans */ confreg[0 ] =superio_inb (sioaddr,0xF0 );
@@ -731,9 +716,7 @@return 0 ; } -/* We don't really care about the address. -Read from extra_isa instead. */ -int pc87360_detect (struct i2c_adapter *adapter,int address,int kind) +static int pc87360_detect (struct i2c_adapter *adapter) {int i;struct i2c_client *new_client;
@@ -742,9 +725,6 @@const char *name ="pc87360" ;int use_thermistors =0 ; -if (!i2c_is_isa_adapter (adapter)) -return -ENODEV ; -if (!(data =kmalloc (sizeof (struct pc87360_data ),GFP_KERNEL )))return -ENOMEM ;memset (data,0x00 ,sizeof (struct pc87360_data ));
@@ -1334,12 +1314,12 @@/* Arbitrarily pick one of the addresses */ for (i =0 ; i <3 ; i++) {if (extra_isa[i] !=0x0000 ) { - normal_isa[0 ] = extra_isa[i]; + address = extra_isa[i];break ; } } -if (normal_isa[0 ] ==0x0000 ) { +if (address ==0x0000 ) {printk (KERN_WARNING "pc87360: No active logical device, " "module not inserted.\n" );return -ENODEV ;
drivers/hwmon/sis5595.c +9 -32
98 lines not on this page · raw message
drivers/hwmon/via686a.c +8 -33
91 lines not on this page · raw message
drivers/hwmon/it87.c +11 -5
@@ -48,7 +48,8 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e ,0x2f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {0x0290 ,I2C_CLIENT_ISA_END }; +static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END }; +static unsigned short isa_address =0x290 ;/* Insmod parameters */ SENSORS_INSMOD_2 (it87, it8712);
@@ -222,7 +223,7 @@static int it87_attach_adapter (struct i2c_adapter *adapter); -static int it87_find (int *address); +static int it87_isa_attach_adapter (struct i2c_adapter *adapter);static int it87_detect (struct i2c_adapter *adapter,int address,int kind);static int it87_detach_client (struct i2c_client *client);
@@ -246,7 +247,7 @@static struct i2c_driver it87_isa_driver = { .owner =THIS_MODULE , .name ="it87-isa" , - .attach_adapter = it87_attach_adapter, + .attach_adapter = it87_isa_attach_adapter, .detach_client = it87_detach_client, };
@@ -701,7 +702,12 @@return i2c_detect (adapter, &addr_data, it87_detect); } -/* SuperIO detection - will change normal_isa[0] if a chip is found */ +static int it87_isa_attach_adapter (struct i2c_adapter *adapter) +{ +return it87_detect (adapter, isa_address,-1 ); +} + +/* SuperIO detection - will change isa_address if a chip is found */ static int it87_find (int *address) {int err = -ENODEV ;
@@ -1184,7 +1190,7 @@int addr, res;if (!it87_find (&addr)) { - normal_isa[0 ] = addr; + isa_address = addr; } res =i2c_add_driver (&it87_driver);
drivers/hwmon/lm78.c +9 -2
@@ -34,7 +34,8 @@0x25 ,0x26 ,0x27 ,0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e , 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = {0x0290 ,I2C_CLIENT_ISA_END }; +static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END }; +static unsigned short isa_address =0x290 ;/* Insmod parameters */ SENSORS_INSMOD_3 (lm78, lm78j, lm79);
@@ -160,6 +161,7 @@static int lm78_attach_adapter (struct i2c_adapter *adapter); +static int lm78_isa_attach_adapter (struct i2c_adapter *adapter);static int lm78_detect (struct i2c_adapter *adapter,int address,int kind);static int lm78_detach_client (struct i2c_client *client);
@@ -181,7 +183,7 @@static struct i2c_driver lm78_isa_driver = { .owner =THIS_MODULE , .name ="lm78-isa" , - .attach_adapter = lm78_attach_adapter, + .attach_adapter = lm78_isa_attach_adapter, .detach_client = lm78_detach_client, };
@@ -480,6 +482,11 @@return i2c_detect (adapter, &addr_data, lm78_detect); } +static int lm78_isa_attach_adapter (struct i2c_adapter *adapter) +{ +return lm78_detect (adapter, isa_address,-1 ); +} +/* This function is called by i2c_detect */ int lm78_detect (struct i2c_adapter *adapter,int address,int kind) {
drivers/hwmon/w83781d.c +10 -2
@@ -50,7 +50,8 @@static unsigned short normal_i2c[] = {0x20 ,0x21 ,0x22 ,0x23 ,0x24 ,0x25 ,0x26 ,0x27 ,0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e ,0x2f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {0x0290 ,I2C_CLIENT_ISA_END }; +static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END }; +static unsigned short isa_address =0x290 ;/* Insmod parameters */ SENSORS_INSMOD_5 (w83781d, w83782d, w83783s, w83627hf, as99127f);
@@ -259,6 +260,7 @@ };static int w83781d_attach_adapter (struct i2c_adapter *adapter); +static int w83781d_isa_attach_adapter (struct i2c_adapter *adapter);static int w83781d_detect (struct i2c_adapter *adapter,int address,int kind);static int w83781d_detach_client (struct i2c_client *client);
@@ -280,7 +282,7 @@static struct i2c_driver w83781d_isa_driver = { .owner =THIS_MODULE , .name ="w83781d-isa" , - .attach_adapter = w83781d_attach_adapter, + .attach_adapter = w83781d_isa_attach_adapter, .detach_client = w83781d_detach_client, };
@@ -871,6 +873,12 @@return i2c_detect (adapter, &addr_data, w83781d_detect); } +static int +w83781d_isa_attach_adapter (struct i2c_adapter *adapter) +{ +return w83781d_detect (adapter, isa_address,-1 ); +} +/* Assumes that adapter is of I2C, not ISA variety. * OTHERWISE DON'T CALL THIS */
drivers/hwmon/smsc47b397.c +12 -36
104 lines not on this page · raw message
drivers/hwmon/smsc47m1.c +9 -33
92 lines not on this page · raw message
drivers/hwmon/w83627ehf.c +9 -26
@@ -38,19 +38,13 @@#include <linux/slab.h> #include <linux/i2c.h> #include <linux/i2c-isa.h> -#include <linux/i2c-sensor.h> #include <linux/hwmon.h> #include <linux/err.h> #include <asm/io.h> #include "lm75.h" -/* Addresses to scan -The actual ISA address is read from Super-I/O configuration space */ -static unsigned short normal_i2c[] = {I2C_CLIENT_END }; -static unsigned int normal_isa[] = {0 ,I2C_CLIENT_ISA_END }; - -/* Insmod parameters */ -SENSORS_INSMOD_1 (w83627ehf); +/* The actual ISA address is read from Super-I/O configuration space */ +static unsigned short address;/* * Super-I/O constants and functions
@@ -670,15 +664,12 @@ } } -static int w83627ehf_detect (struct i2c_adapter *adapter,int address,int kind) +static int w83627ehf_detect (struct i2c_adapter *adapter) {struct i2c_client *client;struct w83627ehf_data *data;int i, err =0 ; -if (!i2c_is_isa_adapter (adapter)) -return 0 ; -if (!request_region (address,REGION_LENGTH , w83627ehf_driver.name)) { err = -EBUSY ; goto exit;
@@ -773,13 +764,6 @@return err; } -static int w83627ehf_attach_adapter (struct i2c_adapter *adapter) -{ -if (!(adapter->class &I2C_CLASS_HWMON )) -return 0 ; -return i2c_detect (adapter, &addr_data, w83627ehf_detect); -} -static int w83627ehf_detach_client (struct i2c_client *client) {struct w83627ehf_data *data =i2c_get_clientdata (client);
@@ -801,12 +785,11 @@static struct i2c_driver w83627ehf_driver = { .owner =THIS_MODULE , .name ="w83627ehf" , - .flags =I2C_DF_NOTIFY , - .attach_adapter = w83627ehf_attach_adapter, + .attach_adapter = w83627ehf_detect, .detach_client = w83627ehf_detach_client, }; -static int __init w83627ehf_find (int sioaddr,int *address) +static int __init w83627ehf_find (int sioaddr,unsigned short *addr) {u16 val;
@@ -824,8 +807,8 @@superio_select (W83627EHF_LD_HWM ); val = (superio_inb (SIO_REG_ADDR ) <<8 ) |superio_inb (SIO_REG_ADDR +1 ); - *address = val & ~(REGION_LENGTH -1 ); -if (*address ==0 ) { + *addr = val & ~(REGION_LENGTH -1 ); +if (*addr ==0 ) {superio_exit ();return -ENODEV ; }
@@ -841,8 +824,8 @@static int __init sensors_w83627ehf_init (void ) { -if (w83627ehf_find (0x2e , &normal_isa[0 ]) - &&w83627ehf_find (0x4e , &normal_isa[0 ])) +if (w83627ehf_find (0x2e , &address) + &&w83627ehf_find (0x4e , &address))return -ENODEV ;return i2c_isa_add_driver (&w83627ehf_driver);
drivers/hwmon/w83627hf.c +12 -37
103 lines not on this page · raw message
PATCH 1/1 I2C: Separate non-i2c hwmon drivers from i2c-core (6/9)
In reply to Jean DelvareKill all isa-related stuff from i2c_detect, it's not used anymore.
This is one major step in the directiom of merging i2c_probe and i2c_detect. The last obstacle I can think of is the different way forced addresses work between sensors and non-sensors i2c drivers. I'll deal with that in a later patchset.
drivers/i2c/i2c-sensor-detect.c | 45 +++++++++++----------------------------- 1 files changed, 13 insertions(+), 32 deletions(-)
drivers/i2c/i2c-sensor-detect.c +13 -32
@@ -25,42 +25,34 @@#include <linux/i2c-sensor.h> static unsigned short empty[] = {I2C_CLIENT_END }; -static unsigned int empty_isa[] = {I2C_CLIENT_ISA_END }; -/* Very inefficient for ISA detects, and won't work for 10-bit addresses! */ +/* Won't work for 10-bit addresses! */ int i2c_detect (struct i2c_adapter *adapter,struct i2c_address_data *address_data,int (*found_proc) (struct i2c_adapter *,int ,int )) {int addr, i, found, j, err;struct i2c_force_data *this_force; -int is_isa =i2c_is_isa_adapter (adapter); -int adapter_id = - is_isa ?ANY_I2C_ISA_BUS :i2c_adapter_id (adapter); +int adapter_id =i2c_adapter_id (adapter);unsigned short *normal_i2c; -unsigned int *normal_isa;unsigned short *probe;unsigned short *ignore;/* Forget it if we can't probe using SMBUS_QUICK */ -if ((!is_isa) && - !i2c_check_functionality (adapter,I2C_FUNC_SMBUS_QUICK )) +if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_QUICK ))return -1 ;/* Use default "empty" list if the adapter doesn't specify any */ normal_i2c = probe = ignore = empty; - normal_isa = empty_isa;if (address_data->normal_i2c) normal_i2c = address_data->normal_i2c; -if (address_data->normal_isa) - normal_isa = address_data->normal_isa;if (address_data->probe) probe = address_data->probe;if (address_data->ignore) ignore = address_data->ignore; -for (addr =0x00 ; addr <= (is_isa ?0xffff :0x7f ); addr++) { -if (!is_isa &&i2c_check_addr (adapter, addr)) +for (addr =0x00 ; addr <=0x7f ; addr++) { +if (i2c_check_addr (adapter, addr))continue ;/* If it is in one of the force entries, we don't do any
@@ -69,7 +61,7 @@for (i =0 ; !found && (this_force = address_data->forces + i, this_force->force); i++) {for (j =0 ; !found && (this_force->force[j] !=I2C_CLIENT_END ); j +=2 ) {if ( ((adapter_id == this_force->force[j]) || - ((this_force->force[j] ==ANY_I2C_BUS ) && !is_isa)) && + (this_force->force[j] ==ANY_I2C_BUS )) && (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, this_force->kind)))
@@ -85,8 +77,7 @@right now */ for (i =0 ; !found && (ignore[i] !=I2C_CLIENT_END ); i +=2 ) {if ( ((adapter_id == ignore[i]) || - ((ignore[i] ==ANY_I2C_BUS ) && - !is_isa)) && + (ignore[i] ==ANY_I2C_BUS )) && (addr == ignore[i +1 ])) {dev_dbg (&adapter->dev,"found ignore parameter for adapter %d, addr %04x\n" , adapter_id, addr); found =1 ;
@@ -97,19 +88,10 @@/* Now, we will do a detection, but only if it is in the normal or probe entries */ -if (is_isa) { -for (i =0 ; !found && (normal_isa[i] !=I2C_CLIENT_ISA_END ); i +=1 ) { -if (addr == normal_isa[i]) { -dev_dbg (&adapter->dev,"found normal isa entry for adapter %d, addr %04x\n" , adapter_id, addr); - found =1 ; - } - } - }else { -for (i =0 ; !found && (normal_i2c[i] !=I2C_CLIENT_END ); i +=1 ) { -if (addr == normal_i2c[i]) { - found =1 ; -dev_dbg (&adapter->dev,"found normal i2c entry for adapter %d, addr %02x\n" , adapter_id, addr); - } +for (i =0 ; !found && (normal_i2c[i] !=I2C_CLIENT_END ); i +=1 ) { +if (addr == normal_i2c[i]) { + found =1 ; +dev_dbg (&adapter->dev,"found normal i2c entry for adapter %d, addr %02x\n" , adapter_id, addr); } }
@@ -117,7 +99,7 @@ !found && (probe[i] !=I2C_CLIENT_END ); i += 2) {if (((adapter_id == probe[i]) || - ((probe[i] ==ANY_I2C_BUS ) && !is_isa)) + (probe[i] ==ANY_I2C_BUS )) && (addr == probe[i +1 ])) {dev_dbg (&adapter->dev,"found probe parameter for adapter %d, addr %04x\n" , adapter_id, addr); found =1 ;
@@ -128,8 +110,7 @@/* OK, so we really should examine this address. First check 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 (i2c_smbus_xfer (adapter, addr,0 ,0 ,0 ,I2C_SMBUS_QUICK ,NULL ) >=0 )if ((err =found_proc (adapter, addr,-1 )))return err; }
Signature · 1 line
Jean Delvare
PATCH 1/1 I2C: Separate non-i2c hwmon drivers from i2c-core (7/9)
In reply to Jean DelvareKill normal_isa in header files, documentation and all chip drivers, as it is no more used.
normal_i2c could be renamed to normal, but I decided not to do so at the moment, so as to limit the number of changes. This might be done later as part of the i2c_probe/i2c_detect merge.
Documentation/i2c/porting-clients | 7 ++++--- Documentation/i2c/writing-clients | 35 +++++++++++++++-------------------- drivers/hwmon/adm1021.c | 1 - drivers/hwmon/adm1025.c | 1 - drivers/hwmon/adm1026.c | 1 - drivers/hwmon/adm1031.c | 1 - drivers/hwmon/adm9240.c | 2 -- drivers/hwmon/asb100.c | 3 --- drivers/hwmon/atxp1.c | 1 - drivers/hwmon/ds1621.c | 1 - drivers/hwmon/fscher.c | 1 - drivers/hwmon/fscpos.c | 1 - drivers/hwmon/gl518sm.c | 1 - drivers/hwmon/gl520sm.c | 1 - drivers/hwmon/it87.c | 1 - drivers/hwmon/lm63.c | 1 - drivers/hwmon/lm75.c | 1 - drivers/hwmon/lm77.c | 1 - drivers/hwmon/lm78.c | 1 - drivers/hwmon/lm80.c | 1 - drivers/hwmon/lm83.c | 1 - drivers/hwmon/lm85.c | 1 - drivers/hwmon/lm87.c | 1 - drivers/hwmon/lm90.c | 1 - drivers/hwmon/lm92.c | 1 - drivers/hwmon/max1619.c | 1 - drivers/hwmon/w83781d.c | 1 - drivers/hwmon/w83l785ts.c | 1 - drivers/i2c/chips/ds1337.c | 1 - drivers/i2c/chips/eeprom.c | 1 - drivers/i2c/chips/max6875.c | 1 - drivers/i2c/chips/pca9539.c | 1 - drivers/i2c/chips/pcf8574.c | 1 - drivers/i2c/chips/pcf8591.c | 1 - include/linux/i2c-sensor.h | 36 +++++++++++++++--------------------- include/linux/i2c.h | 8 ++------ 36 files changed, 36 insertions(+), 85 deletions(-)
Documentation/i2c/writing-clients +15 -20
@@ -195,31 +195,28 @@ ------------------------- If you write a `sensors' driver, you use a slightly different interface. -As well as I2C addresses, we have to cope with ISA addresses. Also, we -use a enum of chip types. Don't forget to include `sensors.h'. +Also, we use a enum of chip types. Don't forget to include `sensors.h'. The following lists are used internally. They are all lists of integers. - normal_i2c: filled in by the module writer. Terminated by SENSORS_I2C_END. + normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_END. A list of I2C addresses which should normally be examined. - normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END. - A list of ISA addresses which should normally be examined. - probe: insmod parameter. Initialize this list with SENSORS_I2C_END values. - A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for - the ISA bus, -1 for any I2C bus), the second is the address. These - addresses are also probed, as if they were in the 'normal' list. - ignore: insmod parameter. Initialize this list with SENSORS_I2C_END values. - A list of pairs. The first value is a bus number (SENSORS_ISA_BUS for - the ISA bus, -1 for any I2C bus), the second is the I2C address. These - addresses are never probed. This parameter overrules 'normal' and - 'probe', but not the 'force' lists. + probe: insmod parameter. Initialize this list with I2C_CLIENT_END values. + A list of pairs. The first value is a bus number (ANY_I2C_BUS for any + I2C bus), the second is the address. These addresses are also probed, + as if they were in the 'normal' list. + ignore: insmod parameter. Initialize this list with I2C_CLIENT_END values. + A list of pairs. The first value is a bus number (ANY_I2C_BUS for any + I2C bus), the second is the I2C address. These addresses are never + probed. This parameter overrules 'normal' and 'probe', but not the + 'force' lists. Also used is a list of pointers to sensors_force_data structures: force_data: insmod parameters. A list, ending with an element of which the force field is NULL. Each element contains the type of chip and a list of pairs. - The first value is a bus number (SENSORS_ISA_BUS for the ISA bus, - -1 for any I2C bus), the second is the address. + The first value is a bus number (ANY_I2C_BUS for any I2C bus), the + second is the address. These are automatically translated to insmod variables of the form force_foo.
@@ -227,13 +224,11 @@ `force_CHIPNAME'. Fortunately, as a module writer, you just have to define the `normal_i2c' -and `normal_isa' parameters, and define what chip names are used. -The complete declaration could look like this: +parameter, and define what chip names are used. The complete declaration +could look like this: /* Scan i2c addresses 0x37, and 0x48 to 0x4f */ static unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; - /* Scan ISA address 0x290 */ - static unsigned int normal_isa[] = {0x0290,SENSORS_ISA_END}; /* Define chips foo and bar, as well as all module parameters and things */ SENSORS_INSMOD_2(foo,bar);
drivers/hwmon/adm1021.c +0 -1
@@ -34,7 +34,6 @@0x29 ,0x2a ,0x2b ,0x4c ,0x4d ,0x4e , I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_8 (adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066);
drivers/hwmon/adm1025.c +0 -1
@@ -62,7 +62,6 @@*/ static unsigned short normal_i2c[] = {0x2c ,0x2d ,0x2e ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* * Insmod parameters
drivers/hwmon/adm1026.c +0 -1
@@ -36,7 +36,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x2c ,0x2d ,0x2e ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (adm1026);
drivers/hwmon/adm1031.c +0 -1
@@ -61,7 +61,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x2c ,0x2d ,0x2e ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_2 (adm1030, adm1031);
drivers/hwmon/adm9240.c +0 -2
@@ -54,8 +54,6 @@static unsigned short normal_i2c[] = {0x2c ,0x2d ,0x2e ,0x2f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END }; -/* Insmod parameters */ SENSORS_INSMOD_3 (adm9240, ds1780, lm81);
drivers/hwmon/asb100.c +0 -3
@@ -56,9 +56,6 @@/* I2C addresses to scan */ static unsigned short normal_i2c[] = {0x2d ,I2C_CLIENT_END }; -/* ISA addresses to scan (none) */ -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END }; -/* Insmod parameters */ SENSORS_INSMOD_1 (asb100); I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
drivers/hwmon/atxp1.c +0 -1
@@ -42,7 +42,6 @@#define ATXP1_GPIO1MASK 0x0fstatic unsigned short normal_i2c[] = {0x37 ,0x4e ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };SENSORS_INSMOD_1 (atxp1);
drivers/hwmon/ds1621.c +0 -1
@@ -34,7 +34,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x48 ,0x49 ,0x4a ,0x4b ,0x4c ,0x4d ,0x4e ,0x4f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (ds1621);
drivers/hwmon/fscher.c +0 -1
@@ -40,7 +40,6 @@*/ static unsigned short normal_i2c[] = {0x73 ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* * Insmod parameters
drivers/hwmon/fscpos.c +0 -1
@@ -43,7 +43,6 @@* Addresses to scan */ static unsigned short normal_i2c[] = {0x73 ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* * Insmod parameters
drivers/hwmon/gl518sm.c +0 -1
@@ -47,7 +47,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x2c ,0x2d ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_2 (gl518sm_r00, gl518sm_r80);
drivers/hwmon/gl520sm.c +0 -1
@@ -38,7 +38,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x2c ,0x2d ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (gl520sm);
drivers/hwmon/it87.c +0 -1
@@ -48,7 +48,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e ,0x2f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };static unsigned short isa_address =0x290 ;/* Insmod parameters */
drivers/hwmon/lm63.c +0 -1
@@ -53,7 +53,6 @@*/ static unsigned short normal_i2c[] = {0x4c ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* * Insmod parameters
drivers/hwmon/lm75.c +0 -1
@@ -32,7 +32,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x48 ,0x49 ,0x4a ,0x4b ,0x4c ,0x4d ,0x4e ,0x4f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (lm75);
drivers/hwmon/lm77.c +0 -1
@@ -36,7 +36,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x48 ,0x49 ,0x4a ,0x4b ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (lm77);
drivers/hwmon/lm78.c +0 -1
@@ -34,7 +34,6 @@0x25 ,0x26 ,0x27 ,0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e , 0x2f, I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };static unsigned short isa_address =0x290 ;/* Insmod parameters */
drivers/hwmon/lm80.c +0 -1
@@ -33,7 +33,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e ,0x2f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (lm80);
drivers/hwmon/lm83.c +0 -1
@@ -47,7 +47,6 @@0x29 ,0x2a ,0x2b ,0x4c ,0x4d ,0x4e , I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* * Insmod parameters
drivers/hwmon/lm85.c +0 -1
@@ -35,7 +35,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x2c ,0x2d ,0x2e ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_6 (lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102);
drivers/hwmon/lm87.c +0 -1
@@ -68,7 +68,6 @@*/ static unsigned short normal_i2c[] = {0x2c ,0x2d ,0x2e ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* * Insmod parameters
drivers/hwmon/lm90.c +0 -1
@@ -91,7 +91,6 @@*/ static unsigned short normal_i2c[] = {0x4c ,0x4d ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* * Insmod parameters
drivers/hwmon/lm92.c +0 -1
@@ -52,7 +52,6 @@resulting in 4 possible addresses. */ static unsigned short normal_i2c[] = {0x48 ,0x49 ,0x4a ,0x4b ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (lm92);
drivers/hwmon/max1619.c +0 -1
@@ -39,7 +39,6 @@0x29 ,0x2a ,0x2b ,0x4c ,0x4d ,0x4e , I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* * Insmod parameters
drivers/hwmon/w83781d.c +0 -1
@@ -50,7 +50,6 @@static unsigned short normal_i2c[] = {0x20 ,0x21 ,0x22 ,0x23 ,0x24 ,0x25 ,0x26 ,0x27 ,0x28 ,0x29 ,0x2a ,0x2b ,0x2c ,0x2d ,0x2e ,0x2f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };static unsigned short isa_address =0x290 ;/* Insmod parameters */
drivers/hwmon/w83l785ts.c +0 -1
@@ -49,7 +49,6 @@*/ static unsigned short normal_i2c[] = {0x2e ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* * Insmod parameters
drivers/i2c/chips/ds1337.c +0 -1
@@ -39,7 +39,6 @@* Functions declaration */ static unsigned short normal_i2c[] = {0x68 ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };SENSORS_INSMOD_1 (ds1337);
drivers/i2c/chips/eeprom.c +0 -1
@@ -38,7 +38,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x50 ,0x51 ,0x52 ,0x53 ,0x54 ,0x55 ,0x56 ,0x57 ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (eeprom);
drivers/i2c/chips/max6875.c +0 -1
@@ -39,7 +39,6 @@/* Addresses to scan */ /* No address scanned by default, as this could corrupt standard EEPROMS. */ static unsigned short normal_i2c[] = {I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (max6875);
drivers/i2c/chips/pca9539.c +0 -1
@@ -17,7 +17,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x74 ,0x75 ,0x76 ,0x77 ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (pca9539);
drivers/i2c/chips/pcf8574.c +0 -1
@@ -45,7 +45,6 @@static unsigned short normal_i2c[] = {0x20 ,0x21 ,0x22 ,0x23 ,0x24 ,0x25 ,0x26 ,0x27 ,0x38 ,0x39 ,0x3a ,0x3b ,0x3c ,0x3d ,0x3e ,0x3f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_2 (pcf8574, pcf8574a);
drivers/i2c/chips/pcf8591.c +0 -1
@@ -29,7 +29,6 @@/* Addresses to scan */ static unsigned short normal_i2c[] = {0x48 ,0x49 ,0x4a ,0x4b ,0x4c ,0x4d ,0x4e ,0x4f ,I2C_CLIENT_END }; -static unsigned int normal_isa[] = {I2C_CLIENT_ISA_END };/* Insmod parameters */ SENSORS_INSMOD_1 (pcf8591);
include/linux/i2c-sensor.h +15 -21
@@ -27,11 +27,10 @@that place. If a specific chip is given, the module blindly assumes this chip type is present; if a general force (kind == 0) is given, the module will still try to figure out what type of chip is present. This is useful -if for some reasons the detect for SMBus or ISA address space filled -fails. -probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values. -A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for -the ISA bus, -1 for any I2C bus), the second is the address. +if for some reasons the detect for SMBus address space filled fails. +probe: insmod parameter. Initialize this list with I2C_CLIENT_END values. +A list of pairs. The first value is a bus number (ANY_I2C_BUS for any +I2C bus), the second is the address. kind: The kind of chip. 0 equals any chip. */ struct i2c_force_data {
@@ -40,25 +39,22 @@ };/* A structure containing the detect information. -normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_ISA_END. +normal_i2c: filled in by the module writer. Terminated by I2C_CLIENT_END. A list of I2C addresses which should normally be examined. -normal_isa: filled in by the module writer. Terminated by SENSORS_ISA_END. -A list of ISA addresses which should normally be examined. -probe: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values. -A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for -the ISA bus, -1 for any I2C bus), the second is the address. These -addresses are also probed, as if they were in the 'normal' list. -ignore: insmod parameter. Initialize this list with I2C_CLIENT_ISA_END values. -A list of pairs. The first value is a bus number (ANY_I2C_ISA_BUS for -the ISA bus, -1 for any I2C bus), the second is the I2C address. These -addresses are never probed. This parameter overrules 'normal' and -'probe', but not the 'force' lists. +probe: insmod parameter. Initialize this list with I2C_CLIENT_END values. +A list of pairs. The first value is a bus number (ANY_I2C_BUS for any +I2C bus), the second is the address. These addresses are also probed, +as if they were in the 'normal' list. +ignore: insmod parameter. Initialize this list with I2C_CLIENT_END values. +A list of pairs. The first value is a bus number (ANY_I2C_BUS for any +I2C bus), the second is the I2C address. These addresses are never +probed. This parameter overrules 'normal' and probe', but not the +'force' lists. force_data: insmod parameters. A list, ending with an element of which the force field is NULL. */ struct i2c_address_data {unsigned short *normal_i2c; -unsigned int *normal_isa;unsigned short *probe;unsigned short *ignore;struct i2c_force_data *forces;
@@ -78,7 +74,6 @@ "List of adapter,address pairs not to scan"); \static struct i2c_address_data addr_data = { \ .normal_i2c = normal_i2c, \ - .normal_isa = normal_isa, \ .probe = probe, \ .ignore = ignore, \ .forces = forces, \
@@ -242,8 +237,7 @@/* Detect function. It iterates over all possible addresses itself. For SMBus addresses, it will only call found_proc if some client is connected -to the SMBus (unless a 'force' matched); for ISA detections, this is not -done. */ +to the SMBus (unless a 'force' matched). */ extern int i2c_detect (struct i2c_adapter *adapter,struct i2c_address_data *address_data,int (*found_proc) (struct i2c_adapter *,int ,int ));
include/linux/i2c.h +2 -6
@@ -150,12 +150,9 @@*/ struct i2c_client {unsigned int flags;/* div., see below */ -unsigned int addr;/* chip address - NOTE: 7bit */ +unsigned short addr;/* chip address - NOTE: 7bit */ /* addresses are stored in the */ -/* _LOWER_ 7 bits of this char */ -/* addr: unsigned int to make lm_sensors i2c-isa adapter work -more cleanly. It does not take any more memory space, due to -alignment considerations */ +/* _LOWER_ 7 bits */ struct i2c_adapter *adapter;/* the adapter we sit on */ struct i2c_driver *driver;/* and our access routines */ int usage_count;/* How many accesses currently */
@@ -304,7 +301,6 @@/* Internal numbers to terminate lists */ #define I2C_CLIENT_END 0xfffeU -#define I2C_CLIENT_ISA_END 0xfffefffeU/* The numbers to use to set I2C bus address */ #define ANY_I2C_BUS 0xffff
Documentation/i2c/porting-clients +4 -3
@@ -29,8 +29,8 @@ Please respect this inclusion order. Some extra headers may be required for a given driver (e.g. "lm75.h"). -* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, SENSORS_ISA_END - becomes I2C_CLIENT_ISA_END. +* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, ISA addresses + are no more handled by the i2c core. * [Client data] Get rid of sysctl_id. Try using standard names for register values (for example, temp_os becomes temp_max). You're
@@ -72,7 +72,8 @@ name string, which will be filled with a lowercase, short string (typically the driver name, e.g. "lm75"). In i2c-only drivers, drop the i2c_is_isa_adapter check, it's - useless. + useless. Same for isa-only drivers, as the test would always be + true. Only hybrid drivers (which are quite rare) still need it. The errorN labels are reduced to the number needed. If that number is 2 (i2c-only drivers), it is advised that the labels are named exit and exit_free. For i2c+isa drivers, labels should be named
Signature · 1 line
Jean Delvare
PATCH 1/1 I2C: Separate non-i2c hwmon drivers from i2c-core (8/9)
In reply to Jean DelvareKill all uses of i2c_is_isa_adapter except for the hybrid drivers (it87, lm78, w83781d). The i2c-isa adapter not being registered with the i2c core anymore, drivers don't have to fear being erroneously attached to it.
Documentation/i2c/writing-clients | 11 +++++------ drivers/hwmon/adm1021.c | 9 --------- drivers/hwmon/asb100.c | 8 -------- drivers/hwmon/lm75.c | 10 ---------- drivers/hwmon/lm85.c | 5 ----- 5 files changed, 5 insertions(+), 38 deletions(-)
Documentation/i2c/writing-clients +5 -6
@@ -315,11 +315,10 @@ const char *type_name = ""; int is_isa = i2c_is_isa_adapter(adapter); - if (is_isa) { + /* Do this only if the chip can additionally be found on the ISA bus + (hybrid chip). */ - /* If this client can't be on the ISA bus at all, we can stop now - (call `goto ERROR0'). But for kicks, we will assume it is all - right. */ + if (is_isa) { /* Discard immediately if this ISA range is already used */ if (check_region(address,FOO_EXTENT))
@@ -495,10 +494,10 @@ return err; } - /* SENSORS ONLY START */ + /* HYBRID SENSORS CHIP ONLY START */ if i2c_is_isa_client(client) release_region(client->addr,LM78_EXTENT); - /* SENSORS ONLY END */ + /* HYBRID SENSORS CHIP ONLY END */ kfree(client); /* Frees client data too, if allocated at the same time */ return 0;
drivers/hwmon/adm1021.c +0 -9
@@ -198,15 +198,6 @@int err =0 ;const char *type_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)) { -dev_dbg (&adapter->dev,"adm1021_detect called for an ISA bus adapter?!?\n" ); -return 0 ; - } -#endif -if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA )) goto error0;
drivers/hwmon/asb100.c +0 -8
@@ -714,14 +714,6 @@struct i2c_client *new_client;struct asb100_data *data; -/* asb100 is SMBus only */ -if (i2c_is_isa_adapter (adapter)) { -pr_debug ("asb100.o: detect failed, " -"cannot attach to legacy adapter!\n" ); - err = -ENODEV ; - goto ERROR0; - } -if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA )) {pr_debug ("asb100.o: detect failed, " "smbus byte data not supported!\n" );
drivers/hwmon/lm75.c +0 -10
@@ -121,16 +121,6 @@int err =0 ;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)) { -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 exit;
drivers/hwmon/lm85.c +0 -5
@@ -1033,11 +1033,6 @@int err =0 ;const char *type_name ="" ; -if (i2c_is_isa_adapter (adapter)) { -/* This chip has no ISA interface */ - goto ERROR0 ; - }; -if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA )) {/* We need to be able to do byte I/O */
Signature · 1 line
Jean Delvare
[email protected]
Appliedpatch i2c-hwmon-split-08.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled
Subject: I2C: Separate non-i2c hwmon drivers from i2c-core (8/9)
to my gregkh-2.6 tree. Its filename is
i2c-hwmon-split-08.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Patches currently in gregkh-2.6 which might be from [email protected] are
i2c/i2c-max6875-documentation-update.patchi2c/i2c-max6875-simplify.patchi2c/i2c-hwmon-class-01.patchi2c/i2c-hwmon-class-02.patchi2c/i2c-hwmon-class-03.patchi2c/i2c-missing-space.patchi2c/i2c-nforce2-cleanup.patchi2c/i2c-hwmon-split-01.patchi2c/i2c-hwmon-split-02.patchi2c/i2c-hwmon-split-03.patchi2c/i2c-hwmon-split-04.patchi2c/i2c-hwmon-split-05.patchi2c/i2c-hwmon-split-06.patchi2c/i2c-hwmon-split-07.patchi2c/i2c-hwmon-split-08.patchi2c/i2c-hwmon-split-09.patch
Quoted 1 line
From [email protected] Tue Jul 19 18:06:45 2005
Date: Wed, 20 Jul 2005 00:05:33 +0200
From: Jean Delvare <[email protected]>
To: LKML <[email protected]>, LM Sensors
<[email protected]>
Cc: Greg KH <[email protected]>
Subject: I2C: Separate non-i2c hwmon drivers from i2c-core (8/9)
Message-Id: <[email protected]>
Kill all uses of i2c_is_isa_adapter except for the hybrid drivers (it87, lm78, w83781d). The i2c-isa adapter not being registered with the i2c core anymore, drivers don't have to fear being erroneously attached to it.
--- Documentation/i2c/writing-clients | 11 +++++------ drivers/hwmon/adm1021.c | 9 --------- drivers/hwmon/asb100.c | 8 -------- drivers/hwmon/lm75.c | 10 ---------- drivers/hwmon/lm85.c | 5 ----- 5 files changed, 5 insertions(+), 38 deletions(-)
Documentation/i2c/writing-clients +5 -6
@@ -315,11 +315,10 @@ const char *type_name = ""; int is_isa = i2c_is_isa_adapter(adapter); - if (is_isa) { + /* Do this only if the chip can additionally be found on the ISA bus + (hybrid chip). */ - /* If this client can't be on the ISA bus at all, we can stop now - (call `goto ERROR0'). But for kicks, we will assume it is all - right. */ + if (is_isa) { /* Discard immediately if this ISA range is already used */ if (check_region(address,FOO_EXTENT))
@@ -495,10 +494,10 @@ return err; } - /* SENSORS ONLY START */ + /* HYBRID SENSORS CHIP ONLY START */ if i2c_is_isa_client(client) release_region(client->addr,LM78_EXTENT); - /* SENSORS ONLY END */ + /* HYBRID SENSORS CHIP ONLY END */ kfree(client); /* Frees client data too, if allocated at the same time */ return 0;
drivers/hwmon/adm1021.c +0 -9
@@ -198,15 +198,6 @@int err =0 ;const char *type_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)) { -dev_dbg (&adapter->dev,"adm1021_detect called for an ISA bus adapter?!?\n" ); -return 0 ; - } -#endif -if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA )) goto error0;
drivers/hwmon/asb100.c +0 -8
@@ -714,14 +714,6 @@struct i2c_client *new_client;struct asb100_data *data; -/* asb100 is SMBus only */ -if (i2c_is_isa_adapter (adapter)) { -pr_debug ("asb100.o: detect failed, " -"cannot attach to legacy adapter!\n" ); - err = -ENODEV ; - goto ERROR0; - } -if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA )) {pr_debug ("asb100.o: detect failed, " "smbus byte data not supported!\n" );
drivers/hwmon/lm75.c +0 -10
@@ -121,16 +121,6 @@int err =0 ;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)) { -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 exit;
drivers/hwmon/lm85.c +0 -5
@@ -1033,11 +1033,6 @@int err =0 ;const char *type_name ="" ; -if (i2c_is_isa_adapter (adapter)) { -/* This chip has no ISA interface */ - goto ERROR0 ; - }; -if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA )) {/* We need to be able to do byte I/O */
PATCH 1/1 I2C: Separate non-i2c hwmon drivers from i2c-core (9/9)
In reply to Jean DelvareMove the definitions of i2c_is_isa_client and i2c_is_isa_adapter from i2c.h to i2c-isa.h. Only hybrid drivers still need them.
include/linux/i2c-isa.h | 7 +++++++ include/linux/i2c.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-)
include/linux/i2c-isa.h +7 -0
@@ -26,4 +26,11 @@extern int i2c_isa_add_driver (struct i2c_driver *driver);extern int i2c_isa_del_driver (struct i2c_driver *driver); +/* Detect whether we are on the isa bus. This is only useful to hybrid +(i2c+isa) drivers. */ +#define i2c_is_isa_client (clientptr) \ + ((clientptr)->adapter->algo->id == I2C_ALGO_ISA) +#define i2c_is_isa_adapter (adapptr) \ + ((adapptr)->algo->id == I2C_ALGO_ISA) +#endif /* _LINUX_I2C_ISA_H */
include/linux/i2c.h +0 -7
@@ -575,11 +575,4 @@ .force = force, \ } -/* Detect whether we are on the isa bus. If this returns true, all i2c -access will fail! */ -#define i2c_is_isa_client (clientptr) \ - ((clientptr)->adapter->algo->id == I2C_ALGO_ISA) -#define i2c_is_isa_adapter (adapptr) \ - ((adapptr)->algo->id == I2C_ALGO_ISA) -#endif /* _LINUX_I2C_H */
Signature · 1 line
Jean Delvare
[email protected]
Appliedpatch i2c-hwmon-split-09.patch added to gregkh-2.6 tree
This is a note to let you know that I've just added the patch titled
Subject: I2C: Separate non-i2c hwmon drivers from i2c-core (9/9)
to my gregkh-2.6 tree. Its filename is
i2c-hwmon-split-09.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Patches currently in gregkh-2.6 which might be from [email protected] are
i2c/i2c-max6875-documentation-update.patchi2c/i2c-max6875-simplify.patchi2c/i2c-hwmon-class-01.patchi2c/i2c-hwmon-class-02.patchi2c/i2c-hwmon-class-03.patchi2c/i2c-missing-space.patchi2c/i2c-nforce2-cleanup.patchi2c/i2c-hwmon-split-01.patchi2c/i2c-hwmon-split-02.patchi2c/i2c-hwmon-split-03.patchi2c/i2c-hwmon-split-04.patchi2c/i2c-hwmon-split-05.patchi2c/i2c-hwmon-split-06.patchi2c/i2c-hwmon-split-07.patchi2c/i2c-hwmon-split-08.patchi2c/i2c-hwmon-split-09.patch
Quoted 1 line
From [email protected] Tue Jul 19 18:12:04 2005
Date: Wed, 20 Jul 2005 00:09:03 +0200
From: Jean Delvare <[email protected]>
To: LKML <[email protected]>, LM Sensors
<[email protected]>
Cc: Greg KH <[email protected]>
Subject: I2C: Separate non-i2c hwmon drivers from i2c-core (9/9)
Message-Id: <[email protected]>
Move the definitions of i2c_is_isa_client and i2c_is_isa_adapter from i2c.h to i2c-isa.h. Only hybrid drivers still need them.
--- include/linux/i2c-isa.h | 7 +++++++ include/linux/i2c.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-)
include/linux/i2c-isa.h +7 -0
@@ -26,4 +26,11 @@extern int i2c_isa_add_driver (struct i2c_driver *driver);extern int i2c_isa_del_driver (struct i2c_driver *driver); +/* Detect whether we are on the isa bus. This is only useful to hybrid +(i2c+isa) drivers. */ +#define i2c_is_isa_client (clientptr) \ + ((clientptr)->adapter->algo->id == I2C_ALGO_ISA) +#define i2c_is_isa_adapter (adapptr) \ + ((adapptr)->algo->id == I2C_ALGO_ISA) +#endif /* _LINUX_I2C_ISA_H */
include/linux/i2c.h +0 -7
@@ -575,11 +575,4 @@ .force = force, \ } -/* Detect whether we are on the isa bus. If this returns true, all i2c -access will fail! */ -#define i2c_is_isa_client (clientptr) \ - ((clientptr)->adapter->algo->id == I2C_ALGO_ISA) -#define i2c_is_isa_adapter (adapptr) \ - ((adapptr)->algo->id == I2C_ALGO_ISA) -#endif /* _LINUX_I2C_H */