Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 109026
b: refs/heads/master
c: b15b3eb
h: refs/heads/master
v: v3
  • Loading branch information
Alan Cox authored and Jeff Garzik committed Aug 22, 2008
1 parent 57f5d66 commit f49bee5
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 20e2de4a505aa02131a95665e8920eb053fce686
refs/heads/master: b15b3ebae102f89c25ccbcae0b2099af312f2e82
4 changes: 2 additions & 2 deletions trunk/drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3288,7 +3288,7 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)
dev->dma_mode = ata_xfer_mask2mode(dma_mask);

found = 1;
if (dev->dma_mode != 0xff)
if (ata_dma_enabled(dev))
used_dma = 1;
}
if (!found)
Expand All @@ -3313,7 +3313,7 @@ int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev)

/* step 3: set host DMA timings */
ata_link_for_each_dev(dev, link) {
if (!ata_dev_enabled(dev) || dev->dma_mode == 0xff)
if (!ata_dev_enabled(dev) || !ata_dma_enabled(dev))
continue;

dev->xfer_mode = dev->dma_mode;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/ata/pata_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static unsigned int pacpi_qc_issue(struct ata_queued_cmd *qc)

if (adev != acpi->last) {
pacpi_set_piomode(ap, adev);
if (adev->dma_mode)
if (ata_dma_enabled(adev))
pacpi_set_dmamode(ap, adev);
acpi->last = adev;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/ata/pata_atiixp.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static void atiixp_bmdma_start(struct ata_queued_cmd *qc)
u16 tmp16;

pci_read_config_word(pdev, ATIIXP_IDE_UDMA_CONTROL, &tmp16);
if (adev->dma_mode >= XFER_UDMA_0)
if (ata_using_udma(adev))
tmp16 |= (1 << dn);
else
tmp16 &= ~(1 << dn);
Expand Down
6 changes: 3 additions & 3 deletions trunk/drivers/ata/pata_cs5530.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ static unsigned int cs5530_qc_issue(struct ata_queued_cmd *qc)
struct ata_device *prev = ap->private_data;

/* See if the DMA settings could be wrong */
if (adev->dma_mode != 0 && adev != prev && prev != NULL) {
if (ata_dma_enabled(adev) && adev != prev && prev != NULL) {
/* Maybe, but do the channels match MWDMA/UDMA ? */
if ((adev->dma_mode >= XFER_UDMA_0 && prev->dma_mode < XFER_UDMA_0) ||
(adev->dma_mode < XFER_UDMA_0 && prev->dma_mode >= XFER_UDMA_0))
if ((ata_using_udma(adev) && !ata_using_udma(prev)) ||
(ata_using_udma(prev) && !ata_using_udma(adev)))
/* Switch the mode bits */
cs5530_set_dmamode(ap, adev);
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/ata/pata_oldpiix.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static unsigned int oldpiix_qc_issue(struct ata_queued_cmd *qc)

if (adev != ap->private_data) {
oldpiix_set_piomode(ap, adev);
if (adev->dma_mode)
if (ata_dma_enabled(adev))
oldpiix_set_dmamode(ap, adev);
}
return ata_sff_qc_issue(qc);
Expand Down
6 changes: 3 additions & 3 deletions trunk/drivers/ata/pata_sc1200.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ static unsigned int sc1200_qc_issue(struct ata_queued_cmd *qc)
struct ata_device *prev = ap->private_data;

/* See if the DMA settings could be wrong */
if (adev->dma_mode != 0 && adev != prev && prev != NULL) {
if (ata_dma_enabled(adev) && adev != prev && prev != NULL) {
/* Maybe, but do the channels match MWDMA/UDMA ? */
if ((adev->dma_mode >= XFER_UDMA_0 && prev->dma_mode < XFER_UDMA_0) ||
(adev->dma_mode < XFER_UDMA_0 && prev->dma_mode >= XFER_UDMA_0))
if ((ata_using_udma(adev) && !ata_using_udma(prev)) ||
(ata_using_udma(prev) && !ata_using_udma(adev)))
/* Switch the mode bits */
sc1200_set_dmamode(ap, adev);
}
Expand Down
22 changes: 22 additions & 0 deletions trunk/include/linux/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,28 @@ static inline unsigned long ata_deadline(unsigned long from_jiffies,
return from_jiffies + msecs_to_jiffies(timeout_msecs);
}

/* Don't open code these in drivers as there are traps. Firstly the range may
change in future hardware and specs, secondly 0xFF means 'no DMA' but is
> UDMA_0. Dyma ddreigiau */

static inline int ata_using_mwdma(struct ata_device *adev)
{
if (adev->dma_mode >= XFER_MW_DMA_0 && adev->dma_mode <= XFER_MW_DMA_4)
return 1;
return 0;
}

static inline int ata_using_udma(struct ata_device *adev)
{
if (adev->dma_mode >= XFER_UDMA_0 && adev->dma_mode <= XFER_UDMA_7)
return 1;
return 0;
}

static inline int ata_dma_enabled(struct ata_device *adev)
{
return (adev->dma_mode == 0xFF ? 0 : 1);
}

/**************************************************************************
* PMP - drivers/ata/libata-pmp.c
Expand Down

0 comments on commit f49bee5

Please sign in to comment.