Skip to contentSkip to conversation

consolidate mdelay by providing a common function for all users

PATCH New Anatolij Gustschin 3 participants 3 messages Oct 12, 2011 – Oct 21, 2011

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 consolidate mdelay by providing a common function for all users

There are several mdelay() definitions in the driver and board code. Remove them all and provide a common mdelay() in lib/time.c.

---
 arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c       |    1 -
 arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |    1 -
 arch/powerpc/cpu/mpc5xxx/usb_ohci.c           |    1 -
 arch/powerpc/cpu/ppc4xx/usb_ohci.c            |    1 -
 arch/powerpc/include/asm/4xx_pcie.h           |    8 --------
 board/amcc/taishan/lcd.c                      |    2 --
 board/freescale/mx35pdk/mx35pdk.c             |    2 --
 board/karo/tx25/tx25.c                        |    6 ------
 board/linkstation/hwctl.c                     |    2 --
 drivers/block/fsl_sata.c                      |    7 -------
 drivers/block/ftide020.c                      |    2 --
 drivers/net/e1000.c                           |    1 -
 drivers/net/ftgmac100.c                       |    2 --
 drivers/net/ne2000.c                          |    1 -
 drivers/net/ne2000_base.c                     |    1 -
 drivers/net/smc911x.c                         |    2 --
 drivers/usb/host/ohci-hcd.c                   |    1 -
 drivers/usb/host/sl811-hcd.c                  |    2 --
 include/common.h                              |    1 +
 lib/time.c                                    |    6 ++++++
 20 files changed, 7 insertions(+), 43 deletions(-)
arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c +0 -1
index 9a0bbae..263d2ce 100644
@@ -1540,7 +1540,6 @@ static int hc_start(struct ohci *ohci)
 	writel(RH_HS_LPSC, &ohci->regs->roothub.status);
 #endif /* OHCI_USE_NPS */
 
-#define mdelay(n) ({unsigned long msec=(n); while (msec--) udelay(1000);})
 	/* POTPGT delay is bits 24-31, in 2 ms units. */
 	mdelay((roothub_a(ohci) >> 23) & 0x1fe);
 
arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c +0 -1
index 0bc2305..866dd6c 100644
@@ -1448,7 +1448,6 @@ static int hc_start (ohci_t * ohci)
 	writel (RH_HS_LPSC, &ohci->regs->roothub.status);
 #endif	/* OHCI_USE_NPS */
 
-#define mdelay(n) ({unsigned long msec=(n); while (msec--) udelay(1000);})
 	/* POTPGT delay is bits 24-31, in 2 ms units. */
 	mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
 
arch/powerpc/cpu/mpc5xxx/usb_ohci.c +0 -1
index 7976e4d..2fc1180 100644
@@ -1455,7 +1455,6 @@ static int hc_start (ohci_t * ohci)
 	writel (RH_HS_LPSC, &ohci->regs->roothub.status);
 #endif	/* OHCI_USE_NPS */
 
-#define mdelay(n) ({unsigned long msec=(n); while (msec--) udelay(1000);})
 	/* POTPGT delay is bits 24-31, in 2 ms units. */
 	mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
 
arch/powerpc/cpu/ppc4xx/usb_ohci.c +0 -1
index a9edacd..fe091e3 100644
@@ -1462,7 +1462,6 @@ static int hc_start (ohci_t * ohci)
 	writel (RH_HS_LPSC, &ohci->regs->roothub.status);
 #endif	/* OHCI_USE_NPS */
 
-#define mdelay(n) ({unsigned long msec=(n); while (msec--) udelay(1000);})
 	/* POTPGT delay is bits 24-31, in 2 ms units. */
 	mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
 
arch/powerpc/include/asm/4xx_pcie.h +0 -8
index 90e0bd9..fbdc28e 100644
@@ -389,14 +389,6 @@ static inline int is_end_point(int port)
 	return 0;
 }
 
