1 From 58a4dbd4160ee4a1428da23b81ff6d94c9a067a8 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Sat, 4 Aug 2012 15:03:55 +0000
4 Subject: [PATCH] MIPS: ath79: use a helper function for USB resource
7 commit 8d3e03e186cb94a333d0176fe8b22a6df200fcc7 upstream.
9 This improves code readability, and ensures that
10 all resource fields will be initialized correctly.
11 Additionally, it helps to reduce the size of the
12 kernel image by using uninitialized resource
15 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
16 Patchwork: http://patchwork.linux-mips.org/patch/4171/
17 Signed-off-by: John Crispin <blogic@openwrt.org>
19 arch/mips/ath79/dev-usb.c | 64 ++++++++++++++++++++-------------------------
20 1 file changed, 28 insertions(+), 36 deletions(-)
22 --- a/arch/mips/ath79/dev-usb.c
23 +++ b/arch/mips/ath79/dev-usb.c
28 -static struct resource ath79_ohci_resources[] = {
30 - /* .start and .end fields are filled dynamically */
31 - .flags = IORESOURCE_MEM,
34 - .start = ATH79_MISC_IRQ_OHCI,
35 - .end = ATH79_MISC_IRQ_OHCI,
36 - .flags = IORESOURCE_IRQ,
39 +static struct resource ath79_ohci_resources[2];
41 static u64 ath79_ohci_dmamask = DMA_BIT_MASK(32);
43 @@ -54,17 +44,7 @@ static struct platform_device ath79_ohci
47 -static struct resource ath79_ehci_resources[] = {
49 - /* .start and .end fields are filled dynamically */
50 - .flags = IORESOURCE_MEM,
53 - .start = ATH79_CPU_IRQ_USB,
54 - .end = ATH79_CPU_IRQ_USB,
55 - .flags = IORESOURCE_IRQ,
58 +static struct resource ath79_ehci_resources[2];
60 static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32);
62 @@ -90,6 +70,20 @@ static struct platform_device ath79_ehci
66 +static void __init ath79_usb_init_resource(struct resource res[2],
71 + res[0].flags = IORESOURCE_MEM;
72 + res[0].start = base;
73 + res[0].end = base + size - 1;
75 + res[1].flags = IORESOURCE_IRQ;
80 #define AR71XX_USB_RESET_MASK (AR71XX_RESET_USB_HOST | \
81 AR71XX_RESET_USB_PHY | \
82 AR71XX_RESET_USB_OHCI_DLL)
83 @@ -114,12 +108,12 @@ static void __init ath79_usb_setup(void)
87 - ath79_ohci_resources[0].start = AR71XX_OHCI_BASE;
88 - ath79_ohci_resources[0].end = AR71XX_OHCI_BASE + AR71XX_OHCI_SIZE - 1;
89 + ath79_usb_init_resource(ath79_ohci_resources, AR71XX_OHCI_BASE,
90 + AR71XX_OHCI_SIZE, ATH79_MISC_IRQ_OHCI);
91 platform_device_register(&ath79_ohci_device);
93 - ath79_ehci_resources[0].start = AR71XX_EHCI_BASE;
94 - ath79_ehci_resources[0].end = AR71XX_EHCI_BASE + AR71XX_EHCI_SIZE - 1;
95 + ath79_usb_init_resource(ath79_ehci_resources, AR71XX_EHCI_BASE,
96 + AR71XX_EHCI_SIZE, ATH79_CPU_IRQ_USB);
97 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v1;
98 platform_device_register(&ath79_ehci_device);
100 @@ -143,10 +137,8 @@ static void __init ar7240_usb_setup(void
102 iounmap(usb_ctrl_base);
104 - ath79_ohci_resources[0].start = AR7240_OHCI_BASE;
105 - ath79_ohci_resources[0].end = AR7240_OHCI_BASE + AR7240_OHCI_SIZE - 1;
106 - ath79_ohci_resources[1].start = ATH79_CPU_IRQ_USB;
107 - ath79_ohci_resources[1].end = ATH79_CPU_IRQ_USB;
108 + ath79_usb_init_resource(ath79_ohci_resources, AR7240_OHCI_BASE,
109 + AR7240_OHCI_SIZE, ATH79_CPU_IRQ_USB);
110 platform_device_register(&ath79_ohci_device);
113 @@ -161,8 +153,8 @@ static void __init ar724x_usb_setup(void
114 ath79_device_reset_clear(AR724X_RESET_USB_PHY);
117 - ath79_ehci_resources[0].start = AR724X_EHCI_BASE;
118 - ath79_ehci_resources[0].end = AR724X_EHCI_BASE + AR724X_EHCI_SIZE - 1;
119 + ath79_usb_init_resource(ath79_ehci_resources, AR724X_EHCI_BASE,
120 + AR724X_EHCI_SIZE, ATH79_CPU_IRQ_USB);
121 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2;
122 platform_device_register(&ath79_ehci_device);
124 @@ -178,8 +170,8 @@ static void __init ar913x_usb_setup(void
125 ath79_device_reset_clear(AR913X_RESET_USB_PHY);
128 - ath79_ehci_resources[0].start = AR913X_EHCI_BASE;
129 - ath79_ehci_resources[0].end = AR913X_EHCI_BASE + AR913X_EHCI_SIZE - 1;
130 + ath79_usb_init_resource(ath79_ehci_resources, AR913X_EHCI_BASE,
131 + AR913X_EHCI_SIZE, ATH79_CPU_IRQ_USB);
132 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2;
133 platform_device_register(&ath79_ehci_device);
135 @@ -195,8 +187,8 @@ static void __init ar933x_usb_setup(void
136 ath79_device_reset_clear(AR933X_RESET_USB_PHY);
139 - ath79_ehci_resources[0].start = AR933X_EHCI_BASE;
140 - ath79_ehci_resources[0].end = AR933X_EHCI_BASE + AR933X_EHCI_SIZE - 1;
141 + ath79_usb_init_resource(ath79_ehci_resources, AR933X_EHCI_BASE,
142 + AR933X_EHCI_SIZE, ATH79_CPU_IRQ_USB);
143 ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2;
144 platform_device_register(&ath79_ehci_device);