Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]

Diff markup

Differences between /linux/drivers/pnp/card.c (Version 2.6.31.13) and /linux/drivers/pnp/card.c (Version 2.6.11.8)


  1 /*                                                  1 /*
  2  * card.c - contains functions for managing gr      2  * card.c - contains functions for managing groups of PnP devices
  3  *                                                  3  *
  4  * Copyright 2002 Adam Belay <ambx1@neo.rr.com      4  * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
                                                   >>   5  *
  5  */                                                 6  */
  6                                                     7 
                                                   >>   8 #include <linux/config.h>
  7 #include <linux/module.h>                           9 #include <linux/module.h>
  8 #include <linux/ctype.h>                       << 
  9 #include <linux/slab.h>                            10 #include <linux/slab.h>
                                                   >>  11 
                                                   >>  12 #ifdef CONFIG_PNP_DEBUG
                                                   >>  13         #define DEBUG
                                                   >>  14 #else
                                                   >>  15         #undef DEBUG
                                                   >>  16 #endif
                                                   >>  17 
 10 #include <linux/pnp.h>                             18 #include <linux/pnp.h>
 11 #include <linux/dma-mapping.h>                 << 
 12 #include "base.h"                                  19 #include "base.h"
 13                                                    20 
 14 LIST_HEAD(pnp_cards);                              21 LIST_HEAD(pnp_cards);
 15 static LIST_HEAD(pnp_card_drivers);            !!  22 LIST_HEAD(pnp_card_drivers);
 16                                                    23 
 17 static const struct pnp_card_device_id *match_ << 
 18                                                << 
 19 {                                              << 
 20         const struct pnp_card_device_id *drv_i << 
 21                                                    24 
 22         while (*drv_id->id) {                  !!  25 static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv, struct pnp_card * card)
 23                 if (compare_pnp_id(card->id, d !!  26 {
                                                   >>  27         const struct pnp_card_device_id * drv_id = drv->id_table;
                                                   >>  28         while (*drv_id->id){
                                                   >>  29                 if (compare_pnp_id(card->id,drv_id->id)) {
 24                         int i = 0;                 30                         int i = 0;
 25                                                << 
 26                         for (;;) {                 31                         for (;;) {
 27                                 int found;         32                                 int found;
 28                                 struct pnp_dev     33                                 struct pnp_dev *dev;
 29                                                !!  34                                 if (i == PNP_MAX_DEVICES || ! *drv_id->devs[i].id)
 30                                 if (i == PNP_M << 
 31                                     !*drv_id-> << 
 32                                         return     35                                         return drv_id;
 33                                 found = 0;         36                                 found = 0;
 34                                 card_for_each_     37                                 card_for_each_dev(card, dev) {
 35                                         if (co !!  38                                         if (compare_pnp_id(dev->id, drv_id->devs[i].id)) {
 36                                                << 
 37                                                    39                                                 found = 1;
 38                                                    40                                                 break;
 39                                         }          41                                         }
 40                                 }                  42                                 }
 41                                 if (!found)    !!  43                                 if (! found)
 42                                         break;     44                                         break;
 43                                 i++;               45                                 i++;
 44                         }                          46                         }
 45                 }                                  47                 }
 46                 drv_id++;                          48                 drv_id++;
 47         }                                          49         }
 48         return NULL;                               50         return NULL;
 49 }                                                  51 }
 50                                                    52 
 51 static void card_remove(struct pnp_dev *dev)   !!  53 static void card_remove(struct pnp_dev * dev)
 52 {                                                  54 {
 53         dev->card_link = NULL;                     55         dev->card_link = NULL;
 54 }                                                  56 }
 55                                                !!  57  
 56 static void card_remove_first(struct pnp_dev * !!  58 static void card_remove_first(struct pnp_dev * dev)
 57 {                                                  59 {
 58         struct pnp_card_driver *drv = to_pnp_c !!  60         struct pnp_card_driver * drv = to_pnp_card_driver(dev->driver);
 59                                                << 
 60         if (!dev->card || !drv)                    61         if (!dev->card || !drv)
 61                 return;                            62                 return;
 62         if (drv->remove)                           63         if (drv->remove)
 63                 drv->remove(dev->card_link);       64                 drv->remove(dev->card_link);
 64         drv->link.remove = &card_remove;           65         drv->link.remove = &card_remove;
 65         kfree(dev->card_link);                     66         kfree(dev->card_link);
 66         card_remove(dev);                          67         card_remove(dev);
 67 }                                                  68 }
 68                                                    69 
 69 static int card_probe(struct pnp_card *card, s !!  70 static int card_probe(struct pnp_card * card, struct pnp_card_driver * drv)
 70 {                                                  71 {
 71         const struct pnp_card_device_id *id;   !!  72         const struct pnp_card_device_id *id = match_card(drv,card);
 72         struct pnp_card_link *clink;           !!  73         if (id) {
 73         struct pnp_dev *dev;                   !!  74                 struct pnp_card_link * clink = pnp_alloc(sizeof(struct pnp_card_link));
 74                                                !!  75                 if (!clink)
 75         if (!drv->probe)                       !!  76                         return 0;
 76                 return 0;                      !!  77                 clink->card = card;
 77         id = match_card(drv, card);            !!  78                 clink->driver = drv;
 78         if (!id)                               !!  79                 if (drv->probe) {
 79                 return 0;                      !!  80                         if (drv->probe(clink, id)>=0)
 80                                                !!  81                                 return 1;
 81         clink = pnp_alloc(sizeof(*clink));     !!  82                         else {
 82         if (!clink)                            !!  83                                 struct pnp_dev * dev;
 83                 return 0;                      !!  84                                 card_for_each_dev(card, dev) {
 84         clink->card = card;                    !!  85                                         if (dev->card_link == clink)
 85         clink->driver = drv;                   !!  86                                                 pnp_release_card_device(dev);
 86         clink->pm_state = PMSG_ON;             !!  87                                 }
 87                                                !!  88                                 kfree(clink);
 88         if (drv->probe(clink, id) >= 0)        !!  89                         }
 89                 return 1;                      !!  90                 } else
 90                                                !!  91                         return 1;
 91         /* Recovery */                         << 
 92         card_for_each_dev(card, dev) {         << 
 93                 if (dev->card_link == clink)   << 
 94                         pnp_release_card_devic << 
 95         }                                          92         }
 96         kfree(clink);                          << 
 97         return 0;                                  93         return 0;
 98 }                                                  94 }
 99                                                    95 
100 /**                                                96 /**
101  * pnp_add_card_id - adds an EISA id to the sp     97  * pnp_add_card_id - adds an EISA id to the specified card
102  * @id: pointer to a pnp_id structure              98  * @id: pointer to a pnp_id structure
103  * @card: pointer to the desired card              99  * @card: pointer to the desired card
                                                   >> 100  *
104  */                                               101  */
105 static struct pnp_id *pnp_add_card_id(struct p << 
106 {                                              << 
107         struct pnp_id *dev_id, *ptr;           << 
108                                                   102 
109         dev_id = kzalloc(sizeof(struct pnp_id) !! 103 int pnp_add_card_id(struct pnp_id *id, struct pnp_card * card)
110         if (!dev_id)                           !! 104 {
111                 return NULL;                   !! 105         struct pnp_id * ptr;
112                                                !! 106         if (!id)
113         dev_id->id[0] = id[0];                 !! 107                 return -EINVAL;
114         dev_id->id[1] = id[1];                 !! 108         if (!card)
115         dev_id->id[2] = id[2];                 !! 109                 return -EINVAL;
116         dev_id->id[3] = tolower(id[3]);        !! 110         id->next = NULL;
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;                   << 
123         ptr = card->id;                           111         ptr = card->id;
124         while (ptr && ptr->next)                  112         while (ptr && ptr->next)
125                 ptr = ptr->next;                  113                 ptr = ptr->next;
126         if (ptr)                                  114         if (ptr)
127                 ptr->next = dev_id;            !! 115                 ptr->next = id;
128         else                                      116         else
129                 card->id = dev_id;             !! 117                 card->id = id;
130                                                !! 118         return 0;
131         return dev_id;                         << 
132 }                                                 119 }
133                                                   120 
134 static void pnp_free_card_ids(struct pnp_card  !! 121 static void pnp_free_card_ids(struct pnp_card * card)
135 {                                                 122 {
136         struct pnp_id *id;                     !! 123         struct pnp_id * id;
137         struct pnp_id *next;                      124         struct pnp_id *next;
138                                                !! 125         if (!card)
                                                   >> 126                 return;
139         id = card->id;                            127         id = card->id;
140         while (id) {                              128         while (id) {
141                 next = id->next;                  129                 next = id->next;
142                 kfree(id);                        130                 kfree(id);
143                 id = next;                        131                 id = next;
144         }                                         132         }
145 }                                                 133 }
146                                                   134 
147 static void pnp_release_card(struct device *dm    135 static void pnp_release_card(struct device *dmdev)
148 {                                                 136 {
149         struct pnp_card *card = to_pnp_card(dm !! 137         struct pnp_card * card = to_pnp_card(dmdev);
150                                                << 
151         pnp_free_card_ids(card);                  138         pnp_free_card_ids(card);
152         kfree(card);                              139         kfree(card);
153 }                                                 140 }
154                                                   141 
155 struct pnp_card *pnp_alloc_card(struct pnp_pro << 
156 {                                              << 
157         struct pnp_card *card;                 << 
158         struct pnp_id *dev_id;                 << 
159                                                << 
160         card = kzalloc(sizeof(struct pnp_card) << 
161         if (!card)                             << 
162                 return NULL;                   << 
163                                                << 
164         card->protocol = protocol;             << 
165         card->number = id;                     << 
166                                                << 
167         card->dev.parent = &card->protocol->de << 
168         dev_set_name(&card->dev, "%02x:%02x",  << 
169                                                << 
170         card->dev.coherent_dma_mask = DMA_BIT_ << 
171         card->dev.dma_mask = &card->dev.cohere << 
172                                                << 
173         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                                                   142 
182 static ssize_t pnp_show_card_name(struct devic !! 143 static ssize_t pnp_show_card_name(struct device *dmdev, char *buf)
183                                   struct devic << 
184 {                                                 144 {
185         char *str = buf;                          145         char *str = buf;
186         struct pnp_card *card = to_pnp_card(dm    146         struct pnp_card *card = to_pnp_card(dmdev);
187                                                !! 147         str += sprintf(str,"%s\n", card->name);
188         str += sprintf(str, "%s\n", card->name << 
189         return (str - buf);                       148         return (str - buf);
190 }                                                 149 }
191                                                   150 
192 static DEVICE_ATTR(name, S_IRUGO, pnp_show_car !! 151 static DEVICE_ATTR(name,S_IRUGO,pnp_show_card_name,NULL);
193                                                   152 
194 static ssize_t pnp_show_card_ids(struct device !! 153 static ssize_t pnp_show_card_ids(struct device *dmdev, char *buf)
195                                  struct device << 
196 {                                                 154 {
197         char *str = buf;                          155         char *str = buf;
198         struct pnp_card *card = to_pnp_card(dm    156         struct pnp_card *card = to_pnp_card(dmdev);
199         struct pnp_id *pos = card->id;         !! 157         struct pnp_id * pos = card->id;
200                                                   158 
201         while (pos) {                             159         while (pos) {
202                 str += sprintf(str, "%s\n", po !! 160                 str += sprintf(str,"%s\n", pos->id);
203                 pos = pos->next;                  161                 pos = pos->next;
204         }                                         162         }
205         return (str - buf);                       163         return (str - buf);
206 }                                                 164 }
207                                                   165 
208 static DEVICE_ATTR(card_id, S_IRUGO, pnp_show_ !! 166 static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL);
209                                                   167 
210 static int pnp_interface_attach_card(struct pn    168 static int pnp_interface_attach_card(struct pnp_card *card)
211 {                                                 169 {
212         int rc = device_create_file(&card->dev !! 170         device_create_file(&card->dev,&dev_attr_name);
213                                                !! 171         device_create_file(&card->dev,&dev_attr_card_id);
214         if (rc)                                << 
215                 return rc;                     << 
216                                                << 
217         rc = device_create_file(&card->dev, &d << 
218         if (rc)                                << 
219                 goto err_name;                 << 
220                                                << 
221         return 0;                                 172         return 0;
222                                                << 
223 err_name:                                      << 
224         device_remove_file(&card->dev, &dev_at << 
225         return rc;                             << 
226 }                                                 173 }
227                                                   174 
228 /**                                               175 /**
229  * pnp_add_card - adds a PnP card to the PnP L    176  * pnp_add_card - adds a PnP card to the PnP Layer
230  * @card: pointer to the card to add              177  * @card: pointer to the card to add
231  */                                               178  */
232 int pnp_add_card(struct pnp_card *card)        !! 179 
                                                   >> 180 int pnp_add_card(struct pnp_card * card)
233 {                                                 181 {
234         int error;                                182         int error;
235         struct list_head *pos, *temp;          !! 183         struct list_head * pos, * temp;
                                                   >> 184         if (!card || !card->protocol)
                                                   >> 185                 return -EINVAL;
236                                                   186 
                                                   >> 187         sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number, card->number);
                                                   >> 188         card->dev.parent = &card->protocol->dev;
237         card->dev.bus = NULL;                     189         card->dev.bus = NULL;
238         card->dev.release = &pnp_release_card;    190         card->dev.release = &pnp_release_card;
239         error = device_register(&card->dev);      191         error = device_register(&card->dev);
240         if (error) {                           << 
241                 dev_err(&card->dev, "could not << 
242                 return error;                  << 
243         }                                      << 
244                                                << 
245         pnp_interface_attach_card(card);       << 
246         spin_lock(&pnp_lock);                  << 
247         list_add_tail(&card->global_list, &pnp << 
248         list_add_tail(&card->protocol_list, &c << 
249         spin_unlock(&pnp_lock);                << 
250                                                   192 
251         /* we wait until now to add devices in !! 193         if (error == 0) {
252          * will be able to use all of the rela !! 194                 pnp_interface_attach_card(card);
253          * without waiting an unreasonable len !! 195                 spin_lock(&pnp_lock);
254         list_for_each(pos, &card->devices) {   !! 196                 list_add_tail(&card->global_list, &pnp_cards);
255                 struct pnp_dev *dev = card_to_ !! 197                 list_add_tail(&card->protocol_list, &card->protocol->cards);
256                 __pnp_add_device(dev);         !! 198                 spin_unlock(&pnp_lock);
257         }                                      !! 199 
                                                   >> 200                 /* we wait until now to add devices in order to ensure the drivers
                                                   >> 201                  * will be able to use all of the related devices on the card
                                                   >> 202                  * without waiting any unresonable length of time */
                                                   >> 203                 list_for_each(pos,&card->devices){
                                                   >> 204                         struct pnp_dev *dev = card_to_pnp_dev(pos);
                                                   >> 205                         __pnp_add_device(dev);
                                                   >> 206                 }
258                                                   207 
259         /* match with card drivers */          !! 208                 /* match with card drivers */
260         list_for_each_safe(pos, temp, &pnp_car !! 209                 list_for_each_safe(pos,temp,&pnp_card_drivers){
261                 struct pnp_card_driver *drv =  !! 210                         struct pnp_card_driver * drv = list_entry(pos, struct pnp_card_driver, global_list);
262                     list_entry(pos, struct pnp !! 211                         card_probe(card,drv);
263                                global_list);   !! 212                 }
264                 card_probe(card, drv);         !! 213         } else
265         }                                      !! 214                 pnp_err("sysfs failure, card '%s' will be unavailable", card->dev.bus_id);
266         return 0;                              !! 215         return error;
267 }                                                 216 }
268                                                   217 
269 /**                                               218 /**
270  * pnp_remove_card - removes a PnP card from t    219  * pnp_remove_card - removes a PnP card from the PnP Layer
271  * @card: pointer to the card to remove           220  * @card: pointer to the card to remove
272  */                                               221  */
273 void pnp_remove_card(struct pnp_card *card)    !! 222 
                                                   >> 223 void pnp_remove_card(struct pnp_card * card)
274 {                                                 224 {
275         struct list_head *pos, *temp;             225         struct list_head *pos, *temp;
276                                                !! 226         if (!card)
                                                   >> 227                 return;
277         device_unregister(&card->dev);            228         device_unregister(&card->dev);
278         spin_lock(&pnp_lock);                     229         spin_lock(&pnp_lock);
279         list_del(&card->global_list);             230         list_del(&card->global_list);
280         list_del(&card->protocol_list);           231         list_del(&card->protocol_list);
281         spin_unlock(&pnp_lock);                   232         spin_unlock(&pnp_lock);
282         list_for_each_safe(pos, temp, &card->d !! 233         list_for_each_safe(pos,temp,&card->devices){
283                 struct pnp_dev *dev = card_to_    234                 struct pnp_dev *dev = card_to_pnp_dev(pos);
284                 pnp_remove_card_device(dev);      235                 pnp_remove_card_device(dev);
285         }                                         236         }
286 }                                                 237 }
287                                                   238 
288 /**                                               239 /**
289  * pnp_add_card_device - adds a device to the     240  * pnp_add_card_device - adds a device to the specified card
290  * @card: pointer to the card to add to           241  * @card: pointer to the card to add to
291  * @dev: pointer to the device to add             242  * @dev: pointer to the device to add
292  */                                               243  */
293 int pnp_add_card_device(struct pnp_card *card, !! 244 
                                                   >> 245 int pnp_add_card_device(struct pnp_card * card, struct pnp_dev * dev)
294 {                                                 246 {
                                                   >> 247         if (!card || !dev || !dev->protocol)
                                                   >> 248                 return -EINVAL;
295         dev->dev.parent = &card->dev;             249         dev->dev.parent = &card->dev;
296         dev->card_link = NULL;                    250         dev->card_link = NULL;
297         dev_set_name(&dev->dev, "%02x:%02x.%02 !! 251         snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x", dev->protocol->number,
298                      dev->protocol->number, ca !! 252                  card->number,dev->number);
299         spin_lock(&pnp_lock);                     253         spin_lock(&pnp_lock);
300         dev->card = card;                         254         dev->card = card;
301         list_add_tail(&dev->card_list, &card->    255         list_add_tail(&dev->card_list, &card->devices);
302         spin_unlock(&pnp_lock);                   256         spin_unlock(&pnp_lock);
303         return 0;                                 257         return 0;
304 }                                                 258 }
305                                                   259 
306 /**                                               260 /**
307  * pnp_remove_card_device- removes a device fr    261  * pnp_remove_card_device- removes a device from the specified card
                                                   >> 262  * @card: pointer to the card to remove from
308  * @dev: pointer to the device to remove          263  * @dev: pointer to the device to remove
309  */                                               264  */
310 void pnp_remove_card_device(struct pnp_dev *de !! 265 
                                                   >> 266 void pnp_remove_card_device(struct pnp_dev * dev)
311 {                                                 267 {
312         spin_lock(&pnp_lock);                     268         spin_lock(&pnp_lock);
313         dev->card = NULL;                         269         dev->card = NULL;
314         list_del(&dev->card_list);                270         list_del(&dev->card_list);
315         spin_unlock(&pnp_lock);                   271         spin_unlock(&pnp_lock);
316         __pnp_remove_device(dev);                 272         __pnp_remove_device(dev);
317 }                                                 273 }
318                                                   274 
319 /**                                               275 /**
320  * pnp_request_card_device - Searches for a Pn    276  * pnp_request_card_device - Searches for a PnP device under the specified card
321  * @clink: pointer to the card link, cannot be !! 277  * @lcard: pointer to the card link, cannot be NULL
322  * @id: pointer to a PnP ID structure that exp    278  * @id: pointer to a PnP ID structure that explains the rules for finding the device
323  * @from: Starting place to search from. If NU    279  * @from: Starting place to search from. If NULL it will start from the begining.
324  */                                               280  */
325 struct pnp_dev *pnp_request_card_device(struct << 
326                                         const  << 
327 {                                              << 
328         struct list_head *pos;                 << 
329         struct pnp_dev *dev;                   << 
330         struct pnp_card_driver *drv;           << 
331         struct pnp_card *card;                 << 
332                                                   281 
                                                   >> 282 struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from)
                                                   >> 283 {
                                                   >> 284         struct list_head * pos;
                                                   >> 285         struct pnp_dev * dev;
                                                   >> 286         struct pnp_card_driver * drv;
                                                   >> 287         struct pnp_card * card;
333         if (!clink || !id)                        288         if (!clink || !id)
334                 return NULL;                   !! 289                 goto done;
335                                                << 
336         card = clink->card;                       290         card = clink->card;
337         drv = clink->driver;                      291         drv = clink->driver;
338         if (!from) {                              292         if (!from) {
339                 pos = card->devices.next;         293                 pos = card->devices.next;
340         } else {                                  294         } else {
341                 if (from->card != card)           295                 if (from->card != card)
342                         return NULL;           !! 296                         goto done;
343                 pos = from->card_list.next;       297                 pos = from->card_list.next;
344         }                                         298         }
345         while (pos != &card->devices) {           299         while (pos != &card->devices) {
346                 dev = card_to_pnp_dev(pos);       300                 dev = card_to_pnp_dev(pos);
347                 if ((!dev->card_link) && compa !! 301                 if ((!dev->card_link) && compare_pnp_id(dev->id,id))
348                         goto found;               302                         goto found;
349                 pos = pos->next;                  303                 pos = pos->next;
350         }                                         304         }
351                                                   305 
                                                   >> 306 done:
352         return NULL;                              307         return NULL;
353                                                   308 
354 found:                                            309 found:
                                                   >> 310         down_write(&dev->dev.bus->subsys.rwsem);
355         dev->card_link = clink;                   311         dev->card_link = clink;
356         dev->dev.driver = &drv->link.driver;      312         dev->dev.driver = &drv->link.driver;
357         if (pnp_bus_type.probe(&dev->dev))     !! 313         if (drv->link.driver.probe) {
358                 goto err_out;                  !! 314                 if (drv->link.driver.probe(&dev->dev)) {
359         if (device_bind_driver(&dev->dev))     !! 315                         dev->dev.driver = NULL;
360                 goto err_out;                  !! 316                         return NULL;
                                                   >> 317                 }
                                                   >> 318         }
                                                   >> 319         device_bind_driver(&dev->dev);
                                                   >> 320         up_write(&dev->dev.bus->subsys.rwsem);
361                                                   321 
362         return dev;                               322         return dev;
363                                                << 
364 err_out:                                       << 
365         dev->dev.driver = NULL;                << 
366         dev->card_link = NULL;                 << 
367         return NULL;                           << 
368 }                                                 323 }
369                                                   324 
370 /**                                               325 /**
371  * pnp_release_card_device - call this when th    326  * pnp_release_card_device - call this when the driver no longer needs the device
372  * @dev: pointer to the PnP device stucture       327  * @dev: pointer to the PnP device stucture
373  */                                               328  */
374 void pnp_release_card_device(struct pnp_dev *d << 
375 {                                              << 
376         struct pnp_card_driver *drv = dev->car << 
377                                                   329 
                                                   >> 330 void pnp_release_card_device(struct pnp_dev * dev)
                                                   >> 331 {
                                                   >> 332         struct pnp_card_driver * drv = dev->card_link->driver;
                                                   >> 333         if (!drv)
                                                   >> 334                 return;
                                                   >> 335         down_write(&dev->dev.bus->subsys.rwsem);
378         drv->link.remove = &card_remove;          336         drv->link.remove = &card_remove;
379         device_release_driver(&dev->dev);         337         device_release_driver(&dev->dev);
380         drv->link.remove = &card_remove_first;    338         drv->link.remove = &card_remove_first;
381 }                                              !! 339         up_write(&dev->dev.bus->subsys.rwsem);
382                                                << 
383 /*                                             << 
384  * suspend/resume callbacks                    << 
385  */                                            << 
386 static int card_suspend(struct pnp_dev *dev, p << 
387 {                                              << 
388         struct pnp_card_link *link = dev->card << 
389                                                << 
390         if (link->pm_state.event == state.even << 
391                 return 0;                      << 
392         link->pm_state = state;                << 
393         return link->driver->suspend(link, sta << 
394 }                                              << 
395                                                << 
396 static int card_resume(struct pnp_dev *dev)    << 
397 {                                              << 
398         struct pnp_card_link *link = dev->card << 
399                                                << 
400         if (link->pm_state.event == PM_EVENT_O << 
401                 return 0;                      << 
402         link->pm_state = PMSG_ON;              << 
403         link->driver->resume(link);            << 
404         return 0;                              << 
405 }                                                 340 }
406                                                   341 
407 /**                                               342 /**
408  * pnp_register_card_driver - registers a PnP     343  * pnp_register_card_driver - registers a PnP card driver with the PnP Layer
409  * @drv: pointer to the driver to register        344  * @drv: pointer to the driver to register
410  */                                               345  */
411 int pnp_register_card_driver(struct pnp_card_d !! 346 
                                                   >> 347 int pnp_register_card_driver(struct pnp_card_driver * drv)
412 {                                                 348 {
413         int error;                             !! 349         int count = 0;
414         struct list_head *pos, *temp;             350         struct list_head *pos, *temp;
415                                                   351 
416         drv->link.name = drv->name;               352         drv->link.name = drv->name;
417         drv->link.id_table = NULL;      /* thi    353         drv->link.id_table = NULL;      /* this will disable auto matching */
418         drv->link.flags = drv->flags;             354         drv->link.flags = drv->flags;
419         drv->link.probe = NULL;                   355         drv->link.probe = NULL;
420         drv->link.remove = &card_remove_first;    356         drv->link.remove = &card_remove_first;
421         drv->link.suspend = drv->suspend ? car << 
422         drv->link.resume = drv->resume ? card_ << 
423                                                << 
424         error = pnp_register_driver(&drv->link << 
425         if (error < 0)                         << 
426                 return error;                  << 
427                                                   357 
428         spin_lock(&pnp_lock);                     358         spin_lock(&pnp_lock);
429         list_add_tail(&drv->global_list, &pnp_    359         list_add_tail(&drv->global_list, &pnp_card_drivers);
430         spin_unlock(&pnp_lock);                   360         spin_unlock(&pnp_lock);
                                                   >> 361         pnp_register_driver(&drv->link);
431                                                   362 
432         list_for_each_safe(pos, temp, &pnp_car !! 363         list_for_each_safe(pos,temp,&pnp_cards){
433                 struct pnp_card *card =        !! 364                 struct pnp_card *card = list_entry(pos, struct pnp_card, global_list);
434                     list_entry(pos, struct pnp !! 365                 count += card_probe(card,drv);
435                 card_probe(card, drv);         << 
436         }                                         366         }
437         return 0;                              !! 367         return count;
438 }                                                 368 }
439                                                   369 
440 /**                                               370 /**
441  * pnp_unregister_card_driver - unregisters a     371  * pnp_unregister_card_driver - unregisters a PnP card driver from the PnP Layer
442  * @drv: pointer to the driver to unregister      372  * @drv: pointer to the driver to unregister
443  */                                               373  */
444 void pnp_unregister_card_driver(struct pnp_car !! 374 
                                                   >> 375 void pnp_unregister_card_driver(struct pnp_card_driver * drv)
445 {                                                 376 {
446         spin_lock(&pnp_lock);                     377         spin_lock(&pnp_lock);
447         list_del(&drv->global_list);              378         list_del(&drv->global_list);
448         spin_unlock(&pnp_lock);                   379         spin_unlock(&pnp_lock);
449         pnp_unregister_driver(&drv->link);        380         pnp_unregister_driver(&drv->link);
450 }                                                 381 }
451                                                   382 
                                                   >> 383 EXPORT_SYMBOL(pnp_add_card);
                                                   >> 384 EXPORT_SYMBOL(pnp_remove_card);
                                                   >> 385 EXPORT_SYMBOL(pnp_add_card_device);
                                                   >> 386 EXPORT_SYMBOL(pnp_remove_card_device);
                                                   >> 387 EXPORT_SYMBOL(pnp_add_card_id);
452 EXPORT_SYMBOL(pnp_request_card_device);           388 EXPORT_SYMBOL(pnp_request_card_device);
453 EXPORT_SYMBOL(pnp_release_card_device);           389 EXPORT_SYMBOL(pnp_release_card_device);
454 EXPORT_SYMBOL(pnp_register_card_driver);          390 EXPORT_SYMBOL(pnp_register_card_driver);
455 EXPORT_SYMBOL(pnp_unregister_card_driver);        391 EXPORT_SYMBOL(pnp_unregister_card_driver);
456                                                   392 
  This page was automatically generated by the LXR engine.