| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for AT73C213 16-bit stereo DAC connected to Atmel SSC |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2006-2007 Atmel Norway |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - * under the terms of the GNU General Public License version 2 as published by |
|---|
| 8 | | - * the Free Software Foundation. |
|---|
| 9 | 6 | */ |
|---|
| 10 | 7 | |
|---|
| 11 | 8 | /*#define DEBUG*/ |
|---|
| .. | .. |
|---|
| 39 | 36 | #define BITRATE_MAX 50000 /* Hardware limit. */ |
|---|
| 40 | 37 | |
|---|
| 41 | 38 | /* Initial (hardware reset) AT73C213 register values. */ |
|---|
| 42 | | -static u8 snd_at73c213_original_image[18] = |
|---|
| 39 | +static const u8 snd_at73c213_original_image[18] = |
|---|
| 43 | 40 | { |
|---|
| 44 | 41 | 0x00, /* 00 - CTRL */ |
|---|
| 45 | 42 | 0x05, /* 01 - LLIG */ |
|---|
| .. | .. |
|---|
| 221 | 218 | runtime->hw = snd_at73c213_playback_hw; |
|---|
| 222 | 219 | chip->substream = substream; |
|---|
| 223 | 220 | |
|---|
| 224 | | - clk_enable(chip->ssc->clk); |
|---|
| 221 | + err = clk_enable(chip->ssc->clk); |
|---|
| 222 | + if (err) |
|---|
| 223 | + return err; |
|---|
| 225 | 224 | |
|---|
| 226 | 225 | return 0; |
|---|
| 227 | 226 | } |
|---|
| .. | .. |
|---|
| 245 | 244 | val = SSC_BFINS(TFMR_DATNB, channels - 1, val); |
|---|
| 246 | 245 | ssc_writel(chip->ssc->regs, TFMR, val); |
|---|
| 247 | 246 | |
|---|
| 248 | | - return snd_pcm_lib_malloc_pages(substream, |
|---|
| 249 | | - params_buffer_bytes(hw_params)); |
|---|
| 250 | | -} |
|---|
| 251 | | - |
|---|
| 252 | | -static int snd_at73c213_pcm_hw_free(struct snd_pcm_substream *substream) |
|---|
| 253 | | -{ |
|---|
| 254 | | - return snd_pcm_lib_free_pages(substream); |
|---|
| 247 | + return 0; |
|---|
| 255 | 248 | } |
|---|
| 256 | 249 | |
|---|
| 257 | 250 | static int snd_at73c213_pcm_prepare(struct snd_pcm_substream *substream) |
|---|
| .. | .. |
|---|
| 325 | 318 | static const struct snd_pcm_ops at73c213_playback_ops = { |
|---|
| 326 | 319 | .open = snd_at73c213_pcm_open, |
|---|
| 327 | 320 | .close = snd_at73c213_pcm_close, |
|---|
| 328 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 329 | 321 | .hw_params = snd_at73c213_pcm_hw_params, |
|---|
| 330 | | - .hw_free = snd_at73c213_pcm_hw_free, |
|---|
| 331 | 322 | .prepare = snd_at73c213_pcm_prepare, |
|---|
| 332 | 323 | .trigger = snd_at73c213_pcm_trigger, |
|---|
| 333 | 324 | .pointer = snd_at73c213_pcm_pointer, |
|---|
| .. | .. |
|---|
| 350 | 341 | |
|---|
| 351 | 342 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &at73c213_playback_ops); |
|---|
| 352 | 343 | |
|---|
| 353 | | - retval = snd_pcm_lib_preallocate_pages_for_all(chip->pcm, |
|---|
| 344 | + snd_pcm_set_managed_buffer_all(chip->pcm, |
|---|
| 354 | 345 | SNDRV_DMA_TYPE_DEV, &chip->ssc->pdev->dev, |
|---|
| 355 | 346 | 64 * 1024, 64 * 1024); |
|---|
| 356 | 347 | out: |
|---|
| .. | .. |
|---|
| 668 | 659 | | (mask << 24) | (invert << 22)) \ |
|---|
| 669 | 660 | } |
|---|
| 670 | 661 | |
|---|
| 671 | | -static struct snd_kcontrol_new snd_at73c213_controls[] = { |
|---|
| 662 | +static const struct snd_kcontrol_new snd_at73c213_controls[] = { |
|---|
| 672 | 663 | AT73C213_STEREO("Master Playback Volume", 0, DAC_LMPG, DAC_RMPG, 0, 0, 0x1f, 1), |
|---|
| 673 | 664 | AT73C213_STEREO("Master Playback Switch", 0, DAC_LMPG, DAC_RMPG, 5, 5, 1, 1), |
|---|
| 674 | 665 | AT73C213_STEREO("PCM Playback Volume", 0, DAC_LLOG, DAC_RLOG, 0, 0, 0x1f, 1), |
|---|
| .. | .. |
|---|
| 787 | 778 | goto out; |
|---|
| 788 | 779 | |
|---|
| 789 | 780 | /* Enable DAC master clock. */ |
|---|
| 790 | | - clk_enable(chip->board->dac_clk); |
|---|
| 781 | + retval = clk_enable(chip->board->dac_clk); |
|---|
| 782 | + if (retval) |
|---|
| 783 | + goto out; |
|---|
| 791 | 784 | |
|---|
| 792 | 785 | /* Initialize at73c213 on SPI bus. */ |
|---|
| 793 | 786 | retval = snd_at73c213_write_reg(chip, DAC_RST, 0x04); |
|---|
| .. | .. |
|---|
| 885 | 878 | static int snd_at73c213_dev_init(struct snd_card *card, |
|---|
| 886 | 879 | struct spi_device *spi) |
|---|
| 887 | 880 | { |
|---|
| 888 | | - static struct snd_device_ops ops = { |
|---|
| 881 | + static const struct snd_device_ops ops = { |
|---|
| 889 | 882 | .dev_free = snd_at73c213_dev_free, |
|---|
| 890 | 883 | }; |
|---|
| 891 | 884 | struct snd_at73c213 *chip = get_chip(card); |
|---|
| .. | .. |
|---|
| 900 | 893 | chip->card = card; |
|---|
| 901 | 894 | chip->irq = -1; |
|---|
| 902 | 895 | |
|---|
| 903 | | - clk_enable(chip->ssc->clk); |
|---|
| 896 | + retval = clk_enable(chip->ssc->clk); |
|---|
| 897 | + if (retval) |
|---|
| 898 | + return retval; |
|---|
| 904 | 899 | |
|---|
| 905 | 900 | retval = request_irq(irq, snd_at73c213_interrupt, 0, "at73c213", chip); |
|---|
| 906 | 901 | if (retval) { |
|---|
| .. | .. |
|---|
| 1019 | 1014 | int retval; |
|---|
| 1020 | 1015 | |
|---|
| 1021 | 1016 | /* Stop playback. */ |
|---|
| 1022 | | - clk_enable(chip->ssc->clk); |
|---|
| 1017 | + retval = clk_enable(chip->ssc->clk); |
|---|
| 1018 | + if (retval) |
|---|
| 1019 | + goto out; |
|---|
| 1023 | 1020 | ssc_writel(chip->ssc->regs, CR, SSC_BIT(CR_TXDIS)); |
|---|
| 1024 | 1021 | clk_disable(chip->ssc->clk); |
|---|
| 1025 | 1022 | |
|---|
| .. | .. |
|---|
| 1099 | 1096 | { |
|---|
| 1100 | 1097 | struct snd_card *card = dev_get_drvdata(dev); |
|---|
| 1101 | 1098 | struct snd_at73c213 *chip = card->private_data; |
|---|
| 1099 | + int retval; |
|---|
| 1102 | 1100 | |
|---|
| 1103 | | - clk_enable(chip->board->dac_clk); |
|---|
| 1104 | | - clk_enable(chip->ssc->clk); |
|---|
| 1101 | + retval = clk_enable(chip->board->dac_clk); |
|---|
| 1102 | + if (retval) |
|---|
| 1103 | + return retval; |
|---|
| 1104 | + retval = clk_enable(chip->ssc->clk); |
|---|
| 1105 | + if (retval) { |
|---|
| 1106 | + clk_disable(chip->board->dac_clk); |
|---|
| 1107 | + return retval; |
|---|
| 1108 | + } |
|---|
| 1105 | 1109 | ssc_writel(chip->ssc->regs, CR, SSC_BIT(CR_TXEN)); |
|---|
| 1106 | 1110 | |
|---|
| 1107 | 1111 | return 0; |
|---|