mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 1/1] software node: Simplify swnode_register() a bit
@ 2024-09-13 11:05 Andy Shevchenko
  2024-09-13 11:16 ` Sakari Ailus
  2024-09-13 13:34 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2024-09-13 11:05 UTC (permalink / raw)
  To: Andy Shevchenko, linux-acpi, linux-kernel
  Cc: Daniel Scally, Heikki Krogerus, Sakari Ailus, Greg Kroah-Hartman,
	Rafael J. Wysocki

By introducing two temporary variables simplify swnode_register() a bit.
No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/swnode.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
index b0be765b12da..810c27a8c9c1 100644
--- a/drivers/base/swnode.c
+++ b/drivers/base/swnode.c
@@ -908,6 +908,7 @@ static struct fwnode_handle *
 swnode_register(const struct software_node *node, struct swnode *parent,
 		unsigned int allocated)
 {
+	struct kobject *kobj_parent = parent ? &parent->kobj : NULL;
 	struct swnode *swnode;
 	int ret;
 
@@ -934,12 +935,10 @@ swnode_register(const struct software_node *node, struct swnode *parent,
 
 	if (node->name)
 		ret = kobject_init_and_add(&swnode->kobj, &software_node_type,
-					   parent ? &parent->kobj : NULL,
-					   "%s", node->name);
+					   kobj_parent, "%s", node->name);
 	else
 		ret = kobject_init_and_add(&swnode->kobj, &software_node_type,
-					   parent ? &parent->kobj : NULL,
-					   "node%d", swnode->id);
+					   kobj_parent, "node%d", swnode->id);
 	if (ret) {
 		kobject_put(&swnode->kobj);
 		return ERR_PTR(ret);
-- 
2.43.0.rc1.1336.g36b5255a03ac


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] software node: Simplify swnode_register() a bit
  2024-09-13 11:05 [PATCH v1 1/1] software node: Simplify swnode_register() a bit Andy Shevchenko
@ 2024-09-13 11:16 ` Sakari Ailus
  2024-09-13 13:34 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2024-09-13 11:16 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-acpi, linux-kernel, Daniel Scally, Heikki Krogerus,
	Greg Kroah-Hartman, Rafael J. Wysocki

On Fri, Sep 13, 2024 at 02:05:23PM +0300, Andy Shevchenko wrote:
> By introducing two temporary variables simplify swnode_register() a bit.
> No functional change intended.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

-- 
Sakari Ailus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] software node: Simplify swnode_register() a bit
  2024-09-13 11:05 [PATCH v1 1/1] software node: Simplify swnode_register() a bit Andy Shevchenko
  2024-09-13 11:16 ` Sakari Ailus
@ 2024-09-13 13:34 ` Greg Kroah-Hartman
  2024-09-13 19:25   ` Andy Shevchenko
  1 sibling, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2024-09-13 13:34 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-acpi, linux-kernel, Daniel Scally, Heikki Krogerus,
	Sakari Ailus, Rafael J. Wysocki

On Fri, Sep 13, 2024 at 02:05:23PM +0300, Andy Shevchenko wrote:
> By introducing two temporary variables simplify swnode_register() a bit.
> No functional change intended.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/base/swnode.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> index b0be765b12da..810c27a8c9c1 100644
> --- a/drivers/base/swnode.c
> +++ b/drivers/base/swnode.c
> @@ -908,6 +908,7 @@ static struct fwnode_handle *
>  swnode_register(const struct software_node *node, struct swnode *parent,
>  		unsigned int allocated)
>  {
> +	struct kobject *kobj_parent = parent ? &parent->kobj : NULL;

I despise ?: use just so much, EXCEPT for when it's used in something
like this:

>  	struct swnode *swnode;
>  	int ret;
>  
> @@ -934,12 +935,10 @@ swnode_register(const struct software_node *node, struct swnode *parent,
>  
>  	if (node->name)
>  		ret = kobject_init_and_add(&swnode->kobj, &software_node_type,
> -					   parent ? &parent->kobj : NULL,
> -					   "%s", node->name);
> +					   kobj_parent, "%s", node->name);

Which really is the only valid way I'd put up with it :)

So can you rewrite the change above to be just:

	struct kobject *kobj_parent = NULL;

	...

	if (parent)
		kobj_parent = &parent->kobj;

Which is much simpler to read, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] software node: Simplify swnode_register() a bit
  2024-09-13 13:34 ` Greg Kroah-Hartman
@ 2024-09-13 19:25   ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2024-09-13 19:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-acpi, linux-kernel, Daniel Scally, Heikki Krogerus,
	Sakari Ailus, Rafael J. Wysocki

On Fri, Sep 13, 2024 at 03:34:58PM +0200, Greg Kroah-Hartman wrote:
> On Fri, Sep 13, 2024 at 02:05:23PM +0300, Andy Shevchenko wrote:

...

> > +	struct kobject *kobj_parent = parent ? &parent->kobj : NULL;
> 
> I despise ?: use just so much, EXCEPT for when it's used in something
> like this:

> >  		ret = kobject_init_and_add(&swnode->kobj, &software_node_type,
> > -					   parent ? &parent->kobj : NULL,
> > -					   "%s", node->name);
> > +					   kobj_parent, "%s", node->name);
> 
> Which really is the only valid way I'd put up with it :)

I see your point!

> So can you rewrite the change above to be just:
> 
> 	struct kobject *kobj_parent = NULL;
> 
> 	...
> 
> 	if (parent)
> 		kobj_parent = &parent->kobj;
> 
> Which is much simpler to read, right?

Yeah, but the point of the patch seems to be diminished. Let's just not
continue with it for now. Maybe later it will make more sense.

Thank you for the review!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-09-13 19:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-13 11:05 [PATCH v1 1/1] software node: Simplify swnode_register() a bit Andy Shevchenko
2024-09-13 11:16 ` Sakari Ailus
2024-09-13 13:34 ` Greg Kroah-Hartman
2024-09-13 19:25   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®