2013-04-12 12:02:15

by Federico Vaga

[permalink] [raw]
Subject: [PATCH] base/core.c: improve comment of the function device_find_child()

Signed-off-by: Federico Vaga <[email protected]>
---
drivers/base/core.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 016312437..eb0c6ea 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1372,6 +1372,10 @@ int device_for_each_child(struct device *parent, void *data,
* if it does. If the callback returns non-zero and a reference to the
* current device can be obtained, this function will return to the caller
* and not iterate over any more devices.
+ *
+ * NOTE: internally, the function does get_device() on the retrieved child.
+ * It is duty of the caller performing a put_device() on the retrieved
+ * child device when the caller finishes to work on it.
*/
struct device *device_find_child(struct device *parent, void *data,
int (*match)(struct device *dev, void *data))
--
1.8.1.4


2013-04-12 21:51:29

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] base/core.c: improve comment of the function device_find_child()

On Fri, Apr 12, 2013 at 01:59:32PM +0200, Federico Vaga wrote:
> Signed-off-by: Federico Vaga <[email protected]>
> ---
> drivers/base/core.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 016312437..eb0c6ea 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -1372,6 +1372,10 @@ int device_for_each_child(struct device *parent, void *data,
> * if it does. If the callback returns non-zero and a reference to the
> * current device can be obtained, this function will return to the caller
> * and not iterate over any more devices.
> + *
> + * NOTE: internally, the function does get_device() on the retrieved child.
> + * It is duty of the caller performing a put_device() on the retrieved
> + * child device when the caller finishes to work on it.
> */

Why not just use the same wording that class_find_device() has, which is
simpler and easier to understand (IMHO)?

thanks,

greg k-h

2013-04-15 08:32:21

by Federico Vaga

[permalink] [raw]
Subject: Re: [PATCH] base/core.c: improve comment of the function device_find_child()

On Friday 12 April 2013 14:51:25 Greg Kroah-Hartman wrote:
> On Fri, Apr 12, 2013 at 01:59:32PM +0200, Federico Vaga wrote:
> > Signed-off-by: Federico Vaga <[email protected]>
> > ---
> >
> > drivers/base/core.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > index 016312437..eb0c6ea 100644
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -1372,6 +1372,10 @@ int device_for_each_child(struct device *parent,
> > void *data,>
> > * if it does. If the callback returns non-zero and a reference to the
> > * current device can be obtained, this function will return to the
> > caller
> > * and not iterate over any more devices.
> >
> > + *
> > + * NOTE: internally, the function does get_device() on the retrieved
> > child. + * It is duty of the caller performing a put_device() on the
> > retrieved + * child device when the caller finishes to work on it.
> >
> > */
>
> Why not just use the same wording that class_find_device() has, which is
> simpler and easier to understand (IMHO)?

Mh, yes. You are right. I'll send a new patch

--
Federico Vaga