[PARPORT] Backward compatibility /proc/.../parportX/hardware entry

From: Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
Date: Thu Apr 12 2001 - 10:09:39 EDT

  • Next message: Tim Waugh: "Re: [PARPORT] Backward compatibility /proc/.../parportX/hardware entry"

    Hallo,

    vmware (http://www.vmware.com), a programm to emulate a PC on Linux/NT, used
    /proc/sys/dev/parport/parportX/hardware to determine the characteristics of
    the parallel port. However the 2.4 parport implementation dropped that
    proc entry, and as vmware is closed source and vmware hasn't released an
    update for this problem, people who need the parallel port with vmware need
    to patch the kernel with appended patch.

    Could that /proc/.../hardware entry be restored temporary in the standard
    kernel until there is a new vmware release? I would be very pleased!

    Thanks

    -- 
    Uwe Bonnes                bon@elektron.ikp.physik.tu-darmstadt.de
    

    Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ---------- --- linux/drivers/parport/procfs.c.sav Fri Feb 9 20:30:23 2001 +++ linux/drivers/parport/procfs.c Thu Apr 12 15:54:22 2001 @@ -232,6 +232,53 @@ return copy_to_user(result, buffer, len) ? -EFAULT : 0; } +static int do_hardware_compat (ctl_table *table, int write, + struct file *filp, void *result, + size_t *lenp) +{ + struct parport *port = (struct parport *)table->extra1; + char buffer[200]; + int len = 0; + + if (filp->f_pos) { + *lenp = 0; + return 0; + } + + if (write) /* permissions prevent this anyway */ + return -EACCES; + + /* base */ + len += sprintf (buffer+len, "base:\t0x%lx\n", port->base); + /* irq */ + len += sprintf (buffer+len, "irq:\t%d\n", port->irq); + /* dma */ + len += sprintf (buffer+len, "dma:\t%d\n", port->dma); + /* modes */ + 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; + printmode(PCSPP); + printmode(TRISTATE); + printmode(COMPAT); + printmode(EPP); + printmode(ECP); + printmode(DMA); +#undef printmode + } + buffer[len++] = '\n'; + + if (len > *lenp) + len = *lenp; + else + *lenp = len; + + filp->f_pos += len; + + return copy_to_user(result, buffer, len) ? -EFAULT : 0; +} + #define PARPORT_PORT_DIR(child) { 0, NULL, NULL, 0, 0555, child } #define PARPORT_PARPORT_DIR(child) { DEV_PARPORT, "parport", \ NULL, 0, 0555, child } @@ -254,7 +301,7 @@ struct parport_sysctl_table { struct ctl_table_header *sysctl_header; - ctl_table vars[12]; + ctl_table vars[13]; ctl_table device_dir[2]; ctl_table port_dir[2]; ctl_table parport_dir[2]; @@ -281,7 +328,10 @@ { DEV_PARPORT_MODES, "modes", NULL, 0, 0444, NULL, &do_hardware_modes }, - PARPORT_DEVICES_ROOT_DIR, + { DEV_PARPORT_COMPAT, "hardware", + NULL, 0, 0444, NULL, + &do_hardware_compat }, + PARPORT_DEVICES_ROOT_DIR, #ifdef CONFIG_PARPORT_1284 { DEV_PARPORT_AUTOPROBE, "autoprobe", NULL, 0, 0444, NULL, --- linux/include/linux/sysctl.h.sav Wed Apr 11 15:26:37 2001 +++ linux/include/linux/sysctl.h Thu Apr 12 15:50:38 2001 @@ -578,6 +578,7 @@ DEV_PARPORT_DMA=4, DEV_PARPORT_MODES=5, DEV_PARPORT_DEVICES=6, + DEV_PARPORT_COMPAT=7, DEV_PARPORT_AUTOPROBE=16 };

    -- To unsubscribe, send mail to: linux-parport-request@torque.net -- -- with the single word "unsubscribe" in the body of the message. --



    This archive was generated by hypermail 2b29 : Thu Apr 12 2001 - 10:15:13 EDT