From c227536b4cc2600fc9d22ba0067f699165f6621f Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Fri, 27 Jun 2008 16:57:11 -0600 Subject: 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 Signed-off-by: Andi Kleen Acked-by: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/resource.c | 54 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'drivers/pnp/resource.c') diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index 391828c7f207..61145491f363 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c @@ -78,13 +78,20 @@ struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, } int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option, - struct pnp_irq *data) + pnp_irq_mask_t *map, unsigned char flags) { - struct pnp_irq *ptr; + struct pnp_irq *data, *ptr; #ifdef DEBUG char buf[PNP_IRQ_NR]; /* hex-encoded, so this is overkill but safe */ #endif + data = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->map = *map; + data->flags = flags; + ptr = option->irq; while (ptr && ptr->next) ptr = ptr->next; @@ -112,9 +119,16 @@ int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option, } int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option, - struct pnp_dma *data) + unsigned char map, unsigned char flags) { - struct pnp_dma *ptr; + struct pnp_dma *data, *ptr; + + data = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->map = map; + data->flags = flags; ptr = option->dma; while (ptr && ptr->next) @@ -130,9 +144,21 @@ int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option, } int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, - struct pnp_port *data) + resource_size_t min, resource_size_t max, + resource_size_t align, resource_size_t size, + unsigned char flags) { - struct pnp_port *ptr; + struct pnp_port *data, *ptr; + + data = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->min = min; + data->max = max; + data->align = align; + data->size = size; + data->flags = flags; ptr = option->port; while (ptr && ptr->next) @@ -152,9 +178,21 @@ int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, } int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option, - struct pnp_mem *data) + resource_size_t min, resource_size_t max, + resource_size_t align, resource_size_t size, + unsigned char flags) { - struct pnp_mem *ptr; + struct pnp_mem *data, *ptr; + + data = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->min = min; + data->max = max; + data->align = align; + data->size = size; + data->flags = flags; ptr = option->mem; while (ptr && ptr->next) -- cgit v1.2.3