diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-01-26 06:40:31 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-01-29 17:32:53 -0500 |
commit | 7d2aae1e88660cf09be913e9754e45189dc33412 (patch) | |
tree | af56ebcced14fb8e40640d9555129aab2ffa0532 | |
parent | 5263bf65d6342e12ab716db8e529501670979321 (diff) |
[PATCH] ALSA: Fix sysfs breakage
The recent change for a new sysfs tree with card* object breaks the
/sys/class/sound tree if CONFIG_SYSFS_DEPRECATED is enabled.
The device in each entry doesn't point the correct device object:
/sys/class/sound
...
|-- pcmC0D0c
| |-- dev
| |-- device -> ../../../class/sound/card0
| |-- pcm_class
| |-- power
| | `-- wakeup
| |-- subsystem -> ../../../class/sound
| `-- uevent
Also, this change breaks some drivers (like sound/arm/*) referring
card->dev directly to obtain the device object for memory handling.
This patch reverts the semantics of card->dev to the former version,
which points to a real device object. The card* object is stored in a
new card->card_dev field, instead. The device parent is chosen either
card->dev or card->card_dev according to CONFIG_SYSFS_DEPRECATED to
keep the tree compatibility.
Also, card* isn't created if CONFIG_SYSFS_DEPRECATED is enabled. The
reason of card* object is a root of all beloing devices, and it makes
little sense if each sound device points to the real device object
directly.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Monty Montgomery <xiphmont@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | include/sound/core.h | 18 | ||||
-rw-r--r-- | sound/core/init.c | 18 | ||||
-rw-r--r-- | sound/core/sound.c | 4 | ||||
-rw-r--r-- | sound/core/sound_oss.c | 4 |
4 files changed, 28 insertions, 16 deletions
diff --git a/include/sound/core.h b/include/sound/core.h index a994bea09cd6..521f036cce99 100644 --- a/include/sound/core.h +++ b/include/sound/core.h | |||
@@ -132,8 +132,10 @@ struct snd_card { | |||
132 | int shutdown; /* this card is going down */ | 132 | int shutdown; /* this card is going down */ |
133 | int free_on_last_close; /* free in context of file_release */ | 133 | int free_on_last_close; /* free in context of file_release */ |
134 | wait_queue_head_t shutdown_sleep; | 134 | wait_queue_head_t shutdown_sleep; |
135 | struct device *parent; | 135 | struct device *dev; /* device assigned to this card */ |
136 | struct device *dev; | 136 | #ifndef CONFIG_SYSFS_DEPRECATED |
137 | struct device *card_dev; /* cardX object for sysfs */ | ||
138 | #endif | ||
137 | 139 | ||
138 | #ifdef CONFIG_PM | 140 | #ifdef CONFIG_PM |
139 | unsigned int power_state; /* power state */ | 141 | unsigned int power_state; /* power state */ |
@@ -191,6 +193,16 @@ struct snd_minor { | |||
191 | struct device *dev; /* device for sysfs */ | 193 | struct device *dev; /* device for sysfs */ |
192 | }; | 194 | }; |
193 | 195 | ||
196 | /* return a device pointer linked to each sound device as a parent */ | ||
197 | static inline struct device *snd_card_get_device_link(struct snd_card *card) | ||
198 | { | ||
199 | #ifdef CONFIG_SYSFS_DEPRECATED | ||
200 | return card ? card->dev : NULL; | ||
201 | #else | ||
202 | return card ? card->card_dev : NULL; | ||
203 | #endif | ||
204 | } | ||
205 | |||
194 | /* sound.c */ | 206 | /* sound.c */ |
195 | 207 | ||
196 | extern int snd_major; | 208 | extern int snd_major; |
@@ -257,7 +269,7 @@ int snd_card_file_add(struct snd_card *card, struct file *file); | |||
257 | int snd_card_file_remove(struct snd_card *card, struct file *file); | 269 | int snd_card_file_remove(struct snd_card *card, struct file *file); |
258 | 270 | ||
259 | #ifndef snd_card_set_dev | 271 | #ifndef snd_card_set_dev |
260 | #define snd_card_set_dev(card,devptr) ((card)->parent = (devptr)) | 272 | #define snd_card_set_dev(card,devptr) ((card)->dev = (devptr)) |
261 | #endif | 273 | #endif |
262 | 274 | ||
263 | /* device.c */ | 275 | /* device.c */ |
diff --git a/sound/core/init.c b/sound/core/init.c index 6152a7554dfd..a4cc6b155ae9 100644 --- a/sound/core/init.c +++ b/sound/core/init.c | |||
@@ -361,8 +361,10 @@ static int snd_card_do_free(struct snd_card *card) | |||
361 | snd_printk(KERN_WARNING "unable to free card info\n"); | 361 | snd_printk(KERN_WARNING "unable to free card info\n"); |
362 | /* Not fatal error */ | 362 | /* Not fatal error */ |
363 | } | 363 | } |
364 | if (card->dev) | 364 | #ifndef CONFIG_SYSFS_DEPRECATED |
365 | device_unregister(card->dev); | 365 | if (card->card_dev) |
366 | device_unregister(card->card_dev); | ||
367 | #endif | ||
366 | kfree(card); | 368 | kfree(card); |
367 | return 0; | 369 | return 0; |
368 | } | 370 | } |
@@ -497,12 +499,14 @@ int snd_card_register(struct snd_card *card) | |||
497 | int err; | 499 | int err; |
498 | 500 | ||
499 | snd_assert(card != NULL, return -EINVAL); | 501 | snd_assert(card != NULL, return -EINVAL); |
500 | if (!card->dev) { | 502 | #ifndef CONFIG_SYSFS_DEPRECATED |
501 | card->dev = device_create(sound_class, card->parent, 0, | 503 | if (!card->card_dev) { |
502 | "card%i", card->number); | 504 | card->card_dev = device_create(sound_class, card->dev, 0, |
503 | if (IS_ERR(card->dev)) | 505 | "card%i", card->number); |
504 | card->dev = NULL; | 506 | if (IS_ERR(card->card_dev)) |
507 | card->card_dev = NULL; | ||
505 | } | 508 | } |
509 | #endif | ||
506 | if ((err = snd_device_register_all(card)) < 0) | 510 | if ((err = snd_device_register_all(card)) < 0) |
507 | return err; | 511 | return err; |
508 | mutex_lock(&snd_card_mutex); | 512 | mutex_lock(&snd_card_mutex); |
diff --git a/sound/core/sound.c b/sound/core/sound.c index 282742022de6..82a61c67cf3a 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c | |||
@@ -238,7 +238,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, | |||
238 | { | 238 | { |
239 | int minor; | 239 | int minor; |
240 | struct snd_minor *preg; | 240 | struct snd_minor *preg; |
241 | struct device *device = NULL; | 241 | struct device *device = snd_card_get_device_link(card); |
242 | 242 | ||
243 | snd_assert(name, return -EINVAL); | 243 | snd_assert(name, return -EINVAL); |
244 | preg = kmalloc(sizeof *preg, GFP_KERNEL); | 244 | preg = kmalloc(sizeof *preg, GFP_KERNEL); |
@@ -263,8 +263,6 @@ int snd_register_device(int type, struct snd_card *card, int dev, | |||
263 | return minor; | 263 | return minor; |
264 | } | 264 | } |
265 | snd_minors[minor] = preg; | 265 | snd_minors[minor] = preg; |
266 | if (card) | ||
267 | device = card->dev; | ||
268 | preg->dev = device_create(sound_class, device, MKDEV(major, minor), | 266 | preg->dev = device_create(sound_class, device, MKDEV(major, minor), |
269 | "%s", name); | 267 | "%s", name); |
270 | if (preg->dev) | 268 | if (preg->dev) |
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index b2fc40aa520b..4566df41912a 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c | |||
@@ -106,7 +106,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, | |||
106 | int cidx = SNDRV_MINOR_OSS_CARD(minor); | 106 | int cidx = SNDRV_MINOR_OSS_CARD(minor); |
107 | int track2 = -1; | 107 | int track2 = -1; |
108 | int register1 = -1, register2 = -1; | 108 | int register1 = -1, register2 = -1; |
109 | struct device *carddev = NULL; | 109 | struct device *carddev = snd_card_get_device_link(card); |
110 | 110 | ||
111 | if (card && card->number >= 8) | 111 | if (card && card->number >= 8) |
112 | return 0; /* ignore silently */ | 112 | return 0; /* ignore silently */ |
@@ -134,8 +134,6 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, | |||
134 | track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1); | 134 | track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1); |
135 | break; | 135 | break; |
136 | } | 136 | } |
137 | if (card) | ||
138 | carddev = card->dev; | ||
139 | register1 = register_sound_special_device(f_ops, minor, carddev); | 137 | register1 = register_sound_special_device(f_ops, minor, carddev); |
140 | if (register1 != minor) | 138 | if (register1 != minor) |
141 | goto __end; | 139 | goto __end; |