--- zzzz-none-000/linux-3.10.107/sound/atmel/abdac.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/atmel/abdac.c 2021-02-04 17:41:59.000000000 +0000 @@ -9,7 +9,6 @@ */ #include #include -#include #include #include #include @@ -25,6 +24,9 @@ #include #include +#include +#include + /* DAC register offsets */ #define DAC_DATA 0x0000 #define DAC_CTRL 0x0008 @@ -240,7 +242,7 @@ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: /* fall through */ case SNDRV_PCM_TRIGGER_RESUME: /* fall through */ case SNDRV_PCM_TRIGGER_START: - clk_enable(dac->sample_clk); + clk_prepare_enable(dac->sample_clk); retval = dw_dma_cyclic_start(dac->dma.chan); if (retval) goto out; @@ -252,7 +254,7 @@ dw_dma_cyclic_stop(dac->dma.chan); dac_writel(dac, DATA, 0); dac_writel(dac, CTRL, 0); - clk_disable(dac->sample_clk); + clk_disable_unprepare(dac->sample_clk); break; default: retval = -EINVAL; @@ -354,10 +356,11 @@ /* we start at 192 kHz and work our way down to 5112 Hz */ while (new_rate >= RATE_MIN && index < (MAX_NUM_RATES + 1)) { new_rate = clk_round_rate(dac->sample_clk, 256 * new_rate); - if (new_rate < 0) + if (new_rate <= 0) break; /* make sure we are below the ABDAC clock */ - if (new_rate <= clk_get_rate(dac->pclk)) { + if (index < MAX_NUM_RATES && + new_rate <= clk_get_rate(dac->pclk)) { dac->rates[index] = new_rate / 256; index++; } @@ -426,10 +429,11 @@ retval = PTR_ERR(sample_clk); goto out_put_pclk; } - clk_enable(pclk); + clk_prepare_enable(pclk); - retval = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, - THIS_MODULE, sizeof(struct atmel_abdac), &card); + retval = snd_card_new(&pdev->dev, SNDRV_DEFAULT_IDX1, + SNDRV_DEFAULT_STR1, THIS_MODULE, + sizeof(struct atmel_abdac), &card); if (retval) { dev_dbg(&pdev->dev, "could not create sound card device\n"); goto out_put_sample_clk; @@ -466,8 +470,6 @@ goto out_unmap_regs; } - snd_card_set_dev(card, &pdev->dev); - if (pdata->dws.dma_dev) { dma_cap_mask_t mask; @@ -491,7 +493,7 @@ if (!pdata->dws.dma_dev || !dac->dma.chan) { dev_dbg(&pdev->dev, "DMA not available\n"); retval = -ENODEV; - goto out_unset_card_dev; + goto out_unmap_regs; } strcpy(card->driver, "Atmel ABDAC"); @@ -520,16 +522,13 @@ out_release_dma: dma_release_channel(dac->dma.chan); dac->dma.chan = NULL; -out_unset_card_dev: - snd_card_set_dev(card, NULL); - free_irq(irq, dac); out_unmap_regs: iounmap(dac->regs); out_free_card: snd_card_free(card); out_put_sample_clk: clk_put(sample_clk); - clk_disable(pclk); + clk_disable_unprepare(pclk); out_put_pclk: clk_put(pclk); return retval; @@ -542,8 +541,8 @@ struct atmel_abdac *dac = card->private_data; dw_dma_cyclic_stop(dac->dma.chan); - clk_disable(dac->sample_clk); - clk_disable(dac->pclk); + clk_disable_unprepare(dac->sample_clk); + clk_disable_unprepare(dac->pclk); return 0; } @@ -553,8 +552,8 @@ struct snd_card *card = dev_get_drvdata(pdev); struct atmel_abdac *dac = card->private_data; - clk_enable(dac->pclk); - clk_enable(dac->sample_clk); + clk_prepare_enable(dac->pclk); + clk_prepare_enable(dac->sample_clk); if (test_bit(DMA_READY, &dac->flags)) dw_dma_cyclic_start(dac->dma.chan); @@ -573,12 +572,11 @@ struct atmel_abdac *dac = get_dac(card); clk_put(dac->sample_clk); - clk_disable(dac->pclk); + clk_disable_unprepare(dac->pclk); clk_put(dac->pclk); dma_release_channel(dac->dma.chan); dac->dma.chan = NULL; - snd_card_set_dev(card, NULL); iounmap(dac->regs); free_irq(dac->irq, dac); snd_card_free(card); @@ -590,7 +588,6 @@ .remove = atmel_abdac_remove, .driver = { .name = "atmel_abdac", - .owner = THIS_MODULE, .pm = ATMEL_ABDAC_PM_OPS, }, };