diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-01-29 15:32:47 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-02-02 08:42:33 -0500 |
commit | 4b440be667c6187717c99e4d427119fa415ced29 (patch) | |
tree | 20e9fe801416caf247eb883bec998598d32e2ce2 | |
parent | 23c18d4bfd73ee24070849faf98b3ab01263a3c4 (diff) |
ALSA: Add a helper to initialize device
Introduce a new helper function snd_device_initialize() to initialize
the device object for sound devices.
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | include/sound/core.h | 2 | ||||
-rw-r--r-- | sound/core/init.c | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/include/sound/core.h b/include/sound/core.h index 39d14234961d..de7a878217d7 100644 --- a/include/sound/core.h +++ b/include/sound/core.h | |||
@@ -207,6 +207,8 @@ extern struct class *sound_class; | |||
207 | 207 | ||
208 | void snd_request_card(int card); | 208 | void snd_request_card(int card); |
209 | 209 | ||
210 | void snd_device_initialize(struct device *dev, struct snd_card *card); | ||
211 | |||
210 | int snd_register_device_for_dev(int type, struct snd_card *card, int dev, | 212 | int snd_register_device_for_dev(int type, struct snd_card *card, int dev, |
211 | const struct file_operations *f_ops, | 213 | const struct file_operations *f_ops, |
212 | void *private_data, struct device *device, | 214 | void *private_data, struct device *device, |
diff --git a/sound/core/init.c b/sound/core/init.c index 074875d68c15..96194599e82e 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -157,6 +157,29 @@ static int get_slot_from_bitmask(int mask, int (*check)(struct module *, int), | |||
157 | return mask; /* unchanged */ | 157 | return mask; /* unchanged */ |
158 | } | 158 | } |
159 | 159 | ||
160 | /* the default release callback set in snd_device_initialize() below; | ||
161 | * this is just NOP for now, as almost all jobs are already done in | ||
162 | * dev_free callback of snd_device chain instead. | ||
163 | */ | ||
164 | static void default_release(struct device *dev) | ||
165 | { | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * snd_device_initialize - Initialize struct device for sound devices | ||
170 | * @dev: device to initialize | ||
171 | * @card: card to assign, optional | ||
172 | */ | ||
173 | void snd_device_initialize(struct device *dev, struct snd_card *card) | ||
174 | { | ||
175 | device_initialize(dev); | ||
176 | if (card) | ||
177 | dev->parent = &card->card_dev; | ||
178 | dev->class = sound_class; | ||
179 | dev->release = default_release; | ||
180 | } | ||
181 | EXPORT_SYMBOL_GPL(snd_device_initialize); | ||
182 | |||
160 | static int snd_card_do_free(struct snd_card *card); | 183 | static int snd_card_do_free(struct snd_card *card); |
161 | static const struct attribute_group *card_dev_attr_groups[]; | 184 | static const struct attribute_group *card_dev_attr_groups[]; |
162 | 185 | ||