aboutsummaryrefslogtreecommitdiffstats
path: root/sound/aoa/soundbus
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-04-29 22:38:01 -0400
committerPaul Mackerras <paulus@samba.org>2007-04-29 22:38:01 -0400
commit49e1900d4cc2e7bcecb681fe60f0990bec2dcce8 (patch)
tree253801ebf57e0a23856a2c7be129c2c178f62fdf /sound/aoa/soundbus
parent34f6d749c0a328817d5e36274e53121c1db734dc (diff)
parentb9099ff63c75216d6ca10bce5a1abcd9293c27e6 (diff)
Merge branch 'linux-2.6' into for-2.6.22
Diffstat (limited to 'sound/aoa/soundbus')
-rw-r--r--sound/aoa/soundbus/core.c77
1 files changed, 31 insertions, 46 deletions
diff --git a/sound/aoa/soundbus/core.c b/sound/aoa/soundbus/core.c
index 6f004f70e308..8b2e9b905cda 100644
--- a/sound/aoa/soundbus/core.c
+++ b/sound/aoa/soundbus/core.c
@@ -61,10 +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;
65 const char *compat; 64 const char *compat;
66 int i = 0; 65 int retval = 0, i = 0, length = 0;
67 int length, cplen, seen = 0; 66 int cplen, seen = 0;
68 67
69 if (!dev) 68 if (!dev)
70 return -ENODEV; 69 return -ENODEV;
@@ -76,21 +75,17 @@ static int soundbus_uevent(struct device *dev, char **envp, int num_envp,
76 of = &soundbus_dev->ofdev; 75 of = &soundbus_dev->ofdev;
77 76
78 /* stuff we want to pass to /sbin/hotplug */ 77 /* stuff we want to pass to /sbin/hotplug */
79 envp[i++] = scratch = buffer; 78 retval = add_uevent_var(envp, num_envp, &i,
80 length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name); 79 buffer, buffer_size, &length,
81 ++length; 80 "OF_NAME=%s", of->node->name);
82 buffer_size -= length; 81 if (retval)
83 if ((buffer_size <= 0) || (i >= num_envp)) 82 return retval;
84 return -ENOMEM; 83
85 scratch += length; 84 retval = add_uevent_var(envp, num_envp, &i,
86 85 buffer, buffer_size, &length,
87 envp[i++] = scratch; 86 "OF_TYPE=%s", of->node->type);
88 length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type); 87 if (retval)
89 ++length; 88 return retval;
90 buffer_size -= length;
91 if ((buffer_size <= 0) || (i >= num_envp))
92 return -ENOMEM;
93 scratch += length;
94 89
95 /* Since the compatible field can contain pretty much anything 90 /* Since the compatible field can contain pretty much anything
96 * 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
@@ -98,39 +93,29 @@ static int soundbus_uevent(struct device *dev, char **envp, int num_envp,
98 93
99 compat = of_get_property(of->node, "compatible", &cplen); 94 compat = of_get_property(of->node, "compatible", &cplen);
100 while (compat && cplen > 0) { 95 while (compat && cplen > 0) {
101 envp[i++] = scratch; 96 int tmp = length;
102 length = scnprintf (scratch, buffer_size, 97 retval = add_uevent_var(envp, num_envp, &i,
103 "OF_COMPATIBLE_%d=%s", seen, compat); 98 buffer, buffer_size, &length,
104 ++length; 99 "OF_COMPATIBLE_%d=%s", seen, compat);
105 buffer_size -= length; 100 if (retval)
106 if ((buffer_size <= 0) || (i >= num_envp)) 101 return retval;
107 return -ENOMEM; 102 compat += length - tmp;
108 scratch += length; 103 cplen -= length - tmp;
109 length = strlen (compat) + 1; 104 seen += 1;
110 compat += length;
111 cplen -= length;
112 seen++;
113 } 105 }
114 106
115 envp[i++] = scratch; 107 retval = add_uevent_var(envp, num_envp, &i,
116 length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen); 108 buffer, buffer_size, &length,
117 ++length; 109 "OF_COMPATIBLE_N=%d", seen);
118 buffer_size -= length; 110 if (retval)
119 if ((buffer_size <= 0) || (i >= num_envp)) 111 return retval;
120 return -ENOMEM; 112 retval = add_uevent_var(envp, num_envp, &i,
121 scratch += length; 113 buffer, buffer_size, &length,
122 114 "MODALIAS=%s", soundbus_dev->modalias);
123 envp[i++] = scratch;
124 length = scnprintf (scratch, buffer_size, "MODALIAS=%s",
125 soundbus_dev->modalias);
126
127 buffer_size -= length;
128 if ((buffer_size <= 0) || (i >= num_envp))
129 return -ENOMEM;
130 115
131 envp[i] = NULL; 116 envp[i] = NULL;
132 117
133 return 0; 118 return retval;
134} 119}
135 120
136static int soundbus_device_remove(struct device *dev) 121static int soundbus_device_remove(struct device *dev)