aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/ds.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2005-06-27 19:28:04 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-27 21:03:05 -0400
commit840c2ac5d3c1d50e8a181e3f661da814e89c8cf8 (patch)
treebd9239d8116ff69a9be8085a2e8ae3f7499a55f5 /drivers/pcmcia/ds.c
parent7925407aa02653ba462b1d8b0b1229b99aee5411 (diff)
[PATCH] pcmcia: hotplug event for PCMCIA devices
Export information to /sbin/hotplug for PCMCIA devices: card_id, manf_id, func_id, bus_id (like pcmcia1.0) and crc32-hashes of the prod_id strings. Why not the prod_id strings themselves? a) They may contain all sorts of strange and difficult to handle characters, like " ". b) It's impossible to pass multiple strings to userspace. 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.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 569e55feecfd..35d479b0df64 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -35,6 +35,7 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/kref.h> 36#include <linux/kref.h>
37#include <linux/workqueue.h> 37#include <linux/workqueue.h>
38#include <linux/crc32.h>
38 39
39#include <asm/atomic.h> 40#include <asm/atomic.h>
40 41
@@ -601,6 +602,71 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
601 return 0; 602 return 0;
602} 603}
603 604
605#ifdef CONFIG_HOTPLUG
606
607static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp,
608 char *buffer, int buffer_size)
609{
610 struct pcmcia_device *p_dev;
611 int i, length = 0;
612 u32 hash[4] = { 0, 0, 0, 0};
613
614 if (!dev)
615 return -ENODEV;
616
617 p_dev = to_pcmcia_dev(dev);
618
619 /* calculate hashes */
620 for (i=0; i<4; i++) {
621 if (!p_dev->prod_id[i])
622 continue;
623 hash[i] = crc32(0, p_dev->prod_id[i], strlen(p_dev->prod_id[i]));
624 }
625
626 i = 0;
627
628 if (add_hotplug_env_var(envp, num_envp, &i,
629 buffer, buffer_size, &length,
630 "SOCKET_NO=%u",
631 p_dev->socket->sock))
632 return -ENOMEM;
633
634 if (add_hotplug_env_var(envp, num_envp, &i,
635 buffer, buffer_size, &length,
636 "DEVICE_NO=%02X",
637 p_dev->device_no))
638 return -ENOMEM;
639
640 if (add_hotplug_env_var(envp, num_envp, &i,
641 buffer, buffer_size, &length,
642 "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X"
643 "pa%08Xpb%08Xpc%08Xpd%08X",
644 p_dev->has_manf_id ? p_dev->manf_id : 0,
645 p_dev->has_card_id ? p_dev->card_id : 0,
646 p_dev->has_func_id ? p_dev->func_id : 0,
647 p_dev->func,
648 p_dev->device_no,
649 hash[0],
650 hash[1],
651 hash[2],
652 hash[3]))
653 return -ENOMEM;
654
655 envp[i] = NULL;
656
657 return 0;
658}
659
660#else
661
662static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp,
663 char *buffer, int buffer_size)
664{
665 return -ENODEV;
666}
667
668#endif
669
604/************************ per-device sysfs output ***************************/ 670/************************ per-device sysfs output ***************************/
605 671
606#define pcmcia_device_attr(field, test, format) \ 672#define pcmcia_device_attr(field, test, format) \
@@ -1575,6 +1641,7 @@ static struct class_interface pcmcia_bus_interface = {
1575 1641
1576struct bus_type pcmcia_bus_type = { 1642struct bus_type pcmcia_bus_type = {
1577 .name = "pcmcia", 1643 .name = "pcmcia",
1644 .hotplug = pcmcia_bus_hotplug,
1578 .match = pcmcia_bus_match, 1645 .match = pcmcia_bus_match,
1579 .dev_attrs = pcmcia_dev_attrs, 1646 .dev_attrs = pcmcia_dev_attrs,
1580}; 1647};