public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/8] isaectomy: toshiba.c
@ 2005-11-16  3:50 Al Viro
  2005-11-16  4:03 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2005-11-16  3:50 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

From: Al Viro <viro@zeniv.linux.org.uk>
Date: 1132110323 -0500

switch from isa_read...() to ioremap() and read...()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---

 drivers/char/toshiba.c |   38 +++++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 15 deletions(-)

0bb582c17832859733b3dd6d408f64234cccf860
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -355,14 +355,14 @@ static void tosh_set_fn_port(void)
 /*
  * Get the machine identification number of the current model
  */
-static int tosh_get_machine_id(void)
+static int tosh_get_machine_id(void __iomem *bios)
 {
 	int id;
 	SMMRegisters regs;
 	unsigned short bx,cx;
 	unsigned long address;
 
-	id = (0x100*(int) isa_readb(0xffffe))+((int) isa_readb(0xffffa));
+	id = (0x100*(int) readb(bios+0xfffe))+((int) readb(bios+0xfffa));
 
 	/* do we have a SCTTable machine identication number on our hands */
 
@@ -388,12 +388,12 @@ static int tosh_get_machine_id(void)
 
 		/* now twiddle with our pointer a bit */
 
-		address = 0x000f0000+bx;
-		cx = isa_readw(address);
-		address = 0x000f0009+bx+cx;
-		cx = isa_readw(address);
-		address = 0x000f000a+cx;
-		cx = isa_readw(address);
+		address = bx;
+		cx = readw(bios + address);
+		address = 9+bx+cx;
+		cx = readw(bios + address);
+		address = 0xa+cx;
+		cx = readw(bios + address);
 
 		/* now construct our machine identification number */
 
@@ -416,13 +416,18 @@ static int tosh_probe(void)
 	int i,major,minor,day,year,month,flag;
 	unsigned char signature[7] = { 0x54,0x4f,0x53,0x48,0x49,0x42,0x41 };
 	SMMRegisters regs;
+	void __iomem *bios = ioremap(0xf0000, 0x10000);
+
+	if (!bios)
+		return -ENOMEM;
 
 	/* extra sanity check for the string "TOSHIBA" in the BIOS because
 	   some machines that are not Toshiba's pass the next test */
 
 	for (i=0;i<7;i++) {
-		if (isa_readb(0xfe010+i)!=signature[i]) {
+		if (readb(bios+0xe010+i)!=signature[i]) {
 			printk("toshiba: not a supported Toshiba laptop\n");
+			iounmap(bios);
 			return -ENODEV;
 		}
 	}
@@ -438,6 +443,7 @@ static int tosh_probe(void)
 
 	if ((flag==1) || ((regs.eax & 0xff00)==0x8600)) {
 		printk("toshiba: not a supported Toshiba laptop\n");
+		iounmap(bios);
 		return -ENODEV;
 	}
 
@@ -447,19 +453,19 @@ static int tosh_probe(void)
 
 	/* next get the machine ID of the current laptop */
 
-	tosh_id = tosh_get_machine_id();
+	tosh_id = tosh_get_machine_id(bios);
 
 	/* get the BIOS version */
 
-	major = isa_readb(0xfe009)-'0';
-	minor = ((isa_readb(0xfe00b)-'0')*10)+(isa_readb(0xfe00c)-'0');
+	major = readb(bios+0xe009)-'0';
+	minor = ((readb(bios+0xe00b)-'0')*10)+(readb(bios+0xe00c)-'0');
 	tosh_bios = (major*0x100)+minor;
 
 	/* get the BIOS date */
 
-	day = ((isa_readb(0xffff5)-'0')*10)+(isa_readb(0xffff6)-'0');
-	month = ((isa_readb(0xffff8)-'0')*10)+(isa_readb(0xffff9)-'0');
-	year = ((isa_readb(0xffffb)-'0')*10)+(isa_readb(0xffffc)-'0');
+	day = ((readb(bios+0xfff5)-'0')*10)+(readb(bios+0xfff6)-'0');
+	month = ((readb(bios+0xfff8)-'0')*10)+(readb(bios+0xfff9)-'0');
+	year = ((readb(bios+0xfffb)-'0')*10)+(readb(bios+0xfffc)-'0');
 	tosh_date = (((year-90) & 0x1f)<<10) | ((month & 0xf)<<6)
 		| ((day & 0x1f)<<1);
 
@@ -476,6 +482,8 @@ static int tosh_probe(void)
 	if ((tosh_id==0xfccb) || (tosh_id==0xfccc))
 		tosh_fan = 1;
 
+	iounmap(bios);
+
 	return 0;
 }
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/8] isaectomy: toshiba.c
  2005-11-16  3:50 [PATCH 1/8] isaectomy: toshiba.c Al Viro
@ 2005-11-16  4:03 ` Linus Torvalds
  2005-11-16  4:09   ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2005-11-16  4:03 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-kernel



On Wed, 16 Nov 2005, Al Viro wrote:
> 
> switch from isa_read...() to ioremap() and read...()

Hmm.. I actually believe that the isa_read() functions are more portable 
and easier to use than ioremap().

The reason? A platform will always know where any legacy ISA bus resides, 
while the "ioremap()" thing will depend on platform PCI code to have set 
the right offsets (and thus the resource addresses) for whatever bus the 
PCI device is on.

So doing a "ioremap(0xf0000)" is actually a harder operation at run-time 
when you have to basically have some special case ("is this address range 
in the ISA legacy region") than for the platform code to just always map 
the ISA legacy region at some random offset and then doing "isa_read()" 
from that.

Is there some underlying reason you want to remove the isa_xxx stuff?

		Linus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/8] isaectomy: toshiba.c
  2005-11-16  4:03 ` Linus Torvalds
@ 2005-11-16  4:09   ` Al Viro
  0 siblings, 0 replies; 3+ messages in thread
From: Al Viro @ 2005-11-16  4:09 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel

On Tue, Nov 15, 2005 at 08:03:19PM -0800, Linus Torvalds wrote:
> Hmm.. I actually believe that the isa_read() functions are more portable 
> and easier to use than ioremap().
> 
> The reason? A platform will always know where any legacy ISA bus resides, 
> while the "ioremap()" thing will depend on platform PCI code to have set 
> the right offsets (and thus the resource addresses) for whatever bus the 
> PCI device is on.
> 
> So doing a "ioremap(0xf0000)" is actually a harder operation at run-time 
> when you have to basically have some special case ("is this address range 
> in the ISA legacy region") than for the platform code to just always map 
> the ISA legacy region at some random offset and then doing "isa_read()" 
> from that.
> 
> Is there some underlying reason you want to remove the isa_xxx stuff?

The fact that it has almost no users?  And nearly all drivers that do
use it (and not just have it in dead code) are using it for access to
very specific locations in BIOS...

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-11-16  4:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-16  3:50 [PATCH 1/8] isaectomy: toshiba.c Al Viro
2005-11-16  4:03 ` Linus Torvalds
2005-11-16  4:09   ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox