aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-03-31 11:38:18 -0500
committerJeff Garzik <jeff@garzik.org>2006-04-01 12:33:46 -0500
commite8e0619f68bff8f39d98c46aac85ed1d4557ccfd (patch)
tree96bd428799db0694f6ebfd29fcb207857fa60c0f
parent4f65977df0b9a667fdcd85b95d457a220c94113f (diff)
[PATCH] libata: reorganize ata_set_mode()
Merge ata_host_set_pio() and ata_host_set_dma() into ata_set_mode() and use function-level *dev to iterate over devices. This eases soon-to-follow ata_set_mode() interface change. While at it, kill an unnecessary comment and normalize others. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/scsi/libata-core.c91
1 files changed, 35 insertions, 56 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 913e378eca7f..f04561abf6d8 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1771,47 +1771,6 @@ static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
1771 return 0; 1771 return 0;
1772} 1772}
1773 1773
1774static int ata_host_set_pio(struct ata_port *ap)
1775{
1776 int i;
1777
1778 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1779 struct ata_device *dev = &ap->device[i];
1780
1781 if (!ata_dev_enabled(dev))
1782 continue;
1783
1784 if (!dev->pio_mode) {
1785 printk(KERN_WARNING "ata%u: no PIO support for device %d.\n", ap->id, i);
1786 return -1;
1787 }
1788
1789 dev->xfer_mode = dev->pio_mode;
1790 dev->xfer_shift = ATA_SHIFT_PIO;
1791 if (ap->ops->set_piomode)
1792 ap->ops->set_piomode(ap, dev);
1793 }
1794
1795 return 0;
1796}
1797
1798static void ata_host_set_dma(struct ata_port *ap)
1799{
1800 int i;
1801
1802 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1803 struct ata_device *dev = &ap->device[i];
1804
1805 if (!ata_dev_enabled(dev) || !dev->dma_mode)
1806 continue;
1807
1808 dev->xfer_mode = dev->dma_mode;
1809 dev->xfer_shift = ata_xfer_mode2shift(dev->dma_mode);
1810 if (ap->ops->set_dmamode)
1811 ap->ops->set_dmamode(ap, dev);
1812 }
1813}
1814
1815/** 1774/**
1816 * ata_set_mode - Program timings and issue SET FEATURES - XFER 1775 * ata_set_mode - Program timings and issue SET FEATURES - XFER
1817 * @ap: port on which timings will be programmed 1776 * @ap: port on which timings will be programmed
@@ -1823,20 +1782,20 @@ static void ata_host_set_dma(struct ata_port *ap)
1823 */ 1782 */
1824static void ata_set_mode(struct ata_port *ap) 1783static void ata_set_mode(struct ata_port *ap)
1825{ 1784{
1785 struct ata_device *dev;
1826 int i, rc, used_dma = 0, found = 0; 1786 int i, rc, used_dma = 0, found = 0;
1827 1787
1828 /* step 1: calculate xfer_mask */ 1788 /* step 1: calculate xfer_mask */
1829 for (i = 0; i < ATA_MAX_DEVICES; i++) { 1789 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1830 struct ata_device *dev = &ap->device[i];
1831 unsigned int pio_mask, dma_mask; 1790 unsigned int pio_mask, dma_mask;
1832 1791
1792 dev = &ap->device[i];
1793
1833 if (!ata_dev_enabled(dev)) 1794 if (!ata_dev_enabled(dev))
1834 continue; 1795 continue;
1835 1796
1836 ata_dev_xfermask(ap, dev); 1797 ata_dev_xfermask(ap, dev);
1837 1798
1838 /* TODO: let LLDD filter dev->*_mask here */
1839
1840 pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0); 1799 pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0);
1841 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask); 1800 dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask);
1842 dev->pio_mode = ata_xfer_mask2mode(pio_mask); 1801 dev->pio_mode = ata_xfer_mask2mode(pio_mask);
@@ -1850,16 +1809,40 @@ static void ata_set_mode(struct ata_port *ap)
1850 return; 1809 return;
1851 1810
1852 /* step 2: always set host PIO timings */ 1811 /* step 2: always set host PIO timings */
1853 rc = ata_host_set_pio(ap); 1812 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1854 if (rc) 1813 dev = &ap->device[i];
1855 goto err_out; 1814 if (!ata_dev_enabled(dev))
1815 continue;
1816
1817 if (!dev->pio_mode) {
1818 printk(KERN_WARNING "ata%u: dev %u no PIO support\n",
1819 ap->id, dev->devno);
1820 rc = -EINVAL;
1821 goto err_out;
1822 }
1823
1824 dev->xfer_mode = dev->pio_mode;
1825 dev->xfer_shift = ATA_SHIFT_PIO;
1826 if (ap->ops->set_piomode)
1827 ap->ops->set_piomode(ap, dev);
1828 }
1856 1829
1857 /* step 3: set host DMA timings */ 1830 /* step 3: set host DMA timings */
1858 ata_host_set_dma(ap); 1831 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1832 dev = &ap->device[i];
1833
1834 if (!ata_dev_enabled(dev) || !dev->dma_mode)
1835 continue;
1836
1837 dev->xfer_mode = dev->dma_mode;
1838 dev->xfer_shift = ata_xfer_mode2shift(dev->dma_mode);
1839 if (ap->ops->set_dmamode)
1840 ap->ops->set_dmamode(ap, dev);
1841 }
1859 1842
1860 /* step 4: update devices' xfer mode */ 1843 /* step 4: update devices' xfer mode */
1861 for (i = 0; i < ATA_MAX_DEVICES; i++) { 1844 for (i = 0; i < ATA_MAX_DEVICES; i++) {
1862 struct ata_device *dev = &ap->device[i]; 1845 dev = &ap->device[i];
1863 1846
1864 if (!ata_dev_enabled(dev)) 1847 if (!ata_dev_enabled(dev))
1865 continue; 1848 continue;
@@ -1869,17 +1852,13 @@ static void ata_set_mode(struct ata_port *ap)
1869 goto err_out; 1852 goto err_out;
1870 } 1853 }
1871 1854
1872 /* 1855 /* Record simplex status. If we selected DMA then the other
1873 * Record simplex status. If we selected DMA then the other 1856 * host channels are not permitted to do so.
1874 * host channels are not permitted to do so.
1875 */ 1857 */
1876
1877 if (used_dma && (ap->host_set->flags & ATA_HOST_SIMPLEX)) 1858 if (used_dma && (ap->host_set->flags & ATA_HOST_SIMPLEX))
1878 ap->host_set->simplex_claimed = 1; 1859 ap->host_set->simplex_claimed = 1;
1879 1860
1880 /* 1861 /* step5: chip specific finalisation */
1881 * Chip specific finalisation
1882 */
1883 if (ap->ops->post_set_mode) 1862 if (ap->ops->post_set_mode)
1884 ap->ops->post_set_mode(ap); 1863 ap->ops->post_set_mode(ap);
1885 1864