aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/card.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2007-07-26 13:41:20 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-26 14:35:20 -0400
commit9dd78466c956ac4b4f38e12032dc4249ccf57ad1 (patch)
tree57ee3822b79049d38c1df952fe77e72a97c718f3 /drivers/pnp/card.c
parent8ec3cf7d29aef773eee5bc6cd9b0fa4d3fb42480 (diff)
PNP: Lindent all source files
Run Lindent on all PNP source files. Produced by: $ quilt new pnp-lindent $ find drivers/pnp -name \*.[ch] | xargs quilt add $ quilt add include/linux/{pnp.h,pnpbios.h} $ scripts/Lindent drivers/pnp/*.c drivers/pnp/*/*.c include/linux/pnp*.h $ quilt refresh --sort Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Cc: Len Brown <lenb@kernel.org> Cc: Adam Belay <ambx1@neo.rr.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pnp/card.c')
-rw-r--r--drivers/pnp/card.c135
1 files changed, 73 insertions, 62 deletions
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index dd6384b1efce..a379a38c196c 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -13,26 +13,28 @@
13LIST_HEAD(pnp_cards); 13LIST_HEAD(pnp_cards);
14static LIST_HEAD(pnp_card_drivers); 14static LIST_HEAD(pnp_card_drivers);
15 15
16 16static const struct pnp_card_device_id *match_card(struct pnp_card_driver *drv,
17static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv, struct pnp_card * card) 17 struct pnp_card *card)
18{ 18{
19 const struct pnp_card_device_id * drv_id = drv->id_table; 19 const struct pnp_card_device_id *drv_id = drv->id_table;
20 while (*drv_id->id){ 20 while (*drv_id->id) {
21 if (compare_pnp_id(card->id,drv_id->id)) { 21 if (compare_pnp_id(card->id, drv_id->id)) {
22 int i = 0; 22 int i = 0;
23 for (;;) { 23 for (;;) {
24 int found; 24 int found;
25 struct pnp_dev *dev; 25 struct pnp_dev *dev;
26 if (i == PNP_MAX_DEVICES || ! *drv_id->devs[i].id) 26 if (i == PNP_MAX_DEVICES
27 || !*drv_id->devs[i].id)
27 return drv_id; 28 return drv_id;
28 found = 0; 29 found = 0;
29 card_for_each_dev(card, dev) { 30 card_for_each_dev(card, dev) {
30 if (compare_pnp_id(dev->id, drv_id->devs[i].id)) { 31 if (compare_pnp_id
32 (dev->id, drv_id->devs[i].id)) {
31 found = 1; 33 found = 1;
32 break; 34 break;
33 } 35 }
34 } 36 }
35 if (! found) 37 if (!found)
36 break; 38 break;
37 i++; 39 i++;
38 } 40 }
@@ -42,14 +44,14 @@ static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv
42 return NULL; 44 return NULL;
43} 45}
44 46
45static void card_remove(struct pnp_dev * dev) 47static void card_remove(struct pnp_dev *dev)
46{ 48{
47 dev->card_link = NULL; 49 dev->card_link = NULL;
48} 50}
49 51
50static void card_remove_first(struct pnp_dev * dev) 52static void card_remove_first(struct pnp_dev *dev)
51{ 53{
52 struct pnp_card_driver * drv = to_pnp_card_driver(dev->driver); 54 struct pnp_card_driver *drv = to_pnp_card_driver(dev->driver);
53 if (!dev->card || !drv) 55 if (!dev->card || !drv)
54 return; 56 return;
55 if (drv->remove) 57 if (drv->remove)
@@ -67,7 +69,7 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
67 69
68 if (!drv->probe) 70 if (!drv->probe)
69 return 0; 71 return 0;
70 id = match_card(drv,card); 72 id = match_card(drv, card);
71 if (!id) 73 if (!id)
72 return 0; 74 return 0;
73 75
@@ -97,9 +99,9 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
97 * 99 *
98 */ 100 */
99 101
100int pnp_add_card_id(struct pnp_id *id, struct pnp_card * card) 102int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card)
101{ 103{
102 struct pnp_id * ptr; 104 struct pnp_id *ptr;
103 if (!id) 105 if (!id)
104 return -EINVAL; 106 return -EINVAL;
105 if (!card) 107 if (!card)
@@ -115,9 +117,9 @@ int pnp_add_card_id(struct pnp_id *id, struct pnp_card * card)
115 return 0; 117 return 0;
116} 118}
117 119
118static void pnp_free_card_ids(struct pnp_card * card) 120static void pnp_free_card_ids(struct pnp_card *card)
119{ 121{
120 struct pnp_id * id; 122 struct pnp_id *id;
121 struct pnp_id *next; 123 struct pnp_id *next;
122 if (!card) 124 if (!card)
123 return; 125 return;
@@ -131,49 +133,52 @@ static void pnp_free_card_ids(struct pnp_card * card)
131 133
132static void pnp_release_card(struct device *dmdev) 134static void pnp_release_card(struct device *dmdev)
133{ 135{
134 struct pnp_card * card = to_pnp_card(dmdev); 136 struct pnp_card *card = to_pnp_card(dmdev);
135 pnp_free_card_ids(card); 137 pnp_free_card_ids(card);
136 kfree(card); 138 kfree(card);
137} 139}
138 140
139 141static ssize_t pnp_show_card_name(struct device *dmdev,
140static ssize_t pnp_show_card_name(struct device *dmdev, struct device_attribute *attr, char *buf) 142 struct device_attribute *attr, char *buf)
141{ 143{
142 char *str = buf; 144 char *str = buf;
143 struct pnp_card *card = to_pnp_card(dmdev); 145 struct pnp_card *card = to_pnp_card(dmdev);
144 str += sprintf(str,"%s\n", card->name); 146 str += sprintf(str, "%s\n", card->name);
145 return (str - buf); 147 return (str - buf);
146} 148}
147 149
148static DEVICE_ATTR(name,S_IRUGO,pnp_show_card_name,NULL); 150static DEVICE_ATTR(name, S_IRUGO, pnp_show_card_name, NULL);
149 151
150static ssize_t pnp_show_card_ids(struct device *dmdev, struct device_attribute *attr, char *buf) 152static ssize_t pnp_show_card_ids(struct device *dmdev,
153 struct device_attribute *attr, char *buf)
151{ 154{
152 char *str = buf; 155 char *str = buf;
153 struct pnp_card *card = to_pnp_card(dmdev); 156 struct pnp_card *card = to_pnp_card(dmdev);
154 struct pnp_id * pos = card->id; 157 struct pnp_id *pos = card->id;
155 158
156 while (pos) { 159 while (pos) {
157 str += sprintf(str,"%s\n", pos->id); 160 str += sprintf(str, "%s\n", pos->id);
158 pos = pos->next; 161 pos = pos->next;
159 } 162 }
160 return (str - buf); 163 return (str - buf);
161} 164}
162 165
163static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL); 166static DEVICE_ATTR(card_id, S_IRUGO, pnp_show_card_ids, NULL);
164 167
165static int pnp_interface_attach_card(struct pnp_card *card) 168static int pnp_interface_attach_card(struct pnp_card *card)
166{ 169{
167 int rc = device_create_file(&card->dev,&dev_attr_name); 170 int rc = device_create_file(&card->dev, &dev_attr_name);
168 if (rc) return rc; 171 if (rc)
172 return rc;
169 173
170 rc = device_create_file(&card->dev,&dev_attr_card_id); 174 rc = device_create_file(&card->dev, &dev_attr_card_id);
171 if (rc) goto err_name; 175 if (rc)
176 goto err_name;
172 177
173 return 0; 178 return 0;
174 179
175err_name: 180 err_name:
176 device_remove_file(&card->dev,&dev_attr_name); 181 device_remove_file(&card->dev, &dev_attr_name);
177 return rc; 182 return rc;
178} 183}
179 184
@@ -182,14 +187,15 @@ err_name:
182 * @card: pointer to the card to add 187 * @card: pointer to the card to add
183 */ 188 */
184 189
185int pnp_add_card(struct pnp_card * card) 190int pnp_add_card(struct pnp_card *card)
186{ 191{
187 int error; 192 int error;
188 struct list_head * pos, * temp; 193 struct list_head *pos, *temp;
189 if (!card || !card->protocol) 194 if (!card || !card->protocol)
190 return -EINVAL; 195 return -EINVAL;
191 196
192 sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number, card->number); 197 sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
198 card->number);
193 card->dev.parent = &card->protocol->dev; 199 card->dev.parent = &card->protocol->dev;
194 card->dev.bus = NULL; 200 card->dev.bus = NULL;
195 card->dev.release = &pnp_release_card; 201 card->dev.release = &pnp_release_card;
@@ -205,18 +211,21 @@ int pnp_add_card(struct pnp_card * card)
205 /* we wait until now to add devices in order to ensure the drivers 211 /* we wait until now to add devices in order to ensure the drivers
206 * will be able to use all of the related devices on the card 212 * will be able to use all of the related devices on the card
207 * without waiting any unresonable length of time */ 213 * without waiting any unresonable length of time */
208 list_for_each(pos,&card->devices){ 214 list_for_each(pos, &card->devices) {
209 struct pnp_dev *dev = card_to_pnp_dev(pos); 215 struct pnp_dev *dev = card_to_pnp_dev(pos);
210 __pnp_add_device(dev); 216 __pnp_add_device(dev);
211 } 217 }
212 218
213 /* match with card drivers */ 219 /* match with card drivers */
214 list_for_each_safe(pos,temp,&pnp_card_drivers){ 220 list_for_each_safe(pos, temp, &pnp_card_drivers) {
215 struct pnp_card_driver * drv = list_entry(pos, struct pnp_card_driver, global_list); 221 struct pnp_card_driver *drv =
216 card_probe(card,drv); 222 list_entry(pos, struct pnp_card_driver,
223 global_list);
224 card_probe(card, drv);
217 } 225 }
218 } else 226 } else
219 pnp_err("sysfs failure, card '%s' will be unavailable", card->dev.bus_id); 227 pnp_err("sysfs failure, card '%s' will be unavailable",
228 card->dev.bus_id);
220 return error; 229 return error;
221} 230}
222 231
@@ -225,7 +234,7 @@ int pnp_add_card(struct pnp_card * card)
225 * @card: pointer to the card to remove 234 * @card: pointer to the card to remove
226 */ 235 */
227 236
228void pnp_remove_card(struct pnp_card * card) 237void pnp_remove_card(struct pnp_card *card)
229{ 238{
230 struct list_head *pos, *temp; 239 struct list_head *pos, *temp;
231 if (!card) 240 if (!card)
@@ -235,7 +244,7 @@ void pnp_remove_card(struct pnp_card * card)
235 list_del(&card->global_list); 244 list_del(&card->global_list);
236 list_del(&card->protocol_list); 245 list_del(&card->protocol_list);
237 spin_unlock(&pnp_lock); 246 spin_unlock(&pnp_lock);
238 list_for_each_safe(pos,temp,&card->devices){ 247 list_for_each_safe(pos, temp, &card->devices) {
239 struct pnp_dev *dev = card_to_pnp_dev(pos); 248 struct pnp_dev *dev = card_to_pnp_dev(pos);
240 pnp_remove_card_device(dev); 249 pnp_remove_card_device(dev);
241 } 250 }
@@ -247,14 +256,14 @@ void pnp_remove_card(struct pnp_card * card)
247 * @dev: pointer to the device to add 256 * @dev: pointer to the device to add
248 */ 257 */
249 258
250int pnp_add_card_device(struct pnp_card * card, struct pnp_dev * dev) 259int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
251{ 260{
252 if (!card || !dev || !dev->protocol) 261 if (!card || !dev || !dev->protocol)
253 return -EINVAL; 262 return -EINVAL;
254 dev->dev.parent = &card->dev; 263 dev->dev.parent = &card->dev;
255 dev->card_link = NULL; 264 dev->card_link = NULL;
256 snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x", dev->protocol->number, 265 snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x",
257 card->number,dev->number); 266 dev->protocol->number, card->number, dev->number);
258 spin_lock(&pnp_lock); 267 spin_lock(&pnp_lock);
259 dev->card = card; 268 dev->card = card;
260 list_add_tail(&dev->card_list, &card->devices); 269 list_add_tail(&dev->card_list, &card->devices);
@@ -267,7 +276,7 @@ int pnp_add_card_device(struct pnp_card * card, struct pnp_dev * dev)
267 * @dev: pointer to the device to remove 276 * @dev: pointer to the device to remove
268 */ 277 */
269 278
270void pnp_remove_card_device(struct pnp_dev * dev) 279void pnp_remove_card_device(struct pnp_dev *dev)
271{ 280{
272 spin_lock(&pnp_lock); 281 spin_lock(&pnp_lock);
273 dev->card = NULL; 282 dev->card = NULL;
@@ -283,12 +292,13 @@ void pnp_remove_card_device(struct pnp_dev * dev)
283 * @from: Starting place to search from. If NULL it will start from the begining. 292 * @from: Starting place to search from. If NULL it will start from the begining.
284 */ 293 */
285 294
286struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from) 295struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
296 const char *id, struct pnp_dev *from)
287{ 297{
288 struct list_head * pos; 298 struct list_head *pos;
289 struct pnp_dev * dev; 299 struct pnp_dev *dev;
290 struct pnp_card_driver * drv; 300 struct pnp_card_driver *drv;
291 struct pnp_card * card; 301 struct pnp_card *card;
292 if (!clink || !id) 302 if (!clink || !id)
293 goto done; 303 goto done;
294 card = clink->card; 304 card = clink->card;
@@ -302,15 +312,15 @@ struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char
302 } 312 }
303 while (pos != &card->devices) { 313 while (pos != &card->devices) {
304 dev = card_to_pnp_dev(pos); 314 dev = card_to_pnp_dev(pos);
305 if ((!dev->card_link) && compare_pnp_id(dev->id,id)) 315 if ((!dev->card_link) && compare_pnp_id(dev->id, id))
306 goto found; 316 goto found;
307 pos = pos->next; 317 pos = pos->next;
308 } 318 }
309 319
310done: 320 done:
311 return NULL; 321 return NULL;
312 322
313found: 323 found:
314 dev->card_link = clink; 324 dev->card_link = clink;
315 dev->dev.driver = &drv->link.driver; 325 dev->dev.driver = &drv->link.driver;
316 if (pnp_bus_type.probe(&dev->dev)) 326 if (pnp_bus_type.probe(&dev->dev))
@@ -320,7 +330,7 @@ found:
320 330
321 return dev; 331 return dev;
322 332
323err_out: 333 err_out:
324 dev->dev.driver = NULL; 334 dev->dev.driver = NULL;
325 dev->card_link = NULL; 335 dev->card_link = NULL;
326 return NULL; 336 return NULL;
@@ -331,9 +341,9 @@ err_out:
331 * @dev: pointer to the PnP device stucture 341 * @dev: pointer to the PnP device stucture
332 */ 342 */
333 343
334void pnp_release_card_device(struct pnp_dev * dev) 344void pnp_release_card_device(struct pnp_dev *dev)
335{ 345{
336 struct pnp_card_driver * drv = dev->card_link->driver; 346 struct pnp_card_driver *drv = dev->card_link->driver;
337 if (!drv) 347 if (!drv)
338 return; 348 return;
339 drv->link.remove = &card_remove; 349 drv->link.remove = &card_remove;
@@ -368,7 +378,7 @@ static int card_resume(struct pnp_dev *dev)
368 * @drv: pointer to the driver to register 378 * @drv: pointer to the driver to register
369 */ 379 */
370 380
371int pnp_register_card_driver(struct pnp_card_driver * drv) 381int pnp_register_card_driver(struct pnp_card_driver *drv)
372{ 382{
373 int error; 383 int error;
374 struct list_head *pos, *temp; 384 struct list_head *pos, *temp;
@@ -389,9 +399,10 @@ int pnp_register_card_driver(struct pnp_card_driver * drv)
389 list_add_tail(&drv->global_list, &pnp_card_drivers); 399 list_add_tail(&drv->global_list, &pnp_card_drivers);
390 spin_unlock(&pnp_lock); 400 spin_unlock(&pnp_lock);
391 401
392 list_for_each_safe(pos,temp,&pnp_cards){ 402 list_for_each_safe(pos, temp, &pnp_cards) {
393 struct pnp_card *card = list_entry(pos, struct pnp_card, global_list); 403 struct pnp_card *card =
394 card_probe(card,drv); 404 list_entry(pos, struct pnp_card, global_list);
405 card_probe(card, drv);
395 } 406 }
396 return 0; 407 return 0;
397} 408}
@@ -401,7 +412,7 @@ int pnp_register_card_driver(struct pnp_card_driver * drv)
401 * @drv: pointer to the driver to unregister 412 * @drv: pointer to the driver to unregister
402 */ 413 */
403 414
404void pnp_unregister_card_driver(struct pnp_card_driver * drv) 415void pnp_unregister_card_driver(struct pnp_card_driver *drv)
405{ 416{
406 spin_lock(&pnp_lock); 417 spin_lock(&pnp_lock);
407 list_del(&drv->global_list); 418 list_del(&drv->global_list);
@@ -415,7 +426,7 @@ EXPORT_SYMBOL(pnp_remove_card);
415EXPORT_SYMBOL(pnp_add_card_device); 426EXPORT_SYMBOL(pnp_add_card_device);
416EXPORT_SYMBOL(pnp_remove_card_device); 427EXPORT_SYMBOL(pnp_remove_card_device);
417EXPORT_SYMBOL(pnp_add_card_id); 428EXPORT_SYMBOL(pnp_add_card_id);
418#endif /* 0 */ 429#endif /* 0 */
419EXPORT_SYMBOL(pnp_request_card_device); 430EXPORT_SYMBOL(pnp_request_card_device);
420EXPORT_SYMBOL(pnp_release_card_device); 431EXPORT_SYMBOL(pnp_release_card_device);
421EXPORT_SYMBOL(pnp_register_card_driver); 432EXPORT_SYMBOL(pnp_register_card_driver);