Commit c961922b73dab429a759f560952fd4c3f60bd6b3

Authored by Alan Cox
Committed by Jeff Garzik
1 parent 4735ebedf3

[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: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

Showing 17 changed files with 67 additions and 108 deletions Side-by-side Diff

drivers/ata/ata_piix.c
... ... @@ -643,11 +643,9 @@
643 643 {
644 644 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
645 645  
646   - if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) {
647   - ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
648   - ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
649   - return 0;
650   - }
  646 + if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
  647 + return -ENOENT;
  648 +
651 649 ap->cbl = ATA_CBL_PATA40;
652 650 return ata_std_prereset(ap);
653 651 }
drivers/ata/libata-eh.c
... ... @@ -1515,7 +1515,11 @@
1515 1515 if (prereset) {
1516 1516 rc = prereset(ap);
1517 1517 if (rc) {
1518   - ata_port_printk(ap, KERN_ERR,
  1518 + if (rc == -ENOENT) {
  1519 + ata_port_printk(ap, KERN_DEBUG, "port disabled. ignoring.\n");
  1520 + ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
  1521 + } else
  1522 + ata_port_printk(ap, KERN_ERR,
1519 1523 "prereset failed (errno=%d)\n", rc);
1520 1524 return rc;
1521 1525 }
drivers/ata/pata_amd.c
... ... @@ -25,7 +25,7 @@
25 25 #include <linux/libata.h>
26 26  
27 27 #define DRV_NAME "pata_amd"
28   -#define DRV_VERSION "0.2.3"
  28 +#define DRV_VERSION "0.2.4"
29 29  
30 30 /**
31 31 * timing_setup - shared timing computation and load
... ... @@ -137,11 +137,8 @@
137 137 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
138 138 u8 ata66;
139 139  
140   - if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) {
141   - ata_port_disable(ap);
142   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
143   - return 0;
144   - }
  140 + if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no]))
  141 + return -ENOENT;
145 142  
146 143 pci_read_config_byte(pdev, 0x42, &ata66);
147 144 if (ata66 & bitmask[ap->port_no])
... ... @@ -167,11 +164,9 @@
167 164 { 0x40, 1, 0x01, 0x01 }
168 165 };
169 166  
170   - if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no])) {
171   - ata_port_disable(ap);
172   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
173   - return 0;
174   - }
  167 + if (!pci_test_config_bits(pdev, &amd_enable_bits[ap->port_no]))
  168 + return -ENOENT;
  169 +
175 170 /* No host side cable detection */
176 171 ap->cbl = ATA_CBL_PATA80;
177 172 return ata_std_prereset(ap);
... ... @@ -262,12 +257,8 @@
262 257 u8 ata66;
263 258 u16 udma;
264 259  
265   - if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no])) {
266   - ata_port_disable(ap);
267   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
268   - return 0;
269   - }
270   -
  260 + if (!pci_test_config_bits(pdev, &nv_enable_bits[ap->port_no]))
  261 + return -ENOENT;
271 262  
272 263 pci_read_config_byte(pdev, 0x52, &ata66);
273 264 if (ata66 & bitmask[ap->port_no])
drivers/ata/pata_artop.c
... ... @@ -28,7 +28,7 @@
28 28 #include <linux/ata.h>
29 29  
30 30 #define DRV_NAME "pata_artop"
31   -#define DRV_VERSION "0.4.1"
  31 +#define DRV_VERSION "0.4.2"
32 32  
33 33 /*
34 34 * The ARTOP has 33 Mhz and "over clocked" timing tables. Until we
... ... @@ -47,11 +47,9 @@
47 47 { 0x4AU, 1U, 0x04UL, 0x04UL }, /* port 1 */
48 48 };
49 49  
50   - if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) {
51   - ata_port_disable(ap);
52   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
53   - return 0;
54   - }
  50 + if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
  51 + return -ENOENT;
  52 +
55 53 ap->cbl = ATA_CBL_PATA40;
56 54 return ata_std_prereset(ap);
57 55 }
... ... @@ -90,11 +88,9 @@
90 88 u8 tmp;
91 89  
92 90 /* Odd numbered device ids are the units with enable bits (the -R cards) */
93   - if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) {
94   - ata_port_disable(ap);
95   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
96   - return 0;
97   - }
  91 + if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
  92 + return -ENOENT;
  93 +
