aboutsummaryrefslogtreecommitdiffstats
path: root/sound/aoa/soundbus
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 /sound/aoa/soundbus
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 'sound/aoa/soundbus')
-rw-r--r--sound/aoa/soundbus/core.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/sound/aoa/soundbus/core.c b/sound/aoa/soundbus/core.c
index 64d163914335..f84f3e505788 100644
--- a/sound/aoa/soundbus/core.c
+++ b/sound/aoa/soundbus/core.c
@@ -56,13 +56,12 @@ static int soundbus_probe(struct device *dev)
56} 56}
57 57
58 58
59static int soundbus_uevent(struct device *dev, char **envp, int num_envp, 59static int soundbus_uevent(struct device *dev, struct kobj_uevent_env *env)
60 char *buffer, int buffer_size)
61{ 60{
62 struct soundbus_dev * soundbus_dev; 61 struct soundbus_dev * soundbus_dev;
63 struct of_device * of; 62 struct of_device * of;
64 const char *compat; 63 const char *compat;
65 int retval = 0, i = 0, length = 0; 64 int retval = 0;
66 int cplen, seen = 0; 65 int cplen, seen = 0;
67 66
68 if (!dev) 67 if (!dev)
@@ -75,15 +74,11 @@ static int soundbus_uevent(struct device *dev, char **envp, int num_envp,
75 of = &soundbus_dev->ofdev; 74 of = &soundbus_dev->ofdev;
76 75
77 /* stuff we want to pass to /sbin/hotplug */ 76 /* stuff we want to pass to /sbin/hotplug */
78 retval = add_uevent_var(envp, num_envp, &i, 77 retval = add_uevent_var(env, "OF_NAME=%s", of->node->name);
79 buffer, buffer_size, &length,
80 "OF_NAME=%s", of->node->name);
81 if (retval) 78 if (retval)
82 return retval; 79 return retval;
83 80
84 retval = add_uevent_var(envp, num_envp, &i, 81 retval = add_uevent_var(env, "OF_TYPE=%s", of->node->type);
85 buffer, buffer_size, &length,
86 "OF_TYPE=%s", of->node->type);
87 if (retval) 82 if (retval)
88 return retval; 83 return retval;
89 84
@@ -93,27 +88,19 @@ static int soundbus_uevent(struct device *dev, char **envp, int num_envp,
93 88
94 compat = of_get_property(of->node, "compatible", &cplen); 89 compat = of_get_property(of->node, "compatible", &cplen);
95 while (compat && cplen > 0) { 90 while (compat && cplen > 0) {
96 int tmp = length; 91 int tmp = env->buflen;
97 retval = add_uevent_var(envp, num_envp, &i, 92 retval = add_uevent_var(env, "OF_COMPATIBLE_%d=%s", seen, compat);
98 buffer, buffer_size, &length,
99 "OF_COMPATIBLE_%d=%s", seen, compat);
100 if (retval) 93 if (retval)
101 return retval; 94 return retval;
102 compat += length - tmp; 95 compat += env->buflen - tmp;
103 cplen -= length - tmp; 96 cplen -= env->buflen - tmp;
104 seen += 1; 97 seen += 1;
105 } 98 }
106 99
107 retval = add_uevent_var(envp, num_envp, &i, 100 retval = add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen);
108 buffer, buffer_size, &length,
109 "OF_COMPATIBLE_N=%d", seen);
110 if (retval) 101 if (retval)
111 return retval; 102 return retval;
112 retval = add_uevent_var(envp, num_envp, &i, 103 retval = add_uevent_var(env, "MODALIAS=%s", soundbus_dev->modalias);
113 buffer, buffer_size, &length,
114 "MODALIAS=%s", soundbus_dev->modalias);
115
116 envp[i] = NULL;
117 104
118 return retval; 105 return retval;
119} 106}