[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a8e1da0801131736i4fa2eed7pd1569ed1b6214510@mail.gmail.com>
Date: Mon, 14 Jan 2008 09:36:04 +0800
From: "Dave Young" <hidave.darkstar@...il.com>
To: "Jarek Poplawski" <jarkao2@...il.com>
Cc: "Greg KH" <gregkh@...e.de>, stefanr@...6.in-berlin.de,
James.Bottomley@...senpartnership.com, a.zummo@...ertech.it,
peterz@...radead.org, cbou@...l.ru, linux-kernel@...r.kernel.org,
"David Brownell" <david-b@...bell.net>, krh@...hat.com,
stern@...land.harvard.edu, dwmw2@...radead.org, davem@...emloft.net
Subject: Re: [PATCH 1/7] driver-core : add class iteration api
On Jan 13, 2008 4:11 AM, Jarek Poplawski <jarkao2@...il.com> wrote:
>
> On Sat, Jan 12, 2008 at 05:47:54PM +0800, Dave Young wrote:
> > Add the following class iteration functions for driver use:
> > class_for_each_device
> > class_find_device
> > class_for_each_child
> > class_find_child
> >
> > Signed-off-by: Dave Young <hidave.darkstar@...il.com>
> >
> > ---
> > drivers/base/class.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++
> > include/linux/device.h | 8 ++
> > 2 files changed, 167 insertions(+)
> >
> > diff -upr linux/drivers/base/class.c linux.new/drivers/base/class.c
> > --- linux/drivers/base/class.c 2008-01-12 14:42:24.000000000 +0800
> > +++ linux.new/drivers/base/class.c 2008-01-12 14:42:24.000000000 +0800
> > @@ -798,6 +798,165 @@ void class_device_put(struct class_devic
> > kobject_put(&class_dev->kobj);
> > }
> >
> > +/**
> > + * class_for_each_device - device iterator
> > + * @class: the class we're iterating
> > + * @data: data for the callback
> > + * @fn: function to be called for each device
> > + *
> > + * Iterate over @class's list of devices, and call @fn for each,
> > + * passing it @data.
> > + *
> > + * We check the return of @fn each time. If it returns anything
> > + * other than 0, we break out and return that value.
> > + */
> > +int class_for_each_device(struct class *class, void *data,
> > + int (*fn)(struct device *, void *))
> > +{
> > + struct device *dev;
> > + int error = 0;
> > +
> > + if (!class)
> > + return -EINVAL;
> > + down(&class->sem);
> > + list_for_each_entry(dev, &class->devices, node) {
>
> Probably some tiny oversight, but I see this comment to struct class
> doesn't mention devices list, so maybe this needs to be updated BTW?:
>
> (from include/linux/device.h)
> " struct semaphore sem; /* locks both the children and interfaces lists */"
Sorry for my lazy, I think so too.
IMHO, it should be updated after the comments.
>
> Regards,
> Jarek P.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists