aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpbios/rsparser.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2008-06-27 18:57:11 -0400
committerAndi Kleen <andi@basil.nowhere.org>2008-07-16 17:27:07 -0400
commitc227536b4cc2600fc9d22ba0067f699165f6621f (patch)
treeeacf9e90f89f9f71304033e4da1492450c8c644a /drivers/pnp/pnpbios/rsparser.c
parentb08395e5038e3337bb85c7246a635a3be6d5a29c (diff)
PNP: centralize resource option allocations
This patch moves all the option allocations (pnp_mem, pnp_port, etc) into the pnp_register_{mem,port,irq,dma}_resource() functions. This will make it easier to rework the option data structures. The non-trivial part of this patch is the IRQ handling. The backends have to allocate a local pnp_irq_mask_t bitmap, populate it, and pass a pointer to pnp_register_irq_resource(). Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Rene Herman <rene.herman@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/pnp/pnpbios/rsparser.c')
-rw-r--r--drivers/pnp/pnpbios/rsparser.c120
1 files changed, 50 insertions, 70 deletions
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index dd2ea7b03605..26fb04cc12bb 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -218,116 +218,96 @@ static __init void pnpbios_parse_mem_option(struct pnp_dev *dev,
218 unsigned char *p, int size, 218 unsigned char *p, int size,
219 struct pnp_option *option) 219 struct pnp_option *option)
220{ 220{
221 struct pnp_mem *mem; 221 resource_size_t min, max, align, len;
222 222 unsigned char flags;
223 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 223
224 if (!mem) 224 min = ((p[5] << 8) | p[4]) << 8;
225 return; 225 max = ((p[7] << 8) | p[6]) << 8;
226 mem->min = ((p[5] << 8) | p[4]) << 8; 226 align = (p[9] << 8) | p[8];
227 mem->max = ((p[7] << 8) | p[6]) << 8; 227 len = ((p[11] << 8) | p[10]) << 8;
228 mem->align = (p[9] << 8) | p[8]; 228 flags = p[3];
229 mem->size = ((p[11] << 8) | p[10]) << 8; 229 pnp_register_mem_resource(dev, option, min, max, align, len, flags);
230 mem->flags = p[3];
231 pnp_register_mem_resource(dev, option, mem);
232} 230}
233 231
234static __init void pnpbios_parse_mem32_option(struct pnp_dev *dev, 232static __init void pnpbios_parse_mem32_option(struct pnp_dev *dev,
235 unsigned char *p, int size, 233 unsigned char *p, int size,
236 struct pnp_option *option) 234 struct pnp_option *option)
237{ 235{
238 struct pnp_mem *mem; 236 resource_size_t min, max, align, len;
239 237 unsigned char flags;
240 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 238
241 if (!mem) 239 min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4];
242 return; 240 max = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8];
243 mem->min = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; 241 align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12];
244 mem->max = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8]; 242 len = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16];
245 mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12]; 243 flags = p[3];
246 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16]; 244 pnp_register_mem_resource(dev, option, min, max, align, len, flags);
247 mem->flags = p[3];
248 pnp_register_mem_resource(dev, option, mem);
249} 245}
250 246
251static __init void pnpbios_parse_fixed_mem32_option(struct pnp_dev *dev, 247static __init void pnpbios_parse_fixed_mem32_option(struct pnp_dev *dev,
252 unsigned char *p, int size, 248 unsigned char *p, int size,
253 struct pnp_option *option) 249 struct pnp_option *option)
254{ 250{
255 struct pnp_mem *mem; 251 resource_size_t base, len;
256 252 unsigned char flags;
257 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 253
258 if (!mem) 254 base = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4];
259 return; 255 len = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8];
260 mem->min = mem->max = (p[7] << 24) | (p[6] << 16) | (p[5] << 8) | p[4]; 256 flags = p[3];
261 mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8]; 257 pnp_register_mem_resource(dev, option, base, base, 0, len, flags);
262 mem->align = 0;
263 mem->flags = p[3];
264 pnp_register_mem_resource(dev, option, mem);
265} 258}
266 259
267static __init void pnpbios_parse_irq_option(struct pnp_dev *dev, 260static __init void pnpbios_parse_irq_option(struct pnp_dev *dev,
268 unsigned char *p, int size, 261 unsigned char *p, int size,
269 struct pnp_option *option) 262 struct pnp_option *option)
270{ 263{
271 struct pnp_irq *irq;
272 unsigned long bits; 264 unsigned long bits;
265 pnp_irq_mask_t map;
266 unsigned char flags = IORESOURCE_IRQ_HIGHEDGE;
273 267
274 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
275 if (!irq)
276 return;
277 bits = (p[2] << 8) | p[1]; 268 bits = (p[2] << 8) | p[1];
278 bitmap_copy(irq->map.bits, &bits, 16); 269
270 bitmap_zero(map.bits, PNP_IRQ_NR);
271 bitmap_copy(map.bits, &bits, 16);
272
279 if (size > 2) 273 if (size > 2)
280 irq->flags = p[3]; 274 flags = p[3];
281 else 275
282 irq->flags = IORESOURCE_IRQ_HIGHEDGE; 276 pnp_register_irq_resource(dev, option, &map, flags);
283 pnp_register_irq_resource(dev, option, irq);
284} 277}
285 278
286static __init void pnpbios_parse_dma_option(struct pnp_dev *dev, 279static __init void pnpbios_parse_dma_option(struct pnp_dev *dev,
287 unsigned char *p, int size, 280 unsigned char *p, int size,
288 struct pnp_option *option) 281 struct pnp_option *option)
289{ 282{
290 struct pnp_dma *dma; 283 pnp_register_dma_resource(dev, option, p[1], p[2]);
291
292 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
293 if (!dma)
294 return;
295 dma->map = p[1];
296 dma->flags = p[2];
297 pnp_register_dma_resource(dev, option, dma);
298} 284}
299 285
300static __init void pnpbios_parse_port_option(struct pnp_dev *dev, 286static __init void pnpbios_parse_port_option(struct pnp_dev *dev,
301 unsigned char *p, int size, 287 unsigned char *p, int size,
302 struct pnp_option *option) 288 struct pnp_option *option)
303{ 289{
304 struct pnp_port *port; 290 resource_size_t min, max, align, len;
305 291 unsigned char flags;
306 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 292
307 if (!port) 293 min = (p[3] << 8) | p[2];
308 return; 294 max = (p[5] << 8) | p[4];
309 port->min = (p[3] << 8) | p[2]; 295 align = p[6];
310 port->max = (p[5] << 8) | p[4]; 296 len = p[7];
311 port->align = p[6]; 297 flags = p[1] ? IORESOURCE_IO_16BIT_ADDR : 0;
312 port->size = p[7]; 298 pnp_register_port_resource(dev, option, min, max, align, len, flags);
313 port->flags = p[1] ? IORESOURCE_IO_16BIT_ADDR : 0;
314 pnp_register_port_resource(dev, option, port);
315} 299}
316 300
317static __init void pnpbios_parse_fixed_port_option(struct pnp_dev *dev, 301static __init void pnpbios_parse_fixed_port_option(struct pnp_dev *dev,
318 unsigned char *p, int size, 302 unsigned char *p, int size,
319 struct pnp_option *option) 303 struct pnp_option *option)
320{ 304{
321 struct pnp_port *port; 305 resource_size_t base, len;
322 306
323 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 307 base = (p[2] << 8) | p[1];
324 if (!port) 308 len = p[3];
325 return; 309 pnp_register_port_resource(dev, option, base, base, 0, len,
326 port->min = port->max = (p[2] << 8) | p[1]; 310 IORESOURCE_IO_FIXED);
327 port->size = p[3];
328 port->align = 0;
329 port->flags = IORESOURCE_IO_FIXED;
330 pnp_register_port_resource(dev, option, port);
331} 311}
332 312
333static __init unsigned char * 313static __init unsigned char *