diff options
author | David Brownell <david-b@pacbell.net> | 2008-01-27 12:14:51 -0500 |
---|---|---|
committer | Jean Delvare <khali@hyperion.delvare> | 2008-01-27 12:14:51 -0500 |
commit | 9b766b814d6a5f31ca1e9da1ebc08164b9352941 (patch) | |
tree | ce6256c11002c356ee8b632f2a7d08793dd30f82 /drivers/i2c/i2c-dev.c | |
parent | 0d227a7e724460bddcd603a1feb672267bcb0d6c (diff) |
i2c: Stop using the redundant client list
The i2c_adapter.clients list of i2c_client nodes duplicates driver
model state. This patch starts removing that list, letting us remove
most existing users of those i2c-core lists.
* The core I2C code now iterates over the driver model's list instead
of the i2c-internal one in some places where it's safe:
- Passing a command/ioctl to each client, a mechanims
used almost exclusively by DVB adapters;
- Device address checking, in both i2c-core and i2c-dev.
* Provide i2c_verify_client() to use with driver model iterators.
* Flag the relevant i2c_adapter and i2c_client fields as deprecated,
to help prevent new users from appearing.
For the moment the list needs to stick around, since some issues show
up when deleting devices created by legacy I2C drivers. (They don't
follow standard driver model rules. Removing those devices can cause
self-deadlocks.)
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/i2c-dev.c')
-rw-r--r-- | drivers/i2c/i2c-dev.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index df540d5dfaf4..393e679d9faa 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -182,27 +182,22 @@ static ssize_t i2cdev_write (struct file *file, const char __user *buf, size_t c | |||
182 | return ret; | 182 | return ret; |
183 | } | 183 | } |
184 | 184 | ||
185 | static int i2cdev_check(struct device *dev, void *addrp) | ||
186 | { | ||
187 | struct i2c_client *client = i2c_verify_client(dev); | ||
188 | |||
189 | if (!client || client->addr != *(unsigned int *)addrp) | ||
190 | return 0; | ||
191 | |||
192 | return dev->driver ? -EBUSY : 0; | ||
193 | } | ||
194 | |||
185 | /* This address checking function differs from the one in i2c-core | 195 | /* This address checking function differs from the one in i2c-core |
186 | in that it considers an address with a registered device, but no | 196 | in that it considers an address with a registered device, but no |
187 | bound driver, as NOT busy. */ | 197 | driver bound to it, as NOT busy. */ |
188 | static int i2cdev_check_addr(struct i2c_adapter *adapter, unsigned int addr) | 198 | static int i2cdev_check_addr(struct i2c_adapter *adapter, unsigned int addr) |
189 | { | 199 | { |
190 | struct list_head *item; | 200 | return device_for_each_child(&adapter->dev, &addr, i2cdev_check); |
191 | struct i2c_client *client; | ||
192 | int res = 0; | ||
193 | |||
194 | mutex_lock(&adapter->clist_lock); | ||
195 | list_for_each(item, &adapter->clients) { | ||
196 | client = list_entry(item, struct i2c_client, list); | ||
197 | if (client->addr == addr) { | ||
198 | if (client->driver) | ||
199 | res = -EBUSY; | ||
200 | break; | ||
201 | } | ||
202 | } | ||
203 | mutex_unlock(&adapter->clist_lock); | ||
204 | |||
205 | return res; | ||
206 | } | 201 | } |
207 | 202 | ||
208 | static int i2cdev_ioctl(struct inode *inode, struct file *file, | 203 | static int i2cdev_ioctl(struct inode *inode, struct file *file, |