From 8bfb181c17d20956f156e84638912e00e1aaca86 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 29 Jan 2014 11:46:11 +0100 Subject: ALSA: Embed card device into struct snd_card As prepared in the previous patch, we are ready to create a device struct for the card object in snd_card_create() now. This patch changes the scheme from the old style to: - embed a device struct for the card object into snd_card struct, - initialize the card device in snd_card_create() (but not register), - registration is done in snd_card_register() via device_add() The actual card device is stored in card->card_dev. The card->dev pointer is kept unchanged and pointing to the parent device as before for compatibility reason. Signed-off-by: Takashi Iwai --- include/sound/core.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include/sound/core.h') diff --git a/include/sound/core.h b/include/sound/core.h index e946b2428ea0..7e4fb3e93fc7 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -22,6 +22,7 @@ * */ +#include #include /* wake_up() */ #include /* struct mutex */ #include /* struct rw_semaphore */ @@ -41,8 +42,6 @@ /* forward declarations */ struct pci_dev; struct module; -struct device; -struct device_attribute; /* device allocation stuff */ @@ -135,7 +134,8 @@ struct snd_card { wait_queue_head_t shutdown_sleep; atomic_t refcount; /* refcount for disconnection */ struct device *dev; /* device assigned to this card */ - struct device *card_dev; /* cardX object for sysfs */ + struct device card_dev; /* cardX object for sysfs */ + bool registered; /* card_dev is registered? */ #ifdef CONFIG_PM unsigned int power_state; /* power state */ @@ -149,6 +149,8 @@ struct snd_card { #endif }; +#define dev_to_snd_card(p) container_of(p, struct snd_card, card_dev) + #ifdef CONFIG_PM static inline void snd_power_lock(struct snd_card *card) { @@ -197,7 +199,7 @@ struct snd_minor { /* return a device pointer linked to each sound device as a parent */ static inline struct device *snd_card_get_device_link(struct snd_card *card) { - return card ? card->card_dev : NULL; + return card ? &card->card_dev : NULL; } /* sound.c */ -- cgit