patch-2.4.0-test2 linux/drivers/parport/procfs.c
Next file: linux/drivers/parport/share.c
Previous file: linux/drivers/parport/parport_pc.c
Back to the patch index
Back to the overall index
- Lines: 168
- Date:
Mon Jun 19 13:42:38 2000
- Orig file:
v2.4.0-test1/linux/drivers/parport/procfs.c
- Orig date:
Fri Jan 28 15:09:08 2000
diff -u --recursive --new-file v2.4.0-test1/linux/drivers/parport/procfs.c linux/drivers/parport/procfs.c
@@ -109,38 +109,106 @@
}
#endif /* IEEE1284.3 support. */
-static int do_hardware(ctl_table *table, int write, struct file *filp,
- void *result, size_t *lenp)
+static int do_hardware_base_addr (ctl_table *table, int write,
+ struct file *filp, void *result,
+ size_t *lenp)
{
struct parport *port = (struct parport *)table->extra1;
- char buffer[256];
+ char buffer[20];
int len = 0;
if (filp->f_pos) {
*lenp = 0;
return 0;
}
-
- if (write) /* can't happen anyway */
+
+ if (write) /* permissions prevent this anyway */
return -EACCES;
-
- len += sprintf(buffer+len, "base:\t0x%lx", port->base);
- if (port->base_hi)
- len += sprintf(buffer+len, " (0x%lx)", port->base_hi);
- buffer[len++] = '\n';
- if (port->irq == PARPORT_IRQ_NONE) {
- len += sprintf(buffer+len, "irq:\tnone\n");
- } else {
- len += sprintf(buffer+len, "irq:\t%d\n", port->irq);
+ len += sprintf (buffer, "%lu\t%lu\n", port->base, port->base_hi);
+
+ if (len > *lenp)
+ len = *lenp;
+ else
+ *lenp = len;
+
+ filp->f_pos += len;
+
+ return copy_to_user(result, buffer, len) ? -EFAULT : 0;
+}
+
+static int do_hardware_irq (ctl_table *table, int write,
+ struct file *filp, void *result,
+ size_t *lenp)
+{
+ struct parport *port = (struct parport *)table->extra1;
+ char buffer[20];
+ int len = 0;
+
+ if (filp->f_pos) {
+ *lenp = 0;
+ return 0;
}
- if (port->dma == PARPORT_DMA_NONE)
- len += sprintf(buffer+len, "dma:\tnone\n");
+ if (write) /* permissions prevent this anyway */
+ return -EACCES;
+
+ len += sprintf (buffer, "%d\n", port->irq);
+
+ if (len > *lenp)
+ len = *lenp;
else
- len += sprintf(buffer+len, "dma:\t%d\n", port->dma);
+ *lenp = len;
+
+ filp->f_pos += len;
+
+ return copy_to_user(result, buffer, len) ? -EFAULT : 0;
+}
+
+static int do_hardware_dma (ctl_table *table, int write,
+ struct file *filp, void *result,
+ size_t *lenp)
+{
+ struct parport *port = (struct parport *)table->extra1;
+ char buffer[20];
+ int len = 0;
+
+ if (filp->f_pos) {
+ *lenp = 0;
+ return 0;
+ }
+
+ if (write) /* permissions prevent this anyway */
+ return -EACCES;
+
+ len += sprintf (buffer, "%d\n", port->dma);
+
+ if (len > *lenp)
+ len = *lenp;
+ else
+ *lenp = len;
+
+ filp->f_pos += len;
+
+ return copy_to_user(result, buffer, len) ? -EFAULT : 0;
+}
+
+static int do_hardware_modes (ctl_table *table, int write,
+ struct file *filp, void *result,
+ size_t *lenp)
+{
+ struct parport *port = (struct parport *)table->extra1;
+ char buffer[20];
+ int len = 0;
+
+ if (filp->f_pos) {
+ *lenp = 0;
+ return 0;
+ }
+
+ if (write) /* permissions prevent this anyway */
+ return -EACCES;
- len += sprintf(buffer+len, "modes:\t");
{
#define printmode(x) {if(port->modes&PARPORT_MODE_##x){len+=sprintf(buffer+len,"%s%s",f?",":"",#x);f++;}}
int f = 0;
@@ -186,7 +254,7 @@
struct parport_sysctl_table {
struct ctl_table_header *sysctl_header;
- ctl_table vars[9];
+ ctl_table vars[12];
ctl_table device_dir[2];
ctl_table port_dir[2];
ctl_table parport_dir[2];
@@ -201,9 +269,18 @@
&proc_dointvec_minmax, NULL, NULL,
(void*) &parport_min_spintime_value,
(void*) &parport_max_spintime_value },
- { DEV_PARPORT_HARDWARE, "hardware",
+ { DEV_PARPORT_BASE_ADDR, "base-addr",
+ NULL, 0, 0444, NULL,
+ &do_hardware_base_addr },
+ { DEV_PARPORT_IRQ, "irq",
+ NULL, 0, 0444, NULL,
+ &do_hardware_irq },
+ { DEV_PARPORT_DMA, "dma",
+ NULL, 0, 0444, NULL,
+ &do_hardware_dma },
+ { DEV_PARPORT_MODES, "modes",
NULL, 0, 0444, NULL,
- &do_hardware },
+ &do_hardware_modes },
PARPORT_DEVICES_ROOT_DIR,
#ifdef CONFIG_PARPORT_1284
{ DEV_PARPORT_AUTOPROBE, "autoprobe",
@@ -314,10 +391,10 @@
t->vars[i].extra1 = port;
t->vars[0].data = &port->spintime;
- t->vars[2].child = t->device_dir;
+ t->vars[5].child = t->device_dir;
for (i = 0; i < 5; i++)
- t->vars[3 + i].extra2 = &port->probe_info[i];
+ t->vars[6 + i].extra2 = &port->probe_info[i];
t->port_dir[0].procname = port->name;
t->port_dir[0].ctl_name = port->number + 1; /* nb 0 isn't legal here */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)