aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2006-08-08 01:19:37 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-12-01 17:52:01 -0500
commitd80f19fab89cba8a6d16193154c8ff3edab00942 (patch)
tree5d6b567a45ca4cc014bf5a1d10622c91ece2f63e /sound/core
parentebf644c4623bc3eb57683199cd2b9080028b0f6f (diff)
Driver core: convert sound core to use struct device
Converts from using struct "class_device" to "struct device" making everything show up properly in /sys/devices/ with symlinks from the /sys/class directory. It also makes the struct sound_card to show up as a "real" device where all the different sound class devices are placed as childs and different card attribute files can hang off of. /sys/class/sound is still a flat directory, but the symlink targets of all devices belonging to the same card, point the the /sys/devices tree below the new card device object. Thanks to Kay for the updates to this patch. Signed-off-by: Kay Sievers <kay.sievers@novell.com> Acked-by: Jaroslav Kysela <perex@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/init.c8
-rw-r--r--sound/core/pcm.c7
-rw-r--r--sound/core/sound.c22
3 files changed, 21 insertions, 16 deletions
diff --git a/sound/core/init.c b/sound/core/init.c
index 3058d626a90a..6152a7554dfd 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -361,6 +361,8 @@ 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)
365 device_unregister(card->dev);
364 kfree(card); 366 kfree(card);
365 return 0; 367 return 0;
366} 368}
@@ -495,6 +497,12 @@ int snd_card_register(struct snd_card *card)
495 int err; 497 int err;
496 498
497 snd_assert(card != NULL, return -EINVAL); 499 snd_assert(card != NULL, return -EINVAL);
500 if (!card->dev) {
501 card->dev = device_create(sound_class, card->parent, 0,
502 "card%i", card->number);
503 if (IS_ERR(card->dev))
504 card->dev = NULL;
505 }
498 if ((err = snd_device_register_all(card)) < 0) 506 if ((err = snd_device_register_all(card)) < 0)
499 return err; 507 return err;
500 mutex_lock(&snd_card_mutex); 508 mutex_lock(&snd_card_mutex);
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index fbbbcd20c4cc..5ac6e19ccb41 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -910,7 +910,8 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
910 substream->pstr->substream_opened--; 910 substream->pstr->substream_opened--;
911} 911}
912 912
913static ssize_t show_pcm_class(struct class_device *class_device, char *buf) 913static ssize_t show_pcm_class(struct device *dev,
914 struct device_attribute *attr, char *buf)
914{ 915{
915 struct snd_pcm *pcm; 916 struct snd_pcm *pcm;
916 const char *str; 917 const char *str;
@@ -921,7 +922,7 @@ static ssize_t show_pcm_class(struct class_device *class_device, char *buf)
921 [SNDRV_PCM_CLASS_DIGITIZER] = "digitizer", 922 [SNDRV_PCM_CLASS_DIGITIZER] = "digitizer",
922 }; 923 };
923 924
924 if (! (pcm = class_get_devdata(class_device)) || 925 if (! (pcm = dev_get_drvdata(dev)) ||
925 pcm->dev_class > SNDRV_PCM_CLASS_LAST) 926 pcm->dev_class > SNDRV_PCM_CLASS_LAST)
926 str = "none"; 927 str = "none";
927 else 928 else
@@ -929,7 +930,7 @@ static ssize_t show_pcm_class(struct class_device *class_device, char *buf)
929 return snprintf(buf, PAGE_SIZE, "%s\n", str); 930 return snprintf(buf, PAGE_SIZE, "%s\n", str);
930} 931}
931 932
932static struct class_device_attribute pcm_attrs = 933static struct device_attribute pcm_attrs =
933 __ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL); 934 __ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL);
934 935
935static int snd_pcm_dev_register(struct snd_device *device) 936static int snd_pcm_dev_register(struct snd_device *device)
diff --git a/sound/core/sound.c b/sound/core/sound.c
index efa476c5210a..282742022de6 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -61,9 +61,6 @@ EXPORT_SYMBOL(snd_ecards_limit);
61static struct snd_minor *snd_minors[SNDRV_OS_MINORS]; 61static struct snd_minor *snd_minors[SNDRV_OS_MINORS];
62static DEFINE_MUTEX(sound_mutex); 62static DEFINE_MUTEX(sound_mutex);
63 63
64extern struct class *sound_class;
65
66
67#ifdef CONFIG_KMOD 64#ifdef CONFIG_KMOD
68 65
69/** 66/**
@@ -268,11 +265,10 @@ int snd_register_device(int type, struct snd_card *card, int dev,
268 snd_minors[minor] = preg; 265 snd_minors[minor] = preg;
269 if (card) 266 if (card)
270 device = card->dev; 267 device = card->dev;
271 preg->class_dev = class_device_create(sound_class, NULL, 268 preg->dev = device_create(sound_class, device, MKDEV(major, minor),
272 MKDEV(major, minor), 269 "%s", name);
273 device, "%s", name); 270 if (preg->dev)
274 if (preg->class_dev) 271 dev_set_drvdata(preg->dev, private_data);
275 class_set_devdata(preg->class_dev, private_data);
276 272
277 mutex_unlock(&sound_mutex); 273 mutex_unlock(&sound_mutex);
278 return 0; 274 return 0;
@@ -320,7 +316,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
320 return -EINVAL; 316 return -EINVAL;
321 } 317 }
322 318
323 class_device_destroy(sound_class, MKDEV(major, minor)); 319 device_destroy(sound_class, MKDEV(major, minor));
324 320
325 kfree(snd_minors[minor]); 321 kfree(snd_minors[minor]);
326 snd_minors[minor] = NULL; 322 snd_minors[minor] = NULL;
@@ -331,15 +327,15 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
331EXPORT_SYMBOL(snd_unregister_device); 327EXPORT_SYMBOL(snd_unregister_device);
332 328
333int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev, 329int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev,
334 const struct class_device_attribute *attr) 330 struct device_attribute *attr)
335{ 331{
336 int minor, ret = -EINVAL; 332 int minor, ret = -EINVAL;
337 struct class_device *cdev; 333 struct device *d;
338 334
339 mutex_lock(&sound_mutex); 335 mutex_lock(&sound_mutex);
340 minor = find_snd_minor(type, card, dev); 336 minor = find_snd_minor(type, card, dev);
341 if (minor >= 0 && (cdev = snd_minors[minor]->class_dev) != NULL) 337 if (minor >= 0 && (d = snd_minors[minor]->dev) != NULL)
342 ret = class_device_create_file(cdev, attr); 338 ret = device_create_file(d, attr);
343 mutex_unlock(&sound_mutex); 339 mutex_unlock(&sound_mutex);
344 return ret; 340 return ret;
345 341