--lHGcFxmlz1yfXmOs
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
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.
--=20
Andrey Panin | Embedded systems software engineer
pazke@orbita1.ru | PGP key: wwwkeys.eu.pgp.net
--lHGcFxmlz1yfXmOs
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch-ide-bus-clock
Content-Transfer-Encoding: quoted-printable
diff -urN -X /usr/share/dontdiff linux.vanilla/drivers/ide/ata-timing.c lin=
ux/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 @@
=20
return 0;
}
+
+unsigned int ata_system_bus_clock(void)
+{
+ unsigned int clock =3D system_bus_speed * 1000;
+
+ switch (clock) {
+ case 33000: clock =3D 33333; break;
+ case 37000: clock =3D 37500; break;
+ case 41000: clock =3D 41666; break;
+ }
+
+ if (clock < 20000 || clock > 50000) {
+ printk(KERN_WARNING "ATA: User given PCI clock speed impossible (%d), us=
ing 33 MHz instead.\n", clock);
+ printk(KERN_WARNING "ATA: Use ide0=3Data66 if you want to assume 80-wire=
cable\n");
+ clock =3D 33333;
+ }
+
+ return clock;
+}
diff -urN -X /usr/share/dontdiff linux.vanilla/drivers/ide/ata-timing.h lin=
ux/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 =3D system_bus_speed * 1000;
-
- switch (amd_clock) {
- case 33000: amd_clock =3D 33333; break;
- case 37000: amd_clock =3D 37500; break;
- case 41000: amd_clock =3D 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=3Data66 if you want to assume 80-=
wire cable\n");
- amd_clock =3D 33333;
- }
+ amd_clock =3D ata_system_bus_clock();
=20
/*
* Print the boot message.
diff -urN -X /usr/share/dontdiff linux.vanilla/drivers/ide/piix.c linux/dri=
vers/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.
*/
=20
- piix_clock =3D system_bus_speed * 1000;
-
- switch (piix_clock) {
- case 33000: piix_clock =3D 33333; break;
- case 37000: piix_clock =3D 37500; break;
- case 41000: piix_clock =3D 41666; break;
- }
-
- if (piix_clock < 20000 || piix_clock > 50000) {
- printk(KERN_WARNING "PIIX: User given PCI clock speed impossible (%d), u=
sing 33 MHz instead.\n", piix_clock);
- printk(KERN_WARNING "PIIX: Use ide0=3Data66 if you want to assume 80-wir=
e cable\n");
- piix_clock =3D 33333;
- }
+ piix_clock =3D ata_system_bus_clock();
=20
/*
* Print the boot message.
diff -urN -X /usr/share/dontdiff linux.vanilla/drivers/ide/via82cxxx.c linu=
x/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.
*/
=20
- via_clock =3D system_bus_speed * 1000;
-
- switch (via_clock) {
- case 33000: via_clock =3D 33333; break;
- case 37000: via_clock =3D 37500; break;
- case 41000: via_clock =3D 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=3Data66 if you want to assume 80-w=
ire cable.\n");
- via_clock =3D 33333;
- }
+ via_clock =3D ata_system_bus_clock();
=20
/*
* Print the boot message.
--lHGcFxmlz1yfXmOs--
--nFBW6CQlri5Qm8JQ
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE862UlBm4rlNOo3YgRAlsyAJ0W4/wXg7IeeaXjVLOPkZoux+5l2QCfZZb0
8UUJ9qmISQkbWGodd0PHgjE=
=DYnQ
-----END PGP SIGNATURE-----
--nFBW6CQlri5Qm8JQ--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/