linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sysfs sound class patches - [0/2]
@ 2004-01-07 23:21 Greg KH
  2004-01-07 23:23 ` [PATCH] sysfs sound class patch for OSS drivers - [1/2] Greg KH
  2004-01-08 17:33 ` [PATCH] sysfs sound class patches - [0/2] Takashi Iwai
  0 siblings, 2 replies; 6+ messages in thread
From: Greg KH @ 2004-01-07 23:21 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-hotplug-devel

Here are 2 sysfs sound class patches against 2.6.1-rc2 (but should apply
to 2.6.0) that add sysfs support for OSS and ALSA drivers.  This enables
udev to see sound devices and create nodes for them.

I've divided it up into 2 patches:
	- sound support for OSS drivers
	- sound support for ALSA drivers

The ALSA driver patch requires the OSS driver (due to where struct
sound_class is declared), and it also modifies the i810 ALSA sound
driver to provide a symlink in sysfs to the pci device being controlled
by the device node.

I can provide patches to the other ALSA drivers to also add this
information, as it's quite useful if you have more than one sound device
in your system at once.

These patches require the sysfs simple class patch that is currently in
the -mm tree.

Andrew, can you please add these two patches to your -mm tree?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] sysfs sound class patch for OSS drivers - [1/2]
  2004-01-07 23:21 [PATCH] sysfs sound class patches - [0/2] Greg KH
@ 2004-01-07 23:23 ` Greg KH
  2004-01-07 23:24   ` [PATCH] sysfs sound class patch for ALSA drivers - [2/2] Greg KH
  2004-01-08 20:08   ` [PATCH] sysfs sound class patch for OSS drivers - [1/2] Andreas Jellinghaus
  2004-01-08 17:33 ` [PATCH] sysfs sound class patches - [0/2] Takashi Iwai
  1 sibling, 2 replies; 6+ messages in thread
From: Greg KH @ 2004-01-07 23:23 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-hotplug-devel

Adds sysfs sound class support for all OSS drivers

Note, this is based on a previous patch from Leann Ogasawara
<ogasawara@osdl.org>, but modified a lot by me.

diff -Nru a/sound/oss/soundcard.c b/sound/oss/soundcard.c
--- a/sound/oss/soundcard.c	Wed Jan  7 15:10:03 2004
+++ b/sound/oss/soundcard.c	Wed Jan  7 15:10:03 2004
@@ -73,6 +73,7 @@
 
 
 unsigned long seq_time = 0;	/* Time for /dev/sequencer */
+extern struct class sound_class;
 
 /*
  * Table for configurable mixer volume handling
@@ -569,6 +570,9 @@
 		devfs_mk_cdev(MKDEV(SOUND_MAJOR, dev_list[i].minor),
 				S_IFCHR | dev_list[i].mode,
 				"sound/%s", dev_list[i].name);
+		simple_add_class_device(&sound_class, 
+					MKDEV(SOUND_MAJOR, dev_list[i].minor),
+					NULL, "%s", dev_list[i].name);
 
 		if (!dev_list[i].num)
 			continue;
@@ -578,6 +582,10 @@
 						dev_list[i].minor + (j*0x10)),
 					S_IFCHR | dev_list[i].mode,
 					"sound/%s%d", dev_list[i].name, j);
+			simple_add_class_device(&sound_class,
+					MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
+					NULL,
+					"%s%d", dev_list[i].name, j);
 		}
 	}
 
@@ -593,10 +601,13 @@
 
 	for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
 		devfs_remove("sound/%s", dev_list[i].name);
+		simple_remove_class_device(MKDEV(SOUND_MAJOR, dev_list[i].minor));
 		if (!dev_list[i].num)
 			continue;
-		for (j = 1; j < *dev_list[i].num; j++)
+		for (j = 1; j < *dev_list[i].num; j++) {
 			devfs_remove("sound/%s%d", dev_list[i].name, j);
+			simple_remove_class_device(MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)));
+		}
 	}
 	
 	unregister_sound_special(1);
diff -Nru a/sound/sound_core.c b/sound/sound_core.c
--- a/sound/sound_core.c	Wed Jan  7 15:10:03 2004
+++ b/sound/sound_core.c	Wed Jan  7 15:10:03 2004
@@ -65,6 +65,11 @@
 extern int msnd_pinnacle_init(void);
 #endif
 
+struct class sound_class = {
+	.name = "sound",
+};
+EXPORT_SYMBOL(sound_class);
+
 /*
  *	Low level list operator. Scan the ordered list, find a hole and
  *	join into it. Called with the lock asserted
@@ -171,6 +176,8 @@
 
 	devfs_mk_cdev(MKDEV(SOUND_MAJOR, s->unit_minor),
 			S_IFCHR | mode, s->name);
+	simple_add_class_device(&sound_class, MKDEV(SOUND_MAJOR, s->unit_minor),
+				NULL, s->name+6);
 	return r;
 
  fail:
@@ -193,6 +200,7 @@
 	spin_unlock(&sound_loader_lock);
 	if (p) {
 		devfs_remove(p->name);
+		simple_remove_class_device(MKDEV(SOUND_MAJOR, p->unit_minor));
 		kfree(p);
 	}
 }
@@ -556,6 +564,7 @@
 	   empty */
 	unregister_chrdev(SOUND_MAJOR, "sound");
 	devfs_remove("sound");
