Commit ff1882f2 authored by Olaf Hering's avatar Olaf Hering Committed by Linus Torvalds

[PATCH] request_region for winbond and smsc parport drivers

An attempt to fix the random poking in legacy io space...

ask for permissions before poking at io ports.  this affects
detect_and_report_winbond() and detect_and_report_smsc().

Its unclear what port number is returned in show_parconfig_winbond(), so
just request the region as well and free the probing region.
Signed-off-by: default avatarOlaf Hering <olh@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent cd7e4a91
...@@ -1194,7 +1194,7 @@ struct parport_operations parport_pc_ops = ...@@ -1194,7 +1194,7 @@ struct parport_operations parport_pc_ops =
#ifdef CONFIG_PARPORT_PC_SUPERIO #ifdef CONFIG_PARPORT_PC_SUPERIO
/* Super-IO chipset detection, Winbond, SMSC */ /* Super-IO chipset detection, Winbond, SMSC */
static void __devinit show_parconfig_smsc37c669(int io, int key) static int __devinit show_parconfig_smsc37c669(int io, int key)
{ {
int cr1,cr4,cra,cr23,cr26,cr27,i=0; int cr1,cr4,cra,cr23,cr26,cr27,i=0;
static const char *modes[]={ "SPP and Bidirectional (PS/2)", static const char *modes[]={ "SPP and Bidirectional (PS/2)",
...@@ -1261,17 +1261,26 @@ static void __devinit show_parconfig_smsc37c669(int io, int key) ...@@ -1261,17 +1261,26 @@ static void __devinit show_parconfig_smsc37c669(int io, int key)
superios[i].io = 0x278; superios[i].io = 0x278;
superios[i].irq = 5; superios[i].irq = 5;
} }
if (io != superios[i].io) {
/* how many bytes? */
if (!request_region(superios[i].io, 3, "smsc parport")) {
superios[i].io = 0;
return 0;
}
}
d=(cr26 &0x0f); d=(cr26 &0x0f);
if((d==1) || (d==3)) if((d==1) || (d==3))
superios[i].dma= d; superios[i].dma= d;
else else
superios[i].dma= PARPORT_DMA_NONE; superios[i].dma= PARPORT_DMA_NONE;
return 1;
} }
} }
return 0;
} }
static void __devinit show_parconfig_winbond(int io, int key) static int __devinit show_parconfig_winbond(int io, int key)
{ {
int cr30,cr60,cr61,cr70,cr74,crf0,i=0; int cr30,cr60,cr61,cr70,cr74,crf0,i=0;
static const char *modes[] = { static const char *modes[] = {
...@@ -1327,14 +1336,23 @@ static void __devinit show_parconfig_winbond(int io, int key) ...@@ -1327,14 +1336,23 @@ static void __devinit show_parconfig_winbond(int io, int key)
printk(KERN_INFO "Super-IO: too many chips!\n"); printk(KERN_INFO "Super-IO: too many chips!\n");
else { else {
superios[i].io = (cr60<<8)|cr61; superios[i].io = (cr60<<8)|cr61;
if (io != superios[i].io) {
/* how many bytes? */
if (!request_region(superios[i].io, 3, "winbond parport")) {
superios[i].io = 0;
return 0;
}
}
superios[i].irq = cr70&0x0f; superios[i].irq = cr70&0x0f;
superios[i].dma = (((cr74 & 0x07) > 3) ? superios[i].dma = (((cr74 & 0x07) > 3) ?
PARPORT_DMA_NONE : (cr74 & 0x07)); PARPORT_DMA_NONE : (cr74 & 0x07));
return 1;
} }
} }
return 0;
} }
static void __devinit decode_winbond(int efer, int key, int devid, int devrev, int oldid) static int __devinit decode_winbond(int efer, int key, int devid, int devrev, int oldid)
{ {
const char *type = "unknown"; const char *type = "unknown";
int id,progif=2; int id,progif=2;
...@@ -1342,7 +1360,7 @@ static void __devinit decode_winbond(int efer, int key, int devid, int devrev, i ...@@ -1342,7 +1360,7 @@ static void __devinit decode_winbond(int efer, int key, int devid, int devrev, i
if (devid == devrev) if (devid == devrev)
/* simple heuristics, we happened to read some /* simple heuristics, we happened to read some
non-winbond register */ non-winbond register */
return; return 0;
id=(devid<<8) | devrev; id=(devid<<8) | devrev;
...@@ -1367,19 +1385,20 @@ static void __devinit decode_winbond(int efer, int key, int devid, int devrev, i ...@@ -1367,19 +1385,20 @@ static void __devinit decode_winbond(int efer, int key, int devid, int devrev, i
efer, key, devid, devrev, oldid, type); efer, key, devid, devrev, oldid, type);
if (progif == 2) if (progif == 2)
show_parconfig_winbond(efer,key); return show_parconfig_winbond(efer,key);
return 0;
} }
static void __devinit decode_smsc(int efer, int key, int devid, int devrev) static int __devinit decode_smsc(int efer, int key, int devid, int devrev)
{ {
const char *type = "unknown"; const char *type = "unknown";
void (*func)(int io, int key); int (*func)(int io, int key);
int id; int id;
if (devid == devrev) if (devid == devrev)
/* simple heuristics, we happened to read some /* simple heuristics, we happened to read some
non-smsc register */ non-smsc register */
return; return 0;
func=NULL; func=NULL;
id=(devid<<8) | devrev; id=(devid<<8) | devrev;
...@@ -1395,7 +1414,8 @@ static void __devinit decode_smsc(int efer, int key, int devid, int devrev) ...@@ -1395,7 +1414,8 @@ static void __devinit decode_smsc(int efer, int key, int devid, int devrev)
efer, key, devid, devrev, type); efer, key, devid, devrev, type);
if (func) if (func)
func(efer,key); return func(efer,key);
return 0;
} }
...@@ -1403,6 +1423,9 @@ static void __devinit winbond_check(int io, int key) ...@@ -1403,6 +1423,9 @@ static void __devinit winbond_check(int io, int key)
{ {
int devid,devrev,oldid,x_devid,x_devrev,x_oldid; int devid,devrev,oldid,x_devid,x_devrev,x_oldid;
if (!request_region(io, 3, __FUNCTION__))
return;
/* First probe without key */ /* First probe without key */
outb(0x20,io); outb(0x20,io);
x_devid=inb(io+1); x_devid=inb(io+1);
...@@ -1423,15 +1446,21 @@ static void __devinit winbond_check(int io, int key) ...@@ -1423,15 +1446,21 @@ static void __devinit winbond_check(int io, int key)
outb(0xaa,io); /* Magic Seal */ outb(0xaa,io); /* Magic Seal */
if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid)) if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid))
return; /* protection against false positives */ goto out; /* protection against false positives */
decode_winbond(io,key,devid,devrev,oldid); if (decode_winbond(io,key,devid,devrev,oldid));
return;
out:
release_region(io, 3);
} }
static void __devinit winbond_check2(int io,int key) static void __devinit winbond_check2(int io,int key)
{ {
int devid,devrev,oldid,x_devid,x_devrev,x_oldid; int devid,devrev,oldid,x_devid,x_devrev,x_oldid;
if (!request_region(io, 3, __FUNCTION__))
return;
/* First probe without the key */ /* First probe without the key */
outb(0x20,io+2); outb(0x20,io+2);
x_devid=inb(io+2); x_devid=inb(io+2);
...@@ -1451,15 +1480,21 @@ static void __devinit winbond_check2(int io,int key) ...@@ -1451,15 +1480,21 @@ static void __devinit winbond_check2(int io,int key)
outb(0xaa,io); /* Magic Seal */ outb(0xaa,io); /* Magic Seal */
if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid)) if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid))
return; /* protection against false positives */ goto out; /* protection against false positives */
decode_winbond(io,key,devid,devrev,oldid); if (decode_winbond(io,key,devid,devrev,oldid))
return;
out:
release_region(io, 3);
} }
static void __devinit smsc_check(int io, int key) static void __devinit smsc_check(int io, int key)
{ {
int id,rev,oldid,oldrev,x_id,x_rev,x_oldid,x_oldrev; int id,rev,oldid,oldrev,x_id,x_rev,x_oldid,x_oldrev;
if (!request_region(io, 3, __FUNCTION__))
return;
/* First probe without the key */ /* First probe without the key */
outb(0x0d,io); outb(0x0d,io);
x_oldid=inb(io+1); x_oldid=inb(io+1);
...@@ -1485,9 +1520,12 @@ static void __devinit smsc_check(int io, int key) ...@@ -1485,9 +1520,12 @@ static void __devinit smsc_check(int io, int key)
if ((x_id == id) && (x_oldrev == oldrev) && if ((x_id == id) && (x_oldrev == oldrev) &&
(x_oldid == oldid) && (x_rev == rev)) (x_oldid == oldid) && (x_rev == rev))
return; /* protection against false positives */ goto out; /* protection against false positives */
decode_smsc(io,key,oldid,oldrev); if (decode_smsc(io,key,oldid,oldrev))
return;
out:
release_region(io, 3);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment