hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/sound/pci/ac97/ac97_codec.c
....@@ -1,25 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
34 * Universal interface for Audio Codec '97
45 *
56 * For more details look to AC '97 component specification revision 2.2
67 * by Intel Corporation (http://developer.intel.com).
7
- *
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
- *
238 */
249
2510 #include <linux/delay.h>
....@@ -233,11 +218,11 @@
233218 case AC97_ID_ST_AC97_ID4:
234219 if (reg == 0x08)
235220 return 0;
236
- /* fall through */
221
+ fallthrough;
237222 case AC97_ID_ST7597:
238223 if (reg == 0x22 || reg == 0x7a)
239224 return 1;
240
- /* fall through */
225
+ fallthrough;
241226 case AC97_ID_AK4540:
242227 case AC97_ID_AK4542:
243228 if (reg <= 0x1c || reg == 0x20 || reg == 0x26 || reg >= 0x7c)
....@@ -611,11 +596,6 @@
611596 return err;
612597 }
613598
614
-static const struct snd_kcontrol_new snd_ac97_controls_master_mono[2] = {
615
-AC97_SINGLE("Master Mono Playback Switch", AC97_MASTER_MONO, 15, 1, 1),
616
-AC97_SINGLE("Master Mono Playback Volume", AC97_MASTER_MONO, 0, 31, 1)
617
-};
618
-
619599 static const struct snd_kcontrol_new snd_ac97_controls_tone[2] = {
620600 AC97_SINGLE("Tone Control - Bass", AC97_MASTER_TONE, 8, 15, 1),
621601 AC97_SINGLE("Tone Control - Treble", AC97_MASTER_TONE, 0, 15, 1)
....@@ -958,8 +938,8 @@
958938 int codec = kcontrol->private_value & 3;
959939
960940 mutex_lock(&ac97->page_mutex);
961
- ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31);
962
- ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31);
941
+ ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31);
942
+ ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31);
963943 mutex_unlock(&ac97->page_mutex);
964944 return 0;
965945 }
....@@ -1773,10 +1753,10 @@
17731753 {
17741754 unsigned int result = 0;
17751755 int i;
1776
- static unsigned short ctl_bits[] = {
1756
+ static const unsigned short ctl_bits[] = {
17771757 AC97_SC_SPSR_44K, AC97_SC_SPSR_32K, AC97_SC_SPSR_48K
17781758 };
1779
- static unsigned int rate_bits[] = {
1759
+ static const unsigned int rate_bits[] = {
17801760 SNDRV_PCM_RATE_44100, SNDRV_PCM_RATE_32000, SNDRV_PCM_RATE_48000
17811761 };
17821762
....@@ -1914,12 +1894,13 @@
19141894 *
19151895 * Return: Zero if successful, or a negative error code on failure.
19161896 */
1917
-int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
1897
+int snd_ac97_bus(struct snd_card *card, int num,
1898
+ const struct snd_ac97_bus_ops *ops,
19181899 void *private_data, struct snd_ac97_bus **rbus)
19191900 {
19201901 int err;
19211902 struct snd_ac97_bus *bus;
1922
- static struct snd_device_ops dev_ops = {
1903
+ static const struct snd_device_ops dev_ops = {
19231904 .dev_free = snd_ac97_bus_dev_free,
19241905 };
19251906
....@@ -1965,6 +1946,7 @@
19651946 snd_ac97_get_short_name(ac97));
19661947 if ((err = device_register(&ac97->dev)) < 0) {
19671948 ac97_err(ac97, "Can't register ac97 bus\n");
1949
+ put_device(&ac97->dev);
19681950 ac97->dev.bus = NULL;
19691951 return err;
19701952 }
....@@ -2019,7 +2001,7 @@
20192001 unsigned long end_time;
20202002 unsigned int reg;
20212003 const struct ac97_codec_id *pid;
2022
- static struct snd_device_ops ops = {
2004
+ static const struct snd_device_ops ops = {
20232005 .dev_free = snd_ac97_dev_free,
20242006 .dev_register = snd_ac97_dev_register,
20252007 .dev_disconnect = snd_ac97_dev_disconnect,
....@@ -2365,7 +2347,7 @@
23652347
23662348 enum { PWIDX_ADC, PWIDX_FRONT, PWIDX_CLFE, PWIDX_SURR, PWIDX_MIC, PWIDX_SIZE };
23672349
2368
-static struct ac97_power_reg power_regs[PWIDX_SIZE] = {
2350
+static const struct ac97_power_reg power_regs[PWIDX_SIZE] = {
23692351 [PWIDX_ADC] = { AC97_PCM_LR_ADC_RATE, AC97_POWERDOWN, AC97_PD_PR0},
23702352 [PWIDX_FRONT] = { AC97_PCM_FRONT_DAC_RATE, AC97_POWERDOWN, AC97_PD_PR1},
23712353 [PWIDX_CLFE] = { AC97_PCM_LFE_DAC_RATE, AC97_EXTENDED_STATUS,
....@@ -2848,7 +2830,7 @@
28482830 int (*func)(struct snd_ac97 *);
28492831 };
28502832
2851
-static struct quirk_table applicable_quirks[] = {
2833
+static const struct quirk_table applicable_quirks[] = {
28522834 { "none", NULL },
28532835 { "hp_only", tune_hp_only },
28542836 { "swap_hp", tune_swap_hp },
....@@ -2876,7 +2858,7 @@
28762858 static int apply_quirk_str(struct snd_ac97 *ac97, const char *typestr)
28772859 {
28782860 int i;
2879
- struct quirk_table *q;
2861
+ const struct quirk_table *q;
28802862
28812863 for (i = 0; i < ARRAY_SIZE(applicable_quirks); i++) {
28822864 q = &applicable_quirks[i];