* [PATCH] rtc: stm32: One function call less in stm32_rtc_set_alarm()
@ 2019-07-05 20:17 Markus Elfring
2019-07-07 21:16 ` Russell King - ARM Linux admin
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2019-07-05 20:17 UTC (permalink / raw)
To: linux-rtc, linux-stm32, linux-arm-kernel, Alessandro Zummo,
Alexandre Belloni, Alexandre Torgue, Maxime Coquelin
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 5 Jul 2019 22:10:10 +0200
Avoid an extra function call by using a ternary operator instead of
a conditional statement.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/rtc/rtc-stm32.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c
index 8e6c9b3bcc29..83793b530fed 100644
--- a/drivers/rtc/rtc-stm32.c
+++ b/drivers/rtc/rtc-stm32.c
@@ -519,11 +519,7 @@ static int stm32_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
/* Write to Alarm register */
writel_relaxed(alrmar, rtc->base + regs->alrmar);
- if (alrm->enabled)
- stm32_rtc_alarm_irq_enable(dev, 1);
- else
- stm32_rtc_alarm_irq_enable(dev, 0);
-
+ stm32_rtc_alarm_irq_enable(dev, alrm->enabled ? 1 : 0);
end:
stm32_rtc_wpr_lock(rtc);
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rtc: stm32: One function call less in stm32_rtc_set_alarm()
2019-07-05 20:17 [PATCH] rtc: stm32: One function call less in stm32_rtc_set_alarm() Markus Elfring
@ 2019-07-07 21:16 ` Russell King - ARM Linux admin
2019-07-08 8:42 ` [PATCH v2] rtc: stm32: One condition check and " Markus Elfring
0 siblings, 1 reply; 4+ messages in thread
From: Russell King - ARM Linux admin @ 2019-07-07 21:16 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-rtc, linux-stm32, linux-arm-kernel, Alessandro Zummo,
Alexandre Belloni, Alexandre Torgue, Maxime Coquelin,
kernel-janitors, LKML
On Fri, Jul 05, 2019 at 10:17:11PM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 5 Jul 2019 22:10:10 +0200
>
> Avoid an extra function call by using a ternary operator instead of
> a conditional statement.
... and a totally pointless use of the ternary operator.
> @@ -519,11 +519,7 @@ static int stm32_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> /* Write to Alarm register */
> writel_relaxed(alrmar, rtc->base + regs->alrmar);
>
> - if (alrm->enabled)
> - stm32_rtc_alarm_irq_enable(dev, 1);
> - else
> - stm32_rtc_alarm_irq_enable(dev, 0);
> -
> + stm32_rtc_alarm_irq_enable(dev, alrm->enabled ? 1 : 0);
If we look at stm32_rtc_alarm_irq_enable():
static int stm32_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
{
...
if (enabled)
do A;
else
do B;
...
}
alrm->enabled is an unsigned char. So, the above can be simplified to:
stm32_rtc_alarm_irq_enable(dev, alrm->enabled);
without any need what so ever to use the ternary operator.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] rtc: stm32: One condition check and function call less in stm32_rtc_set_alarm()
2019-07-07 21:16 ` Russell King - ARM Linux admin
@ 2019-07-08 8:42 ` Markus Elfring
2019-07-08 9:12 ` Amelie DELAUNAY
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2019-07-08 8:42 UTC (permalink / raw)
To: linux-rtc, linux-stm32, linux-arm-kernel, Alessandro Zummo,
Alexandre Belloni, Alexandre Torgue, Maxime Coquelin,
Russell King
Cc: kernel-janitors, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 8 Jul 2019 10:26:47 +0200
A condition check was repeated in this function implementation despite of
a corresponding check in the stm32_rtc_alarm_irq_enable() function.
Thus delete redundant source code here.
Suggested-by: Russell King <linux@armlinux.org.uk>
Link: https://lore.kernel.org/lkml/20190707211638.sehikkear25dffah@shell.armlinux.org.uk/
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
v2:
Russell King pointed the change possibility out to omit a condition check
at this place.
drivers/rtc/rtc-stm32.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c
index 8e6c9b3bcc29..773a1990b93f 100644
--- a/drivers/rtc/rtc-stm32.c
+++ b/drivers/rtc/rtc-stm32.c
@@ -519,11 +519,7 @@ static int stm32_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
/* Write to Alarm register */
writel_relaxed(alrmar, rtc->base + regs->alrmar);
- if (alrm->enabled)
- stm32_rtc_alarm_irq_enable(dev, 1);
- else
- stm32_rtc_alarm_irq_enable(dev, 0);
-
+ stm32_rtc_alarm_irq_enable(dev, alrm->enabled);
end:
stm32_rtc_wpr_lock(rtc);
--
2.22.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] rtc: stm32: One condition check and function call less in stm32_rtc_set_alarm()
2019-07-08 8:42 ` [PATCH v2] rtc: stm32: One condition check and " Markus Elfring
@ 2019-07-08 9:12 ` Amelie DELAUNAY
0 siblings, 0 replies; 4+ messages in thread
From: Amelie DELAUNAY @ 2019-07-08 9:12 UTC (permalink / raw)
To: Markus Elfring, linux-rtc, linux-stm32, linux-arm-kernel,
Alessandro Zummo, Alexandre Belloni, Alexandre TORGUE,
Maxime Coquelin, Russell King
Cc: kernel-janitors, LKML
On 7/8/19 10:42 AM, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 8 Jul 2019 10:26:47 +0200
>
> A condition check was repeated in this function implementation despite of
> a corresponding check in the stm32_rtc_alarm_irq_enable() function.
> Thus delete redundant source code here.
>
> Suggested-by: Russell King <linux@armlinux.org.uk>
> Link: https://lore.kernel.org/lkml/20190707211638.sehikkear25dffah@shell.armlinux.org.uk/
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Amelie Delaunay <amelie.delaunay@st.com>
> ---
>
> v2:
> Russell King pointed the change possibility out to omit a condition check
> at this place.
>
>
> drivers/rtc/rtc-stm32.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c
> index 8e6c9b3bcc29..773a1990b93f 100644
> --- a/drivers/rtc/rtc-stm32.c
> +++ b/drivers/rtc/rtc-stm32.c
> @@ -519,11 +519,7 @@ static int stm32_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> /* Write to Alarm register */
> writel_relaxed(alrmar, rtc->base + regs->alrmar);
>
> - if (alrm->enabled)
> - stm32_rtc_alarm_irq_enable(dev, 1);
> - else
> - stm32_rtc_alarm_irq_enable(dev, 0);
> -
> + stm32_rtc_alarm_irq_enable(dev, alrm->enabled);
> end:
> stm32_rtc_wpr_lock(rtc);
>
> --
> 2.22.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-08 9:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-05 20:17 [PATCH] rtc: stm32: One function call less in stm32_rtc_set_alarm() Markus Elfring
2019-07-07 21:16 ` Russell King - ARM Linux admin
2019-07-08 8:42 ` [PATCH v2] rtc: stm32: One condition check and " Markus Elfring
2019-07-08 9:12 ` Amelie DELAUNAY
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).