lkml.org 
[lkml]   [2021]   [Jul]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kobject: kobject_add_internal cleanup
On Tue, Jul 27, 2021 at 10:32:12PM +0800, Qiao Yanbo wrote:
> From: qiaoyanbo <qiaoyanbo_310@163.com>

This does not match your "From:" line in your email address, please use
your real name here and in your signed-off-by line like your email
shows.

>
> parent assignment in "if" block only need to consider when parent is NULL.

I do not understand, why is this needed? What does this fix?

>
> Signed-off-by: qiaoyanbo <qiaoyanbo_310@163.com>
> ---
> lib/kobject.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/kobject.c b/lib/kobject.c
> index ea53b30cf..d1f4b3411 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -241,10 +241,11 @@ static int kobject_add_internal(struct kobject *kobj)
>
> /* join kset if set, use it as parent if we do not already have one */
> if (kobj->kset) {
> - if (!parent)
> + if (!parent) {
> parent = kobject_get(&kobj->kset->kobj);
> + kobj->parent = parent;
> + }
> kobj_kset_join(kobj);
> - kobj->parent = parent;

I think this might break code as well, did you test this? What about
the root kobjects with no parent, you still need to set that, right?

What problem does this solve that you have run into?

thanks,

greg k-h

\
 
 \ /
  Last update: 2021-07-28 12:10    [W:0.567 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site