+	class_unregister(&sound_class);
 }
 
 static int __init init_soundcore(void)
@@ -565,6 +574,7 @@
 		return -EBUSY;
 	}
 	devfs_mk_dir ("sound");
+	class_register(&sound_class);
 
 	return 0;
 }

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] sysfs sound class patch for ALSA drivers - [2/2]
  2004-01-07 23:23 ` [PATCH] sysfs sound class patch for OSS drivers - [1/2] Greg KH
@ 2004-01-07 23:24   ` Greg KH
  2004-01-08 20:08   ` [PATCH] sysfs sound class patch for OSS drivers - [1/2] Andreas Jellinghaus
  1 sibling, 0 replies; 6+ messages in thread
From: Greg KH @ 2004-01-07 23:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-hotplug-devel

Adds sysfs sound class support for all ALSA drivers

Note, this is based on a previous patch from Leann Ogasawara
<ogasawara@osdl.org>, but modified a lot by me.


diff -Nru a/include/sound/core.h b/include/sound/core.h
--- a/include/sound/core.h	Wed Jan  7 15:10:03 2004
+++ b/include/sound/core.h	Wed Jan  7 15:10:03 2004
@@ -160,6 +160,7 @@
 	int shutdown;			/* this card is going down */
 	wait_queue_head_t shutdown_sleep;
 	struct work_struct free_workq;	/* for free in workqueue */
+	struct device *dev;
 
 #ifdef CONFIG_PM
 	int (*set_power_state) (snd_card_t *card, unsigned int state);
diff -Nru a/sound/core/sound.c b/sound/core/sound.c
--- a/sound/core/sound.c	Wed Jan  7 15:10:03 2004
+++ b/sound/core/sound.c	Wed Jan  7 15:10:03 2004
@@ -38,9 +38,7 @@
 static int major = CONFIG_SND_MAJOR;
 int snd_major;
 static int cards_limit = SNDRV_CARDS;
-#ifdef CONFIG_DEVFS_FS
 static int device_mode = S_IFCHR | S_IRUGO | S_IWUGO;
-#endif
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards.");
@@ -66,6 +64,7 @@
 
 static DECLARE_MUTEX(sound_mutex);
 
+extern struct class sound_class;
 #ifdef CONFIG_KMOD
 
 /**
@@ -203,6 +202,7 @@
 {
 	int minor = snd_kernel_minor(type, card, dev);
 	snd_minor_t *preg;
+	struct device *device = NULL;
 
 	if (minor < 0)
 		return minor;
@@ -221,10 +221,14 @@
 		return -EBUSY;
 	}
 	list_add_tail(&preg->list, &snd_minors_hash[SNDRV_MINOR_CARD(minor)]);
-#ifdef CONFIG_DEVFS_FS
-	if (strncmp(name, "controlC", 8))     /* created in sound.c */
+
+	if (strncmp(name, "controlC", 8)) {	/* created in sound.c */
 		devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name);
-#endif
+		if (card)
+			device = card->dev;
+		simple_add_class_device(&sound_class, MKDEV(major, minor), device, name);
+	}
+
 	up(&sound_mutex);
 	return 0;
 }
@@ -252,10 +256,12 @@
 		up(&sound_mutex);
 		return -EINVAL;
 	}
-#ifdef CONFIG_DEVFS_FS
-	if (strncmp(mptr->name, "controlC", 8))	/* created in sound.c */
+
+	if (strncmp(mptr->name, "controlC", 8)) {	/* created in sound.c */
 		devfs_remove("snd/%s", mptr->name);
-#endif
+		simple_remove_class_device(MKDEV(major, minor));
+	}
+
 	list_del(&mptr->list);
 	up(&sound_mutex);
 	kfree(mptr);
@@ -322,9 +328,7 @@
 
 static int __init alsa_sound_init(void)
 {
-#ifdef CONFIG_DEVFS_FS
 	short controlnum;
-#endif
 #ifdef CONFIG_SND_OSSEMUL
 	int err;
 #endif
@@ -358,10 +362,10 @@
 #ifdef CONFIG_SND_OSSEMUL
 	snd_info_minor_register();
 #endif
-#ifdef CONFIG_DEVFS_FS
-	for (controlnum = 0; controlnum < cards_limit; controlnum++) 
+	for (controlnum = 0; controlnum < cards_limit; controlnum++) {
 		devfs_mk_cdev(MKDEV(major, controlnum<<5), S_IFCHR | device_mode, "snd/controlC%d", controlnum);
-#endif
+		simple_add_class_device(&sound_class, MKDEV(major, controlnum<<5), NULL, "controlC%d", controlnum);
+	}
 #ifndef MODULE
 	printk(KERN_INFO "Advanced Linux Sound Architecture Driver Version " CONFIG_SND_VERSION CONFIG_SND_DATE ".\n");
 #endif
@@ -372,8 +376,10 @@
 {
 	short controlnum;
 
-	for (controlnum = 0; controlnum < cards_limit; controlnum++)
+	for (controlnum = 0; controlnum < cards_limit; controlnum++) {
 		devfs_remove("snd/controlC%d", controlnum);
+		simple_remove_class_device(MKDEV(major, controlnum<<5));
+	}
 
 #ifdef CONFIG_SND_OSSEMUL
 	snd_info_minor_unregister();
diff -Nru a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
--- a/sound/pci/intel8x0.c	Wed Jan  7 15:10:03 2004
+++ b/sound/pci/intel8x0.c	Wed Jan  7 15:10:03 2004
@@ -2591,6 +2591,7 @@
 			break;
 		}
 	}
+	card->dev = &pci->dev;
 
 	if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, &chip)) < 0) {
 		snd_card_free(card);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] sysfs sound class patches - [0/2]
  2004-01-07 23:21 [PATCH] sysfs sound class patches - [0/2] Greg KH
  2004-01-07 23:23 ` [PATCH] sysfs sound class patch for OSS drivers - [1/2] Greg KH
