public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrey Panin <pazke@orbita1.ru>
To: Martin Dalecki <dalecki@evision-ventures.com>
Cc: vojtech@ucw.cz, linux-kernel@vger.kernel.org
Subject: [PATCH] duplicate clock calculation code in 3 IDE drivers
Date: Wed, 22 May 2002 13:30:13 +0400	[thread overview]
Message-ID: <20020522093013.GD312@pazke.ipt> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 380 bytes --]

Hi,

now it is more interesting patch. AMD, PIIX and VIA IDE drivers contain
some duplicated code for (amd|piix|via)_clock calculation. Attached
patch moves this code into one function in ata-timing.c file.

Please take a look at it.

Best regards.

-- 
Andrey Panin            | Embedded systems software engineer
pazke@orbita1.ru        | PGP key: wwwkeys.eu.pgp.net

[-- Attachment #1.2: patch-ide-bus-clock --]
[-- Type: text/plain, Size: 3838 bytes --]

diff -urN -X /usr/share/dontdiff linux.vanilla/drivers/ide/ata-timing.c linux/drivers/ide/ata-timing.c
--- linux.vanilla/drivers/ide/ata-timing.c	Tue May 21 01:56:18 2002
+++ linux/drivers/ide/ata-timing.c	Wed May 22 04:06:53 2002
@@ -256,3 +256,22 @@
 
 	return 0;
 }
+
+unsigned int ata_system_bus_clock(void)
+{
+	unsigned int clock = system_bus_speed * 1000;
+
+	switch (clock) {
+		case 33000: clock = 33333; break;
+		case 37000: clock = 37500; break;
+		case 41000: clock = 41666; break;
+	}
+
+	if (clock < 20000 || clock > 50000) {
+		printk(KERN_WARNING "ATA: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", clock);
+		printk(KERN_WARNING "ATA: Use ide0=ata66 if you want to assume 80-wire cable\n");
+		clock = 33333;
+	}
+
+	return clock;
+}
diff -urN -X /usr/share/dontdiff linux.vanilla/drivers/ide/ata-timing.h linux/drivers/ide/ata-timing.h
--- linux.vanilla/drivers/ide/ata-timing.h	Tue May  7 23:50:09 2002
+++ linux/drivers/ide/ata-timing.h	Wed May 22 04:02:13 2002
@@ -82,4 +82,6 @@
 extern struct ata_timing* ata_timing_data(short speed);
 extern int ata_timing_compute(struct ata_device *drive,
 		short speed, struct ata_timing *t, int T, int UT);
+
+extern unsigned int ata_system_bus_clock(void);
 #endif
diff -urN -X /usr/share/dontdiff linux.vanilla/drivers/ide/amd74xx.c linux/drivers/ide/amd74xx.c
--- linux.vanilla/drivers/ide/amd74xx.c	Tue May 21 01:55:57 2002
+++ linux/drivers/ide/amd74xx.c	Wed May 22 03:59:12 2002
@@ -360,20 +360,7 @@
 /*
  * Determine the system bus clock.
  */
-
-	amd_clock = system_bus_speed * 1000;
-
-	switch (amd_clock) {
-		case 33000: amd_clock = 33333; break;
-		case 37000: amd_clock = 37500; break;
-		case 41000: amd_clock = 41666; break;
-	}
-
-	if (amd_clock < 20000 || amd_clock > 50000) {
-		printk(KERN_WARNING "AMD_IDE: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", amd_clock);
-		printk(KERN_WARNING "AMD_IDE: Use ide0=ata66 if you want to assume 80-wire cable\n");
-		amd_clock = 33333;
-	}
+	amd_clock = ata_system_bus_clock();
 
 /*
  * Print the boot message.
diff -urN -X /usr/share/dontdiff linux.vanilla/drivers/ide/piix.c linux/drivers/ide/piix.c
--- linux.vanilla/drivers/ide/piix.c	Tue May 21 01:55:58 2002
+++ linux/drivers/ide/piix.c	Wed May 22 04:03:37 2002
@@ -497,19 +497,7 @@
  * Determine the system bus clock.
  */
 
-	piix_clock = system_bus_speed * 1000;
-
-	switch (piix_clock) {
-		case 33000: piix_clock = 33333; break;
-		case 37000: piix_clock = 37500; break;
-		case 41000: piix_clock = 41666; break;
-	}
-
-	if (piix_clock < 20000 || piix_clock > 50000) {
-		printk(KERN_WARNING "PIIX: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", piix_clock);
-		printk(KERN_WARNING "PIIX: Use ide0=ata66 if you want to assume 80-wire cable\n");
-		piix_clock = 33333;
-	}
+	piix_clock = ata_system_bus_clock();
 
 /*
  * Print the boot message.
diff -urN -X /usr/share/dontdiff linux.vanilla/drivers/ide/via82cxxx.c linux/drivers/ide/via82cxxx.c
--- linux.vanilla/drivers/ide/via82cxxx.c	Tue May 21 01:55:59 2002
+++ linux/drivers/ide/via82cxxx.c	Wed May 22 04:03:17 2002
@@ -474,19 +474,7 @@
  * Determine system bus clock.
  */
 
-	via_clock = system_bus_speed * 1000;
-
-	switch (via_clock) {
-		case 33000: via_clock = 33333; break;
-		case 37000: via_clock = 37500; break;
-		case 41000: via_clock = 41666; break;
-	}
-
-	if (via_clock < 20000 || via_clock > 50000) {
-		printk(KERN_WARNING "VP_IDE: User given PCI clock speed impossible (%d), using 33 MHz instead.\n", via_clock);
-		printk(KERN_WARNING "VP_IDE: Use ide0=ata66 if you want to assume 80-wire cable.\n");
-		via_clock = 33333;
-	}
+	via_clock = ata_system_bus_clock();
 
 /*
  * Print the boot message.

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

             reply	other threads:[~2002-05-22  9:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-22  9:30 Andrey Panin [this message]
2002-05-22  9:42 ` [PATCH] duplicate clock calculation code in 3 IDE drivers Vojtech Pavlik
2002-05-22  8:42   ` Martin Dalecki
2002-05-22 11:11     ` Vojtech Pavlik
     [not found]       ` <3CEB70F4.4030902@evision-ventures.com>
2002-05-22 11:36         ` [patch] Remove dead DISK_RECOVERY_TIME code Vojtech Pavlik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020522093013.GD312@pazke.ipt \
    --to=pazke@orbita1.ru \
    --cc=dalecki@evision-ventures.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vojtech@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox