aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2008-04-28 18:33:52 -0400
committerLen Brown <len.brown@intel.com>2008-04-29 03:22:16 -0400
commit772defc6292bae8b6db298476d1dabd22a99492b (patch)
treeb973807f7f65f6d59e8a273ff80ab3d312e71dc3 /drivers
parent1692b27bf37826f85f9c12f8468848885643532a (diff)
PNP: change pnp_add_id() to allocate its own pnp_id structures
This moves some of the pnp_id knowledge out of the backends and into the PNP core. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Acked-By: Rene Herman <rene.herman@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pnp/base.h2
-rw-r--r--drivers/pnp/driver.c28
-rw-r--r--drivers/pnp/isapnp/core.c14
-rw-r--r--drivers/pnp/pnpacpi/core.c25
-rw-r--r--drivers/pnp/pnpbios/core.c6
-rw-r--r--drivers/pnp/pnpbios/rsparser.c9
6 files changed, 36 insertions, 48 deletions
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index abefcc351521..ba55b0623f7e 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -1,6 +1,6 @@
1extern spinlock_t pnp_lock; 1extern spinlock_t pnp_lock;
2void *pnp_alloc(long size); 2void *pnp_alloc(long size);
3int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev); 3struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
4int pnp_interface_attach_device(struct pnp_dev *dev); 4int pnp_interface_attach_device(struct pnp_dev *dev);
5void pnp_fixup_device(struct pnp_dev *dev); 5void pnp_fixup_device(struct pnp_dev *dev);
6void pnp_free_option(struct pnp_option *option); 6void pnp_free_option(struct pnp_option *option);
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index e85cbf116db1..d3f869ee1d92 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -226,22 +226,36 @@ void pnp_unregister_driver(struct pnp_driver *drv)
226 226
227/** 227/**
228 * pnp_add_id - adds an EISA id to the specified device 228 * pnp_add_id - adds an EISA id to the specified device
229 * @id: pointer to a pnp_id structure
230 * @dev: pointer to the desired device 229 * @dev: pointer to the desired device
230 * @id: pointer to an EISA id string
231 */ 231 */
232int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) 232struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id)
233{ 233{
234 struct pnp_id *ptr; 234 struct pnp_id *dev_id, *ptr;
235 235
236 id->next = NULL; 236 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
237 if (!dev_id)
238 return NULL;
239
240 dev_id->id[0] = id[0];
241 dev_id->id[1] = id[1];
242 dev_id->id[2] = id[2];
243 dev_id->id[3] = tolower(id[3]);
244 dev_id->id[4] = tolower(id[4]);
245 dev_id->id[5] = tolower(id[5]);
246 dev_id->id[6] = tolower(id[6]);
247 dev_id->id[7] = '\0';
248
249 dev_id->next = NULL;
237 ptr = dev->id; 250 ptr = dev->id;
238 while (ptr && ptr->next) 251 while (ptr && ptr->next)
239 ptr = ptr->next; 252 ptr = ptr->next;
240 if (ptr) 253 if (ptr)
241 ptr->next = id; 254 ptr->next = dev_id;
242 else 255 else
243 dev->id = id; 256 dev->id = dev_id;
244 return 0; 257
258 return dev_id;
245} 259}
246 260
247EXPORT_SYMBOL(pnp_register_driver); 261EXPORT_SYMBOL(pnp_register_driver);
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index dd67752a5828..10cade831433 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -44,6 +44,8 @@
44#include <linux/mutex.h> 44#include <linux/mutex.h>
45#include <asm/io.h> 45#include <asm/io.h>
46 46
47#include "../base.h"
48
47#if 0 49#if 0
48#define ISAPNP_REGION_OK 50#define ISAPNP_REGION_OK
49#endif 51#endif
@@ -401,20 +403,16 @@ static void __init isapnp_skip_bytes(int count)
401static void isapnp_parse_id(struct pnp_dev *dev, unsigned short vendor, 403static void isapnp_parse_id(struct pnp_dev *dev, unsigned short vendor,
402 unsigned short device) 404 unsigned short device)
403{ 405{
404 struct pnp_id *id; 406 char id[8];
405 407
406 if (!dev) 408 sprintf(id, "%c%c%c%x%x%x%x",
407 return;
408 id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
409 if (!id)
410 return;
411 sprintf(id->id, "%c%c%c%x%x%x%x",
412 'A' + ((vendor >> 2) & 0x3f) - 1, 409 'A' + ((vendor >> 2) & 0x3f) - 1,
413 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, 410 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
414 'A' + ((vendor >> 8) & 0x1f) - 1, 411 'A' + ((vendor >> 8) & 0x1f) - 1,
415 (device >> 4) & 0x0f, 412 (device >> 4) & 0x0f,
416 device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f); 413 device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f);
417 pnp_add_id(id, dev); 414
415 pnp_add_id(dev, id);
418} 416}
419 417
420/* 418/*
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 4807d76f8a04..86aea1ebfee7 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -73,18 +73,6 @@ static int __init ispnpidacpi(char *id)
73 return 1; 73 return 1;
74} 74}
75 75
76static void __init pnpidacpi_to_pnpid(char *id, char *str)
77{
78 str[0] = id[0];
79 str[1] = id[1];
80 str[2] = id[2];
81 str[3] = tolower(id[3]);
82 str[4] = tolower(id[4]);
83 str[5] = tolower(id[5]);
84 str[6] = tolower(id[6]);
85 str[7] = '\0';
86}
87
88static int pnpacpi_get_resources(struct pnp_dev *dev, 76static int pnpacpi_get_resources(struct pnp_dev *dev,
89 struct pnp_resource_table *res) 77 struct pnp_resource_table *res)
90{ 78{
@@ -201,12 +189,9 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
201 189
202 dev->number = num; 190 dev->number = num;
203 191
204 /* set the initial values for the PnP device */ 192 dev_id = pnp_add_id(dev, acpi_device_hid(device));
205 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
206 if (!dev_id) 193 if (!dev_id)
207 goto err; 194 goto err;
208 pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id);
209 pnp_add_id(dev_id, dev);
210 195
211 if (dev->active) { 196 if (dev->active) {
212 /* parse allocated resource */ 197 /* parse allocated resource */
@@ -227,7 +212,6 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
227 } 212 }
228 } 213 }
229 214
230 /* parse compatible ids */
231 if (device->flags.compatible_ids) { 215 if (device->flags.compatible_ids) {
232 struct acpi_compatible_id_list *cid_list = device->pnp.cid_list; 216 struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
233 int i; 217 int i;
@@ -235,12 +219,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
235 for (i = 0; i < cid_list->count; i++) { 219 for (i = 0; i < cid_list->count; i++) {
236 if (!ispnpidacpi(cid_list->id[i].value)) 220 if (!ispnpidacpi(cid_list->id[i].value))
237 continue; 221 continue;
238 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); 222 pnp_add_id(dev, cid_list->id[i].value);
239 if (!dev_id)
240 continue;
241
242 pnpidacpi_to_pnpid(cid_list->id[i].value, dev_id->id);
243 pnp_add_id(dev_id, dev);
244 } 223 }
245 } 224 }
246 225
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index 2a5353bceb24..2d592aea0aa7 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -332,16 +332,14 @@ static int __init insert_device(struct pnp_bios_node *node)
332 if (!dev) 332 if (!dev)
333 return -1; 333 return -1;
334 334
335 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); 335 pnpid32_to_pnpid(node->eisa_id, id);
336 dev_id = pnp_add_id(dev, id);
336 if (!dev_id) { 337 if (!dev_id) {
337 kfree(dev); 338 kfree(dev);
338 return -1; 339 return -1;
339 } 340 }
340 341
341 dev->number = node->handle; 342 dev->number = node->handle;
342 pnpid32_to_pnpid(node->eisa_id, id);
343 memcpy(dev_id->id, id, 7);
344 pnp_add_id(dev_id, dev);
345 pnpbios_parse_data_stream(dev, node); 343 pnpbios_parse_data_stream(dev, node);
346 dev->active = pnp_is_active(dev); 344 dev->active = pnp_is_active(dev);
347 dev->flags = node->flags; 345 dev->flags = node->flags;
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index caade3531416..dbc88412c12e 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -16,6 +16,7 @@ inline void pcibios_penalize_isa_irq(int irq, int active)
16} 16}
17#endif /* CONFIG_PCI */ 17#endif /* CONFIG_PCI */
18 18
19#include "../base.h"
19#include "pnpbios.h" 20#include "pnpbios.h"
20 21
21/* standard resource tags */ 22/* standard resource tags */
@@ -548,13 +549,11 @@ static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p,
548 case SMALL_TAG_COMPATDEVID: /* compatible ID */ 549 case SMALL_TAG_COMPATDEVID: /* compatible ID */
549 if (len != 4) 550 if (len != 4)
550 goto len_err; 551 goto len_err;
551 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
552 if (!dev_id)
553 return NULL;
554 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 552 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] <<
555 24, id); 553 24, id);
556 memcpy(&dev_id->id, id, 7); 554 dev_id = pnp_add_id(dev, id);
557 pnp_add_id(dev_id, dev); 555 if (!dev_id)
556 return NULL;
558 break; 557 break;
559 558
560 case SMALL_TAG_END: 559 case SMALL_TAG_END: