Commit 1626aeb8 authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik

libata: clean up SFF init mess

The intention of using port_mask in SFF init helpers was to eventually
support exoctic configurations such as combination of legacy and
native port on the same controller.  This never became actually
necessary and the related code always has been subtly broken one way
or the other.  Now that new init model is in place, there is no reason
to make common helpers capable of handling all corner cases.  Exotic
cases can simply dealt within LLDs as necessary.

This patch removes port_mask handling in SFF init helpers.  SFF init
helpers don't take n_ports argument and interpret it into port_mask
anymore.  All information is carried via port_info.  n_ports argument
is dropped and always two ports are allocated.  LLD can tell SFF to
skip certain port by marking it dummy.  Note that SFF code has been
treating unuvailable ports this way for a long time until recent
breakage fix from Linus and is consistent with how other drivers
handle with unavailable ports.

This fixes 1-port legacy host handling still broken after the recent
native mode fix and simplifies SFF init logic.  The following changes
are made...

* ata_pci_init_native_host() and ata_init_legacy_host() both now try
  to initialized whatever they can and mark failed ports dummy.  They
  return 0 if any port is successfully initialized.

* ata_pci_prepare_native_host() and ata_pci_init_one() now doesn't
  take n_ports argument.  All info should be specified via port_info
  array.  Always two ports are allocated.

* ata_pci_init_bmdma() exported to be used by LLDs in exotic cases.

