public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hollis Blanchard <hollisb@us.ibm.com>
To: Greg KH <greg@kroah.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: kobj_to_dev ?
Date: Mon, 19 Jan 2004 21:18:05 -0600	[thread overview]
Message-ID: <400C9DED.3040208@us.ibm.com> (raw)
In-Reply-To: <20040120005338.GA5954@kroah.com>

On Jan 19, 2004, at 6:53 PM, Greg KH wrote:

 > I don't know.  If you enable debugging for kobjects (in kobject.c) do
 > you see any kobjects getting added to your bus with no name?

Sigh, that took too long.

c000000001d29828 -- address of the struct device I register
c000000001d29818 -- address present in vio_bus_type.devices.list

I think the problem is that bus_add_device() adds a struct device to 
bus_type.devices.list, but that's a a kset! So it contains a list of 
kobjects, not devices. The obvious fix doesn't work because 
driver_attach() got it wrong too. However it seems bus_for_each_dev() 
got it right.

This patch compiles but I haven't tested the driver_attach() part yet. 
Oh also to_dev is different in bus.c than in core.c, so I don't think it 
will work here. I'm going home... I have a vague feeling that some other 
language might work better for all this list stuff..

-- 
Hollis Blanchard
IBM Linux Technology Center

===== drivers/base/bus.c 1.52 vs edited =====
--- 1.52/drivers/base/bus.c     Tue Sep 30 10:59:35 2003
+++ edited/drivers/base/bus.c   Mon Jan 19 21:19:18 2004
@@ -337,7 +337,12 @@
                 return;

         list_for_each(entry,&bus->devices.list) {
-               struct device * dev = container_of(entry,struct 
device,bus_list);
+               struct kobject * kobj = container_of(entry,struct 
kobject,entry);
+               struct device * dev;
+
+               if (!kobj)
+                       return;
+               dev = container_of(kobj,struct device,kobj);
                 if (!dev->driver) {
                         error = bus_match(dev,drv);
                         if (error && (error != -ENODEV))
@@ -405,7 +410,7 @@
         if (bus) {
                 down_write(&dev->bus->subsys.rwsem);
                 pr_debug("bus %s: add device %s\n",bus->name,dev->bus_id);
-               list_add_tail(&dev->bus_list,&dev->bus->devices.list);
+               list_add_tail(&dev->kobj.entry,&dev->bus->devices.list);
                 device_attach(dev);
                 up_write(&dev->bus->subsys.rwsem);
 
sysfs_create_link(&bus->devices.kobj,&dev->kobj,dev->bus_id);


      reply	other threads:[~2004-01-20  3:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-16 23:32 kobj_to_dev ? Hollis Blanchard
2004-01-17  0:17 ` Greg KH
2004-01-19 20:26   ` Hollis Blanchard
2004-01-20  0:04     ` Greg KH
2004-01-20  0:25       ` Hollis Blanchard
2004-01-20  0:53         ` Greg KH
2004-01-20  3:18           ` Hollis Blanchard [this message]

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=400C9DED.3040208@us.ibm.com \
    --to=hollisb@us.ibm.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox