aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2014-07-22 10:13:56 -0400
committerTakashi Iwai <tiwai@suse.de>2014-07-22 10:21:54 -0400
commitf77ac91e8edade4755f732d52fa094dc3bfd8b8e (patch)
tree8ba708e922f0dc20e0dfb52bcff26b501c8b7840 /sound
parent5a0438f4a6328b47bd3c00b2f03eb766cc72a75c (diff)
ALSA: bebob: Correction for return value of .put callback
This commit is for correction of my misunderstanding about return value of .put callback in ALSA Control interface. According to 'Writing ALSA Driver' (*1), return value of the callback has three patterns; 1: changed, 0: not changed, an negative value: fatal error. But I misunderstood that it's boolean; zero or nonzero. *1: Writing an ALSA Driver (2005, Takashi Iwai) http://www.alsa-project.org/main/index.php/ALSA_Driver_Documentation Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/firewire/bebob/bebob_maudio.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c
index 42e6f22156f0..d6d6ff8cb8dd 100644
--- a/sound/firewire/bebob/bebob_maudio.c
+++ b/sound/firewire/bebob/bebob_maudio.c
@@ -391,7 +391,10 @@ static int special_clk_ctl_put(struct snd_kcontrol *kctl,
391 params->clk_lock); 391 params->clk_lock);
392 mutex_unlock(&bebob->mutex); 392 mutex_unlock(&bebob->mutex);
393 393
394 return err >= 0; 394 if (err >= 0)
395 err = 1;
396
397 return err;
395} 398}
396static struct snd_kcontrol_new special_clk_ctl = { 399static struct snd_kcontrol_new special_clk_ctl = {
397 .name = "Clock Source", 400 .name = "Clock Source",
@@ -491,14 +494,16 @@ static int special_dig_in_iface_ctl_set(struct snd_kcontrol *kctl,
491 unsigned int id, dig_in_fmt, dig_in_iface; 494 unsigned int id, dig_in_fmt, dig_in_iface;
492 int err; 495 int err;
493 496
494 mutex_lock(&bebob->mutex);
495
496 id = uval->value.enumerated.item[0]; 497 id = uval->value.enumerated.item[0];
498 if (id >= ARRAY_SIZE(special_dig_in_iface_labels))
499 return -EINVAL;
497 500
498 /* decode user value */ 501 /* decode user value */
499 dig_in_fmt = (id >> 1) & 0x01; 502 dig_in_fmt = (id >> 1) & 0x01;
500 dig_in_iface = id & 0x01; 503 dig_in_iface = id & 0x01;
501 504
505 mutex_lock(&bebob->mutex);
506
502 err = avc_maudio_set_special_clk(bebob, 507 err = avc_maudio_set_special_clk(bebob,
503 params->clk_src, 508 params->clk_src,
504 dig_in_fmt, 509 dig_in_fmt,
@@ -508,14 +513,17 @@ static int special_dig_in_iface_ctl_set(struct snd_kcontrol *kctl,
508 goto end; 513 goto end;
509 514
510 /* For ADAT, optical interface is only available. */ 515 /* For ADAT, optical interface is only available. */
511 if (params->dig_in_fmt > 0) 516 if (params->dig_in_fmt > 0) {
517 err = 1;
512 goto end; 518 goto end;
519 }
513 520
514 /* For S/PDIF, optical/coaxial interfaces are selectable. */ 521 /* For S/PDIF, optical/coaxial interfaces are selectable. */
515 err = avc_audio_set_selector(bebob->unit, 0x00, 0x04, dig_in_iface); 522 err = avc_audio_set_selector(bebob->unit, 0x00, 0x04, dig_in_iface);
516 if (err < 0) 523 if (err < 0)
517 dev_err(&bebob->unit->device, 524 dev_err(&bebob->unit->device,
518 "fail to set digital input interface: %d\n", err); 525 "fail to set digital input interface: %d\n", err);
526 err = 1;
519end: 527end:
520 special_stream_formation_set(bebob); 528 special_stream_formation_set(bebob);
521 mutex_unlock(&bebob->mutex); 529 mutex_unlock(&bebob->mutex);
@@ -567,16 +575,20 @@ static int special_dig_out_iface_ctl_set(struct snd_kcontrol *kctl,
567 unsigned int id; 575 unsigned int id;
568 int err; 576 int err;
569 577
570 mutex_lock(&bebob->mutex);
571
572 id = uval->value.enumerated.item[0]; 578 id = uval->value.enumerated.item[0];
579 if (id >= ARRAY_SIZE(special_dig_out_iface_labels))
580 return -EINVAL;
581
582 mutex_lock(&bebob->mutex);
573 583
574 err = avc_maudio_set_special_clk(bebob, 584 err = avc_maudio_set_special_clk(bebob,
575 params->clk_src, 585 params->clk_src,
576 params->dig_in_fmt, 586 params->dig_in_fmt,
577 id, params->clk_lock); 587 id, params->clk_lock);
578 if (err >= 0) 588 if (err >= 0) {
579 special_stream_formation_set(bebob); 589 special_stream_formation_set(bebob);
590 err = 1;
591 }
580 592
581 mutex_unlock(&bebob->mutex); 593 mutex_unlock(&bebob->mutex);
582 return err; 594 return err;