patch-2.1.110 linux/drivers/misc/parport_procfs.c
Next file: linux/drivers/misc/parport_share.c
Previous file: linux/drivers/misc/parport_pc.c
Back to the patch index
Back to the overall index
- Lines: 149
- Date:
Sun Jul 19 20:40:43 1998
- Orig file:
v2.1.109/linux/drivers/misc/parport_procfs.c
- Orig date:
Thu May 7 22:51:50 1998
diff -u --recursive --new-file v2.1.109/linux/drivers/misc/parport_procfs.c linux/drivers/misc/parport_procfs.c
@@ -175,6 +175,33 @@
return len;
}
+static int autoprobe_read_proc (char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct parport *pp = (struct parport *) data;
+ int len = 0;
+ const char *str;
+
+ if ((str = pp->probe_info.class_name) != NULL)
+ len += sprintf (page+len, "CLASS:%s;\n", str);
+
+ if ((str = pp->probe_info.model) != NULL)
+ len += sprintf (page+len, "MODEL:%s;\n", str);
+
+ if ((str = pp->probe_info.mfr) != NULL)
+ len += sprintf (page+len, "MANUFACTURER:%s;\n", str);
+
+ if ((str = pp->probe_info.description) != NULL)
+ len += sprintf (page+len, "DESCRIPTION:%s;\n", str);
+
+ if ((str = pp->probe_info.cmdset) != NULL)
+ len += sprintf (page+len, "COMMAND SET:%s;\n", str);
+
+ *start = 0;
+ *eof = 1;
+ return strlen (page);
+}
+
static inline void destroy_proc_entry(struct proc_dir_entry *root,
struct proc_dir_entry **d)
{
@@ -199,7 +226,8 @@
static struct proc_dir_entry *new_proc_entry(const char *name, mode_t mode,
struct proc_dir_entry *parent,
- unsigned short ino)
+ unsigned short ino,
+ struct parport *p)
{
struct proc_dir_entry *ent;
@@ -219,9 +247,12 @@
ent->namelen = strlen(name);
ent->mode = mode;
- if (S_ISDIR(mode))
+ if (S_ISDIR(mode))
+ {
+ if (p && p->ops)
+ ent->fill_inode = p->ops->fill_inode;
ent->nlink = 2;
- else
+ } else
ent->nlink = 1;
proc_register(parent, ent);
@@ -229,10 +260,29 @@
return ent;
}
+/*
+ * This is called as the fill_inode function when an inode
+ * is going into (fill = 1) or out of service (fill = 0).
+ * We use it here to manage the module use counts.
+ *
+ * Note: only the top-level directory needs to do this; if
+ * a lower level is referenced, the parent will be as well.
+ */
+static void parport_modcount(struct inode *inode, int fill)
+{
+#ifdef MODULE
+ if (fill)
+ inc_parport_count();
+ else
+ dec_parport_count();
+#endif
+}
int parport_proc_init(void)
{
- base = new_proc_entry("parport", S_IFDIR, &proc_root,PROC_PARPORT);
+ base = new_proc_entry("parport", S_IFDIR, &proc_root,PROC_PARPORT,
+ NULL);
+ base->fill_inode = &parport_modcount;
if (base == NULL) {
printk(KERN_ERR "Unable to initialise /proc/parport.\n");
@@ -244,8 +294,11 @@
void parport_proc_cleanup(void)
{
- if (base) proc_unregister(&proc_root,base->low_ino);
- base = NULL;
+ if (base) {
+ proc_unregister(&proc_root,base->low_ino);
+ kfree(base);
+ base = NULL;
+ }
}
int parport_proc_register(struct parport *pp)
@@ -260,12 +313,12 @@
strncpy(pp->pdir.name, pp->name + strlen("parport"),
sizeof(pp->pdir.name));
- pp->pdir.entry = new_proc_entry(pp->pdir.name, S_IFDIR, base, 0);
+ pp->pdir.entry = new_proc_entry(pp->pdir.name, S_IFDIR, base, 0, pp);
if (pp->pdir.entry == NULL)
goto out_fail;
pp->pdir.irq = new_proc_entry("irq", S_IFREG | S_IRUGO | S_IWUSR,
- pp->pdir.entry, 0);
+ pp->pdir.entry, 0, pp);
if (pp->pdir.irq == NULL)
goto out_fail;
@@ -273,19 +326,27 @@
pp->pdir.irq->write_proc = irq_write_proc;
pp->pdir.irq->data = pp;
- pp->pdir.devices = new_proc_entry("devices", 0, pp->pdir.entry, 0);
+ pp->pdir.devices = new_proc_entry("devices", 0, pp->pdir.entry, 0, pp);
if (pp->pdir.devices == NULL)
goto out_fail;
pp->pdir.devices->read_proc = devices_read_proc;
pp->pdir.devices->data = pp;
- pp->pdir.hardware = new_proc_entry("hardware", 0, pp->pdir.entry, 0);
+ pp->pdir.hardware = new_proc_entry("hardware", 0, pp->pdir.entry, 0,
+ pp);
if (pp->pdir.hardware == NULL)
goto out_fail;
pp->pdir.hardware->read_proc = hardware_read_proc;
pp->pdir.hardware->data = pp;
+
+ pp->pdir.probe = new_proc_entry("autoprobe", 0, pp->pdir.entry, 0, pp);
+ if (pp->pdir.probe == NULL)
+ goto out_fail;
+
+ pp->pdir.probe->read_proc = autoprobe_read_proc;
+ pp->pdir.probe->data = pp;
return 0;
FUNET's LINUX-ADM group, [email protected]
TCL-scripts by Sam Shen, [email protected]