public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Benjamin Herrenschmidt
	<benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
Subject: [PATCH 2/3] i2c-powermac: Simplify pmac_i2c_adapter_to_bus
Date: Wed, 14 Oct 2009 16:57:43 +0200	[thread overview]
Message-ID: <20091014165743.279789a4@hyperion.delvare> (raw)

pmac_i2c_adapter_to_bus can be simplified. We no longer need to walk
the list of buses, we can get the right bus directly.

The only case where it makes a difference is if the provided adapter
is _not_ a pmac_i2c_bus, but it is not supposed to happen anyway. So
we can also drop the error checks.

Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
---
 arch/powerpc/platforms/powermac/low_i2c.c   |    7 +------
 drivers/macintosh/windfarm_lm75_sensor.c    |    2 --
 drivers/macintosh/windfarm_max6690_sensor.c |    2 --
 drivers/macintosh/windfarm_smu_sat.c        |    2 --
 sound/aoa/codecs/onyx.c                     |    2 --
 sound/aoa/codecs/tas.c                      |    2 --
 6 files changed, 1 insertion(+), 16 deletions(-)

--- linux-2.6.32-rc4.orig/arch/powerpc/platforms/powermac/low_i2c.c	2009-10-14 15:56:23.000000000 +0200
+++ linux-2.6.32-rc4/arch/powerpc/platforms/powermac/low_i2c.c	2009-10-14 15:57:42.000000000 +0200
@@ -1020,12 +1020,7 @@ EXPORT_SYMBOL_GPL(pmac_i2c_get_adapter);
 
 struct pmac_i2c_bus *pmac_i2c_adapter_to_bus(struct i2c_adapter *adapter)
 {
-	struct pmac_i2c_bus *bus;
-
-	list_for_each_entry(bus, &pmac_i2c_busses, link)
-		if (&bus->adapter == adapter)
-			return bus;
-	return NULL;
+	return container_of(adapter, struct pmac_i2c_bus, adapter);
 }
 EXPORT_SYMBOL_GPL(pmac_i2c_adapter_to_bus);
 
--- linux-2.6.32-rc4.orig/drivers/macintosh/windfarm_lm75_sensor.c	2009-10-05 10:45:49.000000000 +0200
+++ linux-2.6.32-rc4/drivers/macintosh/windfarm_lm75_sensor.c	2009-10-14 15:57:42.000000000 +0200
@@ -173,8 +173,6 @@ static int wf_lm75_attach(struct i2c_ada
 	DBG("wf_lm75: adapter %s detected\n", adapter->name);
 
 	bus = pmac_i2c_adapter_to_bus(adapter);
-	if (bus == NULL)
-		return -ENODEV;
 	busnode = pmac_i2c_get_bus_node(bus);
 
 	DBG("wf_lm75: bus found, looking for device...\n");
--- linux-2.6.32-rc4.orig/drivers/macintosh/windfarm_max6690_sensor.c	2009-10-05 10:45:49.000000000 +0200
+++ linux-2.6.32-rc4/drivers/macintosh/windfarm_max6690_sensor.c	2009-10-14 15:57:42.000000000 +0200
@@ -135,8 +135,6 @@ static int wf_max6690_attach(struct i2c_
 	const char *loc;
 
 	bus = pmac_i2c_adapter_to_bus(adapter);
-	if (bus == NULL)
-		return -ENODEV;
 	busnode = pmac_i2c_get_bus_node(bus);
 
 	while ((dev = of_get_next_child(busnode, dev)) != NULL) {
--- linux-2.6.32-rc4.orig/drivers/macintosh/windfarm_smu_sat.c	2009-10-05 10:45:49.000000000 +0200
+++ linux-2.6.32-rc4/drivers/macintosh/windfarm_smu_sat.c	2009-10-14 15:57:42.000000000 +0200
@@ -359,8 +359,6 @@ static int wf_sat_attach(struct i2c_adap
 	struct pmac_i2c_bus *bus;
 
 	bus = pmac_i2c_adapter_to_bus(adapter);
-	if (bus == NULL)
-		return -ENODEV;
 	busnode = pmac_i2c_get_bus_node(bus);
 
 	while ((dev = of_get_next_child(busnode, dev)) != NULL)
--- linux-2.6.32-rc4.orig/sound/aoa/codecs/onyx.c	2009-10-01 09:44:36.000000000 +0200
+++ linux-2.6.32-rc4/sound/aoa/codecs/onyx.c	2009-10-14 15:57:42.000000000 +0200
@@ -1077,8 +1077,6 @@ static int onyx_i2c_attach(struct i2c_ad
 	struct pmac_i2c_bus *bus;
 
 	bus = pmac_i2c_adapter_to_bus(adapter);
-	if (bus == NULL)
-		return -ENODEV;
 	busnode = pmac_i2c_get_bus_node(bus);
 
 	while ((dev = of_get_next_child(busnode, dev)) != NULL) {
--- linux-2.6.32-rc4.orig/sound/aoa/codecs/tas.c	2009-10-05 10:45:51.000000000 +0200
+++ linux-2.6.32-rc4/sound/aoa/codecs/tas.c	2009-10-14 15:57:42.000000000 +0200
@@ -958,8 +958,6 @@ static int tas_i2c_attach(struct i2c_ada
 	struct pmac_i2c_bus *bus;
 
 	bus = pmac_i2c_adapter_to_bus(adapter);
-	if (bus == NULL)
-		return -ENODEV;
 	busnode = pmac_i2c_get_bus_node(bus);
 
 	while ((dev = of_get_next_child(busnode, dev)) != NULL) {


-- 
Jean Delvare

             reply	other threads:[~2009-10-14 14:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14 14:57 Jean Delvare [this message]
     [not found] ` <20091014165743.279789a4-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-11-05  1:01   ` [PATCH 2/3] i2c-powermac: Simplify pmac_i2c_adapter_to_bus Benjamin Herrenschmidt
2009-11-05  9:16     ` Jean Delvare
     [not found]       ` <20091105101627.0a086c04-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-11-05  9:29         ` Benjamin Herrenschmidt
2009-11-05  9:53           ` Jean Delvare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091014165743.279789a4@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox