const: struct nla_policy
[safe/jmp/linux-2.6] / drivers / pnp / card.c
index d606a16..4a651f6 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/ctype.h>
 #include <linux/slab.h>
 #include <linux/pnp.h>
+#include <linux/dma-mapping.h>
 #include "base.h"
 
 LIST_HEAD(pnp_cards);
@@ -101,7 +102,7 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
  * @id: pointer to a pnp_id structure
  * @card: pointer to the desired card
  */
-struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id)
+static struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id)
 {
        struct pnp_id *dev_id, *ptr;
 
@@ -151,6 +152,33 @@ static void pnp_release_card(struct device *dmdev)
        kfree(card);
 }
 
+struct pnp_card *pnp_alloc_card(struct pnp_protocol *protocol, int id, char *pnpid)
+{
+       struct pnp_card *card;
+       struct pnp_id *dev_id;
+
+       card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL);
+       if (!card)
+               return NULL;
+
+       card->protocol = protocol;
+       card->number = id;
+
+       card->dev.parent = &card->protocol->dev;
+       dev_set_name(&card->dev, "%02x:%02x", card->protocol->number, card->number);
+
+       card->dev.coherent_dma_mask = DMA_BIT_MASK(24);
+       card->dev.dma_mask = &card->dev.coherent_dma_mask;
+
+       dev_id = pnp_add_card_id(card, pnpid);
+       if (!dev_id) {
+               kfree(card);
+               return NULL;
+       }
+
+       return card;
+}
+
 static ssize_t pnp_show_card_name(struct device *dmdev,
                                  struct device_attribute *attr, char *buf)
 {
@@ -206,9 +234,6 @@ int pnp_add_card(struct pnp_card *card)
        int error;
        struct list_head *pos, *temp;
 
-       sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
-               card->number);
-       card->dev.parent = &card->protocol->dev;
        card->dev.bus = NULL;
        card->dev.release = &pnp_release_card;
        error = device_register(&card->dev);
@@ -269,8 +294,8 @@ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
 {
        dev->dev.parent = &card->dev;
        dev->card_link = NULL;
-       snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x",
-                dev->protocol->number, card->number, dev->number);
+       dev_set_name(&dev->dev, "%02x:%02x.%02x",
+                    dev->protocol->number, card->number, dev->number);
        spin_lock(&pnp_lock);
        dev->card = card;
        list_add_tail(&dev->card_list, &card->devices);