Thread (4 messages) 4 messages, 3 authors, 2019-07-08

Re: [PATCH] rtc: stm32: One function call less in stm32_rtc_set_alarm()

From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Date: 2019-07-07 21:16:53
Also in: kernel-janitors, linux-rtc, lkml

On Fri, Jul 05, 2019 at 10:17:11PM +0200, Markus Elfring wrote:
From: Markus Elfring <redacted>
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.
quoted hunk ↗ jump to hunk
@@ -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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help