.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * OSS emulation layer for the mixer interface |
---|
3 | 4 | * 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 | | - * |
---|
20 | 5 | */ |
---|
21 | 6 | |
---|
22 | 7 | #include <linux/init.h> |
---|
.. | .. |
---|
524 | 509 | unsigned int channels; |
---|
525 | 510 | unsigned int numid[SNDRV_MIXER_OSS_ITEM_COUNT]; |
---|
526 | 511 | unsigned int capture_item; |
---|
527 | | - struct snd_mixer_oss_assign_table *assigned; |
---|
| 512 | + const struct snd_mixer_oss_assign_table *assigned; |
---|
528 | 513 | unsigned int allocated: 1; |
---|
529 | 514 | }; |
---|
530 | 515 | |
---|
.. | .. |
---|
972 | 957 | struct slot *p = chn->private_data; |
---|
973 | 958 | if (p) { |
---|
974 | 959 | 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); |
---|
977 | 962 | } |
---|
978 | 963 | kfree(p); |
---|
979 | 964 | } |
---|
.. | .. |
---|
991 | 976 | /* In a separate function to keep gcc 3.2 happy - do NOT merge this in |
---|
992 | 977 | snd_mixer_oss_build_input! */ |
---|
993 | 978 | 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, |
---|
995 | 980 | struct slot *slot) |
---|
996 | 981 | { |
---|
997 | 982 | char str[64]; |
---|
.. | .. |
---|
1055 | 1040 | * ptr_allocated means the entry is dynamically allocated (change via proc file). |
---|
1056 | 1041 | * when replace_old = 1, the old entry is replaced with the new one. |
---|
1057 | 1042 | */ |
---|
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) |
---|
1059 | 1046 | { |
---|
1060 | 1047 | struct slot slot; |
---|
1061 | 1048 | struct slot *pslot; |
---|
.. | .. |
---|
1145 | 1132 | /* |
---|
1146 | 1133 | */ |
---|
1147 | 1134 | #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] = { |
---|
1149 | 1136 | MIXER_VOL(VOLUME), |
---|
1150 | 1137 | MIXER_VOL(BASS), |
---|
1151 | 1138 | MIXER_VOL(TREBLE), |
---|
.. | .. |
---|
1293 | 1280 | |
---|
1294 | 1281 | static void snd_mixer_oss_build(struct snd_mixer_oss *mixer) |
---|
1295 | 1282 | { |
---|
1296 | | - static struct snd_mixer_oss_assign_table table[] = { |
---|
| 1283 | + static const struct snd_mixer_oss_assign_table table[] = { |
---|
1297 | 1284 | { SOUND_MIXER_VOLUME, "Master", 0 }, |
---|
1298 | 1285 | { SOUND_MIXER_VOLUME, "Front", 0 }, /* fallback */ |
---|
1299 | 1286 | { SOUND_MIXER_BASS, "Tone Control - Bass", 0 }, |
---|
.. | .. |
---|
1426 | 1413 | |
---|
1427 | 1414 | static int __init alsa_mixer_oss_init(void) |
---|
1428 | 1415 | { |
---|
| 1416 | + struct snd_card *card; |
---|
1429 | 1417 | int idx; |
---|
1430 | 1418 | |
---|
1431 | 1419 | snd_mixer_oss_notify_callback = snd_mixer_oss_notify_handler; |
---|
1432 | 1420 | 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 | + } |
---|
1435 | 1426 | } |
---|
1436 | 1427 | return 0; |
---|
1437 | 1428 | } |
---|
1438 | 1429 | |
---|
1439 | 1430 | static void __exit alsa_mixer_oss_exit(void) |
---|
1440 | 1431 | { |
---|
| 1432 | + struct snd_card *card; |
---|
1441 | 1433 | int idx; |
---|
1442 | 1434 | |
---|
1443 | 1435 | snd_mixer_oss_notify_callback = NULL; |
---|
1444 | 1436 | 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 | + } |
---|
1447 | 1442 | } |
---|
1448 | 1443 | } |
---|
1449 | 1444 | |
---|