aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ice1712/ice1724.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-05-06 11:18:34 -0400
committerTakashi Iwai <tiwai@suse.de>2009-05-06 11:18:34 -0400
commit92d71005e2f305d6dca126d8b8497e885b842dba (patch)
tree9ad3020f747cd64d8768e6dc1c18e43f03e62a03 /sound/pci/ice1712/ice1724.c
parent413f81eba35d6ede9289b0c8a920c013a84fac71 (diff)
ALSA: ice1724 - Check error in set_rate function
The set_rate might return error but the current code doesn't check it. This patch adds a proper error check. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/ice1712/ice1724.c')
-rw-r--r--sound/pci/ice1712/ice1724.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 128510e77a78..5c5ef7fa3e83 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -626,7 +626,7 @@ static unsigned char stdclock_set_mclk(struct snd_ice1712 *ice,
626 return 0; 626 return 0;
627} 627}
628 628
629static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, 629static int snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
630 int force) 630 int force)
631{ 631{
632 unsigned long flags; 632 unsigned long flags;
@@ -634,17 +634,18 @@ static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
634 unsigned int i, old_rate; 634 unsigned int i, old_rate;
635 635
636 if (rate > ice->hw_rates->list[ice->hw_rates->count - 1]) 636 if (rate > ice->hw_rates->list[ice->hw_rates->count - 1])
637 return; 637 return -EINVAL;
638
638 spin_lock_irqsave(&ice->reg_lock, flags); 639 spin_lock_irqsave(&ice->reg_lock, flags);
639 if ((inb(ICEMT1724(ice, DMA_CONTROL)) & DMA_STARTS) || 640 if ((inb(ICEMT1724(ice, DMA_CONTROL)) & DMA_STARTS) ||
640 (inb(ICEMT1724(ice, DMA_PAUSE)) & DMA_PAUSES)) { 641 (inb(ICEMT1724(ice, DMA_PAUSE)) & DMA_PAUSES)) {
641 /* running? we cannot change the rate now... */ 642 /* running? we cannot change the rate now... */
642 spin_unlock_irqrestore(&ice->reg_lock, flags); 643 spin_unlock_irqrestore(&ice->reg_lock, flags);
643 return; 644 return -EBUSY;
644 } 645 }
645 if (!force && is_pro_rate_locked(ice)) { 646 if (!force && is_pro_rate_locked(ice)) {
646 spin_unlock_irqrestore(&ice->reg_lock, flags); 647 spin_unlock_irqrestore(&ice->reg_lock, flags);
647 return; 648 return (rate == ice->cur_rate) ? 0 : -EBUSY;
648 } 649 }
649 650
650 old_rate = ice->get_rate(ice); 651 old_rate = ice->get_rate(ice);
@@ -652,7 +653,7 @@ static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
652 ice->set_rate(ice, rate); 653 ice->set_rate(ice, rate);
653 else if (rate == ice->cur_rate) { 654 else if (rate == ice->cur_rate) {
654 spin_unlock_irqrestore(&ice->reg_lock, flags); 655 spin_unlock_irqrestore(&ice->reg_lock, flags);
655 return; 656 return 0;
656 } 657 }
657 658
658 ice->cur_rate = rate; 659 ice->cur_rate = rate;
@@ -674,13 +675,15 @@ static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate,
674 } 675 }
675 if (ice->spdif.ops.setup_rate) 676 if (ice->spdif.ops.setup_rate)
676 ice->spdif.ops.setup_rate(ice, rate); 677 ice->spdif.ops.setup_rate(ice, rate);
678
679 return 0;
677} 680}
678 681
679static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream, 682static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
680 struct snd_pcm_hw_params *hw_params) 683 struct snd_pcm_hw_params *hw_params)
681{ 684{
682 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); 685 struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
683 int i, chs; 686 int i, chs, err;
684 687
685 chs = params_channels(hw_params); 688 chs = params_channels(hw_params);
686 mutex_lock(&ice->open_mutex); 689 mutex_lock(&ice->open_mutex);
@@ -715,7 +718,11 @@ static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream,
715 } 718 }
716 } 719 }
717 mutex_unlock(&ice->open_mutex); 720 mutex_unlock(&ice->open_mutex);
718 snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0); 721
722 err = snd_vt1724_set_pro_rate(ice, params_rate(hw_params), 0);
723 if (err < 0)
724 return err;
725
719 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 726 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
720} 727}
721 728