98 94 pci_read_config_byte(pdev, 0x49, &tmp);
99 95 if (tmp & (1 >> ap->port_no))
100 96 ap->cbl = ATA_CBL_PATA40;
drivers/ata/pata_atiixp.c
... ... @@ -22,7 +22,7 @@
22 22 #include <linux/libata.h>
23 23  
24 24 #define DRV_NAME "pata_atiixp"
25   -#define DRV_VERSION "0.4.2"
  25 +#define DRV_VERSION "0.4.3"
26 26  
27 27 enum {
28 28 ATIIXP_IDE_PIO_TIMING = 0x40,
... ... @@ -41,11 +41,9 @@
41 41 { 0x48, 1, 0x08, 0x00 }
42 42 };
43 43  
44   - if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no])) {
45   - ata_port_disable(ap);
46   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
47   - return 0;
48   - }
  44 + if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no]))
  45 + return -ENOENT;
  46 +
49 47 ap->cbl = ATA_CBL_PATA80;
50 48 return ata_std_prereset(ap);
51 49 }
drivers/ata/pata_efar.c
... ... @@ -22,7 +22,7 @@
22 22 #include <linux/ata.h>
23 23  
24 24 #define DRV_NAME "pata_efar"
25   -#define DRV_VERSION "0.4.1"
  25 +#define DRV_VERSION "0.4.2"
26 26  
27 27 /**
28 28 * efar_pre_reset - check for 40/80 pin
... ... @@ -42,11 +42,9 @@
42 42 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
43 43 u8 tmp;
44 44  
45   - if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no])) {
46   - ata_port_disable(ap);
47   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
48   - return 0;
49   - }
  45 + if (!pci_test_config_bits(pdev, &efar_enable_bits[ap->port_no]))
  46 + return -ENOENT;
  47 +
50 48 pci_read_config_byte(pdev, 0x47, &tmp);
51 49 if (tmp & (2 >> ap->port_no))
52 50 ap->cbl = ATA_CBL_PATA40;
drivers/ata/pata_jmicron.c
... ... @@ -51,7 +51,7 @@
51 51 /* Check if our port is enabled */
52 52 pci_read_config_dword(pdev, 0x40, &control);
53 53 if ((control & port_mask) == 0)
54   - return 0;
  54 + return -ENOENT;
55 55  
56 56 /* There are two basic mappings. One has the two SATA ports merged
57 57 as master/slave and the secondary as PATA, the other has only the
drivers/ata/pata_mpiix.c
... ... @@ -18,7 +18,7 @@
18 18 * The driver conciously keeps this logic internally to avoid pushing quirky
19 19 * PATA history into the clean libata layer.
20 20 *
21   - * Thinkpad specific note: If you boot an MPIIX using thinkpad with a PCMCIA
  21 + * Thinkpad specific note: If you boot an MPIIX using a thinkpad with a PCMCIA
22 22 * hard disk present this driver will not detect it. This is not a bug. In this
23 23 * configuration the secondary port of the MPIIX is disabled and the addresses
24 24 * are decoded by the PCMCIA bridge and therefore are for a generic IDE driver
... ... @@ -35,7 +35,7 @@
35 35 #include <linux/libata.h>
36 36  
37 37 #define DRV_NAME "pata_mpiix"
38   -#define DRV_VERSION "0.7.1"
  38 +#define DRV_VERSION "0.7.2"
39 39  
40 40 enum {
41 41 IDETIM = 0x6C, /* IDE control register */
... ... @@ -54,11 +54,8 @@
54 54 { 0x6F, 1, 0x80, 0x80 }
55 55 };
56 56  
57   - if (!pci_test_config_bits(pdev, &mpiix_enable_bits[ap->port_no])) {
58   - ata_port_disable(ap);
59   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
60   - return 0;
61   - }
  57 + if (!pci_test_config_bits(pdev, &mpiix_enable_bits[ap->port_no]))
  58 + return -ENOENT;
62 59 ap->cbl = ATA_CBL_PATA40;
63 60 return ata_std_prereset(ap);
64 61 }
drivers/ata/pata_ns87410.c
... ... @@ -45,11 +45,8 @@
45 45 { 0x47, 1, 0x08, 0x08 }
46 46 };
47 47  
48   - if (!pci_test_config_bits(pdev, &ns87410_enable_bits[ap->port_no])) {
49   - ata_port_disable(ap);
50   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
51   - return 0;
52   - }
  48 + if (!pci_test_config_bits(pdev, &ns87410_enable_bits[ap->port_no]))
  49 + return -ENOENT;
