Skip to content

Commit 987b420

Browse files
lipnitsktsbogend
authored andcommitted
MIPS: pci-legacy: revert "use generic pci_enable_resources"
This mostly reverts commit 99bca61 ("MIPS: pci-legacy: use generic pci_enable_resources"). Fixes regressions such as: ata_piix 0000:00:0a.1: can't enable device: BAR 0 [io 0x01f0-0x01f7] not claimed ata_piix: probe of 0000:00:0a.1 failed with error -22 The only changes from the strict revert are to fix checkpatch errors: ERROR: spaces required around that '=' (ctx:VxV) #33: FILE: arch/mips/pci/pci-legacy.c:252: + for (idx=0; idx < PCI_NUM_RESOURCES; idx++) { ^ ERROR: do not use assignment in if condition #67: FILE: arch/mips/pci/pci-legacy.c:284: + if ((err = pcibios_enable_resources(dev, mask)) < 0) Reported-by: Guenter Roeck <[email protected]> Signed-off-by: Ilya Lipnitskiy <[email protected]> Tested-by: Guenter Roeck <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 6ce4889 commit 987b420

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

arch/mips/pci/pci-legacy.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,45 @@ static int __init pcibios_init(void)
241241

242242
subsys_initcall(pcibios_init);
243243

244+
static int pcibios_enable_resources(struct pci_dev *dev, int mask)
245+
{
246+
u16 cmd, old_cmd;
247+
int idx;
248+
struct resource *r;
249+
250+
pci_read_config_word(dev, PCI_COMMAND, &cmd);
251+
old_cmd = cmd;
252+
for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) {
253+
/* Only set up the requested stuff */
254+
if (!(mask & (1<<idx)))
255+
continue;
256+
257+
r = &dev->resource[idx];
258+
if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
259+
continue;
260+
if ((idx == PCI_ROM_RESOURCE) &&
261+
(!(r->flags & IORESOURCE_ROM_ENABLE)))
262+
continue;
263+
if (!r->start && r->end) {
264+
pci_err(dev,
265+
"can't enable device: resource collisions\n");
266+
return -EINVAL;
267+
}
268+
if (r->flags & IORESOURCE_IO)
269+
cmd |= PCI_COMMAND_IO;
270+
if (r->flags & IORESOURCE_MEM)
271+
cmd |= PCI_COMMAND_MEMORY;
272+
}
273+
if (cmd != old_cmd) {
274+
pci_info(dev, "enabling device (%04x -> %04x)\n", old_cmd, cmd);
275+
pci_write_config_word(dev, PCI_COMMAND, cmd);
276+
}
277+
return 0;
278+
}
279+
244280
int pcibios_enable_device(struct pci_dev *dev, int mask)
245281
{
246-
int err = pci_enable_resources(dev, mask);
282+
int err = pcibios_enable_resources(dev, mask);
247283

248284
if (err < 0)
249285
return err;

0 commit comments

Comments
 (0)