From 83e890a1f63baee491247fc447f61a3bcd9fefa7 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 8 Jan 2007 12:10:05 +0000 Subject: [PATCH] --- yaml --- r: 47343 b: refs/heads/master c: 4112e16a7c606a80810d22d55bfc742eaa61fecb h: refs/heads/master i: 47341: 95a45023573165c7048337f78091d1ac2e9a176d 47339: 89d5701d21b072d3708eaa6ffc955c8d03f33e00 47335: e0b779735d098a7f75c0b18ea357c9b612927aa6 47327: 7980b788c3330fd512d11fd801b1004558ea8ada v: v3 --- [refs] | 2 +- trunk/drivers/ata/libata-sff.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 06232f417cc9..9053da36c048 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d73f30e1c9a9af14757fa5bf4014343926047156 +refs/heads/master: 4112e16a7c606a80810d22d55bfc742eaa61fecb diff --git a/trunk/drivers/ata/libata-sff.c b/trunk/drivers/ata/libata-sff.c index 12c88c588039..cfa9ed179d9c 100644 --- a/trunk/drivers/ata/libata-sff.c +++ b/trunk/drivers/ata/libata-sff.c @@ -832,6 +832,21 @@ void ata_bmdma_post_internal_cmd(struct ata_queued_cmd *qc) } #ifdef CONFIG_PCI + +static int ata_resources_present(struct pci_dev *pdev, int port) +{ + int i; + + /* Check the PCI resources for this channel are enabled */ + port = port * 2; + for (i = 0; i < 2; i ++) { + if (pci_resource_start(pdev, port + i) == 0 || + pci_resource_len(pdev, port + i) == 0) + return 0; + } + return 1; +} + /** * ata_pci_init_native_mode - Initialize native-mode driver * @pdev: pci device to be initialized @@ -863,6 +878,13 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int probe_ent->irq = pdev->irq; probe_ent->irq_flags = IRQF_SHARED; + + /* Discard disabled ports. Some controllers show their + unused channels this way */ + if (ata_resources_present(pdev, 0) == 0) + ports &= ~ATA_PORT_PRIMARY; + if (ata_resources_present(pdev, 1) == 0) + ports &= ~ATA_PORT_SECONDARY; if (ports & ATA_PORT_PRIMARY) { probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 0);