diff options
author | Eric Rannaud <eric.rannaud@gmail.com> | 2007-03-31 01:23:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-04-27 13:57:29 -0400 |
commit | bf62456eb91f3d2ef0736081583d09b0b3c8b7ea (patch) | |
tree | 851c2559ae11835e19763b7c7c54393f0ae0d5f6 /sound | |
parent | bdc4960a0b4831a24276b65f1f7afdfc57f2f5cf (diff) |
uevent: use add_uevent_var() instead of open coding it
Make use of add_uevent_var() instead of (often incorrectly) open coding it.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Eric Rannaud <eric.rannaud@gmail.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/aoa/soundbus/core.c | 80 |
1 files changed, 32 insertions, 48 deletions
diff --git a/sound/aoa/soundbus/core.c b/sound/aoa/soundbus/core.c index 47b3e3768df0..418a98a10c73 100644 --- a/sound/aoa/soundbus/core.c +++ b/sound/aoa/soundbus/core.c | |||
@@ -61,9 +61,9 @@ static int soundbus_uevent(struct device *dev, char **envp, int num_envp, | |||
61 | { | 61 | { |
62 | struct soundbus_dev * soundbus_dev; | 62 | struct soundbus_dev * soundbus_dev; |
63 | struct of_device * of; | 63 | struct of_device * of; |
64 | char *scratch, *compat, *compat2; | 64 | char *compat; |
65 | int i = 0; | 65 | int retval = 0, i = 0, length = 0; |
66 | int length, cplen, cplen2, seen = 0; | 66 | int cplen, seen = 0; |
67 | 67 | ||
68 | if (!dev) | 68 | if (!dev) |
69 | return -ENODEV; | 69 | return -ENODEV; |
@@ -75,63 +75,47 @@ static int soundbus_uevent(struct device *dev, char **envp, int num_envp, | |||
75 | of = &soundbus_dev->ofdev; | 75 | of = &soundbus_dev->ofdev; |
76 | 76 | ||
77 | /* stuff we want to pass to /sbin/hotplug */ | 77 | /* stuff we want to pass to /sbin/hotplug */ |
78 | envp[i++] = scratch = buffer; | 78 | retval = add_uevent_var(envp, num_envp, &i, |
79 | length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name); | 79 | buffer, buffer_size, &length, |
80 | ++length; | 80 | "OF_NAME=%s", of->node->name); |
81 | buffer_size -= length; | 81 | if (retval) |
82 | if ((buffer_size <= 0) || (i >= num_envp)) | 82 | return retval; |
83 | return -ENOMEM; | 83 | |
84 | scratch += length; | 84 | retval = add_uevent_var(envp, num_envp, &i, |
85 | 85 | buffer, buffer_size, &length, | |
86 | envp[i++] = scratch; | 86 | "OF_TYPE=%s", of->node->type); |
87 | length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type); | 87 | if (retval) |
88 | ++length; | 88 | return retval; |
89 | buffer_size -= length; | ||
90 | if ((buffer_size <= 0) || (i >= num_envp)) | ||
91 | return -ENOMEM; | ||
92 | scratch += length; | ||
93 | 89 | ||
94 | /* Since the compatible field can contain pretty much anything | 90 | /* Since the compatible field can contain pretty much anything |
95 | * it's not really legal to split it out with commas. We split it | 91 | * it's not really legal to split it out with commas. We split it |
96 | * up using a number of environment variables instead. */ | 92 | * up using a number of environment variables instead. */ |
97 | 93 | ||
98 | compat = (char *) get_property(of->node, "compatible", &cplen); | 94 | compat = (char *) get_property(of->node, "compatible", &cplen); |
99 | compat2 = compat; | ||
100 | cplen2= cplen; | ||
101 | while (compat && cplen > 0) { | 95 | while (compat && cplen > 0) { |
102 | envp[i++] = scratch; | 96 | int tmp = length; |
103 | length = scnprintf (scratch, buffer_size, | 97 | retval = add_uevent_var(envp, num_envp, &i, |
104 | "OF_COMPATIBLE_%d=%s", seen, compat); | 98 | buffer, buffer_size, &length, |
105 | ++length; | 99 | "OF_COMPATIBLE_%d=%s", seen, compat); |
106 | buffer_size -= length; | 100 | if (retval) |
107 | if ((buffer_size <= 0) || (i >= num_envp)) | 101 | return retval; |
108 | return -ENOMEM; | 102 | compat += length - tmp; |
109 | scratch += length; | 103 | cplen -= length - tmp; |
110 | length = strlen (compat) + 1; | 104 | seen += 1; |
111 | compat += length; | ||
112 | cplen -= length; | ||
113 | seen++; | ||
114 | } | 105 | } |
115 | 106 | ||
116 | envp[i++] = scratch; | 107 | retval = add_uevent_var(envp, num_envp, &i, |
117 | length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen); | 108 | buffer, buffer_size, &length, |
118 | ++length; | 109 | "OF_COMPATIBLE_N=%d", seen); |
119 | buffer_size -= length; | 110 | if (retval) |
120 | if ((buffer_size <= 0) || (i >= num_envp)) | 111 | return retval; |
121 | return -ENOMEM; | 112 | retval = add_uevent_var(envp, num_envp, &i, |
122 | scratch += length; | 113 | buffer, buffer_size, &length, |
123 | 114 | "MODALIAS=%s", soundbus_dev->modalias); | |
124 | envp[i++] = scratch; | ||
125 | length = scnprintf (scratch, buffer_size, "MODALIAS=%s", | ||
126 | soundbus_dev->modalias); | ||
127 | |||
128 | buffer_size -= length; | ||
129 | if ((buffer_size <= 0) || (i >= num_envp)) | ||
130 | return -ENOMEM; | ||
131 | 115 | ||
132 | envp[i] = NULL; | 116 | envp[i] = NULL; |
133 | 117 | ||
134 | return 0; | 118 | return retval; |
135 | } | 119 | } |
136 | 120 | ||
137 | static int soundbus_device_remove(struct device *dev) | 121 | static int soundbus_device_remove(struct device *dev) |