blob: 874c236ac1a7abd4a3200008ce8242f759f67c2f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * card.c - contains functions for managing groups of PnP devices
3 *
4 * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <linux/module.h>
Bjorn Helgaase4366752008-04-28 16:33:56 -06008#include <linux/ctype.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/pnp.h>
Rene Hermane86b19c2008-07-25 19:44:42 -070011#include <linux/dma-mapping.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include "base.h"
13
14LIST_HEAD(pnp_cards);
Adrian Bunkb449f632005-11-07 01:01:48 -080015static LIST_HEAD(pnp_card_drivers);
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070017static const struct pnp_card_device_id *match_card(struct pnp_card_driver *drv,
18 struct pnp_card *card)
Linus Torvalds1da177e2005-04-16 15:20:36 -070019{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070020 const struct pnp_card_device_id *drv_id = drv->id_table;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -070021
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070022 while (*drv_id->id) {
23 if (compare_pnp_id(card->id, drv_id->id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 int i = 0;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -070025
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 for (;;) {
27 int found;
28 struct pnp_dev *dev;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -070029
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -060030 if (i == PNP_MAX_DEVICES ||
31 !*drv_id->devs[i].id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 return drv_id;
33 found = 0;
34 card_for_each_dev(card, dev) {
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -060035 if (compare_pnp_id(dev->id,
36 drv_id->devs[i].id)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 found = 1;
38 break;
39 }
40 }
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070041 if (!found)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 break;
43 i++;
44 }
45 }
46 drv_id++;
47 }
48 return NULL;
49}
50
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070051static void card_remove(struct pnp_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052{
53 dev->card_link = NULL;
54}
Bjorn Helgaas982c6092006-03-27 01:17:08 -080055
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070056static void card_remove_first(struct pnp_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070057{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070058 struct pnp_card_driver *drv = to_pnp_card_driver(dev->driver);
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -070059
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 if (!dev->card || !drv)
61 return;
62 if (drv->remove)
63 drv->remove(dev->card_link);
64 drv->link.remove = &card_remove;
65 kfree(dev->card_link);
66 card_remove(dev);
67}
68
Jesper Juhla9adb8d2006-06-25 05:47:17 -070069static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070{
Jesper Juhla9adb8d2006-06-25 05:47:17 -070071 const struct pnp_card_device_id *id;
72 struct pnp_card_link *clink;
73 struct pnp_dev *dev;
74
75 if (!drv->probe)
76 return 0;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -070077 id = match_card(drv, card);
Jesper Juhla9adb8d2006-06-25 05:47:17 -070078 if (!id)
79 return 0;
80
81 clink = pnp_alloc(sizeof(*clink));
82 if (!clink)
83 return 0;
84 clink->card = card;
85 clink->driver = drv;
86 clink->pm_state = PMSG_ON;
87
88 if (drv->probe(clink, id) >= 0)
89 return 1;
90
91 /* Recovery */
92 card_for_each_dev(card, dev) {
93 if (dev->card_link == clink)
94 pnp_release_card_device(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 }
Jesper Juhla9adb8d2006-06-25 05:47:17 -070096 kfree(clink);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 return 0;
98}
99
100/**
101 * pnp_add_card_id - adds an EISA id to the specified card
102 * @id: pointer to a pnp_id structure
103 * @card: pointer to the desired card
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 */
Adrian Bunk25cdcd02008-07-25 19:46:21 -0700105static struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106{
Bjorn Helgaase4366752008-04-28 16:33:56 -0600107 struct pnp_id *dev_id, *ptr;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700108
Bjorn Helgaase4366752008-04-28 16:33:56 -0600109 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
110 if (!dev_id)
111 return NULL;
112
113 dev_id->id[0] = id[0];
114 dev_id->id[1] = id[1];
115 dev_id->id[2] = id[2];
116 dev_id->id[3] = tolower(id[3]);
117 dev_id->id[4] = tolower(id[4]);
118 dev_id->id[5] = tolower(id[5]);
119 dev_id->id[6] = tolower(id[6]);
120 dev_id->id[7] = '\0';
121
122 dev_id->next = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 ptr = card->id;
124 while (ptr && ptr->next)
125 ptr = ptr->next;
126 if (ptr)
Bjorn Helgaase4366752008-04-28 16:33:56 -0600127 ptr->next = dev_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 else
Bjorn Helgaase4366752008-04-28 16:33:56 -0600129 card->id = dev_id;
130
131 return dev_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132}
133
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700134static void pnp_free_card_ids(struct pnp_card *card)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700136 struct pnp_id *id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 struct pnp_id *next;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700138
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 id = card->id;
140 while (id) {
141 next = id->next;
142 kfree(id);
143 id = next;
144 }
145}
146
147static void pnp_release_card(struct device *dmdev)
148{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700149 struct pnp_card *card = to_pnp_card(dmdev);
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 pnp_free_card_ids(card);
152 kfree(card);
153}
154
Bjorn Helgaas6bf2aab2008-04-28 16:33:58 -0600155struct pnp_card *pnp_alloc_card(struct pnp_protocol *protocol, int id, char *pnpid)
156{
157 struct pnp_card *card;
158 struct pnp_id *dev_id;
159
160 card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL);
161 if (!card)
162 return NULL;
163
164 card->protocol = protocol;
165 card->number = id;
166
167 card->dev.parent = &card->protocol->dev;
Kay Sieversc85e37c2009-01-06 10:44:38 -0800168 dev_set_name(&card->dev, "%02x:%02x", card->protocol->number, card->number);
Bjorn Helgaas6bf2aab2008-04-28 16:33:58 -0600169
Yang Hongyang2f4f27d2009-04-06 19:01:18 -0700170 card->dev.coherent_dma_mask = DMA_BIT_MASK(24);
Rene Hermane86b19c2008-07-25 19:44:42 -0700171 card->dev.dma_mask = &card->dev.coherent_dma_mask;
172
Bjorn Helgaas6bf2aab2008-04-28 16:33:58 -0600173 dev_id = pnp_add_card_id(card, pnpid);
174 if (!dev_id) {
175 kfree(card);
176 return NULL;
177 }
178
179 return card;
180}
181
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700182static ssize_t pnp_show_card_name(struct device *dmdev,
183 struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184{
185 char *str = buf;
186 struct pnp_card *card = to_pnp_card(dmdev);
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700187
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700188 str += sprintf(str, "%s\n", card->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 return (str - buf);
190}
191
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700192static DEVICE_ATTR(name, S_IRUGO, pnp_show_card_name, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700194static ssize_t pnp_show_card_ids(struct device *dmdev,
195 struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196{
197 char *str = buf;
198 struct pnp_card *card = to_pnp_card(dmdev);
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700199 struct pnp_id *pos = card->id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
201 while (pos) {
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700202 str += sprintf(str, "%s\n", pos->id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 pos = pos->next;
204 }
205 return (str - buf);
206}
207
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700208static DEVICE_ATTR(card_id, S_IRUGO, pnp_show_card_ids, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
210static int pnp_interface_attach_card(struct pnp_card *card)
211{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700212 int rc = device_create_file(&card->dev, &dev_attr_name);
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700213
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700214 if (rc)
215 return rc;
Jeff Garzikbfc7ee22006-12-06 20:35:33 -0800216
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700217 rc = device_create_file(&card->dev, &dev_attr_card_id);
218 if (rc)
219 goto err_name;
Jeff Garzikbfc7ee22006-12-06 20:35:33 -0800220
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 return 0;
Jeff Garzikbfc7ee22006-12-06 20:35:33 -0800222
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -0600223err_name:
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700224 device_remove_file(&card->dev, &dev_attr_name);
Jeff Garzikbfc7ee22006-12-06 20:35:33 -0800225 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226}
227
228/**
229 * pnp_add_card - adds a PnP card to the PnP Layer
230 * @card: pointer to the card to add
231 */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700232int pnp_add_card(struct pnp_card *card)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233{
234 int error;
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700235 struct list_head *pos, *temp;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 card->dev.bus = NULL;
238 card->dev.release = &pnp_release_card;
239 error = device_register(&card->dev);
Bjorn Helgaas5bfc43a2007-10-16 23:31:09 -0700240 if (error) {
Bjorn Helgaasa05d0782007-10-16 23:31:10 -0700241 dev_err(&card->dev, "could not register (err=%d)\n", error);
Levente Kurusa75365d02013-12-19 16:03:36 +0100242 put_device(&card->dev);
Bjorn Helgaas5bfc43a2007-10-16 23:31:09 -0700243 return error;
244 }
245
246 pnp_interface_attach_card(card);
247 spin_lock(&pnp_lock);
248 list_add_tail(&card->global_list, &pnp_cards);
249 list_add_tail(&card->protocol_list, &card->protocol->cards);
250 spin_unlock(&pnp_lock);
251
252 /* we wait until now to add devices in order to ensure the drivers
253 * will be able to use all of the related devices on the card
254 * without waiting an unreasonable length of time */
255 list_for_each(pos, &card->devices) {
256 struct pnp_dev *dev = card_to_pnp_dev(pos);
257 __pnp_add_device(dev);
258 }
259
260 /* match with card drivers */
261 list_for_each_safe(pos, temp, &pnp_card_drivers) {
262 struct pnp_card_driver *drv =
263 list_entry(pos, struct pnp_card_driver,
264 global_list);
265 card_probe(card, drv);
266 }
267 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268}
269
270/**
271 * pnp_remove_card - removes a PnP card from the PnP Layer
272 * @card: pointer to the card to remove
273 */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700274void pnp_remove_card(struct pnp_card *card)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275{
276 struct list_head *pos, *temp;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700277
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 device_unregister(&card->dev);
279 spin_lock(&pnp_lock);
280 list_del(&card->global_list);
281 list_del(&card->protocol_list);
282 spin_unlock(&pnp_lock);
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700283 list_for_each_safe(pos, temp, &card->devices) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 struct pnp_dev *dev = card_to_pnp_dev(pos);
285 pnp_remove_card_device(dev);
286 }
287}
288
289/**
290 * pnp_add_card_device - adds a device to the specified card
291 * @card: pointer to the card to add to
292 * @dev: pointer to the device to add
293 */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700294int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 dev->dev.parent = &card->dev;
297 dev->card_link = NULL;
Kay Sieversc85e37c2009-01-06 10:44:38 -0800298 dev_set_name(&dev->dev, "%02x:%02x.%02x",
299 dev->protocol->number, card->number, dev->number);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 spin_lock(&pnp_lock);
301 dev->card = card;
302 list_add_tail(&dev->card_list, &card->devices);
303 spin_unlock(&pnp_lock);
304 return 0;
305}
306
307/**
308 * pnp_remove_card_device- removes a device from the specified card
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 * @dev: pointer to the device to remove
310 */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700311void pnp_remove_card_device(struct pnp_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312{
313 spin_lock(&pnp_lock);
314 dev->card = NULL;
315 list_del(&dev->card_list);
316 spin_unlock(&pnp_lock);
317 __pnp_remove_device(dev);
318}
319
320/**
321 * pnp_request_card_device - Searches for a PnP device under the specified card
Martin Waitz3d410882005-06-23 22:05:21 -0700322 * @clink: pointer to the card link, cannot be NULL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 * @id: pointer to a PnP ID structure that explains the rules for finding the device
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300324 * @from: Starting place to search from. If NULL it will start from the beginning.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700326struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
327 const char *id, struct pnp_dev *from)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700329 struct list_head *pos;
330 struct pnp_dev *dev;
331 struct pnp_card_driver *drv;
332 struct pnp_card *card;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700333
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 if (!clink || !id)
Bjorn Helgaas5bfc43a2007-10-16 23:31:09 -0700335 return NULL;
336
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 card = clink->card;
338 drv = clink->driver;
339 if (!from) {
340 pos = card->devices.next;
341 } else {
342 if (from->card != card)
Bjorn Helgaas5bfc43a2007-10-16 23:31:09 -0700343 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 pos = from->card_list.next;
345 }
346 while (pos != &card->devices) {
347 dev = card_to_pnp_dev(pos);
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700348 if ((!dev->card_link) && compare_pnp_id(dev->id, id))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 goto found;
350 pos = pos->next;
351 }
352
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 return NULL;
354
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -0600355found:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 dev->card_link = clink;
357 dev->dev.driver = &drv->link.driver;
Jeff Garzikbfc7ee22006-12-06 20:35:33 -0800358 if (pnp_bus_type.probe(&dev->dev))
359 goto err_out;
360 if (device_bind_driver(&dev->dev))
361 goto err_out;
362
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 return dev;
Jeff Garzikbfc7ee22006-12-06 20:35:33 -0800364
Bjorn Helgaas1e0aa9a2007-08-15 10:32:08 -0600365err_out:
Jeff Garzikbfc7ee22006-12-06 20:35:33 -0800366 dev->dev.driver = NULL;
367 dev->card_link = NULL;
Jeff Garzikbfc7ee22006-12-06 20:35:33 -0800368 return NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369}
370
371/**
372 * pnp_release_card_device - call this when the driver no longer needs the device
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300373 * @dev: pointer to the PnP device structure
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700375void pnp_release_card_device(struct pnp_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376{
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700377 struct pnp_card_driver *drv = dev->card_link->driver;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 drv->link.remove = &card_remove;
380 device_release_driver(&dev->dev);
381 drv->link.remove = &card_remove_first;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382}
383
Takashi Iwai4c98cfe2005-11-29 09:09:32 +0100384/*
385 * suspend/resume callbacks
386 */
387static int card_suspend(struct pnp_dev *dev, pm_message_t state)
388{
389 struct pnp_card_link *link = dev->card_link;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700390
Takashi Iwai4c98cfe2005-11-29 09:09:32 +0100391 if (link->pm_state.event == state.event)
392 return 0;
393 link->pm_state = state;
394 return link->driver->suspend(link, state);
395}
396
397static int card_resume(struct pnp_dev *dev)
398{
399 struct pnp_card_link *link = dev->card_link;
Bjorn Helgaas07d4e9a2007-07-26 10:41:21 -0700400
Takashi Iwai4c98cfe2005-11-29 09:09:32 +0100401 if (link->pm_state.event == PM_EVENT_ON)
402 return 0;
403 link->pm_state = PMSG_ON;
404 link->driver->resume(link);
405 return 0;
406}
407
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408/**
409 * pnp_register_card_driver - registers a PnP card driver with the PnP Layer
410 * @drv: pointer to the driver to register
411 */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700412int pnp_register_card_driver(struct pnp_card_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413{
Bjorn Helgaas982c6092006-03-27 01:17:08 -0800414 int error;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 struct list_head *pos, *temp;
416
417 drv->link.name = drv->name;
418 drv->link.id_table = NULL; /* this will disable auto matching */
419 drv->link.flags = drv->flags;
420 drv->link.probe = NULL;
421 drv->link.remove = &card_remove_first;
Takashi Iwai4c98cfe2005-11-29 09:09:32 +0100422 drv->link.suspend = drv->suspend ? card_suspend : NULL;
423 drv->link.resume = drv->resume ? card_resume : NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424
Bjorn Helgaas982c6092006-03-27 01:17:08 -0800425 error = pnp_register_driver(&drv->link);
426 if (error < 0)
427 return error;
Adam Belayd1d051b22006-01-20 09:29:27 +0100428
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 spin_lock(&pnp_lock);
430 list_add_tail(&drv->global_list, &pnp_card_drivers);
431 spin_unlock(&pnp_lock);
Adam Belayd1d051b22006-01-20 09:29:27 +0100432
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700433 list_for_each_safe(pos, temp, &pnp_cards) {
434 struct pnp_card *card =
435 list_entry(pos, struct pnp_card, global_list);
436 card_probe(card, drv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 }
Bjorn Helgaas982c6092006-03-27 01:17:08 -0800438 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439}
440
441/**
442 * pnp_unregister_card_driver - unregisters a PnP card driver from the PnP Layer
443 * @drv: pointer to the driver to unregister
444 */
Bjorn Helgaas9dd78462007-07-26 10:41:20 -0700445void pnp_unregister_card_driver(struct pnp_card_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446{
447 spin_lock(&pnp_lock);
448 list_del(&drv->global_list);
449 spin_unlock(&pnp_lock);
450 pnp_unregister_driver(&drv->link);
451}
452
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453EXPORT_SYMBOL(pnp_request_card_device);
454EXPORT_SYMBOL(pnp_release_card_device);
455EXPORT_SYMBOL(pnp_register_card_driver);
456EXPORT_SYMBOL(pnp_unregister_card_driver);