patch-2.2.0-pre9-parportpc-2

Tim Waugh (tim@cyberelk.demon.co.uk)
Sun, 24 Jan 1999 23:39:18 +0000 (GMT)


Here is a patch that I plan to send to Linus after 2.2.0 is out the door.
It should fix the problems that people were seeing where parport_pc would
fail to load.

Please test it out, and let me know of successes and failures.

This patch is also available at
<URL:ftp://ftp.torque.net/pub/parport/patch-2.2.0-pre9-parportpc-2>.

Thanks,
Tim.
*/

--- /big/linux-2.2.0-pre9/drivers/misc/parport_pc.c Sun Jan 3 13:34:30 1999
+++ linux/drivers/misc/parport_pc.c Sun Jan 24 23:38:00 1999
@@ -378,34 +378,35 @@
*/
static int parport_ECR_present(struct parport *pb)
{
- unsigned char r, octr = parport_pc_read_control(pb);
- unsigned char oecr = parport_pc_read_econtrol(pb);
- unsigned char tmp;
+ unsigned char r;

+ parport_pc_write_control (pb, 0xc);
r = parport_pc_read_control(pb);
if ((parport_pc_read_econtrol(pb) & 0x3) == (r & 0x3)) {
parport_pc_write_control(pb, r ^ 0x2 ); /* Toggle bit 1 */

r = parport_pc_read_control(pb);
- if ((parport_pc_read_econtrol(pb) & 0x2) == (r & 0x2)) {
- parport_pc_write_control(pb, octr);
- return 0; /* Sure that no ECR register exists */
- }
+ if ((parport_pc_read_econtrol(pb) & 0x2) == (r & 0x2))
+ goto no_reg; /* Sure that no ECR register exists */
}

if ((parport_pc_read_econtrol(pb) & 0x3 ) != 0x1)
- return 0;
+ goto no_reg;

parport_pc_write_econtrol(pb, 0x34);
- tmp = parport_pc_read_econtrol(pb);
+ if (parport_pc_read_econtrol(pb) != 0x35)
+ goto no_reg;

- parport_pc_write_econtrol(pb, oecr);
- parport_pc_write_control(pb, octr);
-
- if (tmp != 0x35)
- return 0;
+ parport_pc_write_control(pb, 0xc);

+ /* Go to mode 000; SPP, reset FIFO */
+ parport_pc_frob_econtrol (pb, 0xe0, 0x00);
+
return PARPORT_MODE_PCECR;
+
+ no_reg:
+ parport_pc_write_control (pb, 0xc);
+ return 0;
}

static int parport_ECP_supported(struct parport *pb)
@@ -706,14 +707,11 @@

static int probe_one_port(unsigned long int base, int irq, int dma)
{
- struct parport tmpport, *p;
+ struct parport *p;
int probedirq = PARPORT_IRQ_NONE;
if (check_region(base, 3)) return 0;
- tmpport.base = base;
- tmpport.ops = &parport_pc_ops;
- if (!(parport_SPP_supported(&tmpport))) return 0;
- if (!(p = parport_register_port(base, irq, dma, &parport_pc_ops))) return 0;
- p->modes = PARPORT_MODE_PCSPP | parport_PS2_supported(p);
+ if (!(p = parport_register_port(base, irq, dma, &parport_pc_ops)))
+ return 0;
if (p->base != 0x3bc) {
if (!check_region(base+0x400,3)) {
p->modes |= parport_ECR_present(p);
@@ -725,6 +723,12 @@
p->modes |= parport_ECPEPP_supported(p);
}
}
+ if (!parport_SPP_supported(p)) {
+ /* No port. */
+ parport_unregister_port (p);
+ return 0;
+ }
+ p->modes |= PARPORT_MODE_PCSPP | parport_PS2_supported(p);
p->size = (p->modes & (PARPORT_MODE_PCEPP
| PARPORT_MODE_PCECPEPP))?8:3;
printk(KERN_INFO "%s: PC-style at 0x%lx", p->name, p->base);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/