aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/ds.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-08-14 09:15:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 17:51:01 -0400
commit7eff2e7a8b65c25920207324e56611150eb1cd9a (patch)
tree02a0eeba9d25d996233e30c18f258dfae0ae2139 /drivers/pcmcia/ds.c
parent8380770c842faef3001e44662953d64ad9a93663 (diff)
Driver core: change add_uevent_var to use a struct
This changes the uevent buffer functions to use a struct instead of a long list of parameters. It does no longer require the caller to do the proper buffer termination and size accounting, which is currently wrong in some places. It fixes a known bug where parts of the uevent environment are overwritten because of wrong index calculations. Many thanks to Mathieu Desnoyers for finding bugs and improving the error handling. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Cc: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pcmcia/ds.c')
-rw-r--r--drivers/pcmcia/ds.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index a99607142fc8..55baa1f0fcbb 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1064,11 +1064,10 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
1064 1064
1065#ifdef CONFIG_HOTPLUG 1065#ifdef CONFIG_HOTPLUG
1066 1066
1067static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp, 1067static int pcmcia_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
1068 char *buffer, int buffer_size)
1069{ 1068{
1070 struct pcmcia_device *p_dev; 1069 struct pcmcia_device *p_dev;
1071 int i, length = 0; 1070 int i;
1072 u32 hash[4] = { 0, 0, 0, 0}; 1071 u32 hash[4] = { 0, 0, 0, 0};
1073 1072
1074 if (!dev) 1073 if (!dev)
@@ -1083,23 +1082,13 @@ static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp,
1083 hash[i] = crc32(0, p_dev->prod_id[i], strlen(p_dev->prod_id[i])); 1082 hash[i] = crc32(0, p_dev->prod_id[i], strlen(p_dev->prod_id[i]));
1084 } 1083 }
1085 1084
1086 i = 0; 1085 if (add_uevent_var(env, "SOCKET_NO=%u", p_dev->socket->sock))
1087
1088 if (add_uevent_var(envp, num_envp, &i,
1089 buffer, buffer_size, &length,
1090 "SOCKET_NO=%u",
1091 p_dev->socket->sock))
1092 return -ENOMEM; 1086 return -ENOMEM;
1093 1087
1094 if (add_uevent_var(envp, num_envp, &i, 1088 if (add_uevent_var(env, "DEVICE_NO=%02X", p_dev->device_no))
1095 buffer, buffer_size, &length,
1096 "DEVICE_NO=%02X",
1097 p_dev->device_no))
1098 return -ENOMEM; 1089 return -ENOMEM;
1099 1090
1100 if (add_uevent_var(envp, num_envp, &i, 1091 if (add_uevent_var(env, "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X"
1101 buffer, buffer_size, &length,
1102 "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X"
1103 "pa%08Xpb%08Xpc%08Xpd%08X", 1092 "pa%08Xpb%08Xpc%08Xpd%08X",
1104 p_dev->has_manf_id ? p_dev->manf_id : 0, 1093 p_dev->has_manf_id ? p_dev->manf_id : 0,
1105 p_dev->has_card_id ? p_dev->card_id : 0, 1094 p_dev->has_card_id ? p_dev->card_id : 0,
@@ -1112,15 +1101,12 @@ static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp,
1112 hash[3])) 1101 hash[3]))
1113 return -ENOMEM; 1102 return -ENOMEM;
1114 1103
1115 envp[i] = NULL;
1116
1117 return 0; 1104 return 0;
1118} 1105}
1119 1106
1120#else 1107#else
1121 1108
1122static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp, 1109static int pcmcia_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
1123 char *buffer, int buffer_size)
1124{ 1110{
1125 return -ENODEV; 1111 return -ENODEV;
1126} 1112}