aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2012-03-11 16:12:09 -0400
committerJeff Garzik <jgarzik@redhat.com>2012-03-13 16:41:08 -0400
commitd01159dffa15e3a734e43cf58c5d9f04c4106d83 (patch)
treeaf258b5f60df7cf7d2a38ad94cc54b641c20b8f9 /drivers/ata
parentd408e2b14fba4fa214fa5bc24b7baae8a55e563c (diff)
drivers/ata/pata_mpc52xx.c: clean up error handling code
This patch makes a number of changes with respect to the error-handling code: * Remove cleanup calls for the devm functions in both the error handling code and the remove function. This cleanup is done automatically. * The previous change simplifies the cleanup code at the end of the function such that there is nothing to do on the failure of the call to devm_ioremap. So it is changed to just return directly. * There is no need for the ifs in the cleanup code at the end of the function, because in each case the cleanup needed is statically known. Drop the ifs, add new err labels, and drop the initializations of the tested variables to NULL. * Change the call to request_irq to a call to devm_request_irq, so that it is cleaned up on exit. * Cause the return value of devm_request_irq to go into the returned variable rv rather than the unused variable ret. Drop ret. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/pata_mpc52xx.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 00748ae1a016..d2c102fd4330 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -687,11 +687,11 @@ mpc52xx_ata_probe(struct platform_device *op)
687 int ata_irq = 0; 687 int ata_irq = 0;
688 struct mpc52xx_ata __iomem *ata_regs; 688 struct mpc52xx_ata __iomem *ata_regs;
689 struct mpc52xx_ata_priv *priv = NULL; 689 struct mpc52xx_ata_priv *priv = NULL;
690 int rv, ret, task_irq = 0; 690 int rv, task_irq;
691 int mwdma_mask = 0, udma_mask = 0; 691 int mwdma_mask = 0, udma_mask = 0;
692 const __be32 *prop; 692 const __be32 *prop;
693 int proplen; 693 int proplen;
694 struct bcom_task *dmatsk = NULL; 694 struct bcom_task *dmatsk;
695 695
696 /* Get ipb frequency */ 696 /* Get ipb frequency */
697 ipb_freq = mpc5xxx_get_bus_frequency(op->dev.of_node); 697 ipb_freq = mpc5xxx_get_bus_frequency(op->dev.of_node);
@@ -717,8 +717,7 @@ mpc52xx_ata_probe(struct platform_device *op)
717 ata_regs = devm_ioremap(&op->dev, res_mem.start, sizeof(*ata_regs)); 717 ata_regs = devm_ioremap(&op->dev, res_mem.start, sizeof(*ata_regs));
718 if (!ata_regs) { 718 if (!ata_regs) {
719 dev_err(&op->dev, "error mapping device registers\n"); 719 dev_err(&op->dev, "error mapping device registers\n");
720 rv = -ENOMEM; 720 return -ENOMEM;
721 goto err;
722 } 721 }
723 722
724 /* 723 /*
@@ -753,7 +752,7 @@ mpc52xx_ata_probe(struct platform_device *op)
753 if (!priv) { 752 if (!priv) {
754 dev_err(&op->dev, "error allocating private structure\n"); 753 dev_err(&op->dev, "error allocating private structure\n");
755 rv = -ENOMEM; 754 rv = -ENOMEM;
756 goto err; 755 goto err1;
757 } 756 }
758 757
759 priv->ipb_period = 1000000000 / (ipb_freq / 1000); 758 priv->ipb_period = 1000000000 / (ipb_freq / 1000);
@@ -776,15 +775,15 @@ mpc52xx_ata_probe(struct platform_device *op)
776 if (!dmatsk) { 775 if (!dmatsk) {
777 dev_err(&op->dev, "bestcomm initialization failed\n"); 776 dev_err(&op->dev, "bestcomm initialization failed\n");
778 rv = -ENOMEM; 777 rv = -ENOMEM;
779 goto err; 778 goto err1;
780 } 779 }
781 780
782 task_irq = bcom_get_task_irq(dmatsk); 781 task_irq = bcom_get_task_irq(dmatsk);
783 ret = request_irq(task_irq, &mpc52xx_ata_task_irq, 0, 782 rv = devm_request_irq(&op->dev, task_irq, &mpc52xx_ata_task_irq, 0,
784 "ATA task", priv); 783 "ATA task", priv);
785 if (ret) { 784 if (rv) {
786 dev_err(&op->dev, "error requesting DMA IRQ\n"); 785 dev_err(&op->dev, "error requesting DMA IRQ\n");
787 goto err; 786 goto err2;
788 } 787 }
789 priv->dmatsk = dmatsk; 788 priv->dmatsk = dmatsk;
790 789
@@ -792,7 +791,7 @@ mpc52xx_ata_probe(struct platform_device *op)
792 rv = mpc52xx_ata_hw_init(priv); 791 rv = mpc52xx_ata_hw_init(priv);
793 if (rv) { 792 if (rv) {
794 dev_err(&op->dev, "error initializing hardware\n"); 793 dev_err(&op->dev, "error initializing hardware\n");
795 goto err; 794 goto err2;
796 } 795 }
797 796
798 /* Register ourselves to libata */ 797 /* Register ourselves to libata */
@@ -800,23 +799,16 @@ mpc52xx_ata_probe(struct platform_device *op)
800 mwdma_mask, udma_mask); 799 mwdma_mask, udma_mask);
801 if (rv) { 800 if (rv) {
802 dev_err(&op->dev, "error registering with ATA layer\n"); 801 dev_err(&op->dev, "error registering with ATA layer\n");
803 goto err; 802 goto err2;
804 } 803 }
805 804
806 return 0; 805 return 0;
807 806
808 err: 807 err2:
809 devm_release_mem_region(&op->dev, res_mem.start, sizeof(*ata_regs)); 808 irq_dispose_mapping(task_irq);
810 if (ata_irq) 809 bcom_ata_release(dmatsk);
811 irq_dispose_mapping(ata_irq); 810 err1:
812 if (task_irq) 811 irq_dispose_mapping(ata_irq);
813 irq_dispose_mapping(task_irq);
814 if (dmatsk)
815 bcom_ata_release(dmatsk);
816 if (ata_regs)
817 devm_iounmap(&op->dev, ata_regs);
818 if (priv)
819 devm_kfree(&op->dev, priv);
820 return rv; 812 return rv;
821} 813}
822 814
@@ -835,12 +827,6 @@ mpc52xx_ata_remove(struct platform_device *op)
835 bcom_ata_release(priv->dmatsk); 827 bcom_ata_release(priv->dmatsk);
836 irq_dispose_mapping(priv->ata_irq); 828 irq_dispose_mapping(priv->ata_irq);
837 829
838 /* Clear up IO allocations */
839 devm_iounmap(&op->dev, priv->ata_regs);
840 devm_release_mem_region(&op->dev, priv->ata_regs_pa,
841 sizeof(*priv->ata_regs));
842 devm_kfree(&op->dev, priv);
843
844 return 0; 830 return 0;
845} 831}
846 832