Skip to content

Commit 42cb60d

Browse files
juhosgJohn Crispin
authored andcommitted
MIPS: pci-ar71xx: remove static PCI IO/MEM resources
Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/4927/ Signed-off-by: John Crispin <blogic@openwrt.org>
1 parent f18118a commit 42cb60d

2 files changed

Lines changed: 35 additions & 17 deletions

File tree

‎arch/mips/ath79/pci.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static struct platform_device *
117117
ath79_register_pci_ar71xx(void)
118118
{
119119
struct platform_device *pdev;
120-
struct resource res[2];
120+
struct resource res[4];
121121

122122
memset(res, 0, sizeof(res));
123123

@@ -130,6 +130,16 @@ ath79_register_pci_ar71xx(void)
130130
res[1].start = ATH79_CPU_IRQ_IP2;
131131
res[1].end = ATH79_CPU_IRQ_IP2;
132132

133+
res[2].name = "io_base";
134+
res[2].flags = IORESOURCE_IO;
135+
res[2].start = 0;
136+
res[2].end = 0;
137+
138+
res[3].name = "mem_base";
139+
res[3].flags = IORESOURCE_MEM;
140+
res[3].start = AR71XX_PCI_MEM_BASE;
141+
res[3].end = AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE - 1;
142+
133143
pdev = platform_device_register_simple("ar71xx-pci", -1,
134144
res, ARRAY_SIZE(res));
135145
return pdev;

‎arch/mips/pci/pci-ar71xx.c‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ struct ar71xx_pci_controller {
5353
spinlock_t lock;
5454
int irq;
5555
struct pci_controller pci_ctrl;
56+
struct resource io_res;
57+
struct resource mem_res;
5658
};
5759

5860
/* Byte lane enable bits */
@@ -234,20 +236,6 @@ static struct pci_ops ar71xx_pci_ops = {
234236
.write = ar71xx_pci_write_config,
235237
};
236238

237-
static struct resource ar71xx_pci_io_resource = {
238-
.name = "PCI IO space",
239-
.start = 0,
240-
.end = 0,
241-
.flags = IORESOURCE_IO,
242-
};
243-
244-
static struct resource ar71xx_pci_mem_resource = {
245-
.name = "PCI memory space",
246-
.start = AR71XX_PCI_MEM_BASE,
247-
.end = AR71XX_PCI_MEM_BASE + AR71XX_PCI_MEM_SIZE - 1,
248-
.flags = IORESOURCE_MEM
249-
};
250-
251239
static void ar71xx_pci_irq_handler(unsigned int irq, struct irq_desc *desc)
252240
{
253241
void __iomem *base = ath79_reset_base;
@@ -370,6 +358,26 @@ static int ar71xx_pci_probe(struct platform_device *pdev)
370358
if (apc->irq < 0)
371359
return -EINVAL;
372360

361+
res = platform_get_resource_byname(pdev, IORESOURCE_IO, "io_base");
362+
if (!res)
363+
return -EINVAL;
364+
365+
apc->io_res.parent = res;
366+
apc->io_res.name = "PCI IO space";
367+
apc->io_res.start = res->start;
368+
apc->io_res.end = res->end;
369+
apc->io_res.flags = IORESOURCE_IO;
370+
371+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mem_base");
372+
if (!res)
373+
return -EINVAL;
374+
375+
apc->mem_res.parent = res;
376+
apc->mem_res.name = "PCI memory space";
377+
apc->mem_res.start = res->start;
378+
apc->mem_res.end = res->end;
379+
apc->mem_res.flags = IORESOURCE_MEM;
380+
373381
ar71xx_pci_reset();
374382

375383
/* setup COMMAND register */
@@ -383,8 +391,8 @@ static int ar71xx_pci_probe(struct platform_device *pdev)
383391
ar71xx_pci_irq_init(apc);
384392

385393
apc->pci_ctrl.pci_ops = &ar71xx_pci_ops;
386-
apc->pci_ctrl.mem_resource = &ar71xx_pci_mem_resource;
387-
apc->pci_ctrl.io_resource = &ar71xx_pci_io_resource;
394+
apc->pci_ctrl.mem_resource = &apc->mem_res;
395+
apc->pci_ctrl.io_resource = &apc->io_res;
388396

389397
register_pci_controller(&apc->pci_ctrl);
390398

0 commit comments

Comments
 (0)