hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/core/oss/mixer_oss.c
....@@ -1,22 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * OSS emulation layer for the mixer interface
34 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4
- *
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- *
205 */
216
227 #include <linux/init.h>
....@@ -524,7 +509,7 @@
524509 unsigned int channels;
525510 unsigned int numid[SNDRV_MIXER_OSS_ITEM_COUNT];
526511 unsigned int capture_item;
527
- struct snd_mixer_oss_assign_table *assigned;
512
+ const struct snd_mixer_oss_assign_table *assigned;
528513 unsigned int allocated: 1;
529514 };
530515
....@@ -972,8 +957,8 @@
972957 struct slot *p = chn->private_data;
973958 if (p) {
974959 if (p->allocated && p->assigned) {
975
- kfree(p->assigned->name);
976
- kfree(p->assigned);
960
+ kfree_const(p->assigned->name);
961
+ kfree_const(p->assigned);
977962 }
978963 kfree(p);
979964 }
....@@ -991,7 +976,7 @@
991976 /* In a separate function to keep gcc 3.2 happy - do NOT merge this in
992977 snd_mixer_oss_build_input! */
993978 static int snd_mixer_oss_build_test_all(struct snd_mixer_oss *mixer,
994
- struct snd_mixer_oss_assign_table *ptr,
979
+ const struct snd_mixer_oss_assign_table *ptr,
995980 struct slot *slot)
996981 {
997982 char str[64];
....@@ -1055,7 +1040,9 @@
10551040 * ptr_allocated means the entry is dynamically allocated (change via proc file).
10561041 * when replace_old = 1, the old entry is replaced with the new one.
10571042 */
1058
-static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, struct snd_mixer_oss_assign_table *ptr, int ptr_allocated, int replace_old)
1043
+static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer,
1044
+ const struct snd_mixer_oss_assign_table *ptr,
1045
+ int ptr_allocated, int replace_old)
10591046 {
10601047 struct slot slot;
10611048 struct slot *pslot;
....@@ -1145,7 +1132,7 @@
11451132 /*
11461133 */
11471134 #define MIXER_VOL(name) [SOUND_MIXER_##name] = #name
1148
-static char *oss_mixer_names[SNDRV_OSS_MAX_MIXERS] = {
1135
+static const char * const oss_mixer_names[SNDRV_OSS_MAX_MIXERS] = {
11491136 MIXER_VOL(VOLUME),
11501137 MIXER_VOL(BASS),
11511138 MIXER_VOL(TREBLE),
....@@ -1293,7 +1280,7 @@
12931280
12941281 static void snd_mixer_oss_build(struct snd_mixer_oss *mixer)
12951282 {
1296
- static struct snd_mixer_oss_assign_table table[] = {
1283
+ static const struct snd_mixer_oss_assign_table table[] = {
12971284 { SOUND_MIXER_VOLUME, "Master", 0 },
12981285 { SOUND_MIXER_VOLUME, "Front", 0 }, /* fallback */
12991286 { SOUND_MIXER_BASS, "Tone Control - Bass", 0 },
....@@ -1426,24 +1413,32 @@
14261413
14271414 static int __init alsa_mixer_oss_init(void)
14281415 {
1416
+ struct snd_card *card;
14291417 int idx;
14301418
14311419 snd_mixer_oss_notify_callback = snd_mixer_oss_notify_handler;
14321420 for (idx = 0; idx < SNDRV_CARDS; idx++) {
1433
- if (snd_cards[idx])
1434
- snd_mixer_oss_notify_handler(snd_cards[idx], SND_MIXER_OSS_NOTIFY_REGISTER);
1421
+ card = snd_card_ref(idx);
1422
+ if (card) {
1423
+ snd_mixer_oss_notify_handler(card, SND_MIXER_OSS_NOTIFY_REGISTER);
1424
+ snd_card_unref(card);
1425
+ }
14351426 }
14361427 return 0;
14371428 }
14381429
14391430 static void __exit alsa_mixer_oss_exit(void)
14401431 {
1432
+ struct snd_card *card;
14411433 int idx;
14421434
14431435 snd_mixer_oss_notify_callback = NULL;
14441436 for (idx = 0; idx < SNDRV_CARDS; idx++) {
1445
- if (snd_cards[idx])
1446
- snd_mixer_oss_notify_handler(snd_cards[idx], SND_MIXER_OSS_NOTIFY_FREE);
1437
+ card = snd_card_ref(idx);
1438
+ if (card) {
1439
+ snd_mixer_oss_notify_handler(card, SND_MIXER_OSS_NOTIFY_FREE);
1440
+ snd_card_unref(card);
1441
+ }
14471442 }
14481443 }
14491444