diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-11-04 22:08:00 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-11-04 22:08:00 -0500 |
commit | 6037d6bbdff65eb5a84fe35e140f4da4f7cc103a (patch) | |
tree | 67b86d8559935c04a0918afd3274eef778017d57 /drivers/scsi/sata_mv.c | |
parent | c2cc87ca9561ddfe744d446789cc10f507e87db9 (diff) |
[libata] ATAPI pad allocation fixes/cleanup
Use ata_pad_{alloc,free} in two drivers, to factor out common code.
Add ata_pad_{alloc,free} to two other drivers, which needed the padding
but had not been updated.
Diffstat (limited to 'drivers/scsi/sata_mv.c')
-rw-r--r-- | drivers/scsi/sata_mv.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index 64af334e71f4..0f469e3dabe2 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c | |||
@@ -670,6 +670,11 @@ static void mv_host_stop(struct ata_host_set *host_set) | |||
670 | ata_host_stop(host_set); | 670 | ata_host_stop(host_set); |
671 | } | 671 | } |
672 | 672 | ||
673 | static inline void mv_priv_free(struct mv_port_priv *pp, struct device *dev) | ||
674 | { | ||
675 | dma_free_coherent(dev, MV_PORT_PRIV_DMA_SZ, pp->crpb, pp->crpb_dma); | ||
676 | } | ||
677 | |||
673 | /** | 678 | /** |
674 | * mv_port_start - Port specific init/start routine. | 679 | * mv_port_start - Port specific init/start routine. |
675 | * @ap: ATA channel to manipulate | 680 | * @ap: ATA channel to manipulate |
@@ -687,21 +692,23 @@ static int mv_port_start(struct ata_port *ap) | |||
687 | void __iomem *port_mmio = mv_ap_base(ap); | 692 | void __iomem *port_mmio = mv_ap_base(ap); |
688 | void *mem; | 693 | void *mem; |
689 | dma_addr_t mem_dma; | 694 | dma_addr_t mem_dma; |
695 | int rc = -ENOMEM; | ||
690 | 696 | ||
691 | pp = kmalloc(sizeof(*pp), GFP_KERNEL); | 697 | pp = kmalloc(sizeof(*pp), GFP_KERNEL); |
692 | if (!pp) { | 698 | if (!pp) |
693 | return -ENOMEM; | 699 | goto err_out; |
694 | } | ||
695 | memset(pp, 0, sizeof(*pp)); | 700 | memset(pp, 0, sizeof(*pp)); |
696 | 701 | ||
697 | mem = dma_alloc_coherent(dev, MV_PORT_PRIV_DMA_SZ, &mem_dma, | 702 | mem = dma_alloc_coherent(dev, MV_PORT_PRIV_DMA_SZ, &mem_dma, |
698 | GFP_KERNEL); | 703 | GFP_KERNEL); |
699 | if (!mem) { | 704 | if (!mem) |
700 | kfree(pp); | 705 | goto err_out_pp; |
701 | return -ENOMEM; | ||
702 | } | ||
703 | memset(mem, 0, MV_PORT_PRIV_DMA_SZ); | 706 | memset(mem, 0, MV_PORT_PRIV_DMA_SZ); |
704 | 707 | ||
708 | rc = ata_pad_alloc(ap, dev); | ||
709 | if (rc) | ||
710 | goto err_out_priv; | ||
711 | |||
705 | /* First item in chunk of DMA memory: | 712 | /* First item in chunk of DMA memory: |
706 | * 32-slot command request table (CRQB), 32 bytes each in size | 713 | * 32-slot command request table (CRQB), 32 bytes each in size |
707 | */ | 714 | */ |
@@ -746,6 +753,13 @@ static int mv_port_start(struct ata_port *ap) | |||
746 | */ | 753 | */ |
747 | ap->private_data = pp; | 754 | ap->private_data = pp; |
748 | return 0; | 755 | return 0; |
756 | |||
757 | err_out_priv: | ||
758 | mv_priv_free(pp, dev); | ||
759 | err_out_pp: | ||
760 | kfree(pp); | ||
761 | err_out: | ||
762 | return rc; | ||
749 | } | 763 | } |
750 | 764 | ||
751 | /** | 765 | /** |
@@ -768,7 +782,8 @@ static void mv_port_stop(struct ata_port *ap) | |||
768 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 782 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
769 | 783 | ||
770 | ap->private_data = NULL; | 784 | ap->private_data = NULL; |
771 | dma_free_coherent(dev, MV_PORT_PRIV_DMA_SZ, pp->crpb, pp->crpb_dma); | 785 | ata_pad_free(ap, dev); |
786 | mv_priv_free(pp, dev); | ||
772 | kfree(pp); | 787 | kfree(pp); |
773 | } | 788 | } |
774 | 789 | ||