Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c961922b authored by Alan Cox's avatar Alan Cox Committed by Jeff Garzik
Browse files

[PATCH] libata-eh: Remove layering violation and duplication when handling absent ports



This removes the layering violation where drivers have to fiddle
directly with EH flags. Instead we now recognize -ENOENT means "no port"
and do the handling in the core code.

This also removes an instance of a call to disable the port, and an
identical printk from each driver doing this. Even better - future rule
changes will be in one place only.

Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 4735ebed
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -643,11 +643,9 @@ static int piix_pata_prereset(struct ata_port *ap)
{
	struct pci_dev *pdev = to_pci_dev(ap->host->dev);

	if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) {
		ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
		ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
		return 0;
	}
	if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
		return -ENOENT;
		
	ap->cbl = ATA_CBL_PATA40;
	return ata_std_prereset(ap);
}
+5 −1
Original line number Diff line number Diff line
@@ -1515,6 +1515,10 @@ static int ata_eh_reset(struct ata_port *ap, int classify,
	if (prereset) {
		rc = prereset(ap);
		if (rc) {
			if (rc == -ENOENT) {
				ata_port_printk(ap, KERN_DEBUG, "port disabled. ignoring.\n");
				ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
			} else
				ata_port_printk(ap, KERN_ERR,
					"prereset failed (errno=%d)\n", rc);
			return rc;
+8 −17
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
#include <linux/libata.h>

#define DRV_NAME "pata_amd"
#define DRV_VERSION "0.2.3"
#define DRV_VERSION "0.2.4"

/**
 *	timing_setup		-	shared timing computation and load
@@ -137,11 +137,8 @@ static int amd_pre_reset(struct ata_port *ap)
	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
	u8 ata66;

	if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) {
		ata_port_disable(ap);
		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
		return 0;
	}
	if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no]))
		return -ENOENT;

	pci_read_config_byte(pdev, 0x42, &ata66);
	if (ata66 & bitmask[ap->port_no])
@@ -167,11 +164,9 @@ static int amd_early_pre_reset(struct ata_port *ap)
		{ 0x40, 1, 0x01, 0x01 }
	};

	if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) {
		ata_port_disable(ap);
		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
		return 0;
	}
	if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no]))
		return -ENOENT;

	/* No host side cable detection */
	ap->cbl = ATA_CBL_PATA80;
	return ata_std_prereset(ap);
@@ -262,12 +257,8 @@ static int nv_pre_reset(struct ata_port *ap) {
	u8 ata66;
	u16 udma;

	if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no])) {
		ata_port_disable(ap);
		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
		return 0;
	}

	if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no]))
		return -ENOENT;

	pci_read_config_byte(pdev, 0x52, &ata66);
	if (ata66 & bitmask[ap->port_no])
+7 −11
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
#include <linux/ata.h>

#define DRV_NAME	"pata_artop"
#define DRV_VERSION	"0.4.1"
#define DRV_VERSION	"0.4.2"

/*
 *	The ARTOP has 33 Mhz and "over clocked" timing tables. Until we
@@ -47,11 +47,9 @@ static int artop6210_pre_reset(struct ata_port *ap)
		{ 0x4AU, 1U, 0x04UL, 0x04UL },	/* port 1 */
	};

	if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) {
		ata_port_disable(ap);
		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
		return 0;
	}
	if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
		return -ENOENT;

	ap->cbl = ATA_CBL_PATA40;
	return ata_std_prereset(ap);
}
@@ -90,11 +88,9 @@ static int artop6260_pre_reset(struct ata_port *ap)
	u8 tmp;

	/* Odd numbered device ids are the units with enable bits (the -R cards) */
	if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) {
		ata_port_disable(ap);
		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
		return 0;
	}
	if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
		return -ENOENT;

	pci_read_config_byte(pdev, 0x49, &tmp);
	if (tmp & (1 >> ap->port_no))
		ap->cbl = ATA_CBL_PATA40;
+4 −6
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
#include <linux/libata.h>

#define DRV_NAME "pata_atiixp"
#define DRV_VERSION "0.4.2"
#define DRV_VERSION "0.4.3"

enum {
	ATIIXP_IDE_PIO_TIMING	= 0x40,
@@ -41,11 +41,9 @@ static int atiixp_pre_reset(struct ata_port *ap)
		{ 0x48, 1, 0x08, 0x00 }
	};

	if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no])) {
		ata_port_disable(ap);
		printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
		return 0;
	}
	if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no]))
		return -ENOENT;

	ap->cbl = ATA_CBL_PATA80;
	return ata_std_prereset(ap);
}
Loading