From d582963a027fd63f8dfc97a0bf3654d4380e34ce Mon Sep 17 00:00:00 2001
From: Jean Delvare <khali@linux-fr.org>
Date: Sun, 24 Oct 2010 18:16:57 +0200
Subject: i2c: Simplify i2c_parent_is_i2c_adapter

Only i2c devices can have their type set to i2c_adapter_type, so
testing the bus type is redundant.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Michael Lawnick <ml.lawnick@gmx.de>
---
 include/linux/i2c.h | 1 -
 1 file changed, 1 deletion(-)

(limited to 'include')

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 4bae0b72ed3c..9391a491501a 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -387,7 +387,6 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data)
 static inline int i2c_parent_is_i2c_adapter(const struct i2c_adapter *adapter)
 {
 	return adapter->dev.parent != NULL
-		&& adapter->dev.parent->bus == &i2c_bus_type
 		&& adapter->dev.parent->type == &i2c_adapter_type;
 }
 
-- 
cgit v1.2.3


From 97cc4d49cfcda1c2dad89c00b62a25b628ce2115 Mon Sep 17 00:00:00 2001
From: Jean Delvare <khali@linux-fr.org>
Date: Sun, 24 Oct 2010 18:16:57 +0200
Subject: i2c: Let i2c_parent_is_i2c_adapter return the parent adapter

This makes the calling site's code clearer IMHO.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Michael Lawnick <ml.lawnick@gmx.de>
---
 include/linux/i2c.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

(limited to 'include')

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 9391a491501a..1f66fa06a97c 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -384,10 +384,15 @@ static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data)
 	dev_set_drvdata(&dev->dev, data);
 }
 
-static inline int i2c_parent_is_i2c_adapter(const struct i2c_adapter *adapter)
+static inline struct i2c_adapter *
+i2c_parent_is_i2c_adapter(const struct i2c_adapter *adapter)
 {
-	return adapter->dev.parent != NULL
-		&& adapter->dev.parent->type == &i2c_adapter_type;
+	struct device *parent = adapter->dev.parent;
+
+	if (parent != NULL && parent->type == &i2c_adapter_type)
+		return to_i2c_adapter(parent);
+	else
+		return NULL;
 }
 
 /* Adapter locking functions, exported for shared pin cases */
-- 
cgit v1.2.3