[ALSA] Remove vmalloc wrapper, kfree_nocheck()
[linux-2.6.git] / sound / isa / ad1816a / ad1816a_lib.c
index 625b2ef..7ae0239 100644 (file)
@@ -234,7 +234,7 @@ static int snd_ad1816a_playback_prepare(snd_pcm_substream_t *substream)
        ad1816a_t *chip = snd_pcm_substream_chip(substream);
        unsigned long flags;
        snd_pcm_runtime_t *runtime = substream->runtime;
-       unsigned int size;
+       unsigned int size, rate;
 
        spin_lock_irqsave(&chip->lock, flags);
 
@@ -245,7 +245,10 @@ static int snd_ad1816a_playback_prepare(snd_pcm_substream_t *substream)
        snd_dma_program(chip->dma1, runtime->dma_addr, size,
                        DMA_MODE_WRITE | DMA_AUTOINIT);
 
-       snd_ad1816a_write(chip, AD1816A_PLAYBACK_SAMPLE_RATE, runtime->rate);
+       rate = runtime->rate;
+       if (chip->clock_freq)
+               rate = (rate * 33000) / chip->clock_freq;
+       snd_ad1816a_write(chip, AD1816A_PLAYBACK_SAMPLE_RATE, rate);
        snd_ad1816a_out_mask(chip, AD1816A_PLAYBACK_CONFIG,
                AD1816A_FMT_ALL | AD1816A_FMT_STEREO,
                snd_ad1816a_get_format(chip, runtime->format,
@@ -263,7 +266,7 @@ static int snd_ad1816a_capture_prepare(snd_pcm_substream_t *substream)
        ad1816a_t *chip = snd_pcm_substream_chip(substream);
        unsigned long flags;
        snd_pcm_runtime_t *runtime = substream->runtime;
-       unsigned int size;
+       unsigned int size, rate;
 
        spin_lock_irqsave(&chip->lock, flags);
 
@@ -274,7 +277,10 @@ static int snd_ad1816a_capture_prepare(snd_pcm_substream_t *substream)
        snd_dma_program(chip->dma2, runtime->dma_addr, size,
                        DMA_MODE_READ | DMA_AUTOINIT);
 
-       snd_ad1816a_write(chip, AD1816A_CAPTURE_SAMPLE_RATE, runtime->rate);
+       rate = runtime->rate;
+       if (chip->clock_freq)
+               rate = (rate * 33000) / chip->clock_freq;
+       snd_ad1816a_write(chip, AD1816A_CAPTURE_SAMPLE_RATE, rate);
        snd_ad1816a_out_mask(chip, AD1816A_CAPTURE_CONFIG,
                AD1816A_FMT_ALL | AD1816A_FMT_STEREO,
                snd_ad1816a_get_format(chip, runtime->format,
@@ -536,10 +542,7 @@ static int snd_ad1816a_probe(ad1816a_t *chip)
 
 static int snd_ad1816a_free(ad1816a_t *chip)
 {
-       if (chip->res_port) {
-               release_resource(chip->res_port);
-               kfree_nocheck(chip->res_port);
-       }
+       release_and_free_resource(chip->res_port);
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *) chip);
        if (chip->dma1 >= 0) {
@@ -585,7 +588,7 @@ int snd_ad1816a_create(snd_card_t *card,
 
        *rchip = NULL;
 
-       chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
+       chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (chip == NULL)
                return -ENOMEM;
        chip->irq = -1;