Message ID | 20241212-class_fix-v3-5-04e20c4f0971@quicinc.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | driver core: class: Fix bug and code improvements for class APIs | expand |
On Thu, 12 Dec 2024 21:38:41 +0800 Zijun Hu <zijun_hu@icloud.com> wrote: > From: Zijun Hu <quic_zijuhu@quicinc.com> > > For device_find_child(), get_device() in the if condition always returns > true, move it to if body to make the API's logic more clearer. > > Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> I'd squash with previous 2. They are all the same change in the same area of the kernel. Jonathan > --- > drivers/base/core.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 8bdbc9e657e832a063542391426f570ccb5c18b9..69bb6bf4bd12395226ee3c99e2f63d15c7e342a5 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -4089,9 +4089,12 @@ struct device *device_find_child(struct device *parent, const void *data, > return NULL; > > klist_iter_init(&parent->p->klist_children, &i); > - while ((child = next_device(&i))) > - if (match(child, data) && get_device(child)) > + while ((child = next_device(&i))) { > + if (match(child, data)) { > + get_device(child); > break; > + } > + } > klist_iter_exit(&i); > return child; > } >
On Thu, Dec 12, 2024 at 09:38:41PM +0800, Zijun Hu wrote: > From: Zijun Hu <quic_zijuhu@quicinc.com> > > For device_find_child(), get_device() in the if condition always returns > true, move it to if body to make the API's logic more clearer. > > Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com> Reviewed-by: Fan Ni <fan.ni@samsung.com> > --- > drivers/base/core.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index 8bdbc9e657e832a063542391426f570ccb5c18b9..69bb6bf4bd12395226ee3c99e2f63d15c7e342a5 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -4089,9 +4089,12 @@ struct device *device_find_child(struct device *parent, const void *data, > return NULL; > > klist_iter_init(&parent->p->klist_children, &i); > - while ((child = next_device(&i))) > - if (match(child, data) && get_device(child)) > + while ((child = next_device(&i))) { > + if (match(child, data)) { > + get_device(child); > break; > + } > + } > klist_iter_exit(&i); > return child; > } > > -- > 2.34.1 >
diff --git a/drivers/base/core.c b/drivers/base/core.c index 8bdbc9e657e832a063542391426f570ccb5c18b9..69bb6bf4bd12395226ee3c99e2f63d15c7e342a5 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4089,9 +4089,12 @@ struct device *device_find_child(struct device *parent, const void *data, return NULL; klist_iter_init(&parent->p->klist_children, &i); - while ((child = next_device(&i))) - if (match(child, data) && get_device(child)) + while ((child = next_device(&i))) { + if (match(child, data)) { + get_device(child); break; + } + } klist_iter_exit(&i); return child; }