Skip to contentSkip to conversation

usb: ehci: use linux-way ehci_readl and ehci_writel

RFC Applied Antony Pavlov 2 participants 4 messages Jul 17, 2014 – Jul 24, 2014

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC 1/1 usb: ehci: use linux-way ehci_readl and ehci_writel

Also drop nowhere defined CONFIG_EHCI_DESC_BIG_ENDIAN.

---
 drivers/usb/host/ehci.h | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/usb/host/ehci.h +11 -8
index 5d899cc..2ec69f6 100644
@@ -18,6 +18,8 @@
 #ifndef USB_EHCI_H
 #define USB_EHCI_H
 
+#include <io.h>
+
 #if !defined(CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS)
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS	16
 #endif
@@ -109,14 +111,15 @@ struct usb_linux_config_descriptor {
 	unsigned char	MaxPower;
 } __attribute__ ((packed));
 
-#if defined CONFIG_EHCI_DESC_BIG_ENDIAN
-#define	ehci_readl(x)		(*((volatile u32 *)(x)))
-#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = ((volatile u32)b))
-#else
-#define ehci_readl(x)		cpu_to_le32((*((volatile u32 *)(x))))
-#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = \
-					cpu_to_le32(((volatile u32)b)))
-#endif
+static inline void ehci_writel(const unsigned int val, __u32 __iomem *regs)
+{
+	writel(val, regs);
+}
+
+static inline unsigned int ehci_readl(__u32 __iomem *regs)
+{
+	return readl(regs);
+}
 
 #if defined CONFIG_EHCI_MMIO_BIG_ENDIAN
 #define hc32_to_cpu(x)		be32_to_cpu((x))
Signature · 7 lines
2.0.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 3 lines · Antony Pavlov

Also drop nowhere defined CONFIG_EHCI_DESC_BIG_ENDIAN.

Applied, thanks

Sascha

Quoted 45 lines
---
 drivers/usb/host/ehci.h | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/usb/host/ehci.h +11 -8
index 5d899cc..2ec69f6 100644
@@ -18,6 +18,8 @@
 #ifndef USB_EHCI_H
 #define USB_EHCI_H
 
+#include <io.h>
+
 #if !defined(CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS)
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS	16
 #endif
@@ -109,14 +111,15 @@ struct usb_linux_config_descriptor {
 	unsigned char	MaxPower;
 } __attribute__ ((packed));
 
-#if defined CONFIG_EHCI_DESC_BIG_ENDIAN
-#define	ehci_readl(x)		(*((volatile u32 *)(x)))
-#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = ((volatile u32)b))
-#else
-#define ehci_readl(x)		cpu_to_le32((*((volatile u32 *)(x))))
-#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = \
-					cpu_to_le32(((volatile u32)b)))
-#endif
+static inline void ehci_writel(const unsigned int val, __u32 __iomem *regs)
+{
+	writel(val, regs);
+}
+
+static inline unsigned int ehci_readl(__u32 __iomem *regs)
+{
+	return readl(regs);
+}
 
 #if defined CONFIG_EHCI_MMIO_BIG_ENDIAN
 #define hc32_to_cpu(x)		be32_to_cpu((x))
Signature · 1 line
2.0.1
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw
Quoted 6 lines · Sascha Hauer
Quoted 3 lines · Antony Pavlov

Also drop nowhere defined CONFIG_EHCI_DESC_BIG_ENDIAN.

Applied, thanks

And reverted it.

Quoted 4 lines
Quoted 4 lines
drivers/usb/host/ehci.h +0 -4
-#if defined CONFIG_EHCI_DESC_BIG_ENDIAN
-#define	ehci_readl(x)		(*((volatile u32 *)(x)))
-#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = ((volatile u32)b))
-#else
Quoted 8 lines

drivers/usb/host/ehci.h struct usb_linux_config_descriptor { · line 117

Quoted 8 lines
drivers/usb/host/ehci.h +4 -4
-#define ehci_readl(x)		cpu_to_le32((*((volatile u32 *)(x))))
-#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = \
-					cpu_to_le32(((volatile u32)b)))
-#endif
+static inline void ehci_writel(const unsigned int val, __u32 __iomem *regs)
+{
+	writel(val, regs);
+}

ehci_writel has the argument order (reg, val), not (val, reg)

Putting a 'writel' in a function name with this argument order wasn't the best idea...

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw
Quoted 25 lines · On Thu, 24 Jul 2014 09:03:47 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 6 lines · Sascha Hauer
Quoted 3 lines · Antony Pavlov

Also drop nowhere defined CONFIG_EHCI_DESC_BIG_ENDIAN.

Applied, thanks

And reverted it.

Quoted 4 lines
Quoted 4 lines
drivers/usb/host/ehci.h +0 -4
-#if defined CONFIG_EHCI_DESC_BIG_ENDIAN
-#define	ehci_readl(x)		(*((volatile u32 *)(x)))
-#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = ((volatile u32)b))
-#else
Quoted 8 lines

drivers/usb/host/ehci.h struct usb_linux_config_descriptor { · line 117

Quoted 8 lines
drivers/usb/host/ehci.h +4 -4
-#define ehci_readl(x)		cpu_to_le32((*((volatile u32 *)(x))))
-#define ehci_writel(a, b)	(*((volatile u32 *)(a)) = \
-					cpu_to_le32(((volatile u32)b)))
-#endif
+static inline void ehci_writel(const unsigned int val, __u32 __iomem *regs)
+{
+	writel(val, regs);
+}

ehci_writel has the argument order (reg, val), not (val, reg)

Quoted 2 lines

Putting a 'writel' in a function name with this argument order wasn't the best idea...

Sorry!

I have made this patch while I was working on AR933x USB support (big-endian EHCI). I suppose this patch was initial buggy version and I have forgot to ammend fixup.

--
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox