diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-11 09:21:23 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-03-11 09:21:23 -0400 |
commit | 3d7a8278fdfdea5be4c647853171a0df5d13c1d3 (patch) | |
tree | b80b6f13899a06e88cd379f60bff1940e7bb9323 /drivers/pcmcia/rsrc_pci.c | |
parent | 05c0006776374a1013bc30a7daeee3f8017147f2 (diff) |
Revert "pcmcia: add a new resource manager for non ISA systems"
This reverts commit 02b03846bb2befc558bfd0665749d6bb26f4c2f1.
Alan writes:
it seems there is a regression in there for some configuration of I/O
based devices. I'll take a look at it over the next couple of kernel
releases and see what is up then resubmit it with fixes.
Reported-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/pcmcia/rsrc_pci.c')
-rw-r--r-- | drivers/pcmcia/rsrc_pci.c | 172 |
1 files changed, 0 insertions, 172 deletions
diff --git a/drivers/pcmcia/rsrc_pci.c b/drivers/pcmcia/rsrc_pci.c deleted file mode 100644 index 8934d3c01f80..000000000000 --- a/drivers/pcmcia/rsrc_pci.c +++ /dev/null | |||
@@ -1,172 +0,0 @@ | |||
1 | #include <linux/slab.h> | ||
2 | #include <linux/module.h> | ||
3 | #include <linux/kernel.h> | ||
4 | |||
5 | #include <pcmcia/ss.h> | ||
6 | #include <pcmcia/cistpl.h> | ||
7 | #include "cs_internal.h" | ||
8 | |||
9 | |||
10 | struct pcmcia_align_data { | ||
11 | unsigned long mask; | ||
12 | unsigned long offset; | ||
13 | }; | ||
14 | |||
15 | static resource_size_t pcmcia_align(void *align_data, | ||
16 | const struct resource *res, | ||
17 | resource_size_t size, resource_size_t align) | ||
18 | { | ||
19 | struct pcmcia_align_data *data = align_data; | ||
20 | resource_size_t start; | ||
21 | |||
22 | start = (res->start & ~data->mask) + data->offset; | ||
23 | if (start < res->start) | ||
24 | start += data->mask + 1; | ||
25 | return start; | ||
26 | } | ||
27 | |||
28 | static struct resource *find_io_region(struct pcmcia_socket *s, | ||
29 | unsigned long base, int num, | ||
30 | unsigned long align) | ||
31 | { | ||
32 | struct resource *res = pcmcia_make_resource(0, num, IORESOURCE_IO, | ||
33 | dev_name(&s->dev)); | ||
34 | struct pcmcia_align_data data; | ||
35 | int ret; | ||
36 | |||
37 | data.mask = align - 1; | ||
38 | data.offset = base & data.mask; | ||
39 | |||
40 | ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1, | ||
41 | base, 0, pcmcia_align, &data); | ||
42 | if (ret != 0) { | ||
43 | kfree(res); | ||
44 | res = NULL; | ||
45 | } | ||
46 | return res; | ||
47 | } | ||
48 | |||
49 | static int res_pci_find_io(struct pcmcia_socket *s, unsigned int attr, | ||
50 | unsigned int *base, unsigned int num, | ||
51 | unsigned int align, struct resource **parent) | ||
52 | { | ||
53 | int i, ret = 0; | ||
54 | |||
55 | /* Check for an already-allocated window that must conflict with | ||
56 | * what was asked for. It is a hack because it does not catch all | ||
57 | * potential conflicts, just the most obvious ones. | ||
58 | */ | ||
59 | for (i = 0; i < MAX_IO_WIN; i++) { | ||
60 | if (!s->io[i].res) | ||
61 | continue; | ||
62 | |||
63 | if (!*base) | ||
64 | continue; | ||
65 | |||
66 | if ((s->io[i].res->start & (align-1)) == *base) | ||
67 | return -EBUSY; | ||
68 | } | ||
69 | |||
70 | for (i = 0; i < MAX_IO_WIN; i++) { | ||
71 | struct resource *res = s->io[i].res; | ||
72 | unsigned int try; | ||
73 | |||
74 | if (res && (res->flags & IORESOURCE_BITS) != | ||
75 | (attr & IORESOURCE_BITS)) | ||
76 | continue; | ||
77 | |||
78 | if (!res) { | ||
79 | if (align == 0) | ||
80 | align = 0x10000; | ||
81 | |||
82 | res = s->io[i].res = find_io_region(s, *base, num, | ||
83 | align); | ||
84 | if (!res) | ||
85 | return -EINVAL; | ||
86 | |||
87 | *base = res->start; | ||
88 | s->io[i].res->flags = | ||
89 | ((res->flags & ~IORESOURCE_BITS) | | ||
90 | (attr & IORESOURCE_BITS)); | ||
91 | s->io[i].InUse = num; | ||
92 | *parent = res; | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | /* Try to extend top of window */ | ||
97 | try = res->end + 1; | ||
98 | if ((*base == 0) || (*base == try)) { | ||
99 | ret = adjust_resource(s->io[i].res, res->start, | ||
100 | resource_size(res) + num); | ||
101 | if (ret) | ||
102 | continue; | ||
103 | *base = try; | ||
104 | s->io[i].InUse += num; | ||
105 | *parent = res; | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | /* Try to extend bottom of window */ | ||
110 | try = res->start - num; | ||
111 | if ((*base == 0) || (*base == try)) { | ||
112 | ret = adjust_resource(s->io[i].res, | ||
113 | res->start - num, | ||
114 | resource_size(res) + num); | ||
115 | if (ret) | ||
116 | continue; | ||
117 | *base = try; | ||
118 | s->io[i].InUse += num; | ||
119 | *parent = res; | ||
120 | return 0; | ||
121 | } | ||
122 | } | ||
123 | return -EINVAL; | ||
124 | } | ||
125 | |||
126 | static struct resource *res_pci_find_mem(u_long base, u_long num, | ||
127 | u_long align, int low, struct pcmcia_socket *s) | ||
128 | { | ||
129 | struct resource *res = pcmcia_make_resource(0, num, IORESOURCE_MEM, | ||
130 | dev_name(&s->dev)); | ||
131 | struct pcmcia_align_data data; | ||
132 | unsigned long min; | ||
133 | int ret; | ||
134 | |||
135 | if (align < 0x20000) | ||
136 | align = 0x20000; | ||
137 | data.mask = align - 1; | ||
138 | data.offset = base & data.mask; | ||
139 | |||
140 | min = 0; | ||
141 | if (!low) | ||
142 | min = 0x100000UL; | ||
143 | |||
144 | ret = pci_bus_alloc_resource(s->cb_dev->bus, | ||
145 | res, num, 1, min, 0, | ||
146 | pcmcia_align, &data); | ||
147 | |||
148 | if (ret != 0) { | ||
149 | kfree(res); | ||
150 | res = NULL; | ||
151 | } | ||
152 | return res; | ||
153 | } | ||
154 | |||
155 | |||
156 | static int res_pci_init(struct pcmcia_socket *s) | ||
157 | { | ||
158 | if (!s->cb_dev || (!s->features & SS_CAP_PAGE_REGS)) { | ||
159 | dev_err(&s->dev, "not supported by res_pci\n"); | ||
160 | return -EOPNOTSUPP; | ||
161 | } | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | struct pccard_resource_ops pccard_nonstatic_ops = { | ||
166 | .validate_mem = NULL, | ||
167 | .find_io = res_pci_find_io, | ||
168 | .find_mem = res_pci_find_mem, | ||
169 | .init = res_pci_init, | ||
170 | .exit = NULL, | ||
171 | }; | ||
172 | EXPORT_SYMBOL(pccard_nonstatic_ops); | ||