remove unnecessary checks in pcmcia
PATCH 1/1 remove unnecessary checks in pcmcia
io->stop/start are 16 bits, so will never be >0xffff
drivers/pcmcia/i82092.c +1 -1
@@ -675,7 +675,7 @@ static int i82092aa_set_io_map(struct pcleave ("i82092aa_set_io_map with invalid map" );return -EINVAL ; } -if ((io->start >0xffff ) || (io->stop >0xffff ) || (io->stop < io->start)){ +if (io->stop < io->start) {leave ("i82092aa_set_io_map with invalid io" );return -EINVAL ; }
drivers/pcmcia/i82365.c +2 -2
@@ -1143,8 +1143,8 @@ static int i365_set_io_map(u_short sock,"%#4.4x-%#4.4x)\n" , sock, io->map, io->flags, io->speed, io->start, io->stop); map = io->map; -if ((map >1 ) || (io->start >0xffff ) || (io->stop >0xffff ) || - (io->stop < io->start))return -EINVAL ; +if ((map >1 ) || (io->stop < io->start)) +return -EINVAL ;/* Turn off the window before changing anything */ if (i365_get (sock,I365_ADDRWIN ) &I365_ENA_IO (map))i365_bclr (sock,I365_ADDRWIN ,I365_ENA_IO (map));
drivers/pcmcia/tcic.c +2 -2
@@ -786,8 +786,8 @@ static int tcic_set_io_map(struct pcmciaDEBUG (1 ,"tcic: SetIOMap(%d, %d, %#2.2x, %d ns, " "%#4.4x-%#4.4x)\n" , lsock, io->map, io->flags, io->speed, io->start, io->stop); -if ((io->map >1 ) || (io->start >0xffff ) || (io->stop >0xffff ) || - (io->stop < io->start))return -EINVAL ; +if ((io->map >1 ) || (io->stop < io->start)) +return -EINVAL ;tcic_setw (TCIC_ADDR +2 ,TCIC_ADR2_INDREG | (psock <<TCIC_SS_SHFT )); addr =TCIC_IWIN (psock, io->map);
Quoted 1 line · On Mon, Sep 29, 2003 at 06:04:34PM +0100, [email protected] wrote:
io->stop/start are 16 bits, so will never be >0xffff
Not necessarily. On x86 yes. On ARM, no.
Signature · 4 lines
Russell King ([email protected]) http://www.arm.linux.org.uk/personal/ Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/ 2.6 Serial core
Quoted 4 lines · Russell King
Quoted 1 line · On Mon, Sep 29, 2003 at 06:04:34PM +0100, [email protected] wrote:
io->stop/start are 16 bits, so will never be >0xffff
Not necessarily. On x86 yes. On ARM, no.
I recall discussing this with you when I first wrote that patch. Mind explaining what I've missed ?
Dave
Signature · 1 line
Dave Jones http://www.codemonkey.org.uk
Quoted 6 lines · On Mon, Sep 29, 2003 at 06:04:34PM +0100, [email protected] wrote:
io->stop/start are 16 bits, so will never be >0xffff
diff -urpN --exclude-from=/home/davej/.exclude
bk-linus/drivers/pcmcia/i82092.clinux-2.5/drivers/pcmcia/i82092.c
drivers/pcmcia/i82092.c static int i82092aa_set_io_map(struct pc · line 681
Quoted 8 lines
drivers/pcmcia/i82092.c +1
-1@@ -675,7 +675,7 @@ static int i82092aa_set_io_map(struct pcleave ("i82092aa_set_io_map with invalid map" );return -EINVAL ; } -if ((io->start >0xffff ) || (io->stop >0xffff ) || (io->stop < io->start)){ +if (io->stop < io->start) {leave ("i82092aa_set_io_map with invalid io" );return -EINVAL ; }
I would think the code should fail on ==0 and ==0xffff, no?
Also, does this need the "if map > 1" check the code below has?
Quoted 4 lines
diff -urpN --exclude-from=/home/davej/.exclude
bk-linus/drivers/pcmcia/i82365.clinux-2.5/drivers/pcmcia/i82365.c
drivers/pcmcia/i82365.c static int i365_set_io_map(u_short sock, · line 1150
Quoted 10 lines
drivers/pcmcia/i82365.c +2
-2@@ -1143,8 +1143,8 @@ static int i365_set_io_map(u_short sock,"%#4.4x-%#4.4x)\n" , sock, io->map, io->flags, io->speed, io->start, io->stop); map = io->map; -if ((map >1 ) || (io->start >0xffff ) || (io->stop >0xffff ) || - (io->stop < io->start))return -EINVAL ; +if ((map >1 ) || (io->stop < io->start)) +return -EINVAL ;/* Turn off the window before changing anything */ if (i365_get (sock,I365_ADDRWIN ) &I365_ENA_IO (map))i365_bclr (sock,I365_ADDRWIN ,I365_ENA_IO (map));
likewise
drivers/pcmcia/tcic.c static int tcic_set_io_map(struct pcmcia · line 792
Quoted 13 lines
diff -urpN --exclude-from=/home/davej/.exclude
bk-linus/drivers/pcmcia/tcic.clinux-2.5/drivers/pcmcia/tcic.cdrivers/pcmcia/tcic.c +2
-2@@ -786,8 +786,8 @@ static int tcic_set_io_map(struct pcmciaDEBUG (1 ,"tcic: SetIOMap(%d, %d, %#2.2x, %d ns, " "%#4.4x-%#4.4x)\n" , lsock, io->map, io->flags, io->speed, io->start, io->stop); -if ((io->map >1 ) || (io->start >0xffff ) || (io->stop >0xffff ) || - (io->stop < io->start))return -EINVAL ; +if ((io->map >1 ) || (io->stop < io->start)) +return -EINVAL ;tcic_setw (TCIC_ADDR +2 ,TCIC_ADR2_INDREG | (psock <<TCIC_SS_SHFT )); addr =TCIC_IWIN (psock, io->map);
likewise