Hello. On 08-02-2011 15:24, Bartlomiej Zolnierkiewicz wrote:
From 2de7db4bcc16b7e95cca9ceb5921a6f620be76b7 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz<bzolnier@xxxxxxxxx> Date: Tue, 8 Feb 2011 12:39:25 +0100 Subject: [PATCH 04/20] pata_efar: unify code for programming PIO and MWDMA timings
Besides making things noticably simpler it results in ~10% decrease in the driver LOC count and also ~8% decrease in the driver binary size (as measured on x86-32).
Signed-off-by: Bartlomiej Zolnierkiewicz<bzolnier@xxxxxxxxx>
[...]
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c index afe92b7..1e2ff7d 100644 --- a/drivers/ata/pata_efar.c +++ b/drivers/ata/pata_efar.c
[...]
@@ -103,13 +92,18 @@ static void efar_set_piomode (struct ata_port *ap, struct ata_device *adev) { 2, 1 }, { 2, 3 }, }; - if (pio> 1) + if (pio> 1 || use_mwdma) control |= 1; /* TIME */ - if (ata_pio_need_iordy(adev)) /* PIO 3/4 require IORDY */ + if (ata_pio_need_iordy(adev) || use_mwdma) control |= 2; /* IE */
Same comments as for ata_piix for these two bits...
/* Intel specifies that the prefetch/posting is for disk only */ if (adev->class == ATA_DEV_ATA) control |= 4; /* PPE */ + /* If the drive MWDMA is faster than it can do PIO then + we must force PIO into PIO0 */
Fix comment style, like in ata_piix.
+ if (use_mwdma && adev->pio_mode < (XFER_PIO_0 + pio))
Parens not needed around +.
@@ -145,6 +139,22 @@ static void efar_set_piomode (struct ata_port *ap, struct ata_device *adev) } /** + * efar_set_piomode - Initialize host controller PATA PIO timings + * @ap: Port whose timings we are configuring + * @adev: Device to program + * + * Set PIO mode for device, in host controller PCI config space. + * + * LOCKING: + * None (inherited from caller). + */ + +static void efar_set_piomode(struct ata_port *ap, struct ata_device *adev) +{ + efar_set_timings(ap, adev, adev->pio_mode - XFER_PIO_0, 0);
s/0/false/? Likewise in ata_piix...
@@ -158,29 +168,19 @@ static void efar_set_piomode (struct ata_port *ap, struct ata_device *adev) static void efar_set_dmamode (struct ata_port *ap, struct ata_device *adev) { struct pci_dev *dev = to_pci_dev(ap->host->dev); - u8 master_port = ap->port_no ? 0x42 : 0x40; - u16 master_data; u8 speed = adev->dma_mode; int devid = adev->devno + 2 * ap->port_no; unsigned long flags; u8 udma_enable; - static const /* ISP RTC */ - u8 timings[][2] = { { 0, 0 }, - { 0, 0 }, - { 1, 0 }, - { 2, 1 }, - { 2, 3 }, }; - - spin_lock_irqsave(&efar_lock, flags); - - pci_read_config_word(dev, master_port, &master_data); - pci_read_config_byte(dev, 0x48, &udma_enable); - if (speed>= XFER_UDMA_0) { - unsigned int udma = adev->dma_mode - XFER_UDMA_0; + unsigned int udma = speed - XFER_UDMA_0; u16 udma_timing; + spin_lock_irqsave(&efar_lock, flags); + + pci_read_config_byte(dev, 0x48, &udma_enable);
Don't think you should have moved this...
+ udma_enable |= (1 << devid); /* Load the UDMA mode number */ @@ -188,50 +188,20 @@ static void efar_set_dmamode (struct ata_port *ap, struct ata_device *adev)
[...]
- udma_enable &= ~(1 << devid); - pci_write_config_word(dev, master_port, master_data);
No, you should disable UDMA when programming MWDMA.
+ efar_set_timings(ap, adev, pio, 1);
s/1/true/? Likewise in ata_piix... WBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html