diff options
Diffstat (limited to 'drivers/pnp/system.c')
-rw-r--r-- | drivers/pnp/system.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/drivers/pnp/system.c b/drivers/pnp/system.c index d42015c382af..2065e74bb63f 100644 --- a/drivers/pnp/system.c +++ b/drivers/pnp/system.c | |||
@@ -3,7 +3,8 @@ | |||
3 | * | 3 | * |
4 | * Some code is based on pnpbios_core.c | 4 | * Some code is based on pnpbios_core.c |
5 | * Copyright 2002 Adam Belay <ambx1@neo.rr.com> | 5 | * Copyright 2002 Adam Belay <ambx1@neo.rr.com> |
6 | * | 6 | * (c) Copyright 2007 Hewlett-Packard Development Company, L.P. |
7 | * Bjorn Helgaas <bjorn.helgaas@hp.com> | ||
7 | */ | 8 | */ |
8 | 9 | ||
9 | #include <linux/pnp.h> | 10 | #include <linux/pnp.h> |
@@ -21,18 +22,21 @@ static const struct pnp_device_id pnp_dev_table[] = { | |||
21 | { "", 0 } | 22 | { "", 0 } |
22 | }; | 23 | }; |
23 | 24 | ||
24 | static void reserve_ioport_range(char *pnpid, int start, int end) | 25 | static void reserve_range(char *pnpid, int start, int end, int port) |
25 | { | 26 | { |
26 | struct resource *res; | 27 | struct resource *res; |
27 | char *regionid; | 28 | char *regionid; |
28 | 29 | ||
29 | regionid = kmalloc(16, GFP_KERNEL); | 30 | regionid = kmalloc(16, GFP_KERNEL); |
30 | if ( regionid == NULL ) | 31 | if (regionid == NULL) |
31 | return; | 32 | return; |
32 | snprintf(regionid, 16, "pnp %s", pnpid); | 33 | snprintf(regionid, 16, "pnp %s", pnpid); |
33 | res = request_region(start,end-start+1,regionid); | 34 | if (port) |
34 | if ( res == NULL ) | 35 | res = request_region(start,end-start+1,regionid); |
35 | kfree( regionid ); | 36 | else |
37 | res = request_mem_region(start,end-start+1,regionid); | ||
38 | if (res == NULL) | ||
39 | kfree(regionid); | ||
36 | else | 40 | else |
37 | res->flags &= ~IORESOURCE_BUSY; | 41 | res->flags &= ~IORESOURCE_BUSY; |
38 | /* | 42 | /* |
@@ -41,26 +45,20 @@ static void reserve_ioport_range(char *pnpid, int start, int end) | |||
41 | * have double reservations. | 45 | * have double reservations. |
42 | */ | 46 | */ |
43 | printk(KERN_INFO | 47 | printk(KERN_INFO |
44 | "pnp: %s: ioport range 0x%x-0x%x %s reserved\n", | 48 | "pnp: %s: %s range 0x%x-0x%x %s reserved\n", |
45 | pnpid, start, end, | 49 | pnpid, port ? "ioport" : "iomem", start, end, |
46 | NULL != res ? "has been" : "could not be" | 50 | NULL != res ? "has been" : "could not be"); |
47 | ); | ||
48 | |||
49 | return; | ||
50 | } | 51 | } |
51 | 52 | ||
52 | static void reserve_resources_of_dev( struct pnp_dev *dev ) | 53 | static void reserve_resources_of_dev(struct pnp_dev *dev) |
53 | { | 54 | { |
54 | int i; | 55 | int i; |
55 | 56 | ||
56 | for (i=0;i<PNP_MAX_PORT;i++) { | 57 | for (i = 0; i < PNP_MAX_PORT; i++) { |
57 | if (!pnp_port_valid(dev, i)) | 58 | if (!pnp_port_valid(dev, i)) |
58 | /* end of resources */ | ||
59 | continue; | 59 | continue; |
60 | if (pnp_port_start(dev, i) == 0) | 60 | if (pnp_port_start(dev, i) == 0) |
61 | /* disabled */ | 61 | continue; /* disabled */ |
62 | /* Do nothing */ | ||
63 | continue; | ||
64 | if (pnp_port_start(dev, i) < 0x100) | 62 | if (pnp_port_start(dev, i) < 0x100) |
65 | /* | 63 | /* |
66 | * Below 0x100 is only standard PC hardware | 64 | * Below 0x100 is only standard PC hardware |
@@ -72,14 +70,18 @@ static void reserve_resources_of_dev( struct pnp_dev *dev ) | |||
72 | */ | 70 | */ |
73 | continue; | 71 | continue; |
74 | if (pnp_port_end(dev, i) < pnp_port_start(dev, i)) | 72 | if (pnp_port_end(dev, i) < pnp_port_start(dev, i)) |
75 | /* invalid endpoint */ | 73 | continue; /* invalid */ |
76 | /* Do nothing */ | 74 | |
75 | reserve_range(dev->dev.bus_id, pnp_port_start(dev, i), | ||
76 | pnp_port_end(dev, i), 1); | ||
77 | } | ||
78 | |||
79 | for (i = 0; i < PNP_MAX_MEM; i++) { | ||
80 | if (!pnp_mem_valid(dev, i)) | ||
77 | continue; | 81 | continue; |
78 | reserve_ioport_range( | 82 | |
79 | dev->dev.bus_id, | 83 | reserve_range(dev->dev.bus_id, pnp_mem_start(dev, i), |
80 | pnp_port_start(dev, i), | 84 | pnp_mem_end(dev, i), 0); |
81 | pnp_port_end(dev, i) | ||
82 | ); | ||
83 | } | 85 | } |
84 | 86 | ||
85 | return; | 87 | return; |