All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-rtc@vger.kernel.org,
	Alessandro Zummo <a.zummo@towertech.it>,
	kernel-janitors@vger.kernel.org,
	Michal Simek <michal.simek@xilinx.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] rtc: zynqmp: One function call less in xlnx_rtc_alarm_irq_enable()
Date: Fri, 05 Jul 2019 22:36:17 +0000	[thread overview]
Message-ID: <20190705223617.GC12409@piout.net> (raw)
In-Reply-To: <6f1db217-cb0a-9f6c-0e2e-5d932103f6ef@web.de>

On 05/07/2019 22:45:39+0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 5 Jul 2019 22:37:58 +0200
> 
> Avoid an extra function call by using a ternary operator instead of
> a conditional statement for a setting selection.
> 

Please elaborate on why this is a good thing.

> This issue was detected by using the Coccinelle software.
> 

Unless you use an upstream coccinelle script or you share the one you
are using, this is not a useful information.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/rtc/rtc-zynqmp.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
> index 00639594de0c..4631019a54e2 100644
> --- a/drivers/rtc/rtc-zynqmp.c
> +++ b/drivers/rtc/rtc-zynqmp.c
> @@ -124,11 +124,8 @@ static int xlnx_rtc_alarm_irq_enable(struct device *dev, u32 enabled)
>  {
>  	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
> 
> -	if (enabled)
> -		writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_EN);
> -	else
> -		writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_DIS);
> -
> +	writel(RTC_INT_ALRM,
> +	       xrtcdev->reg_base + (enabled ? RTC_INT_EN : RTC_INT_DIS));

This makes the code less readable.

>  	return 0;
>  }
> 
> --
> 2.22.0
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Alessandro Zummo <a.zummo@towertech.it>,
	Michal Simek <michal.simek@xilinx.com>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] rtc: zynqmp: One function call less in xlnx_rtc_alarm_irq_enable()
Date: Sat, 6 Jul 2019 00:36:17 +0200	[thread overview]
Message-ID: <20190705223617.GC12409@piout.net> (raw)
In-Reply-To: <6f1db217-cb0a-9f6c-0e2e-5d932103f6ef@web.de>

On 05/07/2019 22:45:39+0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 5 Jul 2019 22:37:58 +0200
> 
> Avoid an extra function call by using a ternary operator instead of
> a conditional statement for a setting selection.
> 

Please elaborate on why this is a good thing.

> This issue was detected by using the Coccinelle software.
> 

Unless you use an upstream coccinelle script or you share the one you
are using, this is not a useful information.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/rtc/rtc-zynqmp.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
> index 00639594de0c..4631019a54e2 100644
> --- a/drivers/rtc/rtc-zynqmp.c
> +++ b/drivers/rtc/rtc-zynqmp.c
> @@ -124,11 +124,8 @@ static int xlnx_rtc_alarm_irq_enable(struct device *dev, u32 enabled)
>  {
>  	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
> 
> -	if (enabled)
> -		writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_EN);
> -	else
> -		writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_DIS);
> -
> +	writel(RTC_INT_ALRM,
> +	       xrtcdev->reg_base + (enabled ? RTC_INT_EN : RTC_INT_DIS));

This makes the code less readable.

>  	return 0;
>  }
> 
> --
> 2.22.0
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-rtc@vger.kernel.org,
	Alessandro Zummo <a.zummo@towertech.it>,
	kernel-janitors@vger.kernel.org,
	Michal Simek <michal.simek@xilinx.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] rtc: zynqmp: One function call less in xlnx_rtc_alarm_irq_enable()
Date: Sat, 6 Jul 2019 00:36:17 +0200	[thread overview]
Message-ID: <20190705223617.GC12409@piout.net> (raw)
In-Reply-To: <6f1db217-cb0a-9f6c-0e2e-5d932103f6ef@web.de>

On 05/07/2019 22:45:39+0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 5 Jul 2019 22:37:58 +0200
> 
> Avoid an extra function call by using a ternary operator instead of
> a conditional statement for a setting selection.
> 

Please elaborate on why this is a good thing.

> This issue was detected by using the Coccinelle software.
> 

Unless you use an upstream coccinelle script or you share the one you
are using, this is not a useful information.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/rtc/rtc-zynqmp.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
> index 00639594de0c..4631019a54e2 100644
> --- a/drivers/rtc/rtc-zynqmp.c
> +++ b/drivers/rtc/rtc-zynqmp.c
> @@ -124,11 +124,8 @@ static int xlnx_rtc_alarm_irq_enable(struct device *dev, u32 enabled)
>  {
>  	struct xlnx_rtc_dev *xrtcdev = dev_get_drvdata(dev);
> 
> -	if (enabled)
> -		writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_EN);
> -	else
> -		writel(RTC_INT_ALRM, xrtcdev->reg_base + RTC_INT_DIS);
> -
> +	writel(RTC_INT_ALRM,
> +	       xrtcdev->reg_base + (enabled ? RTC_INT_EN : RTC_INT_DIS));

This makes the code less readable.

>  	return 0;
>  }
> 
> --
> 2.22.0
> 

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-07-05 22:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05 20:45 [PATCH] rtc: zynqmp: One function call less in xlnx_rtc_alarm_irq_enable() Markus Elfring
2019-07-05 20:45 ` Markus Elfring
2019-07-05 20:45 ` Markus Elfring
2019-07-05 22:36 ` Alexandre Belloni [this message]
2019-07-05 22:36   ` Alexandre Belloni
2019-07-05 22:36   ` Alexandre Belloni
2019-07-06  5:07   ` Markus Elfring
2019-07-06  5:07     ` Markus Elfring
2019-07-06  5:07     ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190705223617.GC12409@piout.net \
    --to=alexandre.belloni@bootlin.com \
    --cc=Markus.Elfring@web.de \
    --cc=a.zummo@towertech.it \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.