hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/sound/core/jack.c
....@@ -1,22 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Jack abstraction layer
34 *
45 * Copyright 2008 Wolfson Microelectronics
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
- *
206 */
217
228 #include <linux/input.h>
....@@ -33,17 +19,13 @@
3319 };
3420
3521 #ifdef CONFIG_SND_JACK_INPUT_DEV
36
-static int jack_switch_types[] = {
22
+static const int jack_switch_types[SND_JACK_SWITCH_TYPES] = {
3723 SW_HEADPHONE_INSERT,
3824 SW_MICROPHONE_INSERT,
3925 SW_LINEOUT_INSERT,
4026 SW_JACK_PHYSICAL_INSERT,
4127 SW_VIDEOOUT_INSERT,
4228 SW_LINEIN_INSERT,
43
- SW_HPHL_OVERCURRENT,
44
- SW_HPHR_OVERCURRENT,
45
- SW_UNSUPPORT_INSERT,
46
- SW_MICROPHONE2_INSERT,
4729 };
4830 #endif /* CONFIG_SND_JACK_INPUT_DEV */
4931
....@@ -222,7 +204,7 @@
222204 struct snd_jack *jack;
223205 struct snd_jack_kctl *jack_kctl = NULL;
224206 int err;
225
- static struct snd_device_ops ops = {
207
+ static const struct snd_device_ops ops = {
226208 .dev_free = snd_jack_dev_free,
227209 #ifdef CONFIG_SND_JACK_INPUT_DEV
228210 .dev_register = snd_jack_dev_register,
....@@ -261,7 +243,7 @@
261243
262244 jack->type = type;
263245
264
- for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++)
246
+ for (i = 0; i < SND_JACK_SWITCH_TYPES; i++)
265247 if (type & (1 << i))
266248 input_set_capability(jack->input_dev, EV_SW,
267249 jack_switch_types[i]);
....@@ -366,6 +348,7 @@
366348 {
367349 struct snd_jack_kctl *jack_kctl;
368350 #ifdef CONFIG_SND_JACK_INPUT_DEV
351
+ struct input_dev *idev;
369352 int i;
370353 #endif
371354
....@@ -377,26 +360,28 @@
377360 status & jack_kctl->mask_bits);
378361
379362 #ifdef CONFIG_SND_JACK_INPUT_DEV
380
- if (!jack->input_dev)
363
+ idev = input_get_device(jack->input_dev);
364
+ if (!idev)
381365 return;
382366
383367 for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
384368 int testbit = SND_JACK_BTN_0 >> i;
385369
386370 if (jack->type & testbit)
387
- input_report_key(jack->input_dev, jack->key[i],
371
+ input_report_key(idev, jack->key[i],
388372 status & testbit);
389373 }
390374
391375 for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++) {
392376 int testbit = 1 << i;
393377 if (jack->type & testbit)
394
- input_report_switch(jack->input_dev,
378
+ input_report_switch(idev,
395379 jack_switch_types[i],
396380 status & testbit);
397381 }
398382
399
- input_sync(jack->input_dev);
383
+ input_sync(idev);
384
+ input_put_device(idev);
400385 #endif /* CONFIG_SND_JACK_INPUT_DEV */
401386 }
402387 EXPORT_SYMBOL(snd_jack_report);