53 50 ap->cbl = ATA_CBL_PATA40;
54 51 return ata_std_prereset(ap);
55 52 }
drivers/ata/pata_oldpiix.c
... ... @@ -25,7 +25,7 @@
25 25 #include <linux/ata.h>
26 26  
27 27 #define DRV_NAME "pata_oldpiix"
28   -#define DRV_VERSION "0.5.1"
  28 +#define DRV_VERSION "0.5.2"
29 29  
30 30 /**
31 31 * oldpiix_pre_reset - probe begin
... ... @@ -42,11 +42,8 @@
42 42 { 0x43U, 1U, 0x80UL, 0x80UL }, /* port 1 */
43 43 };
44 44  
45   - if (!pci_test_config_bits(pdev, &oldpiix_enable_bits[ap->port_no])) {
46   - ata_port_disable(ap);
47   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
48   - return 0;
49   - }
  45 + if (!pci_test_config_bits(pdev, &oldpiix_enable_bits[ap->port_no]))
  46 + return -ENOENT;
50 47 ap->cbl = ATA_CBL_PATA40;
51 48 return ata_std_prereset(ap);
52 49 }
drivers/ata/pata_opti.c
... ... @@ -34,7 +34,7 @@
34 34 #include <linux/libata.h>
35 35  
36 36 #define DRV_NAME "pata_opti"
37   -#define DRV_VERSION "0.2.4"
  37 +#define DRV_VERSION "0.2.5"
38 38  
39 39 enum {
40 40 READ_REG = 0, /* index of Read cycle timing register */
... ... @@ -59,11 +59,9 @@
59 59 { 0x40, 1, 0x08, 0x00 }
60 60 };
61 61  
62   - if (!pci_test_config_bits(pdev, &opti_enable_bits[ap->port_no])) {
63   - ata_port_disable(ap);
64   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
65   - return 0;
66   - }
  62 + if (!pci_test_config_bits(pdev, &opti_enable_bits[ap->port_no]))
  63 + return -ENOENT;
  64 +
67 65 ap->cbl = ATA_CBL_PATA40;
68 66 return ata_std_prereset(ap);
69 67 }
drivers/ata/pata_optidma.c
... ... @@ -33,7 +33,7 @@
33 33 #include <linux/libata.h>
34 34  
35 35 #define DRV_NAME "pata_optidma"
36   -#define DRV_VERSION "0.2.1"
  36 +#define DRV_VERSION "0.2.2"
37 37  
38 38 enum {
39 39 READ_REG = 0, /* index of Read cycle timing register */
... ... @@ -59,11 +59,9 @@
59 59 0x40, 1, 0x08, 0x00
60 60 };
61 61  
62   - if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits)) {
63   - ata_port_disable(ap);
64   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
65   - return 0;
66   - }
  62 + if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits))
  63 + return -ENOENT;
  64 +
67 65 ap->cbl = ATA_CBL_PATA40;
68 66 return ata_std_prereset(ap);
69 67 }
drivers/ata/pata_pdc2027x.c
... ... @@ -36,7 +36,7 @@
36 36 #include <asm/io.h>
37 37  
38 38 #define DRV_NAME "pata_pdc2027x"
39   -#define DRV_VERSION "0.74-ac3"
  39 +#define DRV_VERSION "0.74-ac5"
40 40 #undef PDC_DEBUG
41 41  
42 42 #ifdef PDC_DEBUG
... ... @@ -311,10 +311,8 @@
311 311 static int pdc2027x_prereset(struct ata_port *ap)
312 312 {
313 313 /* Check whether port enabled */
314   - if (!pdc2027x_port_enabled(ap)) {
315   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
316   - return 0;
317   - }
  314 + if (!pdc2027x_port_enabled(ap))
  315 + return -ENOENT;
318 316 pdc2027x_cbl_detect(ap);
319 317 return ata_std_prereset(ap);
320 318 }
drivers/ata/pata_sis.c
... ... @@ -34,7 +34,7 @@
34 34 #include <linux/ata.h>
35 35  
36 36 #define DRV_NAME "pata_sis"
37   -#define DRV_VERSION "0.4.3"
  37 +#define DRV_VERSION "0.4.4"
38 38  
39 39 struct sis_chipset {
40 40 u16 device; /* PCI host ID */
... ... @@ -74,11 +74,9 @@
74 74 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
75 75 u16 tmp;
76 76  
77   - if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) {
78   - ata_port_disable(ap);
79   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
80   - return 0;
81   - }
  77 + if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no]))
  78 + return -ENOENT;
  79 +
82 80 /* The top bit of this register is the cable detect bit */
83 81 pci_read_config_word(pdev, 0x50 + 2 * ap->port_no, &tmp);
84 82 if (tmp & 0x8000)
drivers/ata/pata_sl82c105.c
... ... @@ -19,7 +19,7 @@
19 19 #include <linux/libata.h>
20 20  
21 21 #define DRV_NAME "pata_sl82c105"
22   -#define DRV_VERSION "0.2.2"
  22 +#define DRV_VERSION "0.2.3"
23 23  
24 24 enum {
25 25 /*
... ... @@ -49,11 +49,8 @@
49 49 };
50 50 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
51 51  
52   - if (ap->port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->port_no])) {
53   - ata_port_disable(ap);
54   - dev_printk(KERN_INFO, &pdev->dev, "port disabled. ignoring.\n");
55   - return 0;
56   - }
  52 + if (ap->port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->port_no]))
  53 + return -ENOENT;
57 54 ap->cbl = ATA_CBL_PATA40;
58 55 return ata_std_prereset(ap);
59 56 }
drivers/ata/pata_triflex.c
... ... @@ -46,13 +46,13 @@
46 46 #define DRV_VERSION "0.2.5"
47 47  
48 48 /**
49   - * triflex_probe_init - probe begin
  49 + * triflex_prereset - probe begin
50 50 * @ap: ATA port
51 51 *
52 52 * Set up cable type and use generic probe init
53 53 */
54 54  
55   -static int triflex_probe_init(struct ata_port *ap)
  55 +static int triflex_prereset(struct ata_port *ap)
56 56 {
57 57 static const struct pci_bits triflex_enable_bits[] = {
58 58 { 0x80, 1, 0x01, 0x01 },
... ... @@ -61,11 +61,8 @@
61 61  
62 62 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
63 63  
64   - if (!pci_test_config_bits(pdev, &triflex_enable_bits[ap->port_no])) {
65   - ata_port_disable(ap);
66   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
67   - return 0;
68   - }
  64 + if (!pci_test_config_bits(pdev, &triflex_enable_bits[ap->port_no]))
  65 + return -ENOENT;
69 66 ap->cbl = ATA_CBL_PATA40;
70 67 return ata_std_prereset(ap);
71 68 }
... ... @@ -74,7 +71,7 @@
74 71  
75 72 static void triflex_error_handler(struct ata_port *ap)
76 73 {
77   - ata_bmdma_drive_eh(ap, triflex_probe_init, ata_std_softreset, NULL, ata_std_postreset);
  74 + ata_bmdma_drive_eh(ap, triflex_prereset, ata_std_softreset, NULL, ata_std_postreset);
78 75 }
79 76  
80 77 /**
drivers/ata/pata_via.c
... ... @@ -60,7 +60,7 @@
60 60 #include <linux/libata.h>
61 61  
62 62 #define DRV_NAME "pata_via"
63   -#define DRV_VERSION "0.1.13"
  63 +#define DRV_VERSION "0.1.14"
64 64  
65 65 /*
66 66 * The following comes directly from Vojtech Pavlik's ide/pci/via82cxxx
... ... @@ -155,11 +155,8 @@
155 155  
156 156 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
157 157  
158   - if (!pci_test_config_bits(pdev, &via_enable_bits[ap->port_no])) {
159   - ata_port_disable(ap);
160   - printk(KERN_INFO "ata%u: port disabled. ignoring.\n", ap->id);
161   - return 0;
162   - }
  158 + if (!pci_test_config_bits(pdev, &via_enable_bits[ap->port_no]))
  159 + return -ENOENT;
163 160 }
164 161  
165 162 if ((config->flags & VIA_UDMA) >= VIA_UDMA_66)