Commit 12b131c4 authored by Johannes Berg's avatar Johannes Berg Committed by Jaroslav Kysela

[ALSA] allow registering an alsa device with struct device pointer

This patch adds snd_register_device_for_dev taking a struct device
pointer to link the new device to and makes snd_register_device a simple
static inline wrapper around it.
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent feaa6a74
...@@ -211,9 +211,40 @@ extern struct class *sound_class; ...@@ -211,9 +211,40 @@ extern struct class *sound_class;
void snd_request_card(int card); void snd_request_card(int card);
int snd_register_device(int type, struct snd_card *card, int dev, int snd_register_device_for_dev(int type, struct snd_card *card,
const struct file_operations *f_ops, void *private_data, int dev,
const char *name); const struct file_operations *f_ops,
void *private_data,
const char *name,
struct device *device);
/**
* snd_register_device - Register the ALSA device file for the card
* @type: the device type, SNDRV_DEVICE_TYPE_XXX
* @card: the card instance
* @dev: the device index
* @f_ops: the file operations
* @private_data: user pointer for f_ops->open()
* @name: the device file name
*
* Registers an ALSA device file for the given card.
* The operators have to be set in reg parameter.
*
* This function uses the card's device pointer to link to the
* correct &struct device.
*
* Returns zero if successful, or a negative error code on failure.
*/
static inline int snd_register_device(int type, struct snd_card *card, int dev,
const struct file_operations *f_ops,
void *private_data,
const char *name)
{
return snd_register_device_for_dev(type, card, dev, f_ops,
private_data, name,
card ? card->dev : NULL);
}
int snd_unregister_device(int type, struct snd_card *card, int dev); int snd_unregister_device(int type, struct snd_card *card, int dev);
void *snd_lookup_minor_data(unsigned int minor, int type); void *snd_lookup_minor_data(unsigned int minor, int type);
int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev, int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev,
......
...@@ -219,26 +219,27 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) ...@@ -219,26 +219,27 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
#endif #endif
/** /**
* snd_register_device - Register the ALSA device file for the card * snd_register_device_for_dev - Register the ALSA device file for the card
* @type: the device type, SNDRV_DEVICE_TYPE_XXX * @type: the device type, SNDRV_DEVICE_TYPE_XXX
* @card: the card instance * @card: the card instance
* @dev: the device index * @dev: the device index
* @f_ops: the file operations * @f_ops: the file operations
* @private_data: user pointer for f_ops->open() * @private_data: user pointer for f_ops->open()
* @name: the device file name * @name: the device file name
* @device: the &struct device to link this new device to
* *
* Registers an ALSA device file for the given card. * Registers an ALSA device file for the given card.
* The operators have to be set in reg parameter. * The operators have to be set in reg parameter.
* *
* Retrurns zero if successful, or a negative error code on failure. * Returns zero if successful, or a negative error code on failure.
*/ */
int snd_register_device(int type, struct snd_card *card, int dev, int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
const struct file_operations *f_ops, void *private_data, const struct file_operations *f_ops,
const char *name) void *private_data,
const char *name, struct device *device)
{ {
int minor; int minor;
struct snd_minor *preg; struct snd_minor *preg;
struct device *device = snd_card_get_device_link(card);
snd_assert(name, return -EINVAL); snd_assert(name, return -EINVAL);
preg = kmalloc(sizeof *preg, GFP_KERNEL); preg = kmalloc(sizeof *preg, GFP_KERNEL);
...@@ -272,7 +273,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, ...@@ -272,7 +273,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
return 0; return 0;
} }
EXPORT_SYMBOL(snd_register_device); EXPORT_SYMBOL(snd_register_device_for_dev);
/* find the matching minor record /* find the matching minor record
* return the index of snd_minor, or -1 if not found * return the index of snd_minor, or -1 if not found
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment