Skip to contentSkip to conversation

i2c-core.c: use list_for_each_entry_safe()

PATCH Applied [email protected] 2 participants 4 messages May 19, 2008 – May 20, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover i2c-core.c: use list_for_each_entry_safe()

i2c-core.c: use list_for_each_entry_safe() in i2c_del_adapter() and i2c_del_driver()

Signature · 10 lines
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
#1 lore raw

PATCH 1/2 i2c_del_adapter(): use list_for_each_entry_safe()

i2c-core.c: use list_for_each_entry_safe() in i2c_del_adapter()

drivers/i2c/i2c-core.c +2 -4
@@ -582,8 +582,7 @@
  */
 int i2c_del_adapter(struct i2c_adapter *adap)
 {
-	struct list_head  *item, *_n;
-	struct i2c_client *client;
+	struct i2c_client *client, *_n;
 	int res = 0;
 
 	mutex_lock(&core_lock);
@@ -604,10 +603,9 @@
 
 	/* detach any active clients. This must be done first, because
 	 * it can fail; in which case we give up. */
-	list_for_each_safe(item, _n, &adap->clients) {
+	list_for_each_entry_safe(client, _n, &adap->clients, list) {
 		struct i2c_driver	*driver;
 
-		client = list_entry(item, struct i2c_client, list);
 		driver = client->driver;
 
 		/* new style, follow standard driver model */
Signature · 10 lines
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
#2 lore raw

PATCH 2/2 i2c_del_driver(): use list_for_each_entry_safe()

In reply to [email protected]

i2c-core.c: use list_for_each_entry_safe() in i2c_del_driver()

drivers/i2c/i2c-core.c +2 -4
Index: linux-2.6/drivers/i2c/i2c-core.c
===================================================================
@@ -707,8 +707,7 @@
  */
 void i2c_del_driver(struct i2c_driver *driver)
 {
-	struct list_head   *item2, *_n;
-	struct i2c_client  *client;
+	struct i2c_client  *client, *_n;
 	struct i2c_adapter *adap;
 
 	mutex_lock(&core_lock);
@@ -730,8 +729,7 @@
 					driver->driver.name);
 			}
 		} else {
-			list_for_each_safe(item2, _n, &adap->clients) {
-				client = list_entry(item2, struct i2c_client, list);
+			list_for_each_entry_safe(client, _n, &adap->clients, list) {
 				if (client->driver != driver)
 					continue;
 				dev_dbg(&adap->dev, "detaching client [%s] "
Signature · 10 lines
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-