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

Commit 1b9da32a authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Bartlomiej Zolnierkiewicz
Browse files

aec62xx: remove init_dma() method (take 2)



Get rid of the init_dma() method (which had no particular reason to exist) by
folding it into the init_hwif() method. While at it, also perform some cleanup
in the latter method:

- get rid of the useless clearing of hwif->autodma;

- fold the serialization code into one 'if' statement;

- fold setting the drives' 'autotune' and 'autodma' fields into the single
  statements...

Signed-off-by: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent b1d19db4
Loading
Loading
Loading
Loading
+16 −35
Original line number Original line Diff line number Diff line
/*
/*
 * linux/drivers/ide/pci/aec62xx.c		Version 0.22	Apr 23, 2007
 * linux/drivers/ide/pci/aec62xx.c		Version 0.23	May 23, 2007
 *
 *
 * Copyright (C) 1999-2002	Andre Hedrick <andre@linux-ide.org>
 * Copyright (C) 1999-2002	Andre Hedrick <andre@linux-ide.org>
 * Copyright (C) 2007		MontaVista Software, Inc. <source@mvista.com>
 * Copyright (C) 2007		MontaVista Software, Inc. <source@mvista.com>
@@ -221,20 +221,17 @@ static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const ch
static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
{
{
	struct pci_dev *dev	= hwif->pci_dev;
	struct pci_dev *dev	= hwif->pci_dev;
	u8 reg54 = 0,  mask	= hwif->channel ? 0xf0 : 0x0f;
	unsigned long flags;


	hwif->autodma = 0;
	hwif->tuneproc = &aec62xx_tune_drive;
	hwif->tuneproc = &aec62xx_tune_drive;
	hwif->speedproc = &aec62xx_tune_chipset;
	hwif->speedproc = &aec62xx_tune_chipset;


	if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF)
	if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF && hwif->mate)
		hwif->serialized = hwif->channel;
		hwif->mate->serialized = hwif->serialized = 1;

	if (hwif->mate)
		hwif->mate->serialized = hwif->serialized;


	if (!hwif->dma_base) {
	if (!hwif->dma_base) {
		hwif->drives[0].autotune = 1;
		hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
		hwif->drives[1].autotune = 1;
		return;
		return;
	}
	}


@@ -244,32 +241,21 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
	hwif->ide_dma_check	= &aec62xx_config_drive_xfer_rate;
	hwif->ide_dma_check	= &aec62xx_config_drive_xfer_rate;
	hwif->dma_lost_irq	= &aec62xx_dma_lost_irq;
	hwif->dma_lost_irq	= &aec62xx_dma_lost_irq;


	if (!noautodma)
		hwif->autodma = 1;
	hwif->drives[0].autodma = hwif->autodma;
	hwif->drives[1].autodma = hwif->autodma;
}

static void __devinit init_dma_aec62xx(ide_hwif_t *hwif, unsigned long dmabase)
{
	struct pci_dev *dev	= hwif->pci_dev;

	if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) {
	if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) {
		u8 reg54h = 0;
		unsigned long flags;

		spin_lock_irqsave(&ide_lock, flags);
		spin_lock_irqsave(&ide_lock, flags);
		pci_read_config_byte(dev, 0x54, &reg54h);
		pci_read_config_byte (dev, 0x54, &reg54);
		pci_write_config_byte(dev, 0x54, reg54h & ~(hwif->channel ? 0xF0 : 0x0F));
		pci_write_config_byte(dev, 0x54, (reg54 & ~mask));
		spin_unlock_irqrestore(&ide_lock, flags);
		spin_unlock_irqrestore(&ide_lock, flags);
	} else {
	} else if (!hwif->udma_four) {
		u8 ata66	= 0;
		u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01;

		pci_read_config_byte(hwif->pci_dev, 0x49, &ata66);
		pci_read_config_byte(hwif->pci_dev, 0x49, &ata66);
	        if (!(hwif->udma_four))
		hwif->udma_four = (ata66 & mask) ? 0 : 1;
			hwif->udma_four = (ata66&(hwif->channel?0x02:0x01))?0:1;
	}
	}


	ide_setup_dma(hwif, dmabase, 8);
	if (!noautodma)
		hwif->autodma = 1;
	hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
}
}


static int __devinit init_setup_aec62xx(struct pci_dev *dev, ide_pci_device_t *d)
static int __devinit init_setup_aec62xx(struct pci_dev *dev, ide_pci_device_t *d)
@@ -296,7 +282,6 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = {
		.init_setup	= init_setup_aec62xx,
		.init_setup	= init_setup_aec62xx,
		.init_chipset	= init_chipset_aec62xx,
		.init_chipset	= init_chipset_aec62xx,
		.init_hwif	= init_hwif_aec62xx,
		.init_hwif	= init_hwif_aec62xx,
		.init_dma	= init_dma_aec62xx,
		.channels	= 2,
		.channels	= 2,
		.autodma	= AUTODMA,
		.autodma	= AUTODMA,
		.enablebits	= {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
		.enablebits	= {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
@@ -307,7 +292,6 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = {
		.init_setup	= init_setup_aec62xx,
		.init_setup	= init_setup_aec62xx,
		.init_chipset	= init_chipset_aec62xx,
		.init_chipset	= init_chipset_aec62xx,
		.init_hwif	= init_hwif_aec62xx,
		.init_hwif	= init_hwif_aec62xx,
		.init_dma	= init_dma_aec62xx,
		.channels	= 2,
		.channels	= 2,
		.autodma	= NOAUTODMA,
		.autodma	= NOAUTODMA,
		.bootable	= OFF_BOARD,
		.bootable	= OFF_BOARD,
@@ -317,7 +301,6 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = {
		.init_setup	= init_setup_aec62xx,
		.init_setup	= init_setup_aec62xx,
		.init_chipset	= init_chipset_aec62xx,
		.init_chipset	= init_chipset_aec62xx,
		.init_hwif	= init_hwif_aec62xx,
		.init_hwif	= init_hwif_aec62xx,
		.init_dma	= init_dma_aec62xx,
		.channels	= 2,
		.channels	= 2,
		.autodma	= AUTODMA,
		.autodma	= AUTODMA,
		.enablebits	= {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
		.enablebits	= {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
@@ -328,7 +311,6 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = {
		.init_setup	= init_setup_aec6x80,
		.init_setup	= init_setup_aec6x80,
		.init_chipset	= init_chipset_aec62xx,
		.init_chipset	= init_chipset_aec62xx,
		.init_hwif	= init_hwif_aec62xx,
		.init_hwif	= init_hwif_aec62xx,
		.init_dma	= init_dma_aec62xx,
		.channels	= 2,
		.channels	= 2,
		.autodma	= AUTODMA,
		.autodma	= AUTODMA,
		.bootable	= OFF_BOARD,
		.bootable	= OFF_BOARD,
@@ -338,7 +320,6 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = {
		.init_setup	= init_setup_aec6x80,
		.init_setup	= init_setup_aec6x80,
		.init_chipset	= init_chipset_aec62xx,
		.init_chipset	= init_chipset_aec62xx,
		.init_hwif	= init_hwif_aec62xx,
		.init_hwif	= init_hwif_aec62xx,
		.init_dma	= init_dma_aec62xx,
		.channels	= 2,
		.channels	= 2,
		.autodma	= AUTODMA,
		.autodma	= AUTODMA,
		.enablebits	= {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
		.enablebits	= {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},