aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_inic162x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/sata_inic162x.c')
-rw-r--r--drivers/ata/sata_inic162x.c52
1 files changed, 13 insertions, 39 deletions
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index b67817e440c5..c98e0227a60c 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -523,7 +523,7 @@ static int inic_port_start(struct ata_port *ap)
523 int rc; 523 int rc;
524 524
525 /* alloc and initialize private data */ 525 /* alloc and initialize private data */
526 pp = kzalloc(sizeof(*pp), GFP_KERNEL); 526 pp = devm_kzalloc(ap->host->dev, sizeof(*pp), GFP_KERNEL);
527 if (!pp) 527 if (!pp)
528 return -ENOMEM; 528 return -ENOMEM;
529 ap->private_data = pp; 529 ap->private_data = pp;
@@ -545,12 +545,6 @@ static int inic_port_start(struct ata_port *ap)
545 return 0; 545 return 0;
546} 546}
547 547
548static void inic_port_stop(struct ata_port *ap)
549{
550 ata_port_stop(ap);
551 kfree(ap->private_data);
552}
553
554static struct ata_port_operations inic_port_ops = { 548static struct ata_port_operations inic_port_ops = {
555 .port_disable = ata_port_disable, 549 .port_disable = ata_port_disable,
556 .tf_load = ata_tf_load, 550 .tf_load = ata_tf_load,
@@ -583,8 +577,6 @@ static struct ata_port_operations inic_port_ops = {
583 .port_resume = inic_port_resume, 577 .port_resume = inic_port_resume,
584 578
585 .port_start = inic_port_start, 579 .port_start = inic_port_start,
586 .port_stop = inic_port_stop,
587 .host_stop = ata_pci_host_stop
588}; 580};
589 581
590static struct ata_port_info inic_port_info = { 582static struct ata_port_info inic_port_info = {
@@ -675,42 +667,37 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
675 if (!printed_version++) 667 if (!printed_version++)
676 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 668 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
677 669
678 rc = pci_enable_device(pdev); 670 rc = pcim_enable_device(pdev);
679 if (rc) 671 if (rc)
680 return rc; 672 return rc;
681 673
682 rc = pci_request_regions(pdev, DRV_NAME); 674 rc = pci_request_regions(pdev, DRV_NAME);
683 if (rc) 675 if (rc)
684 goto err_out; 676 return rc;
685 677
686 rc = -ENOMEM;
687 mmio_base = pci_iomap(pdev, MMIO_BAR, 0); 678 mmio_base = pci_iomap(pdev, MMIO_BAR, 0);
688 if (!mmio_base) 679 if (!mmio_base)
689 goto err_out_regions; 680 return -ENOMEM;
690 681
691 /* Set dma_mask. This devices doesn't support 64bit addressing. */ 682 /* Set dma_mask. This devices doesn't support 64bit addressing. */
692 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 683 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
693 if (rc) { 684 if (rc) {
694 dev_printk(KERN_ERR, &pdev->dev, 685 dev_printk(KERN_ERR, &pdev->dev,
695 "32-bit DMA enable failed\n"); 686 "32-bit DMA enable failed\n");
696 goto err_out_map; 687 return rc;
697 } 688 }
698 689
699 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 690 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
700 if (rc) { 691 if (rc) {
701 dev_printk(KERN_ERR, &pdev->dev, 692 dev_printk(KERN_ERR, &pdev->dev,
702 "32-bit consistent DMA enable failed\n"); 693 "32-bit consistent DMA enable failed\n");
703 goto err_out_map; 694 return rc;
704 } 695 }
705 696
706 rc = -ENOMEM; 697 probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
707 probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL); 698 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
708 if (!probe_ent) 699 if (!probe_ent || !hpriv)
709 goto err_out_map; 700 return -ENOMEM;
710
711 hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
712 if (!hpriv)
713 goto err_out_ent;
714 701
715 probe_ent->dev = &pdev->dev; 702 probe_ent->dev = &pdev->dev;
716 INIT_LIST_HEAD(&probe_ent->node); 703 INIT_LIST_HEAD(&probe_ent->node);
@@ -749,30 +736,17 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
749 if (rc) { 736 if (rc) {
750 dev_printk(KERN_ERR, &pdev->dev, 737 dev_printk(KERN_ERR, &pdev->dev,
751 "failed to initialize controller\n"); 738 "failed to initialize controller\n");
752 goto err_out_hpriv; 739 return rc;
753 } 740 }
754 741
755 pci_set_master(pdev); 742 pci_set_master(pdev);
756 743
757 rc = -ENODEV;
758 if (!ata_device_add(probe_ent)) 744 if (!ata_device_add(probe_ent))
759 goto err_out_hpriv; 745 return -ENODEV;
760 746
761 kfree(probe_ent); 747 devm_kfree(&pdev->dev, probe_ent);
762 748
763 return 0; 749 return 0;
764
765 err_out_hpriv:
766 kfree(hpriv);
767 err_out_ent:
768 kfree(probe_ent);
769 err_out_map:
770 pci_iounmap(pdev, mmio_base);
771 err_out_regions:
772 pci_release_regions(pdev);
773 err_out:
774 pci_disable_device(pdev);
775 return rc;
776} 750}
777 751
778static const struct pci_device_id inic_pci_tbl[] = { 752static const struct pci_device_id inic_pci_tbl[] = {