ide: add ide_use_fast_pio() helper (v3)

* add ide_use_fast_pio() helper for use by host drivers

* add DMA capability and hwif->autodma checks to ide_use_dma()

  - au1xxx-ide/it8213/it821x drivers didn't check for (id->capability & 1)

    [ for the IT8211/2 in SMART mode this check shouldn't be made but since
      in it821x_fixups() we set DMA bit explicitly:

               if(strstr(id->model, "Integrated Technology Express")) {
                       /* In raid mode the ident block is slightly buggy
                          We need to set the bits so that the IDE layer knows
                          LBA28. LBA48 and DMA ar valid */
                       id->capability |= 3;            /* LBA28, DMA */

       we are better off using generic helper if we can ]

  - ide-cris driver didn't set ->autodma

    [ before the patch hwif->autodma was only checked in the chipset specific
      hwif->ide_dma_check implementations, for ide-cris it is cris_dma_check()
      function so there no behavior change here ]

v2:
* updated patch description (thanks to Alan Cox for the feedback)

v3:
* updated for scc_pata driver

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index 236a031..b13a06c 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -282,19 +282,13 @@
 static int pdcnew_config_drive_xfer_rate(ide_drive_t *drive)
 {
 	ide_hwif_t *hwif	= HWIF(drive);
-	struct hd_driveid *id	= drive->id;
 
 	drive->init_speed = 0;
 
-	if ((id->capability & 1) && drive->autodma) {
+	if (ide_use_dma(drive) && config_chipset_for_dma(drive))
+		return hwif->ide_dma_on(drive);
 
-		if (ide_use_dma(drive) && config_chipset_for_dma(drive))
-			return hwif->ide_dma_on(drive);
-
-		goto fast_ata_pio;
-
-	} else if ((id->capability & 8) || (id->field_valid & 2)) {
-fast_ata_pio:
+	if (ide_use_fast_pio(drive)) {
 		hwif->tuneproc(drive, 255);
 		return hwif->ide_dma_off_quietly(drive);
 	}