mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drvres: Improve grp->id setting logics in devres_open_group()
@ 2014-10-29  9:59 Liu Ying
  2014-11-07 19:02 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Liu Ying @ 2014-10-29  9:59 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel

Instead of setting grp->id directly with a temporary value and
then changing it if a certain condition meets, we may check
the condition first and then decide which value should be set
to grp->id.  This may save two lines of code and potentially
reduces a writing operation.

Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
---
 drivers/base/devres.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index c8a53d1..39e1856 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -544,9 +544,7 @@ void * devres_open_group(struct device *dev, void *id, gfp_t gfp)
 	INIT_LIST_HEAD(&grp->node[1].entry);
 	set_node_dbginfo(&grp->node[0], "grp<", 0);
 	set_node_dbginfo(&grp->node[1], "grp>", 0);
-	grp->id = grp;
-	if (id)
-		grp->id = id;
+	grp->id = id ? id : grp;
 
 	spin_lock_irqsave(&dev->devres_lock, flags);
 	add_dr(dev, &grp->node[0]);
-- 
2.1.0


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

* Re: [PATCH] drvres: Improve grp->id setting logics in devres_open_group()
  2014-10-29  9:59 [PATCH] drvres: Improve grp->id setting logics in devres_open_group() Liu Ying
@ 2014-11-07 19:02 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2014-11-07 19:02 UTC (permalink / raw)
  To: Liu Ying; +Cc: linux-kernel

On Wed, Oct 29, 2014 at 05:59:47PM +0800, Liu Ying wrote:
> Instead of setting grp->id directly with a temporary value and
> then changing it if a certain condition meets, we may check
> the condition first and then decide which value should be set
> to grp->id.  This may save two lines of code and potentially
> reduces a writing operation.
> 
> Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
> ---
>  drivers/base/devres.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> index c8a53d1..39e1856 100644
> --- a/drivers/base/devres.c
> +++ b/drivers/base/devres.c
> @@ -544,9 +544,7 @@ void * devres_open_group(struct device *dev, void *id, gfp_t gfp)
>  	INIT_LIST_HEAD(&grp->node[1].entry);
>  	set_node_dbginfo(&grp->node[0], "grp<", 0);
>  	set_node_dbginfo(&grp->node[1], "grp>", 0);
> -	grp->id = grp;
> -	if (id)
> -		grp->id = id;
> +	grp->id = id ? id : grp;

Ick, I _hate_ ? : lines, please don't do that.

greg k-h

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

end of thread, other threads:[~2014-11-07 19:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-29  9:59 [PATCH] drvres: Improve grp->id setting logics in devres_open_group() Liu Ying
2014-11-07 19:02 ` Greg KH

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®