diff options
author | Daniel Mack <daniel@caiaq.de> | 2008-11-27 02:21:05 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-11-27 02:21:05 -0500 |
commit | 12666f050b3b4b122f61ef12707f33fadb4a78b5 (patch) | |
tree | 7858eb3da39b1393b27425ef0494523ea032cdc3 /sound/usb | |
parent | bc4a68fed4b4c01005ef3c71ede6a8cbe91b7dc9 (diff) |
ALSA: snd-usb-caiaq: clean up the control adding code
snd-usb-caiaq: clean up the control adding code by moving dulpicate code
to a function.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/caiaq/caiaq-control.c | 73 | ||||
-rw-r--r-- | sound/usb/caiaq/caiaq-device.c | 2 |
2 files changed, 31 insertions, 44 deletions
diff --git a/sound/usb/caiaq/caiaq-control.c b/sound/usb/caiaq/caiaq-control.c index 798ca124da58..ccd763dd7167 100644 --- a/sound/usb/caiaq/caiaq-control.c +++ b/sound/usb/caiaq/caiaq-control.c | |||
@@ -247,69 +247,56 @@ static struct caiaq_controller a8dj_controller[] = { | |||
247 | { "Software lock", 40 } | 247 | { "Software lock", 40 } |
248 | }; | 248 | }; |
249 | 249 | ||
250 | int __devinit snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev) | 250 | static int __devinit add_controls(struct caiaq_controller *c, int num, |
251 | struct snd_usb_caiaqdev *dev) | ||
251 | { | 252 | { |
252 | int i; | 253 | int i, ret; |
253 | struct snd_kcontrol *kc; | 254 | struct snd_kcontrol *kc; |
254 | 255 | ||
256 | for (i = 0; i < num; i++, c++) { | ||
257 | kcontrol_template.name = c->name; | ||
258 | kcontrol_template.private_value = c->index; | ||
259 | kc = snd_ctl_new1(&kcontrol_template, dev); | ||
260 | ret = snd_ctl_add(dev->chip.card, kc); | ||
261 | if (ret < 0) | ||
262 | return ret; | ||
263 | } | ||
264 | |||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | int __devinit snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev) | ||
269 | { | ||
270 | int ret = 0; | ||
271 | |||
255 | switch (dev->chip.usb_id) { | 272 | switch (dev->chip.usb_id) { |
256 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 273 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
257 | for (i = 0; i < ARRAY_SIZE(ak1_controller); i++) { | 274 | ret = add_controls(ak1_controller, |
258 | struct caiaq_controller *c = ak1_controller + i; | 275 | ARRAY_SIZE(ak1_controller), dev); |
259 | kcontrol_template.name = c->name; | ||
260 | kcontrol_template.private_value = c->index; | ||
261 | kc = snd_ctl_new1(&kcontrol_template, dev); | ||
262 | snd_ctl_add(dev->chip.card, kc); | ||
263 | } | ||
264 | |||
265 | break; | 276 | break; |
266 | 277 | ||
267 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 278 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
268 | for (i = 0; i < ARRAY_SIZE(rk2_controller); i++) { | 279 | ret = add_controls(rk2_controller, |
269 | struct caiaq_controller *c = rk2_controller + i; | 280 | ARRAY_SIZE(rk2_controller), dev); |
270 | kcontrol_template.name = c->name; | ||
271 | kcontrol_template.private_value = c->index; | ||
272 | kc = snd_ctl_new1(&kcontrol_template, dev); | ||
273 | snd_ctl_add(dev->chip.card, kc); | ||
274 | } | ||
275 | |||
276 | break; | 281 | break; |
277 | 282 | ||
278 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 283 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
279 | for (i = 0; i < ARRAY_SIZE(rk3_controller); i++) { | 284 | ret = add_controls(rk3_controller, |
280 | struct caiaq_controller *c = rk3_controller + i; | 285 | ARRAY_SIZE(rk3_controller), dev); |
281 | kcontrol_template.name = c->name; | ||
282 | kcontrol_template.private_value = c->index; | ||
283 | kc = snd_ctl_new1(&kcontrol_template, dev); | ||
284 | snd_ctl_add(dev->chip.card, kc); | ||
285 | } | ||
286 | |||
287 | break; | 286 | break; |
288 | 287 | ||
289 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | 288 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): |
290 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): | 289 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): |
291 | for (i = 0; i < ARRAY_SIZE(kore_controller); i++) { | 290 | ret = add_controls(kore_controller, |
292 | struct caiaq_controller *c = kore_controller + i; | 291 | ARRAY_SIZE(kore_controller), dev); |
293 | kcontrol_template.name = c->name; | ||
294 | kcontrol_template.private_value = c->index; | ||
295 | kc = snd_ctl_new1(&kcontrol_template, dev); | ||
296 | snd_ctl_add(dev->chip.card, kc); | ||
297 | } | ||
298 | |||
299 | break; | 292 | break; |
300 | 293 | ||
301 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 294 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
302 | for (i = 0; i < ARRAY_SIZE(a8dj_controller); i++) { | 295 | ret = add_controls(a8dj_controller, |
303 | struct caiaq_controller *c = a8dj_controller + i; | 296 | ARRAY_SIZE(a8dj_controller), dev); |
304 | kcontrol_template.name = c->name; | ||
305 | kcontrol_template.private_value = c->index; | ||
306 | kc = snd_ctl_new1(&kcontrol_template, dev); | ||
307 | snd_ctl_add(dev->chip.card, kc); | ||
308 | } | ||
309 | |||
310 | break; | 297 | break; |
311 | } | 298 | } |
312 | 299 | ||
313 | return 0; | 300 | return ret; |
314 | } | 301 | } |
315 | 302 | ||
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c index 83175083e50f..b143ef7152f7 100644 --- a/sound/usb/caiaq/caiaq-device.c +++ b/sound/usb/caiaq/caiaq-device.c | |||
@@ -42,7 +42,7 @@ | |||
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); | 44 | MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); |
45 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.8"); | 45 | MODULE_DESCRIPTION("caiaq USB audio, version 1.3.9"); |
46 | MODULE_LICENSE("GPL"); | 46 | MODULE_LICENSE("GPL"); |
47 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," | 47 | MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2}," |
48 | "{Native Instruments, RigKontrol3}," | 48 | "{Native Instruments, RigKontrol3}," |