Re: [patch 1/16] s390: klist bus_find_device & driver_find_device callback.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 22, 2005 at 09:48:02AM +0200, Cornelia Huck wrote:
> Greg KH <[email protected]> wrote on 22.06.2005 08:26:27:
> 
> > What's wrong with just using bus_for_each_dev() instead?  You have to
> > supply a "match" type function anyway, so the caller doesn't have an
> > easier time using this function instead.
> 
> Maybe it's just too early in the morning, but I don't see how I could
> achive what I want to do with bus_for_each_dev(). The idea behind
> bus_find_device() is to scan the bus for a device matching some
> criterium and to return a pointer to it with which the caller can
> continue to work. bus_for_each_dev() calls the match function for
> every device until we abort, but I don't see how I can grab a reference
> to a specific device for later use.

Ah, now I get it.  "later use" is the key point here.  I was thinking
you could do whatever you want within the callback.  But if you want to
do something later on with this pointer, that would be very tough.

Hm, I could use this kind of function, as I had to jump through a few
hoops when iterating over all devices on a bus, when I just wanted to
find a specific device (it involved creating a temp structure on the
stack and doing my logic in the callback function itself, for details
see
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/driver-bind.patch
for a patch that adds manual binding of drivers to devices from
userspace through sysfs.  With this function it should get even smaller.)

> > You also don't increment the reference properly when you return the
> > pointer, so you better document that... :(
> 
> You're right, this should be done in the base code and not by the
> caller...

Care to fix this up and resend it?

Sorry for the misunderstanding.

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux