Commit 438c470261036db25bfae15235ba99812e3dc763

Authored by Bartlomiej Zolnierkiewicz
1 parent b1e0386543

siimage: separate PATA and SATA methods

* Split off sil_sata_udma_filter() from sil_udma_filter()
  and rename sil_udma_filter() to sil_pata_udma_filter().

* Rename siimage_busproc() to sil_sata_busproc().

* Rename siimage_reset_poll() to sil_sata_reset_poll()
  and in init_hwif_siimage() set ->reset_poll method only
  for SATA controllers.

* Rename siimage_pre_reset() to sil_sata_pre_reset(),
  in init_hwif_siimage() set ->pre_reset method only for
  SATA controllers and remove redundant is_sata() call.

* Add CONFIG_BLK_DEV_IDE_SATA #ifdef/#endif to pdev_is_sata()
  so compiler will know to throw out unused SATA code for
  CONFIG_BLK_DEV_IDE_SATA=n case (830 bytes saved on x86-32).

* Bump driver version.

Some minor cleanups while at it:

* Convert sil_{pata,sata}_udma_filter() to use ATA_UDMA* defines.

* In siimage_mmio_ide_dma_test_irq() move 'base' variable
  under 'if (SATA_ERROR_REG)' block.

* Simplify sil_sata_reset_poll() a bit.

* Cache is_sata() result in init_hwif_siimage()

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

Showing 1 changed file with 39 additions and 40 deletions Side-by-side Diff

drivers/ide/pci/siimage.c
1 1 /*
2   - * linux/drivers/ide/pci/siimage.c Version 1.17 Oct 18 2007
  2 + * linux/drivers/ide/pci/siimage.c Version 1.18 Oct 18 2007
3 3 *
4 4 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org>
5 5 * Copyright (C) 2003 Red Hat <alan@redhat.com>
... ... @@ -57,8 +57,8 @@
57 57  
58 58 static int pdev_is_sata(struct pci_dev *pdev)
59 59 {
60   - switch(pdev->device)
61   - {
  60 +#ifdef CONFIG_BLK_DEV_IDE_SATA
  61 + switch(pdev->device) {
62 62 case PCI_DEVICE_ID_SII_3112:
63 63 case PCI_DEVICE_ID_SII_1210SA:
64 64 return 1;
65 65  
... ... @@ -66,9 +66,10 @@
66 66 return 0;
67 67 }
68 68 BUG();
  69 +#endif
69 70 return 0;
70 71 }
71   -
  72 +
72 73 /**
73 74 * is_sata - check if hwif is SATA
74 75 * @hwif: interface to check
... ... @@ -136,7 +137,7 @@
136 137 * SI3112 SATA controller life is a bit simpler.
137 138 */
138 139  
139   -static u8 sil_udma_filter(ide_drive_t *drive)
  140 +static u8 sil_pata_udma_filter(ide_drive_t *drive)
140 141 {
141 142 ide_hwif_t *hwif = drive->hwif;
142 143 unsigned long base = (unsigned long) hwif->hwif_data;
143 144  
144 145  
145 146  
146 147  
147 148  
... ... @@ -147,23 +148,23 @@
147 148 else
148 149 pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc);
149 150  
150   - if (is_sata(hwif)) {
151   - mask = strstr(drive->id->model, "Maxtor") ? 0x3f : 0x7f;
152   - goto out;
153   - }
154   -
155 151 if ((scsc & 0x30) == 0x10) /* 133 */
156   - mask = 0x7f;
  152 + mask = ATA_UDMA6;
157 153 else if ((scsc & 0x30) == 0x20) /* 2xPCI */
158   - mask = 0x7f;
  154 + mask = ATA_UDMA6;
159 155 else if ((scsc & 0x30) == 0x00) /* 100 */
160   - mask = 0x3f;
  156 + mask = ATA_UDMA5;
161 157 else /* Disabled ? */
162 158 BUG();
163   -out:
  159 +
164 160 return mask;
165 161 }
166 162  
  163 +static u8 sil_sata_udma_filter(ide_drive_t *drive)
  164 +{
  165 + return strstr(drive->id->model, "Maxtor") ? ATA_UDMA5 : ATA_UDMA6;
  166 +}
  167 +
