hpt366: convert to use ->host_priv
While at it: * Allocate both struct hpt_info instances at once. Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
parent
60e57ed7c1
commit
74811f355f
@ -620,7 +620,8 @@ static u8 hpt3xx_udma_filter(ide_drive_t *drive)
|
|||||||
{
|
{
|
||||||
ide_hwif_t *hwif = HWIF(drive);
|
ide_hwif_t *hwif = HWIF(drive);
|
||||||
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
||||||
struct hpt_info *info = pci_get_drvdata(dev);
|
struct ide_host *host = pci_get_drvdata(dev);
|
||||||
|
struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
|
||||||
u8 mask = hwif->ultra_mask;
|
u8 mask = hwif->ultra_mask;
|
||||||
|
|
||||||
switch (info->chip_type) {
|
switch (info->chip_type) {
|
||||||
@ -660,7 +661,8 @@ static u8 hpt3xx_mdma_filter(ide_drive_t *drive)
|
|||||||
{
|
{
|
||||||
ide_hwif_t *hwif = HWIF(drive);
|
ide_hwif_t *hwif = HWIF(drive);
|
||||||
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
||||||
struct hpt_info *info = pci_get_drvdata(dev);
|
struct ide_host *host = pci_get_drvdata(dev);
|
||||||
|
struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
|
||||||
|
|
||||||
switch (info->chip_type) {
|
switch (info->chip_type) {
|
||||||
case HPT372 :
|
case HPT372 :
|
||||||
@ -694,8 +696,10 @@ static u32 get_speed_setting(u8 speed, struct hpt_info *info)
|
|||||||
|
|
||||||
static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed)
|
static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
|
ide_hwif_t *hwif = drive->hwif;
|
||||||
struct hpt_info *info = pci_get_drvdata(dev);
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
||||||
|
struct ide_host *host = pci_get_drvdata(dev);
|
||||||
|
struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
|
||||||
struct hpt_timings *t = info->timings;
|
struct hpt_timings *t = info->timings;
|
||||||
u8 itr_addr = 0x40 + (drive->dn * 4);
|
u8 itr_addr = 0x40 + (drive->dn * 4);
|
||||||
u32 old_itr = 0;
|
u32 old_itr = 0;
|
||||||
@ -738,7 +742,8 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
|
|||||||
{
|
{
|
||||||
ide_hwif_t *hwif = HWIF(drive);
|
ide_hwif_t *hwif = HWIF(drive);
|
||||||
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
||||||
struct hpt_info *info = pci_get_drvdata(dev);
|
struct ide_host *host = pci_get_drvdata(dev);
|
||||||
|
struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
|
||||||
|
|
||||||
if (drive->quirk_list) {
|
if (drive->quirk_list) {
|
||||||
if (info->chip_type >= HPT370) {
|
if (info->chip_type >= HPT370) {
|
||||||
@ -965,22 +970,13 @@ static int __devinit hpt37x_calibrate_dpll(struct pci_dev *dev, u16 f_low, u16 f
|
|||||||
|
|
||||||
static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const char *name)
|
static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const char *name)
|
||||||
{
|
{
|
||||||
struct hpt_info *info = kmalloc(sizeof(struct hpt_info), GFP_KERNEL);
|
|
||||||
unsigned long io_base = pci_resource_start(dev, 4);
|
unsigned long io_base = pci_resource_start(dev, 4);
|
||||||
|
struct ide_host *host = pci_get_drvdata(dev);
|
||||||
|
struct hpt_info *info = host->host_priv + (&dev->dev == host->dev[1]);
|
||||||
u8 pci_clk, dpll_clk = 0; /* PCI and DPLL clock in MHz */
|
u8 pci_clk, dpll_clk = 0; /* PCI and DPLL clock in MHz */
|
||||||
u8 chip_type;
|
u8 chip_type;
|
||||||
enum ata_clock clock;
|
enum ata_clock clock;
|
||||||
|
|
||||||
if (info == NULL) {
|
|
||||||
printk(KERN_ERR "%s: out of memory!\n", name);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy everything from a static "template" structure
|
|
||||||
* to just allocated per-chip hpt_info structure.
|
|
||||||
*/
|
|
||||||
memcpy(info, pci_get_drvdata(dev), sizeof(struct hpt_info));
|
|
||||||
chip_type = info->chip_type;
|
chip_type = info->chip_type;
|
||||||
|
|
||||||
pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4));
|
pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4));
|
||||||
@ -1142,7 +1138,6 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
|
|||||||
|
|
||||||
if (info->timings->clock_table[clock] == NULL) {
|
if (info->timings->clock_table[clock] == NULL) {
|
||||||
printk(KERN_ERR "%s: unknown bus timing!\n", name);
|
printk(KERN_ERR "%s: unknown bus timing!\n", name);
|
||||||
kfree(info);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1169,7 +1164,6 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
|
|||||||
}
|
}
|
||||||
if (adjust == 8) {
|
if (adjust == 8) {
|
||||||
printk(KERN_ERR "%s: DPLL did not stabilize!\n", name);
|
printk(KERN_ERR "%s: DPLL did not stabilize!\n", name);
|
||||||
kfree(info);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1186,9 +1180,6 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
|
|||||||
info->pci_clk = pci_clk;
|
info->pci_clk = pci_clk;
|
||||||
info->clock = clock;
|
info->clock = clock;
|
||||||
|
|
||||||
/* Point to this chip's own instance of the hpt_info structure. */
|
|
||||||
pci_set_drvdata(dev, info);
|
|
||||||
|
|
||||||
if (chip_type >= HPT370) {
|
if (chip_type >= HPT370) {
|
||||||
u8 mcr1, mcr4;
|
u8 mcr1, mcr4;
|
||||||
|
|
||||||
@ -1218,7 +1209,8 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
|
|||||||
static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif)
|
static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
||||||
struct hpt_info *info = pci_get_drvdata(dev);
|
struct ide_host *host = pci_get_drvdata(dev);
|
||||||
|
struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
|
||||||
u8 chip_type = info->chip_type;
|
u8 chip_type = info->chip_type;
|
||||||
u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02;
|
u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02;
|
||||||
|
|
||||||
@ -1262,7 +1254,8 @@ static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif)
|
|||||||
static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
|
static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
||||||
struct hpt_info *info = pci_get_drvdata(dev);
|
struct ide_host *host = pci_get_drvdata(dev);
|
||||||
|
struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
|
||||||
int serialize = HPT_SERIALIZE_IO;
|
int serialize = HPT_SERIALIZE_IO;
|
||||||
u8 chip_type = info->chip_type;
|
u8 chip_type = info->chip_type;
|
||||||
u8 new_mcr, old_mcr = 0;
|
u8 new_mcr, old_mcr = 0;
|
||||||
@ -1542,10 +1535,12 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
|
|||||||
static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id)
|
static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id)
|
||||||
{
|
{
|
||||||
const struct hpt_info *info = NULL;
|
const struct hpt_info *info = NULL;
|
||||||
|
struct hpt_info *dyn_info;
|
||||||
struct pci_dev *dev2 = NULL;
|
struct pci_dev *dev2 = NULL;
|
||||||
struct ide_port_info d;
|
struct ide_port_info d;
|
||||||
u8 idx = id->driver_data;
|
u8 idx = id->driver_data;
|
||||||
u8 rev = dev->revision;
|
u8 rev = dev->revision;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if ((idx == 0 || idx == 4) && (PCI_FUNC(dev->devfn) & 1))
|
if ((idx == 0 || idx == 4) && (PCI_FUNC(dev->devfn) & 1))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
@ -1591,15 +1586,24 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
|
|||||||
if (info == &hpt370 || info == &hpt370a)
|
if (info == &hpt370 || info == &hpt370a)
|
||||||
d.dma_ops = &hpt370_dma_ops;
|
d.dma_ops = &hpt370_dma_ops;
|
||||||
|
|
||||||
pci_set_drvdata(dev, (void *)info);
|
|
||||||
|
|
||||||
if (info == &hpt36x || info == &hpt374)
|
if (info == &hpt36x || info == &hpt374)
|
||||||
dev2 = pci_get_slot(dev->bus, dev->devfn + 1);
|
dev2 = pci_get_slot(dev->bus, dev->devfn + 1);
|
||||||
|
|
||||||
if (dev2) {
|
dyn_info = kzalloc(sizeof(*dyn_info) * (dev2 ? 2 : 1), GFP_KERNEL);
|
||||||
int ret;
|
if (dyn_info == NULL) {
|
||||||
|
printk(KERN_ERR "%s: out of memory!\n", d.name);
|
||||||
|
pci_dev_put(dev2);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
pci_set_drvdata(dev2, (void *)info);
|
/*
|
||||||
|
* Copy everything from a static "template" structure
|
||||||
|
* to just allocated per-chip hpt_info structure.
|
||||||
|
*/
|
||||||
|
memcpy(dyn_info, info, sizeof(*dyn_info));
|
||||||
|
|
||||||
|
if (dev2) {
|
||||||
|
memcpy(dyn_info + 1, info, sizeof(*dyn_info));
|
||||||
|
|
||||||
if (info == &hpt374)
|
if (info == &hpt374)
|
||||||
hpt374_init(dev, dev2);
|
hpt374_init(dev, dev2);
|
||||||
@ -1608,13 +1612,19 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
|
|||||||
d.host_flags &= ~IDE_HFLAG_NON_BOOTABLE;
|
d.host_flags &= ~IDE_HFLAG_NON_BOOTABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ide_pci_init_two(dev, dev2, &d, NULL);
|
ret = ide_pci_init_two(dev, dev2, &d, dyn_info);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
pci_dev_put(dev2);
|
pci_dev_put(dev2);
|
||||||
|
kfree(dyn_info);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ide_pci_init_one(dev, &d, NULL);
|
ret = ide_pci_init_one(dev, &d, dyn_info);
|
||||||
|
if (ret < 0)
|
||||||
|
kfree(dyn_info);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = {
|
static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = {
|
||||||
|
Loading…
Reference in New Issue
Block a user