* [PATCH] rtc: zynqmp: One function call less in xlnx_rtc_alarm_irq_enable()
@ 2019-07-05 20:45 Markus Elfring
2019-07-05 22:36 ` Alexandre Belloni
0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2019-07-05 20:45 UTC (permalink / raw)
To: linux-rtc, linux-arm-kernel, Alessandro Zummo, Alexandre Belloni,
Michal Simek
Cc: LKML, kernel-janitors
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.
This issue was detected by using the Coccinelle software.
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));
return 0;
}
--
2.22.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rtc: zynqmp: One function call less in xlnx_rtc_alarm_irq_enable()
2019-07-05 20:45 [PATCH] rtc: zynqmp: One function call less in xlnx_rtc_alarm_irq_enable() Markus Elfring
@ 2019-07-05 22:36 ` Alexandre Belloni
2019-07-06 5:07 ` Markus Elfring
0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2019-07-05 22:36 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-rtc, linux-arm-kernel, Alessandro Zummo, Michal Simek,
LKML, kernel-janitors
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: rtc: zynqmp: One function call less in xlnx_rtc_alarm_irq_enable()
2019-07-05 22:36 ` Alexandre Belloni
@ 2019-07-06 5:07 ` Markus Elfring
0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2019-07-06 5:07 UTC (permalink / raw)
To: Alexandre Belloni, linux-rtc, linux-arm-kernel, kernel-janitors
Cc: Alessandro Zummo, Michal Simek, LKML
> Unless you use an upstream coccinelle script or you share the one you
> are using, this is not a useful information.
How do you think about to extend a software development discussion
on a topic like “Pretty-printing of code for ternary operators?”?
https://systeme.lip6.fr/pipermail/cocci/2019-July/006079.html
https://lore.kernel.org/cocci/3d2a9d9a-790c-a0f0-f980-b560504babb9@web.de/
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-06 5:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-05 20:45 [PATCH] rtc: zynqmp: One function call less in xlnx_rtc_alarm_irq_enable() Markus Elfring
2019-07-05 22:36 ` Alexandre Belloni
2019-07-06 5:07 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).