diff options
Diffstat (limited to 'drivers/pnp/core.c')
-rw-r--r-- | drivers/pnp/core.c | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index 8e7b2dd38810..61066fdb9e6d 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c | |||
@@ -2,7 +2,6 @@ | |||
2 | * core.c - contains all core device and protocol registration functions | 2 | * core.c - contains all core device and protocol registration functions |
3 | * | 3 | * |
4 | * Copyright 2002 Adam Belay <ambx1@neo.rr.com> | 4 | * Copyright 2002 Adam Belay <ambx1@neo.rr.com> |
5 | * | ||
6 | */ | 5 | */ |
7 | 6 | ||
8 | #include <linux/pnp.h> | 7 | #include <linux/pnp.h> |
@@ -18,7 +17,6 @@ | |||
18 | 17 | ||
19 | #include "base.h" | 18 | #include "base.h" |
20 | 19 | ||
21 | |||
22 | static LIST_HEAD(pnp_protocols); | 20 | static LIST_HEAD(pnp_protocols); |
23 | LIST_HEAD(pnp_global); | 21 | LIST_HEAD(pnp_global); |
24 | DEFINE_SPINLOCK(pnp_lock); | 22 | DEFINE_SPINLOCK(pnp_lock); |
@@ -36,7 +34,7 @@ void *pnp_alloc(long size) | |||
36 | void *result; | 34 | void *result; |
37 | 35 | ||
38 | result = kzalloc(size, GFP_KERNEL); | 36 | result = kzalloc(size, GFP_KERNEL); |
39 | if (!result){ | 37 | if (!result) { |
40 | printk(KERN_ERR "pnp: Out of Memory\n"); | 38 | printk(KERN_ERR "pnp: Out of Memory\n"); |
41 | return NULL; | 39 | return NULL; |
42 | } | 40 | } |
@@ -49,11 +47,10 @@ void *pnp_alloc(long size) | |||
49 | * | 47 | * |
50 | * Ex protocols: ISAPNP, PNPBIOS, etc | 48 | * Ex protocols: ISAPNP, PNPBIOS, etc |
51 | */ | 49 | */ |
52 | |||
53 | int pnp_register_protocol(struct pnp_protocol *protocol) | 50 | int pnp_register_protocol(struct pnp_protocol *protocol) |
54 | { | 51 | { |
55 | int nodenum; | 52 | int nodenum; |
56 | struct list_head * pos; | 53 | struct list_head *pos; |
57 | 54 | ||
58 | if (!protocol) | 55 | if (!protocol) |
59 | return -EINVAL; | 56 | return -EINVAL; |
@@ -64,9 +61,9 @@ int pnp_register_protocol(struct pnp_protocol *protocol) | |||
64 | spin_lock(&pnp_lock); | 61 | spin_lock(&pnp_lock); |
65 | 62 | ||
66 | /* assign the lowest unused number */ | 63 | /* assign the lowest unused number */ |
67 | list_for_each(pos,&pnp_protocols) { | 64 | list_for_each(pos, &pnp_protocols) { |
68 | struct pnp_protocol * cur = to_pnp_protocol(pos); | 65 | struct pnp_protocol *cur = to_pnp_protocol(pos); |
69 | if (cur->number == nodenum){ | 66 | if (cur->number == nodenum) { |
70 | pos = &pnp_protocols; | 67 | pos = &pnp_protocols; |
71 | nodenum++; | 68 | nodenum++; |
72 | } | 69 | } |
@@ -83,7 +80,6 @@ int pnp_register_protocol(struct pnp_protocol *protocol) | |||
83 | /** | 80 | /** |
84 | * pnp_protocol_unregister - removes a pnp protocol from the pnp layer | 81 | * pnp_protocol_unregister - removes a pnp protocol from the pnp layer |
85 | * @protocol: pointer to the corresponding pnp_protocol structure | 82 | * @protocol: pointer to the corresponding pnp_protocol structure |
86 | * | ||
87 | */ | 83 | */ |
88 | void pnp_unregister_protocol(struct pnp_protocol *protocol) | 84 | void pnp_unregister_protocol(struct pnp_protocol *protocol) |
89 | { | 85 | { |
@@ -93,11 +89,11 @@ void pnp_unregister_protocol(struct pnp_protocol *protocol) | |||
93 | device_unregister(&protocol->dev); | 89 | device_unregister(&protocol->dev); |
94 | } | 90 | } |
95 | 91 | ||
96 | |||
97 | static void pnp_free_ids(struct pnp_dev *dev) | 92 | static void pnp_free_ids(struct pnp_dev *dev) |
98 | { | 93 | { |
99 | struct pnp_id * id; | 94 | struct pnp_id *id; |
100 | struct pnp_id * next; | 95 | struct pnp_id *next; |
96 | |||
101 | if (!dev) | 97 | if (!dev) |
102 | return; | 98 | return; |
103 | id = dev->id; | 99 | id = dev->id; |
@@ -110,7 +106,8 @@ static void pnp_free_ids(struct pnp_dev *dev) | |||
110 | 106 | ||
111 | static void pnp_release_device(struct device *dmdev) | 107 | static void pnp_release_device(struct device *dmdev) |
112 | { | 108 | { |
113 | struct pnp_dev * dev = to_pnp_dev(dmdev); | 109 | struct pnp_dev *dev = to_pnp_dev(dmdev); |
110 | |||
114 | pnp_free_option(dev->independent); | 111 | pnp_free_option(dev->independent); |
115 | pnp_free_option(dev->dependent); | 112 | pnp_free_option(dev->dependent); |
116 | pnp_free_ids(dev); | 113 | pnp_free_ids(dev); |
@@ -120,6 +117,7 @@ static void pnp_release_device(struct device *dmdev) | |||
120 | int __pnp_add_device(struct pnp_dev *dev) | 117 | int __pnp_add_device(struct pnp_dev *dev) |
121 | { | 118 | { |
122 | int ret; | 119 | int ret; |
120 | |||
123 | pnp_fixup_device(dev); | 121 | pnp_fixup_device(dev); |
124 | dev->dev.bus = &pnp_bus_type; | 122 | dev->dev.bus = &pnp_bus_type; |
125 | dev->dev.dma_mask = &dev->dma_mask; | 123 | dev->dev.dma_mask = &dev->dma_mask; |
@@ -143,13 +141,13 @@ int __pnp_add_device(struct pnp_dev *dev) | |||
143 | * | 141 | * |
144 | * adds to driver model, name database, fixups, interface, etc. | 142 | * adds to driver model, name database, fixups, interface, etc. |
145 | */ | 143 | */ |
146 | |||
147 | int pnp_add_device(struct pnp_dev *dev) | 144 | int pnp_add_device(struct pnp_dev *dev) |
148 | { | 145 | { |
149 | if (!dev || !dev->protocol || dev->card) | 146 | if (!dev || !dev->protocol || dev->card) |
150 | return -EINVAL; | 147 | return -EINVAL; |
151 | dev->dev.parent = &dev->protocol->dev; | 148 | dev->dev.parent = &dev->protocol->dev; |
152 | sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number, dev->number); | 149 | sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number, |
150 | dev->number); | ||
153 | return __pnp_add_device(dev); | 151 | return __pnp_add_device(dev); |
154 | } | 152 | } |
155 | 153 | ||
@@ -162,21 +160,6 @@ void __pnp_remove_device(struct pnp_dev *dev) | |||
162 | device_unregister(&dev->dev); | 160 | device_unregister(&dev->dev); |
163 | } | 161 | } |
164 | 162 | ||
165 | /** | ||
166 | * pnp_remove_device - removes a pnp device from the pnp layer | ||
167 | * @dev: pointer to dev to add | ||
168 | * | ||
169 | * this function will free all mem used by dev | ||
170 | */ | ||
171 | #if 0 | ||
172 | void pnp_remove_device(struct pnp_dev *dev) | ||
173 | { | ||
174 | if (!dev || dev->card) | ||
175 | return; | ||
176 | __pnp_remove_device(dev); | ||
177 | } | ||
178 | #endif /* 0 */ | ||
179 | |||
180 | static int __init pnp_init(void) | 163 | static int __init pnp_init(void) |
181 | { | 164 | { |
182 | printk(KERN_INFO "Linux Plug and Play Support v0.97 (c) Adam Belay\n"); | 165 | printk(KERN_INFO "Linux Plug and Play Support v0.97 (c) Adam Belay\n"); |
@@ -184,10 +167,3 @@ static int __init pnp_init(void) | |||
184 | } | 167 | } |
185 | 168 | ||
186 | subsys_initcall(pnp_init); | 169 | subsys_initcall(pnp_init); |
187 | |||
188 | #if 0 | ||
189 | EXPORT_SYMBOL(pnp_register_protocol); | ||
190 | EXPORT_SYMBOL(pnp_unregister_protocol); | ||
191 | EXPORT_SYMBOL(pnp_add_device); | ||
192 | EXPORT_SYMBOL(pnp_remove_device); | ||
193 | #endif /* 0 */ | ||