lkml.org 
[lkml]   [2020]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] driver core: Remove double assignment
On Tue, Sep 29, 2020 at 01:58:08PM +0200, poeschel@lemonage.de wrote:
> From: Lars Poeschel <poeschel@lemonage.de>
>
> This removes an assignment in device_add. It assigned the parent
> kobject to the kobject of the new device. This is not necessary,
> because the call to kobject_add a few lines later also does this same
> assignment.
>
> Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
> ---
> drivers/base/core.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index bb5806a2bd4c..03b5396cd192 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -2847,8 +2847,6 @@ int device_add(struct device *dev)
> error = PTR_ERR(kobj);
> goto parent_error;
> }
> - if (kobj)
> - dev->kobj.parent = kobj;
>
> /* use parent numa_node */
> if (parent && (dev_to_node(dev) == NUMA_NO_NODE))
> @@ -2856,7 +2854,7 @@ int device_add(struct device *dev)
>
> /* first, register with generic layer. */
> /* we require the name to be set before, and pass NULL */
> - error = kobject_add(&dev->kobj, dev->kobj.parent, NULL);
> + error = kobject_add(&dev->kobj, kobj, NULL);

That's very subtle, and might not really be correct for all users, have
you checked?

Anyway, I'd rather leave this as-is if possible, as we know this works
correctly, and it is not going to save any time/energy to remove that
assignment, right?

thanks,

greg k-h

\
 
 \ /
  Last update: 2020-09-29 14:26    [W:0.039 / U:0.688 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site