2002-01-09 15:43:46

by Salvador Eduardo Tropea

[permalink] [raw]
Subject: [PATCH][RFCA] Sound: adding /proc/driver/{vendor}/{dev_pci}/ac97 entry for es1371 driver

Kernel: 2.4.17
Hardware: CT5880+Sigmatel Codec
Module: sound/es1371.c

The following patch adds a proc entry to fetch information about the codec
attached to the CT5880 (ES137x) chip.
Note: Most of the code is already in ac97_codec.c module.

Doubts:
1) This adds something like: /proc/driver/es1371/00:03.00/ac97 I took the
idea from emu10k1.c module. My doubt is about the `:' it looks wrong in a
file name, specially when that's usually used to separate file names/paths.
Should we pass it by a small routine that converts : into something like _?
2) I used a buffer of fixed length as in other modules, but I don't feel
really good doing it. What solutions are recommended? (if any)


diff -ru linux-2.4.17.ori/drivers/sound/es1371.c
linux-2.4.17/drivers/sound/es1371.c
--- linux-2.4.17.ori/drivers/sound/es1371.c Sun Sep 30 16:26:08 2001
+++ linux-2.4.17/drivers/sound/es1371.c Tue Jan 8 21:56:01 2002
@@ -110,6 +110,8 @@
* 31.01.2001 0.30 Register/Unregister gameport
* Fix SETTRIGGER non OSS API conformity
* 14.07.2001 0.31 Add list of laptops needing amplifier control
+ * 08.01.2002 0.32 Add /proc/driver/es1371/{card}/ac97 entry
+ * Salvador E. Tropea <[email protected]>
*/

/*****************************************************************************/

@@ -2803,6 +2805,7 @@
unsigned long tmo;
signed long tmo2;
unsigned int cssr;
+ char proc_str[80];

if ((res=pci_enable_device(pcidev)))
return res;
@@ -2960,6 +2963,16 @@
for (i = 0; i < sizeof(initvol)/sizeof(initvol[0]); i++) {
val = initvol[i].vol;
mixdev_ioctl(&s->codec, initvol[i].mixch, (unsigned
long)&val);
+ }
+
+ /* create a proc entry to inform about the codec facilities */
+ strcpy(proc_str, "driver/es1371");
+ if (proc_mkdir (proc_str, 0)) {
+ sprintf(proc_str, "driver/es1371/%s", s->dev->slot_name);
+ if (proc_mkdir (proc_str, 0)) {
+ strcat(proc_str, "/ac97");
+ create_proc_read_entry(proc_str, 0, 0,
ac97_read_proc, &s->codec);
+ }
}
/* mute master and PCM when in S/PDIF mode */
if (s->spdif_volume != -1) {
<--------End of patch

--
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Visit my home page: http://welcome.to/SetSoft or
http://www.geocities.com/SiliconValley/Vista/6552/
Alternative e-mail: [email protected] [email protected]
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA Phone: +(5411) 4759 0013




2002-01-09 16:07:26

by Tommy Reynolds

[permalink] [raw]
Subject: Re: [PATCH][RFCA] Sound: adding /proc/driver/{vendor}/{dev_pci}/ac97 entry for es1371 driver

Uttered "salvador" <[email protected]>, spoke thus:

> Doubts:
> 1) This adds something like: /proc/driver/es1371/00:03.00/ac97 I took the
> idea from emu10k1.c module. My doubt is about the `:' it looks wrong in a
> file name, specially when that's usually used to separate file names/paths.
> Should we pass it by a small routine that converts : into something like _?

I wouldn't change it. In fact, Linux allows _any_ character except a NULL in a
filename, although POSIX doesn't. (Well, I wouldn't use a '/' in a filename
even if I escaped it out the wazoo!)

> 2) I used a buffer of fixed length as in other modules, but I don't feel
> really good doing it. What solutions are recommended? (if any)

The kernel stack is really small and doesn't grow, so a buffer allocated on the
stack could cause "load-dependent instability". Using a "vmalloc" and a "vfree"
is fast, cheap and easy.

--
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + -- -- -- -- -- -- -- -- -- --
Tommy Reynolds | mailto: <[email protected]>
Red Hat, Inc., Embedded Development Services | Phone: +1.256.704.9286
307 Wynn Drive NW, Huntsville, AL 35805 USA | FAX: +1.256.837.3839
Senior Software Developer | Mobile: +1.919.641.2923


Attachments:
(No filename) (197.00 B)