-static inline void mdelay(int n)
-{
-	u32 ms = n;
-
-	while (ms--)
-		udelay(1000);
-}
-
 #if defined(PCIE0_SDR)
 static inline u32 sdr_base(int port)
 {
board/amcc/taishan/lcd.c +0 -2
index 7f7730a..8208ef3 100644
@@ -35,8 +35,6 @@
 #define LCD_DATA_ADDR		((volatile char *)(CONFIG_SYS_EBC2_LCM_BASE+1))
 #define LCD_BLK_CTRL		((volatile char *)(CONFIG_SYS_EBC1_FPGA_BASE+0x2))
 
-#define mdelay(t)	({unsigned long msec=(t); while (msec--) { udelay(1000);}})
-
 static int g_lcd_init_b = 0;
 static char *amcc_logo = "  AMCC TAISHAN  440GX EvalBoard";
 static char addr_flag = 0x80;
board/freescale/mx35pdk/mx35pdk.c +0 -2
index 9eefe5e..8f9b857 100644
@@ -46,8 +46,6 @@
 #error "CONFIG_BOARD_EARLY_INIT_F must be set for this board"
 #endif
 
-#define mdelay(n) ({unsigned long msec = (n); while (msec--) udelay(1000); })
-
 DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
board/karo/tx25/tx25.c +0 -6
index 307ffd0..ec83f99 100644
@@ -31,12 +31,6 @@
 #include <asm/gpio.h>
 #include <asm/arch/sys_proto.h>
 
-static void mdelay(int n)
-{
-	while (n-- > 0)
-		udelay(1000);
-}
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_FEC_MXC
board/linkstation/hwctl.c +0 -2
index 9fd56ae..d2090be 100644
@@ -19,8 +19,6 @@
 #include <command.h>
 #include <asm/io.h>
 
-#define mdelay(n)	udelay((n)*1000)
-
 #define AVR_PORT CONFIG_SYS_NS16550_COM2
 
 /* 2005.5.10 BUFFALO add */
drivers/block/fsl_sata.c +0 -7
index 4b97a0e..63561eb 100644
@@ -50,13 +50,6 @@ static struct fsl_sata_info fsl_sata_info[] = {
 #endif
 };
 
-static inline void mdelay(unsigned long msec)
-{
-	unsigned long i;
-	for (i = 0; i < msec; i++)
-		udelay(1000);
-}
-
 static inline void sdelay(unsigned long sec)
 {
 	unsigned long i;
drivers/block/ftide020.c +0 -2
index 2eef3e9..4a7a07f 100644
@@ -54,8 +54,6 @@
 #define WRITE_CMD(x)	outl((x), &ftide020->cmd_fifo)	/* 0x04 */
 #define READ_STATUS()	inl(&ftide020->cmd_fifo)	/* 0x04 */
 
-#define mdelay(n) ({unsigned long msec = (n); while (msec--) udelay(1000); })
-
 void ftide_set_device(int cx8, int dev)
 {
 	static struct ftide020_s *ftide020 = (struct ftide020_s *) FTIDE_BASE;
drivers/net/e1000.c +0 -1
index 98145bc..01bdf81 100644
@@ -50,7 +50,6 @@ tested on both gig copper and gig fiber boards
 
 #define virt_to_bus(devno, v)	pci_virt_to_mem(devno, (void *) (v))
 #define bus_to_phys(devno, a)	pci_mem_to_phys(devno, a)
-#define mdelay(n)	udelay((n)*1000)
 
 #define E1000_DEFAULT_PCI_PBA	0x00000030
 #define E1000_DEFAULT_PCIE_PBA	0x000a0026
drivers/net/ftgmac100.c +0 -2
index dc7a80e..9994213 100644
@@ -33,8 +33,6 @@
 
 #define ETH_ZLEN	60
 
-#define mdelay(n) ({unsigned long msec = (n); while (msec--) udelay(1000); })
-
 /* RBSR - hw default init value is also 0x640 */
 #define RBSR_DEFAULT_VALUE	0x640
 
drivers/net/ne2000.c +0 -1
index 7a85314..3939158 100644
@@ -78,7 +78,6 @@ Add SNMP
 /* NE2000 base header file */
 #include "ne2000_base.h"
 
-#define mdelay(n) udelay((n)*1000)
 /* find prom (taken from pc_net_cs.c from Linux) */
 
 #include "8390.h"
drivers/net/ne2000_base.c +0 -1
index f93f932..f0cd2b6 100644
@@ -77,7 +77,6 @@ Add SNMP
 #include <net.h>
 #include <malloc.h>
 
-#define mdelay(n)	udelay((n)*1000)
 /* forward definition of function used for the uboot interface */
 void uboot_push_packet_len(int len);
 void uboot_push_tx_done(int key, int val);
drivers/net/smc911x.c +0 -2
index a677fd4..e34b487 100644
@@ -35,8 +35,6 @@ u32 pkt_data_pull(struct eth_device *dev, u32 addr) \
 void pkt_data_push(struct eth_device *dev, u32 addr, u32 val) \
 	__attribute__ ((weak, alias ("smc911x_reg_write")));
 
-#define mdelay(n)       udelay((n)*1000)
-
 static void smc911x_handle_mac_address(struct eth_device *dev)
 {
 	unsigned long addrh, addrl;
drivers/usb/host/ohci-hcd.c +0 -1
index c20d706..60c9595 100644
@@ -1749,7 +1749,6 @@ static int hc_start(ohci_t *ohci)
 	ohci_writel(RH_HS_LPSC, &ohci->regs->roothub.status);
 #endif	/* OHCI_USE_NPS */
 
-#define mdelay(n) ({unsigned long msec = (n); while (msec--) udelay(1000); })
 	/* POTPGT delay is bits 24-31, in 2 ms units. */
 	mdelay((roothub_a(ohci) >> 23) & 0x1fe);
 
drivers/usb/host/sl811-hcd.c +0 -2
index 82a8b36..c713d42 100644
@@ -51,8 +51,6 @@
 #define	 SL811_ADR (0x50000000)
 #define	 SL811_DAT (0x50000001)
 
-#define mdelay(n) ({unsigned long msec=(n); while (msec--) udelay(1000);})
-
 #ifdef SL811_DEBUG
 static int debug = 9;
 #endif
include/common.h +1 -0
index eb19a44..b4b6a35 100644
@@ -691,6 +691,7 @@ int strcmp_compar(const void *, const void *);
 
 /* lib/time.c */
 void	udelay        (unsigned long);
+void mdelay(unsigned long);
 
 /* lib/vsprintf.c */
 ulong	simple_strtoul(const char *cp,char **endp,unsigned int base);
lib/time.c +6 -0
index a309c26..6e2937b 100644
@@ -41,3 +41,9 @@ void udelay(unsigned long usec)
 		usec -= kv;
 	} while(usec);
 }
+
+void mdelay(unsigned long msec)
+{
+	while (msec--)
+		udelay(1000);
+}
Signature · 1 line
1.7.1
#2 lore raw

PATCH 1/1 consolidate mdelay by providing a common function for all users

In reply to Anatolij Gustschin

Dear Anatolij Gustschin,

Quoted 19 lines · In message <[email protected]> you wrote:

There are several mdelay() definitions in the driver and board code. Remove them all and provide a common mdelay() in lib/time.c.

---
 arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c       |    1 -
 arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c |    1 -
 arch/powerpc/cpu/mpc5xxx/usb_ohci.c           |    1 -
 arch/powerpc/cpu/ppc4xx/usb_ohci.c            |    1 -
 arch/powerpc/include/asm/4xx_pcie.h           |    8 --------
 board/amcc/taishan/lcd.c                      |    2 --
 board/freescale/mx35pdk/mx35pdk.c             |    2 --
 board/karo/tx25/tx25.c                        |    6 ------
 board/linkstation/hwctl.c                     |    2 --
 drivers/block/fsl_sata.c                      |    7 -------
 drivers/block/ftide020.c                      |    2 --
 drivers/net/e1000.c                           |    1 -
 drivers/net/ftgmac100.c                       |    2 --
Quoted 8 lines
 drivers/net/ne2000.c                          |    1 -
 drivers/net/ne2000_base.c                     |    1 -
 drivers/net/smc911x.c                         |    2 --
 drivers/usb/host/ohci-hcd.c                   |    1 -
 drivers/usb/host/sl811-hcd.c                  |    2 --
 include/common.h                              |    1 +
 lib/time.c                                    |    6 ++++++
 20 files changed, 7 insertions(+), 43 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
... Jesus cried with a loud voice: Lazarus, come forth; the bug  hath
been  found  and  thy  program  runneth.  And  he  that was dead came
forth...                              -- John 11:43-44 [version 2.0?]