.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Device management routines |
---|
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/slab.h> |
---|
.. | .. |
---|
42 | 27 | * Return: Zero if successful, or a negative error code on failure. |
---|
43 | 28 | */ |
---|
44 | 29 | 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) |
---|
46 | 31 | { |
---|
47 | 32 | struct snd_device *dev; |
---|
48 | 33 | struct list_head *p; |
---|
.. | .. |
---|
252 | 237 | list_for_each_entry_safe_reverse(dev, next, &card->devices, list) |
---|
253 | 238 | __snd_device_free(dev); |
---|
254 | 239 | } |
---|
| 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); |
---|