[PATCH] [PNP] 'modalias' sysfs export

From: Pierre Ossman
Date: Mon Feb 27 2006 - 16:37:57 EST


User space hardware detection need the 'modalias' attributes in the
sysfs tree. This patch adds support to the PNP bus.

Signed-off-by: Pierre Ossman <drzeus@xxxxxxxxx>
---

drivers/pnp/card.c | 12 ++++++++++++
drivers/pnp/interface.c | 12 ++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index aaa568a..d33a88f 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -159,10 +159,22 @@ static ssize_t pnp_show_card_ids(struct

static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL);

+static ssize_t pnp_card_modalias_show(struct device *dmdev, struct device_attribute *attr, char *buf)
+{
+ struct pnp_card *card = to_pnp_card(dmdev);
+ struct pnp_id * pos = card->id;
+
+ /* FIXME: modalias can only do one alias */
+ return sprintf(buf, "pnp:c%s\n", pos->id);
+}
+
+static DEVICE_ATTR(modalias,S_IRUGO,pnp_card_modalias_show,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);
+ device_create_file(&card->dev,&dev_attr_modalias);
return 0;
}

diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index a2d8ce7..67bd17c 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -459,10 +459,22 @@ static ssize_t pnp_show_current_ids(stru

static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL);

+static ssize_t pnp_modalias_show(struct device *dmdev, struct device_attribute *attr, char *buf)
+{
+ struct pnp_dev *dev = to_pnp_dev(dmdev);
+ struct pnp_id * pos = dev->id;
+
+ /* FIXME: modalias can only do one alias */
+ return sprintf(buf, "pnp:d%s\n", pos->id);
+}
+
+static DEVICE_ATTR(modalias,S_IRUGO,pnp_modalias_show,NULL);
+
int pnp_interface_attach_device(struct pnp_dev *dev)
{
device_create_file(&dev->dev,&dev_attr_options);
device_create_file(&dev->dev,&dev_attr_resources);
device_create_file(&dev->dev,&dev_attr_id);
+ device_create_file(&dev->dev,&dev_attr_modalias);
return 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/