treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / alpha / kernel / pci-noop.c
blobae82061edae995dc1ee2d9f711c9a1e604915849
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * linux/arch/alpha/kernel/pci-noop.c
5 * Stub PCI interfaces for Jensen-specific kernels.
6 */
8 #include <linux/pci.h>
9 #include <linux/init.h>
10 #include <linux/memblock.h>
11 #include <linux/gfp.h>
12 #include <linux/capability.h>
13 #include <linux/mm.h>
14 #include <linux/errno.h>
15 #include <linux/sched.h>
16 #include <linux/dma-mapping.h>
17 #include <linux/scatterlist.h>
18 #include <linux/syscalls.h>
20 #include "proto.h"
24 * The PCI controller list.
27 struct pci_controller *hose_head, **hose_tail = &hose_head;
28 struct pci_controller *pci_isa_hose;
31 struct pci_controller * __init
32 alloc_pci_controller(void)
34 struct pci_controller *hose;
36 hose = memblock_alloc(sizeof(*hose), SMP_CACHE_BYTES);
37 if (!hose)
38 panic("%s: Failed to allocate %zu bytes\n", __func__,
39 sizeof(*hose));
41 *hose_tail = hose;
42 hose_tail = &hose->next;
44 return hose;
47 struct resource * __init
48 alloc_resource(void)
50 void *ptr = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES);
52 if (!ptr)
53 panic("%s: Failed to allocate %zu bytes\n", __func__,
54 sizeof(struct resource));
56 return ptr;
59 SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
60 unsigned long, dfn)
62 struct pci_controller *hose;
64 /* from hose or from bus.devfn */
65 if (which & IOBASE_FROM_HOSE) {
66 for (hose = hose_head; hose; hose = hose->next)
67 if (hose->index == bus)
68 break;
69 if (!hose)
70 return -ENODEV;
71 } else {
72 /* Special hook for ISA access. */
73 if (bus == 0 && dfn == 0)
74 hose = pci_isa_hose;
75 else
76 return -ENODEV;
79 switch (which & ~IOBASE_FROM_HOSE) {
80 case IOBASE_HOSE:
81 return hose->index;
82 case IOBASE_SPARSE_MEM:
83 return hose->sparse_mem_base;
84 case IOBASE_DENSE_MEM:
85 return hose->dense_mem_base;
86 case IOBASE_SPARSE_IO:
87 return hose->sparse_io_base;
88 case IOBASE_DENSE_IO:
89 return hose->dense_io_base;
90 case IOBASE_ROOT_BUS:
91 return hose->bus->number;
94 return -EOPNOTSUPP;
97 SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,
98 unsigned long, off, unsigned long, len, void __user *, buf)
100 if (!capable(CAP_SYS_ADMIN))
101 return -EPERM;
102 else
103 return -ENODEV;
106 SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,
107 unsigned long, off, unsigned long, len, void __user *, buf)
109 if (!capable(CAP_SYS_ADMIN))
110 return -EPERM;
111 else
112 return -ENODEV;