diff options
author | Tejun Heo <htejun@gmail.com> | 2007-12-05 02:43:07 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2008-01-23 05:24:14 -0500 |
commit | 55dba3120fbcbea6800f9a18503d25f73212a347 (patch) | |
tree | 1b23e606aad8bc58dbe68ca905c0658625fb176e /drivers/ata/pata_winbond.c | |
parent | ceb0c642624f634c5b4f46b0e22df19be87a2e53 (diff) |
libata: update ->data_xfer hook for ATAPI
Depending on how many bytes are transferred as a unit, PIO data
transfer may consume more bytes than requested. Knowing how much
data is consumed is necessary to determine how much is left for
draining. This patch update ->data_xfer such that it returns the
number of consumed bytes.
While at it, it also makes the following changes.
* s/adev/dev/
* use READ/WRITE constants for rw indication
* misc clean ups
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/pata_winbond.c')
-rw-r--r-- | drivers/ata/pata_winbond.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c index 7116a9e7a8b2..7312e9182d69 100644 --- a/drivers/ata/pata_winbond.c +++ b/drivers/ata/pata_winbond.c | |||
@@ -92,29 +92,33 @@ static void winbond_set_piomode(struct ata_port *ap, struct ata_device *adev) | |||
92 | } | 92 | } |
93 | 93 | ||
94 | 94 | ||
95 | static void winbond_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned int buflen, int write_data) | 95 | static void winbond_data_xfer(struct ata_device *dev, unsigned char *buf, |
96 | unsigned int buflen, int rw) | ||
96 | { | 97 | { |
97 | struct ata_port *ap = adev->link->ap; | 98 | struct ata_port *ap = dev->link->ap; |
98 | int slop = buflen & 3; | 99 | int slop = buflen & 3; |
99 | 100 | ||
100 | if (ata_id_has_dword_io(adev->id)) { | 101 | if (ata_id_has_dword_io(dev->id)) { |
101 | if (write_data) | 102 | if (rw == READ) |
102 | iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); | ||
103 | else | ||
104 | ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); | 103 | ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); |
104 | else | ||
105 | iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); | ||
105 | 106 | ||
106 | if (unlikely(slop)) { | 107 | if (unlikely(slop)) { |
107 | __le32 pad = 0; | 108 | u32 pad; |
108 | if (write_data) { | 109 | if (rw == READ) { |
109 | memcpy(&pad, buf + buflen - slop, slop); | ||
110 | iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr); | ||
111 | } else { | ||
112 | pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr)); | 110 | pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr)); |
113 | memcpy(buf + buflen - slop, &pad, slop); | 111 | memcpy(buf + buflen - slop, &pad, slop); |
112 | } else { | ||
113 | memcpy(&pad, buf + buflen - slop, slop); | ||
114 | iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr); | ||
114 | } | 115 | } |
116 | buflen += 4 - slop; | ||
115 | } | 117 | } |
116 | } else | 118 | } else |
117 | ata_data_xfer(adev, buf, buflen, write_data); | 119 | buflen = ata_data_xfer(dev, buf, buflen, rw); |
120 | |||
121 | return buflen; | ||
118 | } | 122 | } |
119 | 123 | ||
120 | static struct scsi_host_template winbond_sht = { | 124 | static struct scsi_host_template winbond_sht = { |