@ 2004-01-08 17:33 ` Takashi Iwai
  2004-01-09  8:00   ` Greg KH
  1 sibling, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2004-01-08 17:33 UTC (permalink / raw)
  To: Greg KH; +Cc: Andrew Morton, linux-kernel, linux-hotplug-devel

At Wed, 7 Jan 2004 15:21:37 -0800,
Greg KH wrote:
> 
> Here are 2 sysfs sound class patches against 2.6.1-rc2 (but should apply
> to 2.6.0) that add sysfs support for OSS and ALSA drivers.  This enables
> udev to see sound devices and create nodes for them.
> 
> I've divided it up into 2 patches:
> 	- sound support for OSS drivers
> 	- sound support for ALSA drivers
> 
> The ALSA driver patch requires the OSS driver (due to where struct
> sound_class is declared),

oh, sound_core.c is not the OSS driver ;)

>  and it also modifies the i810 ALSA sound
> driver to provide a symlink in sysfs to the pci device being controlled
> by the device node.
 
it looks nice and easy.  i'll do that for all pci drivers, too, once
when these patches are merged.

> I can provide patches to the other ALSA drivers to also add this
> information, as it's quite useful if you have more than one sound device
> in your system at once.

not only pci but also isapnp devices can provide dev pointer.
in that case, should the driver gives symlinks of each isapnp devices,
too?  a module usually holds one isapnp card struct and several isapnp
devices below it.  but, hmm, it will need far more codes...

