diff options
| author | Greg Kroah-Hartman <greg@kroah.com> | 2003-03-12 20:26:39 -0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <greg@kroah.com> | 2003-03-12 20:26:39 -0800 |
| commit | 500d525042b8b4f2df766c385380f8a8d5c4920e (patch) | |
| tree | 284df3c98c673d58b9e0c77fea4c0e0db746853c | |
| parent | 1464d8c7d4c095cd21f745ef3c07ea71a75b7fd4 (diff) | |
i2c: add i2c sysfs bus support.
| -rw-r--r-- | drivers/i2c/i2c-core.c | 33 | ||||
| -rw-r--r-- | include/linux/i2c.h | 3 |
2 files changed, 33 insertions, 3 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 238c5a31e4f3..6165e88a660c 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -598,10 +598,37 @@ static void __exit i2cproc_cleanup(void) { remove_proc_entry("i2c",proc_bus); } +#else +static int __init i2cproc_init(void) { return 0; } +static void __exit i2cproc_cleanup(void) { } +#endif /* CONFIG_PROC_FS */ + +/* match always succeeds, as we want the probe() to tell if we really accept this match */ +static int i2c_device_match(struct device *dev, struct device_driver *drv) +{ + return 1; +} + +struct bus_type i2c_bus_type = { + .name = "i2c", + .match = i2c_device_match, +}; + + +static int __init i2c_init(void) +{ + bus_register(&i2c_bus_type); + return i2cproc_init(); +} + +static void __exit i2c_exit(void) +{ + i2cproc_cleanup(); + bus_unregister(&i2c_bus_type); +} -module_init(i2cproc_init); -module_exit(i2cproc_cleanup); -#endif /* def CONFIG_PROC_FS */ +module_init(i2c_init); +module_exit(i2c_exit); /* ---------------------------------------------------- * the functional interface to the i2c busses. diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 0b293a405341..8f86852b16d8 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -34,6 +34,7 @@ #include <linux/module.h> #include <linux/types.h> #include <linux/i2c-id.h> +#include <linux/device.h> /* for struct device */ #include <asm/semaphore.h> /* --- General options ------------------------------------------------ */ @@ -144,6 +145,8 @@ struct i2c_driver { int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); }; +extern struct bus_type i2c_bus_type; + /* * i2c_client identifies a single device (i.e. chip) that is connected to an * i2c bus. The behaviour is defined by the routines of the driver. This |
