All of lore.kernel.org
 help / color / mirror / Atom feed
From: mhoffman@lightlink.com (Mark M. Hoffman)
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] Re: [PATCH 2.6.12-rc5-mm1 3/3] i2c: modify sensors
Date: Fri, 10 Jun 2005 06:26:11 +0000	[thread overview]
Message-ID: <20050610042539.GD23717@jupiter.solarsys.private> (raw)
In-Reply-To: <20050602033727.GD4906@jupiter.solarsys.private>

Hi Jean:

* Mark M. Hoffman <mhoffman@lightlink.com> [2005-06-04 23:41:37 -0400]:
> It would be easy enough to do hwmon1, hwmon2, etc. just like the usb_host
> class does.  Everyone OK with that?

* Jean Delvare <khali@linux-fr.org> [2005-06-04 18:24:28 +0200]:
> > Last, it would be nice if the IDs were reused on driver cycling, just
> > like the i2c bus IDs are. You should be able to pick the code in i2c-dev
> > and reuse it in the hwmon class.

* Mark M. Hoffman <mhoffman@lightlink.com> [2005-06-04 23:41:37 -0400]:
> It would be nice... I'll look into it.

Actually, the bus IDs are assigned in i2c-core.  The i2c-dev ID is just a
copy of that.  The mechanism for the ID recycling is from lib/idr.c.

AFAICT, the ID recycling is a mere side-effect of that (idr.c) modules's
real purpose.  The way it's used in i2c-core.c feels like bloat to me.  
I'm not certain I want to duplicate that in hwmon.c.  Opinions?

* * * * *

Well, i2c_get_adapter() could actually use i2c_adapter_idr properly:
(untested, not signed off, may eet ur branes, /me needs sleep)

Index: linux-2.6.12-rc6-mm1/drivers/i2c/i2c-core.c
=================================--- linux-2.6.12-rc6-mm1.orig/drivers/i2c/i2c-core.c
+++ linux-2.6.12-rc6-mm1/drivers/i2c/i2c-core.c
@@ -156,7 +156,7 @@ int i2c_add_adapter(struct i2c_adapter *
 		goto out_unlock;
 	}
 
-	res = idr_get_new(&i2c_adapter_idr, NULL, &id);
+	res = idr_get_new(&i2c_adapter_idr, adap, &id);
 	if (res < 0) {
 		if (res = -EAGAIN)
 			res = -ENOMEM;
@@ -765,20 +765,15 @@ int i2c_adapter_id(struct i2c_adapter *a
 
 struct i2c_adapter* i2c_get_adapter(int id)
 {
-	struct list_head   *item;
 	struct i2c_adapter *adapter;
 	
 	down(&core_lists);
-	list_for_each(item,&adapters) {
-		adapter = list_entry(item, struct i2c_adapter, list);
-		if (id = adapter->nr &&
-		    try_module_get(adapter->owner)) {
-			up(&core_lists);
-			return adapter;
-		}
-	}
+	adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
+	if (adapter && !try_module_get(adapter->owner))
+		adapter = NULL;
+
 	up(&core_lists);
-	return NULL;
+	return adapter;
 }
 
 void i2c_put_adapter(struct i2c_adapter *adap)

-- 
Mark M. Hoffman
mhoffman@lightlink.com


  parent reply	other threads:[~2005-06-10  6:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-02  5:38 [lm-sensors] Re: [PATCH 2.6.12-rc5-mm1 3/3] i2c: modify sensors Mark M. Hoffman
2005-06-02  8:03 ` Greg KH
2005-06-03  6:00 ` Mark M. Hoffman
2005-06-03  6:47 ` Greg KH
2005-06-03  8:26 ` Yani Ioannou
2005-06-03  8:53 ` Greg KH
2005-06-03 21:00 ` Yani Ioannou
2005-06-04 18:13 ` Jean Delvare
2005-06-04 18:23 ` Jean Delvare
2005-06-04 22:32 ` Yani Ioannou
2005-06-04 23:21 ` Jean Delvare
2005-06-05  1:35 ` Yani Ioannou
2005-06-05  5:42 ` Mark M. Hoffman
2005-06-05  8:06 ` Jean Delvare
2005-06-09  9:28 ` Greg KH
2005-06-09  9:58 ` Yani Ioannou
2005-06-09 10:23 ` Jean Delvare
2005-06-10  6:26 ` Mark M. Hoffman [this message]
2005-06-10  6:40 ` Greg KH
2005-06-10 18:45 ` 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=20050610042539.GD23717@jupiter.solarsys.private \
    --to=mhoffman@lightlink.com \
    --cc=lm-sensors@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.