2002-01-10 17:45:08

by Salvador Eduardo Tropea

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

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 Wed Jan 9 20:53:58 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]>
*/

/*****************************************************************************/
@@ -2794,6 +2796,9 @@
};


+static char driver_str[] = "driver/es1371";
+static char ac97_str[] = "/ac97";
+
static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid)
{
struct es1371_state *s;
@@ -2803,6 +2808,8 @@
unsigned long tmo;
signed long tmo2;
unsigned int cssr;
+ char *proc_str;
+ int proc_success = 0;

if ((res=pci_enable_device(pcidev)))
return res;
@@ -2961,6 +2968,22 @@
val = initvol[i].vol;
mixdev_ioctl(&s->codec, initvol[i].mixch, (unsigned long)&val);
}
+
+ /* create a proc entry to inform about the codec facilities */
+ proc_str = (char *)vmalloc(sizeof(driver_str) + sizeof(ac97_str) +
+ strlen(s->dev->slot_name));
+ if (proc_mkdir(driver_str, 0)) {
+ sprintf(proc_str, "%s/%s", driver_str, s->dev->slot_name);
+ if (proc_mkdir(proc_str, 0)) {
+ strcat(proc_str, ac97_str);
+ if (create_proc_read_entry(proc_str, 0, 0, ac97_read_proc, &s->codec))
+ proc_success = 1;
+ }
+ }
+ vfree(proc_str);
+ if (!proc_success)
+ printk(KERN_WARNING PFX "cannot create /proc entry\n");
+
/* mute master and PCM when in S/PDIF mode */
if (s->spdif_volume != -1) {
val = 0x0000;
@@ -3003,6 +3026,7 @@
static void __devinit es1371_remove(struct pci_dev *dev)
{
struct es1371_state *s = pci_get_drvdata(dev);
+ char *proc_str;

if (!s)
return;
@@ -3011,6 +3035,17 @@
if (s->ps)
remove_proc_entry("es1371", NULL);
#endif /* ES1371_DEBUG */
+
+ /* remove the proc entry */
+ proc_str = (char *)vmalloc(sizeof(driver_str) + sizeof(ac97_str) +
+ strlen(s->dev->slot_name));
+ sprintf(proc_str, "%s/%s%s", driver_str, s->dev->slot_name, ac97_str);
+ remove_proc_entry(proc_str, NULL);
+ sprintf(proc_str, "%s/%s", driver_str, s->dev->slot_name);
+ remove_proc_entry(proc_str, NULL);
+ remove_proc_entry(driver_str, NULL);
+ vfree(proc_str);
+
outl(0, s->io+ES1371_REG_CONTROL); /* switch everything off */
outl(0, s->io+ES1371_REG_SERIAL_CONTROL); /* clear serial interrupts */
synchronize_irq();


Attachments:
es1371.pat (2.60 kB)