12 #include <linux/slab.h>
13 #include <linux/export.h>
71 for (ch = 0; ch < slave->
info.count; ch++)
72 slave->
vals[ch] = uctl->
value.integer.value[ch];
78 static int slave_init(
struct link_slave *slave)
83 if (slave->
info.count) {
86 return slave_update(slave);
101 if (slave->
info.count > 2 ||
112 return slave_update(slave);
120 if (master->
info.count)
124 int err = slave_init(slave);
128 master->
info.count = 1;
130 master->
val = master->
info.max_val;
138 static int slave_get_val(
struct link_slave *slave,
143 err = slave_init(slave);
146 for (ch = 0; ch < slave->
info.count; ch++)
147 ucontrol->
value.integer.value[ch] = slave->
vals[ch];
151 static int slave_put_val(
struct link_slave *slave,
156 err = master_init(slave->
master);
160 switch (slave->
info.type) {
162 for (ch = 0; ch < slave->
info.count; ch++)
163 ucontrol->
value.integer.value[ch] &=
167 for (ch = 0; ch < slave->
info.count; ch++) {
169 vol = ucontrol->
value.integer.value[ch];
170 vol += slave->
master->val - slave->
master->info.max_val;
171 if (vol < slave->
info.min_val)
172 vol = slave->
info.min_val;
173 else if (vol > slave->
info.max_val)
174 vol = slave->
info.max_val;
175 ucontrol->
value.integer.value[ch] =
vol;
179 return slave->
slave.put(&slave->
slave, ucontrol);
189 return slave->
slave.info(&slave->
slave, uinfo);
196 return slave_get_val(slave, ucontrol);
205 err = slave_init(slave);
208 for (ch = 0; ch < slave->
info.count; ch++) {
209 if (slave->
vals[ch] != ucontrol->
value.integer.value[ch]) {
211 slave->
vals[ch] = ucontrol->
value.integer.value[ch];
216 return slave_put_val(slave, ucontrol);
220 int op_flag,
unsigned int size,
221 unsigned int __user *
tlv)
225 return slave->
slave.tlv.c(&slave->
slave, op_flag, size, tlv);
231 if (slave->
slave.private_free)
256 srec = kzalloc(
sizeof(*srec) +
263 srec->
master = master_link;
267 slave->
info = slave_info;
268 slave->
get = slave_get;
269 slave->
put = slave_put;
271 slave->
tlv.
c = slave_tlv_cmd;
289 ret = master_init(master);
303 int err = master_init(master);
306 ucontrol->
value.integer.value[0] = master->
val;
318 err = master_init(master);
321 old_val = master->
val;
322 if (ucontrol->
value.integer.value[0] == old_val)
329 master->
val = old_val;
331 slave_get_val(slave, uval);
332 master->
val = ucontrol->
value.integer.value[0];
333 slave_put_val(slave, uval);
336 if (master->
hook && !err)
352 sctl->
count *
sizeof(*sctl->
vd));
377 const unsigned int *tlv)
383 memset(&knew, 0,
sizeof(knew));
386 knew.
info = master_info;
388 master = kzalloc(
sizeof(*master),
GFP_KERNEL);
391 INIT_LIST_HEAD(&master->
slaves);
399 kctl->
info = master_info;
400 kctl->
get = master_get;
401 kctl->
put = master_put;