]> git.hungrycats.org Git - linux/commitdiff
[PNP]: Add additonal sysfs entries
authorAdam Belay <ambx1@neo.rr.com>
Sun, 8 Feb 2004 15:47:23 +0000 (15:47 +0000)
committerAdam Belay <ambx1@neo.rr.com>
Sun, 8 Feb 2004 15:47:23 +0000 (15:47 +0000)
This patch adds some aditional information to sysfs for pnp cards.  It
should be useful for userland tools.

drivers/pnp/card.c

index 972ddf0ba8a7093c6a384a63acc131198dcec8b0..97eeecfaef1b712682d7a4224682f4463c356050 100644 (file)
@@ -139,6 +139,39 @@ static void pnp_release_card(struct device *dmdev)
        kfree(card);
 }
 
+
+static ssize_t pnp_show_card_name(struct device *dmdev, char *buf)
+{
+       char *str = buf;
+       struct pnp_card *card = to_pnp_card(dmdev);
+       str += sprintf(str,"%s\n", card->name);
+       return (str - buf);
+}
+
+static DEVICE_ATTR(name,S_IRUGO,pnp_show_card_name,NULL);
+
+static ssize_t pnp_show_card_ids(struct device *dmdev, char *buf)
+{
+       char *str = buf;
+       struct pnp_card *card = to_pnp_card(dmdev);
+       struct pnp_id * pos = card->id;
+
+       while (pos) {
+               str += sprintf(str,"%s\n", pos->id);
+               pos = pos->next;
+       }
+       return (str - buf);
+}
+
+static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL);
+
+static int pnp_interface_attach_card(struct pnp_card *card)
+{
+       device_create_file(&card->dev,&dev_attr_name);
+       device_create_file(&card->dev,&dev_attr_card_id);
+       return 0;
+}
+
 /**
  * pnp_add_card - adds a PnP card to the PnP Layer
  * @card: pointer to the card to add
@@ -158,6 +191,7 @@ int pnp_add_card(struct pnp_card * card)
        error = device_register(&card->dev);
 
        if (error == 0) {
+               pnp_interface_attach_card(card);
                spin_lock(&pnp_lock);
                list_add_tail(&card->global_list, &pnp_cards);
                list_add_tail(&card->protocol_list, &card->protocol->cards);