Skip to contentSkip to conversation

base/core.c: improve comment of the function device_find_child()

PATCH Superseded Federico Vaga 2 participants 3 messages Apr 12, 2013 – Apr 15, 2013 Driver core

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 base/core.c: improve comment of the function device_find_child()

---
 drivers/base/core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/base/core.c +4 -0
index 016312437..eb0c6ea 100644
@@ -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))
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 10 lines · Federico Vaga
---
 drivers/base/core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/base/core.c +0 -0
index 016312437..eb0c6ea 100644

drivers/base/core.c int device_for_each_child(struct device *parent, void *data, · line 1379

Quoted 8 lines
drivers/base/core.c +4 -0
@@ -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

#2 lore raw
Quoted 23 lines · On Friday 12 April 2013 14:51:25 Greg Kroah-Hartman wrote:
Quoted 22 lines · Federico Vaga

---

 drivers/base/core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/base/core.c +0 -0
index 016312437..eb0c6ea 100644
@@ -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.

Quoted 4 lines
Quoted 1 line

*/

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

Signature · 1 line
Federico Vaga