summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGerd Knorr <kraxel@bytesex.org>2003-05-06 03:16:15 -0700
committerGreg Kroah-Hartman <greg@kroah.com>2003-05-06 03:16:15 -0700
commit22f0b1c04d049a47efcbdf387ad706d4786d78d8 (patch)
tree33d9e7caf4484718c50fea978ca01918a0dc0d95 /include
parent6230bb0120e2b00b34497683c5c8d88f6ada2546 (diff)
[PATCH] i2c #1/3: listify i2c core
This is the first of tree patches for i2c. Trying to get the i2c cleanups finshed before 2.6.x, so we (hopefully) don't have a ever-changing i2c subsystem in 2.7.x again (which is very annonying for driver maintainance). Changes: * listify i2c-core, i.e. make it use <linux/list.h> instead of statically-sized arrays, removed lots of ugly code :) * added i2c_(get|put)_adapter, changed i2c-dev.c to use these functions instead maintaining is own adapter list. * killed the I2C_DF_DUMMY flag which had the strange semantics to make the i2c subsystem call driver->attach_adapter on detaches. Added a detach_adapter() callback instead. * some other minor cleanups along the way ...
Diffstat (limited to 'include')
-rw-r--r--include/linux/i2c.h28
1 files changed, 16 insertions, 12 deletions
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index c506e41b9303..b73144445657 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -39,12 +39,6 @@
/* --- General options ------------------------------------------------ */
-#define I2C_ALGO_MAX 4 /* control memory consumption */
-#define I2C_ADAP_MAX 16
-#define I2C_DRIVER_MAX 16
-#define I2C_CLIENT_MAX 32
-#define I2C_DUMMY_MAX 4
-
struct i2c_msg;
struct i2c_algorithm;
struct i2c_adapter;
@@ -131,6 +125,7 @@ struct i2c_driver {
* i2c_attach_client.
*/
int (*attach_adapter)(struct i2c_adapter *);
+ int (*detach_adapter)(struct i2c_adapter *);
/* tells the driver that a client is about to be deleted & gives it
* the chance to remove its private data. Also, if the client struct
@@ -145,6 +140,7 @@ struct i2c_driver {
int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
struct device_driver driver;
+ struct list_head list;
};
#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
@@ -169,6 +165,7 @@ struct i2c_client {
int usage_count; /* How many accesses currently */
/* to the client */
struct device dev; /* the device structure */
+ struct list_head list;
};
#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
@@ -236,12 +233,10 @@ struct i2c_adapter {
int (*client_unregister)(struct i2c_client *);
/* data fields that are valid for all devices */
- struct semaphore bus;
- struct semaphore list;
+ struct semaphore bus_lock;
+ struct semaphore clist_lock;
unsigned int flags;/* flags specifying div. data */
- struct i2c_client *clients[I2C_CLIENT_MAX];
-
int timeout;
int retries;
struct device dev; /* the adapter device */
@@ -250,6 +245,10 @@ struct i2c_adapter {
/* No need to set this when you initialize the adapter */
int inode;
#endif /* def CONFIG_PROC_FS */
+
+ int nr;
+ struct list_head clients;
+ struct list_head list;
};
#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
@@ -265,7 +264,11 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
/*flags for the driver struct: */
#define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */
-#define I2C_DF_DUMMY 0x02 /* do not connect any clients */
+#if 0
+/* this flag is gone -- there is a (optional) driver->detach_adapter
+ * callback now which can be used instead */
+# define I2C_DF_DUMMY 0x02
+#endif
/*flags for the client struct: */
#define I2C_CLIENT_ALLOW_USE 0x01 /* Client allows access */
@@ -352,7 +355,8 @@ extern int i2c_control(struct i2c_client *,unsigned int, unsigned long);
* or -1 if the adapter was not registered.
*/
extern int i2c_adapter_id(struct i2c_adapter *adap);
-
+extern struct i2c_adapter* i2c_get_adapter(int id);
+extern void i2c_put_adapter(struct i2c_adapter *adap);
/* Return the functionality mask */