ChangeSet 1.2065.3.21, 2005/03/12 08:26:18-08:00, [EMAIL PROTECTED]

        [PATCH] pcmcia: per-device sysfs output
        
        Per-device sysfs output which reports up to four product ID strings,
        manufactor ID, product ID and function ID.
        
        Signed-off-by: Dominik Brodowski <[EMAIL PROTECTED]>
        Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
        Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>



 ds.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+)


diff -Nru a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
--- a/drivers/pcmcia/ds.c       2005-03-12 21:29:04 -08:00
+++ b/drivers/pcmcia/ds.c       2005-03-12 21:29:04 -08:00
@@ -602,6 +602,44 @@
        return 0;
 }
 
+/************************ per-device sysfs output ***************************/
+
+#define pcmcia_device_attr(field, test, format)                                
\
+static ssize_t field##_show (struct device *dev, char *buf)            \
+{                                                                      \
+       struct pcmcia_device *p_dev = to_pcmcia_dev(dev);               \
+       return p_dev->test ? sprintf (buf, format, p_dev->field) : -ENODEV; \
+}
+
+#define pcmcia_device_stringattr(name, field)                                  
\
+static ssize_t name##_show (struct device *dev, char *buf)             \
+{                                                                      \
+       struct pcmcia_device *p_dev = to_pcmcia_dev(dev);               \
+       return p_dev->field ? sprintf (buf, "%s\n", p_dev->field) : -ENODEV; \
+}
+
+pcmcia_device_attr(func, socket, "0x%02x\n");
+pcmcia_device_attr(func_id, has_func_id, "0x%02x\n");
+pcmcia_device_attr(manf_id, has_manf_id, "0x%04x\n");
+pcmcia_device_attr(card_id, has_card_id, "0x%04x\n");
+pcmcia_device_stringattr(prod_id1, prod_id[0]);
+pcmcia_device_stringattr(prod_id2, prod_id[1]);
+pcmcia_device_stringattr(prod_id3, prod_id[2]);
+pcmcia_device_stringattr(prod_id4, prod_id[3]);
+
+static struct device_attribute pcmcia_dev_attrs[] = {
+       __ATTR(function, 0444, func_show, NULL),
+       __ATTR_RO(func_id),
+       __ATTR_RO(manf_id),
+       __ATTR_RO(card_id),
+       __ATTR_RO(prod_id1),
+       __ATTR_RO(prod_id2),
+       __ATTR_RO(prod_id3),
+       __ATTR_RO(prod_id4),
+       __ATTR_NULL,
+};
+
+
 /*======================================================================
 
     These manage a ring buffer of events pending for one user process
@@ -1575,6 +1613,7 @@
 struct bus_type pcmcia_bus_type = {
        .name = "pcmcia",
        .match = pcmcia_bus_match,
+       .dev_attrs = pcmcia_dev_attrs,
 };
 EXPORT_SYMBOL(pcmcia_bus_type);
 
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to