167 168 /**
168 169 * sil_set_pio_mode - set host controller for PIO mode
169 170 * @drive: drive
170 171  
... ... @@ -340,10 +341,11 @@
340 341 static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
341 342 {
342 343 ide_hwif_t *hwif = HWIF(drive);
343   - unsigned long base = (unsigned long)hwif->hwif_data;
344 344 unsigned long addr = siimage_selreg(hwif, 0x1);
345 345  
346 346 if (SATA_ERROR_REG) {
  347 + unsigned long base = (unsigned long)hwif->hwif_data;
  348 +
347 349 u32 ext_stat = readl((void __iomem *)(base + 0x10));
348 350 u8 watchdog = 0;
349 351 if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) {
... ... @@ -376,7 +378,7 @@
376 378 }
377 379  
378 380 /**
379   - * siimage_busproc - bus isolation ioctl
  381 + * sil_sata_busproc - bus isolation IOCTL
380 382 * @drive: drive to isolate/restore
381 383 * @state: bus state to set
382 384 *
... ... @@ -384,8 +386,8 @@
384 386 * SATA controller the work required is quite limited, we
385 387 * just have to clean up the statistics
386 388 */
387   -
388   -static int siimage_busproc (ide_drive_t * drive, int state)
  389 +
  390 +static int sil_sata_busproc(ide_drive_t * drive, int state)
389 391 {
390 392 ide_hwif_t *hwif = HWIF(drive);
391 393 u32 stat_config = 0;
392 394  
... ... @@ -417,14 +419,14 @@
417 419 }
418 420  
419 421 /**
420   - * siimage_reset_poll - wait for sata reset
  422 + * sil_sata_reset_poll - wait for SATA reset
421 423 * @drive: drive we are resetting
422 424 *
423 425 * Poll the SATA phy and see whether it has come back from the dead
424 426 * yet.
425 427 */
426   -
427   -static int siimage_reset_poll (ide_drive_t *drive)
  428 +
  429 +static int sil_sata_reset_poll(ide_drive_t *drive)
428 430 {
429 431 if (SATA_STATUS_REG) {
430 432 ide_hwif_t *hwif = HWIF(drive);
431 433  
432 434  
433 435  
434 436  
... ... @@ -436,27 +438,22 @@
436 438 HWGROUP(drive)->polling = 0;
437 439 return ide_started;
438 440 }
439   - return 0;
440   - } else {
441   - return 0;
442 441 }
  442 +
  443 + return 0;
443 444 }
444 445  
445 446 /**
446   - * siimage_pre_reset - reset hook
  447 + * sil_sata_pre_reset - reset hook
447 448 * @drive: IDE device being reset
448 449 *
449 450 * For the SATA devices we need to handle recalibration/geometry
450 451 * differently
451 452 */
452   -
453   -static void siimage_pre_reset (ide_drive_t *drive)
454   -{
455   - if (drive->media != ide_disk)
456   - return;
457 453  
458   - if (is_sata(HWIF(drive)))
459   - {
  454 +static void sil_sata_pre_reset(ide_drive_t *drive)
  455 +{
  456 + if (drive->media == ide_disk) {
460 457 drive->special.b.set_geometry = 0;
461 458 drive->special.b.recalibrate = 0;
462 459 }
... ... @@ -502,7 +499,6 @@
502 499 drive->failures++;
503 500 }
504 501 }
505   -
506 502 }
507 503  
508 504 /**
509 505  
510 506  
511 507  
512 508  
513 509  
... ... @@ -864,28 +860,31 @@
864 860  
865 861 static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
866 862 {
  863 + u8 sata = is_sata(hwif);
  864 +
867 865 hwif->resetproc = &siimage_reset;
868 866 hwif->set_pio_mode = &sil_set_pio_mode;
869 867 hwif->set_dma_mode = &sil_set_dma_mode;
870   - hwif->reset_poll = &siimage_reset_poll;
871   - hwif->pre_reset = &siimage_pre_reset;
872   - hwif->udma_filter = &sil_udma_filter;
873 868  
874   - if(is_sata(hwif)) {
  869 + if (sata) {
875 870 static int first = 1;
876 871  
877   - hwif->busproc = &siimage_busproc;
  872 + hwif->busproc = &sil_sata_busproc;
  873 + hwif->reset_poll = &sil_sata_reset_poll;
  874 + hwif->pre_reset = &sil_sata_pre_reset;
  875 + hwif->udma_filter = &sil_sata_udma_filter;
878 876  
879 877 if (first) {
880 878 printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n");
881 879 first = 0;
882 880 }
883   - }
  881 + } else
  882 + hwif->udma_filter = &sil_pata_udma_filter;
884 883  
885 884 if (hwif->dma_base == 0)
886 885 return;
887 886  
888   - if (is_sata(hwif))
  887 + if (sata)
889 888 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
890 889  
891 890 if (hwif->cbl != ATA_CBL_PATA40_SHORT)