Per-device sysfs output which reports up to four product ID strings, manufactor ID, product ID and function ID. Signed-off-by: Dominik Brodowski drivers/pcmcia/ds.c | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+) Index: 2.6.10-rc3/drivers/pcmcia/ds.c =================================================================== --- 2.6.10-rc3.orig/drivers/pcmcia/ds.c 2004-12-06 14:55:51.127008184 +0100 +++ 2.6.10-rc3/drivers/pcmcia/ds.c 2004-12-06 14:55:52.302829432 +0100 @@ -645,6 +645,42 @@ 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_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_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 @@ -1592,6 +1628,7 @@ struct bus_type pcmcia_bus_type = { .name = "pcmcia", .match = pcmcia_bus_match, + .dev_attrs = pcmcia_dev_attrs, }; EXPORT_SYMBOL(pcmcia_bus_type);