hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/sound/core/device.c
....@@ -1,22 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Device management routines
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/slab.h>
....@@ -42,7 +27,7 @@
4227 * Return: Zero if successful, or a negative error code on failure.
4328 */
4429 int snd_device_new(struct snd_card *card, enum snd_device_type type,
45
- void *device_data, struct snd_device_ops *ops)
30
+ void *device_data, const struct snd_device_ops *ops)
4631 {
4732 struct snd_device *dev;
4833 struct list_head *p;
....@@ -252,3 +237,24 @@
252237 list_for_each_entry_safe_reverse(dev, next, &card->devices, list)
253238 __snd_device_free(dev);
254239 }
240
+
241
+/**
242
+ * snd_device_get_state - Get the current state of the given device
243
+ * @card: the card instance
244
+ * @device_data: the data pointer to release
245
+ *
246
+ * Returns the current state of the given device object. For the valid
247
+ * device, either @SNDRV_DEV_BUILD, @SNDRV_DEV_REGISTERED or
248
+ * @SNDRV_DEV_DISCONNECTED is returned.
249
+ * Or for a non-existing device, -1 is returned as an error.
250
+ */
251
+int snd_device_get_state(struct snd_card *card, void *device_data)
252
+{
253
+ struct snd_device *dev;
254
+
255
+ dev = look_for_dev(card, device_data);
256
+ if (dev)
257
+ return dev->state;
258
+ return -1;
259
+}
260
+EXPORT_SYMBOL_GPL(snd_device_get_state);