lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 23 Feb 2021 09:17:32 +0100
From:   Álvaro Fernández Rojas 
        <noltari@...il.com>
To:     f.fainelli@...il.com, Pavel Machek <pavel@....cz>,
        Dan Murphy <dmurphy@...com>, linux-leds@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     Álvaro Fernández Rojas 
        <noltari@...il.com>
Subject: [PATCH 2/2] leds: bcm6358: improve write and read functions

This is proven to work in BMIPS BE/LE and ARM BE/LE, as used in bcm2835-rng
and bcmgenet drivers.
Both should also be inline functions.

Signed-off-by: Álvaro Fernández Rojas <noltari@...il.com>
---
 drivers/leds/leds-bcm6358.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c
index 9d2e487fa08a..775b8c8b562a 100644
--- a/drivers/leds/leds-bcm6358.c
+++ b/drivers/leds/leds-bcm6358.c
@@ -43,22 +43,23 @@ struct bcm6358_led {
 	bool active_low;
 };
 
-static void bcm6358_led_write(void __iomem *reg, unsigned long data)
+static inline void bcm6358_led_write(void __iomem *reg, unsigned long data)
 {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-	iowrite32be(data, reg);
-#else
-	writel(data, reg);
-#endif
+	/* MIPS chips strapped for BE will automagically configure the
+	 * peripheral registers for CPU-native byte order.
+	 */
+	if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
+		__raw_writel(data, reg);
+	else
+		writel_relaxed(data, reg);
 }
 
-static unsigned long bcm6358_led_read(void __iomem *reg)
+static inline unsigned long bcm6358_led_read(void __iomem *reg)
 {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-	return ioread32be(reg);
-#else
-	return readl(reg);
-#endif
+	if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
+		return __raw_readl(reg);
+	else
+		return readl_relaxed(reg);
 }
 
 static unsigned long bcm6358_led_busy(void __iomem *mem)
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