--
Takashi Iwai <tiwai@suse.de>		ALSA Developer - www.alsa-project.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] sysfs sound class patch for OSS drivers - [1/2]
  2004-01-07 23:23 ` [PATCH] sysfs sound class patch for OSS drivers - [1/2] Greg KH
  2004-01-07 23:24   ` [PATCH] sysfs sound class patch for ALSA drivers - [2/2] Greg KH
@ 2004-01-08 20:08   ` Andreas Jellinghaus
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Jellinghaus @ 2004-01-08 20:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-hotplug-devel

On Wed, 07 Jan 2004 15:23:35 -0800, Greg KH wrote:

> Adds sysfs sound class support for all OSS drivers

what is the best way to get all current patches?
wait for the next mm kernel? or do you have a directory
with the latest patches somewhere?

Regards, Andreas


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] sysfs sound class patches - [0/2]
  2004-01-08 17:33 ` [PATCH] sysfs sound class patches - [0/2] Takashi Iwai
@ 2004-01-09  8:00   ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2004-01-09  8:00 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Andrew Morton, linux-kernel, linux-hotplug-devel

On Thu, Jan 08, 2004 at 06:33:44PM +0100, Takashi Iwai wrote:
> At Wed, 7 Jan 2004 15:21:37 -0800,
> Greg KH wrote:
> > 
> > Here are 2 sysfs sound class patches against 2.6.1-rc2 (but should apply
> > to 2.6.0) that add sysfs support for OSS and ALSA drivers.  This enables
> > udev to see sound devices and create nodes for them.
> > 
> > I've divided it up into 2 patches:
> > 	- sound support for OSS drivers
> > 	- sound support for ALSA drivers
> > 
> > The ALSA driver patch requires the OSS driver (due to where struct
> > sound_class is declared),
> 
> oh, sound_core.c is not the OSS driver ;)

Heh, but the changes I made to it are in the OSS specific parts :)

> >  and it also modifies the i810 ALSA sound
> > driver to provide a symlink in sysfs to the pci device being controlled
> > by the device node.
>  
> it looks nice and easy.  i'll do that for all pci drivers, too, once
> when these patches are merged.

Thanks.

> > I can provide patches to the other ALSA drivers to also add this
> > information, as it's quite useful if you have more than one sound device
> > in your system at once.
> 
> not only pci but also isapnp devices can provide dev pointer.

Exactly.  So does USB.

> in that case, should the driver gives symlinks of each isapnp devices,
> too?

Yes.  If the dev pointer is valid, the driver core will create the
symlinks.

> a module usually holds one isapnp card struct and several isapnp
> devices below it.  but, hmm, it will need far more codes...

Just set the dev pointer to the device that is associated with the sound
device.  That's the best you can do.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-01-09  8:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-07 23:21 [PATCH] sysfs sound class patches - [0/2] Greg KH
2004-01-07 23:23 ` [PATCH] sysfs sound class patch for OSS drivers - [1/2] Greg KH
2004-01-07 23:24   ` [PATCH] sysfs sound class patch for ALSA drivers - [2/2] Greg KH
2004-01-08 20:08   ` [PATCH] sysfs sound class patch for OSS drivers - [1/2] Andreas Jellinghaus
2004-01-08 17:33 ` [PATCH] sysfs sound class patches - [0/2] Takashi Iwai
2004-01-09  8:00   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).