mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <petkovbb@googlemail.com>
To: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: alan@redhat.com, linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org
Subject: [PATCH 1/2] pata_legacy: export functionality to ide
Date: Sun, 3 Aug 2008 09:37:56 +0200	[thread overview]
Message-ID: <20080803073756.GA8762@gollum.tnic> (raw)
In-Reply-To: <200808022046.16990.bzolnier@gmail.com>

Ok, here's a definitely better solution:

---
From: Borislav Petkov <petkovbb@gmail.com>
Date: Sun, 3 Aug 2008 08:31:20 +0200
Subject: [PATCH 1/2] pata_legacy: export functionality to ide

export the legacy iobases checking code to other
users (ide) by pushing it up into the header.

CC: Alan Cox <alan@redhat.com>
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/ata/pata_legacy.c |   63 +-----------------------------------------
 include/linux/ata.h       |   67 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 62 deletions(-)

diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index bc037ff..14d187e 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -50,7 +50,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/pci.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/delay.h>
@@ -1040,47 +1039,6 @@ fail:
 	return ret;
 }
 
-/**
- *	legacy_check_special_cases	-	ATA special cases
- *	@p: PCI device to check
- *	@master: set this if we find an ATA master
- *	@master: set this if we find an ATA secondary
- *
- *	A small number of vendors implemented early PCI ATA interfaces
- *	on bridge logic without the ATA interface being PCI visible.
- *	Where we have a matching PCI driver we must skip the relevant
- *	device here. If we don't know about it then the legacy driver
- *	is the right driver anyway.
- */
-
-static void __init legacy_check_special_cases(struct pci_dev *p, int *primary,
-								int *secondary)
-{
-	/* Cyrix CS5510 pre SFF MWDMA ATA on the bridge */
-	if (p->vendor == 0x1078 && p->device == 0x0000) {
-		*primary = *secondary = 1;
-		return;
-	}
-	/* Cyrix CS5520 pre SFF MWDMA ATA on the bridge */
-	if (p->vendor == 0x1078 && p->device == 0x0002) {
-		*primary = *secondary = 1;
-		return;
-	}
-	/* Intel MPIIX - PIO ATA on non PCI side of bridge */
-	if (p->vendor == 0x8086 && p->device == 0x1234) {
-		u16 r;
-		pci_read_config_word(p, 0x6C, &r);
-		if (r & 0x8000) {
-			/* ATA port enabled */
-			if (r & 0x4000)
-				*secondary = 1;
-			else
-				*primary = 1;
-		}
-		return;
-	}
-}
-
 static __init void probe_opti_vlb(void)
 {
 	/* If an OPTI 82C46X is present find out where the channels are */
@@ -1210,26 +1168,7 @@ static __init int legacy_init(void)
 	struct legacy_probe *pl = &probe_list[0];
 	int slot = 0;
 
-	struct pci_dev *p = NULL;
-
-	for_each_pci_dev(p) {
-		int r;
-		/* Check for any overlap of the system ATA mappings. Native
-		   mode controllers stuck on these addresses or some devices
-		   in 'raid' mode won't be found by the storage class test */
-		for (r = 0; r < 6; r++) {
-			if (pci_resource_start(p, r) == 0x1f0)
-				primary = 1;
-			if (pci_resource_start(p, r) == 0x170)
-				secondary = 1;
-		}
-		/* Check for special cases */
-		legacy_check_special_cases(p, &primary, &secondary);
-
-		/* If PCI bus is present then don't probe for tertiary
-		   legacy ports */
-		pci_present = 1;
-	}
+	ata_legacy_check_iobases(&primary, &secondary, &pci_present);
 
 	if (winbond == 1)
 		winbond = 0x130;	/* Default port, alt is 1B0 */
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 11de32c..0470562 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -30,6 +30,7 @@
 #define __LINUX_ATA_H__
 
 #include <linux/types.h>
+#include <linux/pci.h>
 
 /* defines only for the constants which don't work well as enums */
 #define ATA_DMA_BOUNDARY	0xffffUL
@@ -776,4 +777,70 @@ static inline int lba_48_ok(u64 block, u32 n_block)
 #define sata_pmp_gscr_rev(gscr)		(((gscr)[SATA_PMP_GSCR_REV] >> 8) & 0xff)
 #define sata_pmp_gscr_ports(gscr)	((gscr)[SATA_PMP_GSCR_PORT_INFO] & 0xf)
 
+/**
+ *	legacy_check_special_cases	-	ATA special cases
+ *	@p: PCI device to check
+ *	@master: set this if we find an ATA master
+ *	@master: set this if we find an ATA secondary
+ *
+ *	A small number of vendors implemented early PCI ATA interfaces
+ *	on bridge logic without the ATA interface being PCI visible.
+ *	Where we have a matching PCI driver we must skip the relevant
+ *	device here. If we don't know about it then the legacy driver
+ *	is the right driver anyway.
+ */
+static inline void __init ata_legacy_check_special_cases(struct pci_dev *p,
+							 int *primary,
+							 int *secondary)
+{
+	/* Cyrix CS5510 pre SFF MWDMA ATA on the bridge */
+	if (p->vendor == 0x1078 && p->device == 0x0000) {
+		*primary = *secondary = 1;
+		return;
+	}
+	/* Cyrix CS5520 pre SFF MWDMA ATA on the bridge */
+	if (p->vendor == 0x1078 && p->device == 0x0002) {
+		*primary = *secondary = 1;
+		return;
+	}
+	/* Intel MPIIX - PIO ATA on non PCI side of bridge */
+	if (p->vendor == 0x8086 && p->device == 0x1234) {
+		u16 r;
+		pci_read_config_word(p, 0x6C, &r);
+		if (r & 0x8000) {
+			/* ATA port enabled */
+			if (r & 0x4000)
+				*secondary = 1;
+			else
+				*primary = 1;
+		}
+		return;
+	}
+}
+
+static inline void __init ata_legacy_check_iobases(int *primary, int *secondary,
+						   int *pci_present)
+{
+	struct pci_dev *p = NULL;
+
+	for_each_pci_dev(p) {
+		int r;
+		/* Check for any overlap of the system ATA mappings. Native
+		   mode controllers stuck on these addresses or some devices
+		   in 'raid' mode won't be found by the storage class test */
+		for (r = 0; r < 6; r++) {
+			if (pci_resource_start(p, r) == 0x1f0)
+				*primary = 1;
+			if (pci_resource_start(p, r) == 0x170)
+				*secondary = 1;
+		}
+		/* Check for special cases */
+		ata_legacy_check_special_cases(p, primary, secondary);
+
+		/* If PCI bus is present then don't probe for tertiary
+		   legacy ports */
+		*pci_present = 1;
+	}
+}
+
 #endif /* __LINUX_ATA_H__ */
-- 
1.5.5.4

-- 
Regards/Gruss,
    Boris.

  reply	other threads:[~2008-08-03  7:38 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-15  5:33 [PATCH] ide-floppy fix Borislav Petkov
2008-07-15  5:40 ` Borislav Petkov
2008-07-16 15:59 ` Bartlomiej Zolnierkiewicz
2008-07-15 20:39   ` Borislav Petkov
2008-07-15 20:58     ` Bartlomiej Zolnierkiewicz
2008-07-16  5:20       ` Borislav Petkov
2008-07-16 17:56         ` Bartlomiej Zolnierkiewicz
2008-07-20 12:06           ` Borislav Petkov
2008-07-21 19:03             ` Bartlomiej Zolnierkiewicz
2008-07-22  5:27               ` Borislav Petkov
2008-07-22 19:49                 ` Bartlomiej Zolnierkiewicz
2008-07-23  6:32                   ` Borislav Petkov
2008-07-23 18:51                     ` Bartlomiej Zolnierkiewicz
2008-08-01  5:48                       ` [PATCH] ide-generic: skip automatic probing of legacy iobases (was: Re: [PATCH] ide-floppy fix) Borislav Petkov
2008-08-02 17:02                         ` Bartlomiej Zolnierkiewicz
2008-08-02 18:32                           ` Borislav Petkov
2008-08-02 18:46                             ` Bartlomiej Zolnierkiewicz
2008-08-03  7:37                               ` Borislav Petkov [this message]
2008-08-03 11:59                                 ` [PATCH 1/2] pata_legacy: export functionality to ide Alan Cox
2008-08-03 13:37                                   ` Bartlomiej Zolnierkiewicz
2008-08-03 13:39                                     ` Alan Cox
2008-08-03 23:43                                       ` Jeff Garzik
2008-08-03 14:38                                   ` Borislav Petkov
2008-08-03 15:22                                     ` Alan Cox
2008-08-03 16:51                                       ` Borislav Petkov
2008-08-05 14:26                                         ` Sergei Shtylyov
2008-08-05 14:32                                           ` Boris Petkov
2008-08-05 14:41                                             ` Bartlomiej Zolnierkiewicz
2008-08-06  6:10                                               ` Borislav Petkov
2008-08-06 11:34                                                 ` Sergei Shtylyov
2008-08-06 14:03                                                   ` Boris Petkov
2008-08-06 15:57                                                     ` Sergei Shtylyov
2008-08-06 19:47                                                       ` Borislav Petkov
2008-08-06 19:46                                                         ` Alan Cox
2008-08-06 20:04                                                         ` Sergei Shtylyov
2008-08-07  4:36                                                           ` [PATCH] ide-generic: handle probing of legacy io-ports v5 (was: Re: [PATCH 1/2] pata_legacy: export functionality to ide) Borislav Petkov
2008-08-07 17:06                                                             ` Bartlomiej Zolnierkiewicz
2008-08-08 10:04                                                             ` [PATCH] ide-generic: handle probing of legacy io-ports v5 Sergei Shtylyov
2008-08-03  7:38                               ` [PATCH 2/2] ide-generic: handle probing of legacy io-ports Borislav Petkov
2008-08-03 14:11                                 ` Bartlomiej Zolnierkiewicz
2008-08-03 14:45                                   ` Borislav Petkov
2008-08-03 14:54                                     ` Borislav Petkov
2008-08-03 14:59                                     ` Bartlomiej Zolnierkiewicz
2008-08-03 15:08                                   ` Borislav Petkov

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=20080803073756.GA8762@gollum.tnic \
    --to=petkovbb@googlemail.com \
    --cc=alan@redhat.com \
    --cc=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petkovbb@gmail.com \
    /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

all inboxes | Powered by JetHome®