* port_info handling in all LLDs are standardized - all port_info
  arrays are const stack variable named ppi.  Unless the second port
  is different from the first, its port_info is specified as NULL
  (tells libata that it's identical to the last non-NULL port_info).

* pata_hpt37x/hpt3x2n: don't modify static variable directly.  Make an
  on-stack copy instead as ata_piix does.

* pata_uli: It has 4 ports instead of 2.  Don't use
  ata_pci_prepare_native_host().  Allocate the host explicitly and use
  init helpers.  It's simple enough.
Signed-off-by: 's avatarTejun Heo <htejun@gmail.com>
Signed-off-by: 's avatarJeff Garzik <jeff@garzik.org>
parent 920a4b10
......@@ -141,7 +141,7 @@ static int all_generic_ide; /* Set to claim all devices */
static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
u16 command;
static struct ata_port_info info = {
static const struct ata_port_info info = {
.sht = &generic_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -149,7 +149,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
.udma_mask = 0x3f,
.port_ops = &generic_port_ops
};
static struct ata_port_info *port_info[2] = { &info, &info };
const struct ata_port_info *ppi[] = { &info, NULL };
/* Don't use the generic entry unless instructed to do so */
if (id->driver_data == 1 && all_generic_ide == 0)
......@@ -175,7 +175,7 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
if (dev->vendor == PCI_VENDOR_ID_AL)
ata_pci_clear_simplex(dev);
return ata_pci_init_one(dev, port_info, 2);
return ata_pci_init_one(dev, ppi);
}
static struct pci_device_id ata_generic[] = {
......
......@@ -1030,7 +1030,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
static int printed_version;
struct device *dev = &pdev->dev;
struct ata_port_info port_info[2];
struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] };
const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
struct piix_host_priv *hpriv;
unsigned long port_flags;
......@@ -1089,7 +1089,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
port_info[1].mwdma_mask = 0;
port_info[1].udma_mask = 0;
}
return ata_pci_init_one(pdev, ppinfo, 2);
return ata_pci_init_one(pdev, ppi);
}
static int __init piix_init(void)
......
......@@ -6856,6 +6856,7 @@ EXPORT_SYMBOL_GPL(ata_timing_merge);
#ifdef CONFIG_PCI
EXPORT_SYMBOL_GPL(pci_test_config_bits);
EXPORT_SYMBOL_GPL(ata_pci_init_native_host);
EXPORT_SYMBOL_GPL(ata_pci_init_bmdma);
EXPORT_SYMBOL_GPL(ata_pci_prepare_native_host);
EXPORT_SYMBOL_GPL(ata_pci_init_one);
EXPORT_SYMBOL_GPL(ata_pci_remove_one);
......
This diff is collapsed.
......@@ -518,14 +518,14 @@ static void ali_init_chipset(struct pci_dev *pdev)
static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
static struct ata_port_info info_early = {
static const struct ata_port_info info_early = {
.sht = &ali_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f,
.port_ops = &ali_early_port_ops
};
/* Revision 0x20 added DMA */
static struct ata_port_info info_20 = {
static const struct ata_port_info info_20 = {
.sht = &ali_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
.pio_mask = 0x1f,
......@@ -533,7 +533,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
.port_ops = &ali_20_port_ops
};
/* Revision 0x20 with support logic added UDMA */
static struct ata_port_info info_20_udma = {
static const struct ata_port_info info_20_udma = {
.sht = &ali_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
.pio_mask = 0x1f,
......@@ -542,7 +542,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
.port_ops = &ali_20_port_ops
};
/* Revision 0xC2 adds UDMA66 */
static struct ata_port_info info_c2 = {
static const struct ata_port_info info_c2 = {
.sht = &ali_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
.pio_mask = 0x1f,
......@@ -551,7 +551,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
.port_ops = &ali_c2_port_ops
};
/* Revision 0xC3 is UDMA100 */
static struct ata_port_info info_c3 = {
static const struct ata_port_info info_c3 = {
.sht = &ali_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
.pio_mask = 0x1f,
......@@ -560,7 +560,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
.port_ops = &ali_c2_port_ops
};
/* Revision 0xC4 is UDMA133 */
static struct ata_port_info info_c4 = {
static const struct ata_port_info info_c4 = {
.sht = &ali_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | ATA_FLAG_PIO_LBA48,
.pio_mask = 0x1f,
......@@ -569,7 +569,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
.port_ops = &ali_c2_port_ops
};
/* Revision 0xC5 is UDMA133 with LBA48 DMA */
static struct ata_port_info info_c5 = {
static const struct ata_port_info info_c5 = {
.sht = &ali_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -578,7 +578,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
.port_ops = &ali_c5_port_ops
};
static struct ata_port_info *port_info[2];
const struct ata_port_info *ppi[] = { NULL, NULL };
u8 rev, tmp;
struct pci_dev *isa_bridge;
......@@ -590,17 +590,17 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
*/
if (rev < 0x20) {
port_info[0] = port_info[1] = &info_early;
ppi[0] = &info_early;
} else if (rev < 0xC2) {
port_info[0] = port_info[1] = &info_20;
ppi[0] = &info_20;
} else if (rev == 0xC2) {
port_info[0] = port_info[1] = &info_c2;
ppi[0] = &info_c2;
} else if (rev == 0xC3) {
port_info[0] = port_info[1] = &info_c3;
ppi[0] = &info_c3;
} else if (rev == 0xC4) {
port_info[0] = port_info[1] = &info_c4;
ppi[0] = &info_c4;
} else
port_info[0] = port_info[1] = &info_c5;
ppi[0] = &info_c5;
ali_init_chipset(pdev);
......@@ -609,10 +609,10 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
/* Are we paired with a UDMA capable chip */
pci_read_config_byte(isa_bridge, 0x5E, &tmp);
if ((tmp & 0x1E) == 0x12)
port_info[0] = port_info[1] = &info_20_udma;
ppi[0] = &info_20_udma;
pci_dev_put(isa_bridge);
}
return ata_pci_init_one(pdev, port_info, 2);
return ata_pci_init_one(pdev, ppi);
}
#ifdef CONFIG_PM
......
......@@ -538,7 +538,7 @@ static struct ata_port_operations nv133_port_ops = {
static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
static struct ata_port_info info[10] = {
static const struct ata_port_info info[10] = {
{ /* 0: AMD 7401 */
.sht = &amd_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
......@@ -620,7 +620,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
.port_ops = &amd100_port_ops
}
};
static struct ata_port_info *port_info[2];
const struct ata_port_info *ppi[] = { NULL, NULL };
static int printed_version;
int type = id->driver_data;
u8 rev;
......@@ -652,9 +652,8 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
ata_pci_clear_simplex(pdev);
/* And fire it up */
port_info[0] = port_info[1] = &info[type];
return ata_pci_init_one(pdev, port_info, 2);
ppi[0] = &info[type];
return ata_pci_init_one(pdev, ppi);
}
#ifdef CONFIG_PM
......
......@@ -414,7 +414,7 @@ static const struct ata_port_operations artop6260_ops = {
static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
{
static int printed_version;
static struct ata_port_info info_6210 = {
static const struct ata_port_info info_6210 = {
.sht = &artop_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f, /* pio0-4 */
......@@ -422,7 +422,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
.udma_mask = ATA_UDMA2,
.port_ops = &artop6210_ops,
};
static struct ata_port_info info_626x = {
static const struct ata_port_info info_626x = {
.sht = &artop_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f, /* pio0-4 */
......@@ -430,7 +430,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
.udma_mask = ATA_UDMA4,
.port_ops = &artop6260_ops,
};
static struct ata_port_info info_626x_fast = {
static const struct ata_port_info info_626x_fast = {
.sht = &artop_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f, /* pio0-4 */
......@@ -438,32 +438,30 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
.udma_mask = ATA_UDMA5,
.port_ops = &artop6260_ops,
};
struct ata_port_info *port_info[2];
struct ata_port_info *info = NULL;
int ports = 2;
const struct ata_port_info *ppi[] = { NULL, NULL };
if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
if (id->driver_data == 0) { /* 6210 variant */
info = &info_6210;
ppi[0] = &info_6210;
ppi[1] = &ata_dummy_port_info;
/* BIOS may have left us in UDMA, clear it before libata probe */
pci_write_config_byte(pdev, 0x54, 0);
/* For the moment (also lacks dsc) */
printk(KERN_WARNING "ARTOP 6210 requires serialize functionality not yet supported by libata.\n");
printk(KERN_WARNING "Secondary ATA ports will not be activated.\n");
ports = 1;
}
else if (id->driver_data == 1) /* 6260 */
info = &info_626x;
ppi[0] = &info_626x;
else if (id->driver_data == 2) { /* 6260 or 6260 + fast */
unsigned long io = pci_resource_start(pdev, 4);
u8 reg;
info = &info_626x;
ppi[0] = &info_626x;
if (inb(io) & 0x10)
info = &info_626x_fast;
ppi[0] = &info_626x_fast;
/* Mac systems come up with some registers not set as we
will need them */
......@@ -484,10 +482,9 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
}
BUG_ON(info == NULL);
BUG_ON(ppi[0] == NULL);
port_info[0] = port_info[1] = info;
return ata_pci_init_one(pdev, port_info, ports);
return ata_pci_init_one(pdev, ppi);
}
static const struct pci_device_id artop_pci_tbl[] = {
......
......@@ -268,7 +268,7 @@ static struct ata_port_operations atiixp_port_ops = {
static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
static struct ata_port_info info = {
static const struct ata_port_info info = {
.sht = &atiixp_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -276,8 +276,8 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.udma_mask = 0x3F,
.port_ops = &atiixp_port_ops
};
static struct ata_port_info *port_info[2] = { &info, &info };
return ata_pci_init_one(dev, port_info, 2);
const struct ata_port_info *ppi[] = { &info, NULL };
return ata_pci_init_one(dev, ppi);
}
static const struct pci_device_id atiixp[] = {
......
......@@ -249,17 +249,16 @@ static void cmd640_hardware_init(struct pci_dev *pdev)
static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
static struct ata_port_info info = {
static const struct ata_port_info info = {
.sht = &cmd640_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f,
.port_ops = &cmd640_port_ops
};
static struct ata_port_info *port_info[2] = { &info, &info };
const struct ata_port_info *ppi[] = { &info, NULL };
cmd640_hardware_init(pdev);
return ata_pci_init_one(pdev, port_info, 2);
return ata_pci_init_one(pdev, ppi);
}
static int cmd640_reinit_one(struct pci_dev *pdev)
......
......@@ -377,7 +377,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
u32 class_rev;
static struct ata_port_info cmd_info[6] = {
static const struct ata_port_info cmd_info[6] = {
{ /* CMD 643 - no UDMA */
.sht = &cmd64x_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
......@@ -424,11 +424,9 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
.port_ops = &cmd648_port_ops
}
};
static struct ata_port_info *port_info[2], *info;
const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL };
u8 mrdmode;
info = &cmd_info[id->driver_data];
pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class_rev);
class_rev &= 0xFF;
......@@ -438,10 +436,10 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
if (pdev->device == PCI_DEVICE_ID_CMD_646) {
/* Does UDMA work ? */
if (class_rev > 4)
info = &cmd_info[2];
ppi[0] = &cmd_info[2];
/* Early rev with other problems ? */
else if (class_rev == 1)
info = &cmd_info[3];
ppi[0] = &cmd_info[3];
}
pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64);
......@@ -457,8 +455,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
pci_write_config_byte(pdev, UDIDETCR0, 0xF0);
#endif
port_info[0] = port_info[1] = info;
return ata_pci_init_one(pdev, port_info, 2);
return ata_pci_init_one(pdev, ppi);
}
#ifdef CONFIG_PM
......
......@@ -335,7 +335,7 @@ fail_put:
static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
static struct ata_port_info info = {
static const struct ata_port_info info = {
.sht = &cs5530_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -344,23 +344,23 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
.port_ops = &cs5530_port_ops
};
/* The docking connector doesn't do UDMA, and it seems not MWDMA */
static struct ata_port_info info_palmax_secondary = {
static const struct ata_port_info info_palmax_secondary = {
.sht = &cs5530_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
.port_ops = &cs5530_port_ops
};
static struct ata_port_info *port_info[2] = { &info, &info };
const struct ata_port_info *ppi[] = { &info, NULL };
/* Chip initialisation */
if (cs5530_init_chip())
return -ENODEV;
if (cs5530_is_palmax())
port_info[1] = &info_palmax_secondary;
ppi[1] = &info_palmax_secondary;
/* Now kick off ATA set up */
return ata_pci_init_one(pdev, port_info, 2);
return ata_pci_init_one(pdev, ppi);
}
#ifdef CONFIG_PM
......
......@@ -223,7 +223,7 @@ static struct ata_port_operations cs5535_port_ops = {
static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
static struct ata_port_info info = {
static const struct ata_port_info info = {
.sht = &cs5535_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -231,7 +231,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.udma_mask = 0x1f,
.port_ops = &cs5535_port_ops
};
struct ata_port_info *ports[1] = { &info };
const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
u32 timings, dummy;
......@@ -243,7 +243,7 @@ static int cs5535_init_one(struct pci_dev *dev, const struct pci_device_id *id)
rdmsr(ATAC_CH0D1_PIO, timings, dummy);
if (CS5535_BAD_PIO(timings))
wrmsr(ATAC_CH0D1_PIO, 0xF7F4F7F4UL, 0);
return ata_pci_init_one(dev, ports, 1);
return ata_pci_init_one(dev, ppi);
}
static const struct pci_device_id cs5535[] = {
......
......@@ -165,14 +165,14 @@ static struct ata_port_operations cy82c693_port_ops = {
static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
static struct ata_port_info info = {
static const struct ata_port_info info = {
.sht = &cy82c693_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f,
.mwdma_mask = 0x07,
.port_ops = &cy82c693_port_ops
};
static struct ata_port_info *port_info[1] = { &info };
const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
/* Devfn 1 is the ATA primary. The secondary is magic and on devfn2.
For the moment we don't handle the secondary. FIXME */
......@@ -180,7 +180,7 @@ static int cy82c693_init_one(struct pci_dev *pdev, const struct pci_device_id *i
if (PCI_FUNC(pdev->devfn) != 1)
return -ENODEV;
return ata_pci_init_one(pdev, port_info, 1);
return ata_pci_init_one(pdev, ppi);
}
static const struct pci_device_id cy82c693[] = {
......
......@@ -301,7 +301,7 @@ static const struct ata_port_operations efar_ops = {
static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
static struct ata_port_info info = {
static const struct ata_port_info info = {
.sht = &efar_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f, /* pio0-4 */
......@@ -309,13 +309,13 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
.udma_mask = 0x0f, /* UDMA 66 */
.port_ops = &efar_ops,
};
static struct ata_port_info *port_info[2] = { &info, &info };
const struct ata_port_info *ppi[] = { &info, NULL };
if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
return ata_pci_init_one(pdev, port_info, 2);
return ata_pci_init_one(pdev, ppi);
}
static const struct pci_device_id efar_pci_tbl[] = {
......
......@@ -417,7 +417,7 @@ static void hpt36x_init_chipset(struct pci_dev *dev)
static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
static struct ata_port_info info_hpt366 = {
static const struct ata_port_info info_hpt366 = {
.sht = &hpt36x_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -425,7 +425,8 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.udma_mask = 0x1f,
.port_ops = &hpt366_port_ops
};
struct ata_port_info *port_info[2] = {&info_hpt366, &info_hpt366};
struct ata_port_info info = info_hpt366;
const struct ata_port_info *ppi[] = { &info, NULL };
u32 class_rev;
u32 reg1;
......@@ -446,17 +447,17 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
/* info_hpt366 is safe against re-entry so we can scribble on it */
switch((reg1 & 0x700) >> 8) {
case 5:
info_hpt366.private_data = &hpt366_40;
info.private_data = &hpt366_40;
break;
case 9:
info_hpt366.private_data = &hpt366_25;
info.private_data = &hpt366_25;
break;
default:
info_hpt366.private_data = &hpt366_33;
info.private_data = &hpt366_33;
break;
}
/* Now kick off ATA set up */
return ata_pci_init_one(dev, port_info, 2);
return ata_pci_init_one(dev, ppi);
}
#ifdef CONFIG_PM
......
......@@ -887,7 +887,7 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
/* HPT370 - UDMA100 */
static struct ata_port_info info_hpt370 = {
static const struct ata_port_info info_hpt370 = {
.sht = &hpt37x_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -896,7 +896,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.port_ops = &hpt370_port_ops
};
/* HPT370A - UDMA100 */
static struct ata_port_info info_hpt370a = {
static const struct ata_port_info info_hpt370a = {
.sht = &hpt37x_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -905,7 +905,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.port_ops = &hpt370a_port_ops
};
/* HPT370 - UDMA100 */
static struct ata_port_info info_hpt370_33 = {
static const struct ata_port_info info_hpt370_33 = {
.sht = &hpt37x_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -914,7 +914,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.port_ops = &hpt370_port_ops
};
/* HPT370A - UDMA100 */
static struct ata_port_info info_hpt370a_33 = {
static const struct ata_port_info info_hpt370a_33 = {
.sht = &hpt37x_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -923,7 +923,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.port_ops = &hpt370a_port_ops
};
/* HPT371, 372 and friends - UDMA133 */
static struct ata_port_info info_hpt372 = {
static const struct ata_port_info info_hpt372 = {
.sht = &hpt37x_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -932,7 +932,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.port_ops = &hpt372_port_ops
};
/* HPT371, 372 and friends - UDMA100 at 50MHz clock */
static struct ata_port_info info_hpt372_50 = {
static const struct ata_port_info info_hpt372_50 = {
.sht = &hpt37x_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -941,7 +941,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.port_ops = &hpt372_port_ops
};
/* HPT374 - UDMA133 */
static struct ata_port_info info_hpt374 = {
static const struct ata_port_info info_hpt374 = {
.sht = &hpt37x_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -951,9 +951,10 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
};
static const int MHz[4] = { 33, 40, 50, 66 };
struct ata_port_info *port_info[2];
struct ata_port_info *port;
const struct ata_port_info *port;
void *private_data = NULL;
struct ata_port_info port_info;
const struct ata_port_info *ppi[] = { &port_info, NULL };
u8 irqmask;
u32 class_rev;
......@@ -1124,13 +1125,13 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
return -ENODEV;
}
if (clock_slot == 3)
port->private_data = (void *)hpt37x_timings_66;
private_data = (void *)hpt37x_timings_66;
else
port->private_data = (void *)hpt37x_timings_50;
private_data = (void *)hpt37x_timings_50;
printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]);
} else {
port->private_data = (void *)chip_table->clocks[clock_slot];
private_data = (void *)chip_table->clocks[clock_slot];
/*
* Perform a final fixup. Note that we will have used the
* DPLL on the HPT372 which means we don't have to worry
......@@ -1144,9 +1145,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]);
}
port_info[0] = port_info[1] = port;
/* Now kick off ATA set up */
return ata_pci_init_one(dev, port_info, 2);
port_info = *port;
port_info.private_data = private_data;
return ata_pci_init_one(dev, ppi);
}
static const struct pci_device_id hpt37x[] = {
......
......@@ -488,7 +488,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev)
static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
/* HPT372N and friends - UDMA133 */
static struct ata_port_info info = {
static const struct ata_port_info info = {
.sht = &hpt3x2n_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -496,8 +496,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.udma_mask = 0x7f,
.port_ops = &hpt3x2n_port_ops
};
struct ata_port_info *port_info[2];
struct ata_port_info *port = &info;
struct ata_port_info port = info;
const struct ata_port_info *ppi[] = { &port, NULL };
u8 irqmask;
u32 class_rev;
......@@ -585,9 +585,9 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
/* Set our private data up. We only need a few flags so we use
it directly */
port->private_data = NULL;
port.private_data = NULL;
if (pci_mhz > 60) {
port->private_data = (void *)PCI66;
port.private_data = (void *)PCI66;
/*
* On HPT371N, if ATA clock is 66 MHz we must set bit 2 in
* the MISC. register to stretch the UltraDMA Tss timing.
......@@ -598,8 +598,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
}
/* Now kick off ATA set up */
port_info[0] = port_info[1] = port;
return ata_pci_init_one(dev, port_info, 2);
return ata_pci_init_one(dev, ppi);
}
static const struct pci_device_id hpt3x2n[] = {
......
......@@ -171,7 +171,7 @@ static void hpt3x3_init_chipset(struct pci_dev *dev)
static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
static struct ata_port_info info = {
static const struct ata_port_info info = {
.sht = &hpt3x3_sht,
.flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST,
.pio_mask = 0x1f,
......@@ -179,11 +179,11 @@ static int hpt3x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.udma_mask = 0x07,
.port_ops = &hpt3x3_port_ops
};
static struct ata_port_info *port_info[2] = { &info, &info };
const struct ata_port_info *ppi[] = { &info, NULL };
hpt3x3_init_chipset(dev);
/* Now kick off ATA set up */
return ata_pci_init_one(dev, port_info, 2);
return ata_pci_init_one(dev, ppi);
}
#ifdef CONFIG_PM
......
<
......@@ -311,7 +311,7 @@ static const struct ata_port_operations it8213_ops = {
static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
static struct ata_port_info info = {
static const struct ata_port_info info = {
.sht = &it8213_sht,
.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
.pio_mask = 0x1f, /* pio0-4 */
......@@ -319,14 +319,14 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en
.udma_mask = 0x1f, /* UDMA 100 */
.port_ops = &it8213_ops,
};
static struct ata_port_info *port_info[2] = { &info, &info };
/* Current IT8213 stuff is single port */
const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };
if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
/* Current IT8213 stuff is single port */
return ata_pci_init_one(pdev, port_info, 1);
return ata_pci_init_one(pdev, ppi);
}