diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2005-06-27 19:29:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-27 21:03:22 -0400 |
commit | 3248ff43f86493368b321376d447d84fa9a2737d (patch) | |
tree | 36b11c42479f7370e669f8c6747501ad5a72795b /drivers/pcmcia/ds.c | |
parent | 57b6281cea59639cce995745f1dc42fe9da2c533 (diff) |
[PATCH] pcmcia: export modalias in sysfs
Provide a "modalias" entry in sysfs for PCMCIA devices.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/pcmcia/ds.c')
-rw-r--r-- | drivers/pcmcia/ds.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index f018d26f1817..cabddd49f6ff 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -847,9 +847,29 @@ pcmcia_device_stringattr(prod_id2, prod_id[1]); | |||
847 | pcmcia_device_stringattr(prod_id3, prod_id[2]); | 847 | pcmcia_device_stringattr(prod_id3, prod_id[2]); |
848 | pcmcia_device_stringattr(prod_id4, prod_id[3]); | 848 | pcmcia_device_stringattr(prod_id4, prod_id[3]); |
849 | 849 | ||
850 | static ssize_t modalias_show(struct device *dev, char *buf) | ||
851 | { | ||
852 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); | ||
853 | int i; | ||
854 | u32 hash[4] = { 0, 0, 0, 0}; | ||
855 | |||
856 | /* calculate hashes */ | ||
857 | for (i=0; i<4; i++) { | ||
858 | if (!p_dev->prod_id[i]) | ||
859 | continue; | ||
860 | hash[i] = crc32(0,p_dev->prod_id[i],strlen(p_dev->prod_id[i])); | ||
861 | } | ||
862 | return sprintf(buf, "pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X" | ||
863 | "pa%08Xpb%08Xpc%08Xpd%08X\n", | ||
864 | p_dev->has_manf_id ? p_dev->manf_id : 0, | ||
865 | p_dev->has_card_id ? p_dev->card_id : 0, | ||
866 | p_dev->has_func_id ? p_dev->func_id : 0, | ||
867 | p_dev->func, p_dev->device_no, | ||
868 | hash[0], hash[1], hash[2], hash[3]); | ||
869 | } | ||
850 | 870 | ||
851 | static ssize_t pcmcia_store_allow_func_id_match (struct device * dev, struct device_attribute *attr, | 871 | static ssize_t pcmcia_store_allow_func_id_match(struct device *dev, |
852 | const char * buf, size_t count) | 872 | struct device_attribute *attr, const char *buf, size_t count) |
853 | { | 873 | { |
854 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); | 874 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); |
855 | if (!count) | 875 | if (!count) |
@@ -873,6 +893,7 @@ static struct device_attribute pcmcia_dev_attrs[] = { | |||
873 | __ATTR_RO(prod_id2), | 893 | __ATTR_RO(prod_id2), |
874 | __ATTR_RO(prod_id3), | 894 | __ATTR_RO(prod_id3), |
875 | __ATTR_RO(prod_id4), | 895 | __ATTR_RO(prod_id4), |
896 | __ATTR_RO(modalias), | ||
876 | __ATTR(allow_func_id_match, 0200, NULL, pcmcia_store_allow_func_id_match), | 897 | __ATTR(allow_func_id_match, 0200, NULL, pcmcia_store_allow_func_id_match), |
877 | __ATTR_NULL, | 898 | __ATTR_NULL, |
878 | }; | 899 | }; |