aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/resource.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/resource.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/resource.c')
-rw-r--r--drivers/pnp/resource.c54
1 files changed, 46 insertions, 8 deletions
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,
78} 78}
79 79
80int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option, 80int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option,
81 struct pnp_irq *data) 81 pnp_irq_mask_t *map, unsigned char flags)
82{ 82{
83 struct pnp_irq *ptr; 83 struct pnp_irq *data, *ptr;
84#ifdef DEBUG 84#ifdef DEBUG
85 char buf[PNP_IRQ_NR]; /* hex-encoded, so this is overkill but safe */ 85 char buf[PNP_IRQ_NR]; /* hex-encoded, so this is overkill but safe */
86#endif 86#endif
87 87
88 data = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
89 if (!data)
90 return -ENOMEM;
91
92 data->map = *map;
93 data->flags = flags;
94
88 ptr = option->irq; 95 ptr = option->irq;
89 while (ptr && ptr->next) 96 while (ptr && ptr->next)
90 ptr = ptr->next; 97 ptr = ptr->next;
@@ -112,9 +119,16 @@ int pnp_register_irq_resource(struct pnp_dev *dev, struct pnp_option *option,
112} 119}
113 120
114int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option, 121int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option,
115 struct pnp_dma *data) 122 unsigned char map, unsigned char flags)
116{ 123{
117 struct pnp_dma *ptr; 124 struct pnp_dma *data, *ptr;
125
126 data = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
127 if (!data)
128 return -ENOMEM;
129
130 data->map = map;
131 data->flags = flags;
118 132
119 ptr = option->dma; 133 ptr = option->dma;
120 while (ptr && ptr->next) 134 while (ptr && ptr->next)
@@ -130,9 +144,21 @@ int pnp_register_dma_resource(struct pnp_dev *dev, struct pnp_option *option,
130} 144}
131 145
132int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option, 146int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option,
133 struct pnp_port *data) 147 resource_size_t min, resource_size_t max,
148 resource_size_t align, resource_size_t size,
149 unsigned char flags)
134{ 150{
135 struct pnp_port *ptr; 151 struct pnp_port *data, *ptr;
152
153 data = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
154 if (!data)
155 return -ENOMEM;
156
157 data->min = min;
158 data->max = max;
159 data->align = align;
160 data->size = size;
161 data->flags = flags;
136 162
137 ptr = option->port; 163 ptr = option->port;
138 while (ptr && ptr->next) 164 while (ptr && ptr->next)
@@ -152,9 +178,21 @@ int pnp_register_port_resource(struct pnp_dev *dev, struct pnp_option *option,
152} 178}
153 179
154int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option, 180int pnp_register_mem_resource(struct pnp_dev *dev, struct pnp_option *option,
155 struct pnp_mem *data) 181 resource_size_t min, resource_size_t max,
182 resource_size_t align, resource_size_t size,
183 unsigned char flags)
156{ 184{
157 struct pnp_mem *ptr; 185 struct pnp_mem *data, *ptr;
186
187 data = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
188 if (!data)
189 return -ENOMEM;
190
191 data->min = min;
192 data->max = max;
193 data->align = align;
194 data->size = size;
195 data->flags = flags;
158 196
159 ptr = option->mem; 197 ptr = option->mem;
160 while (ptr && ptr->next) 198 while (ptr && ptr->next)