diff options
author | Tejun Heo <htejun@gmail.com> | 2007-01-20 02:00:28 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-09 17:39:37 -0500 |
commit | 24dc5f33ea4b504cfbd23fa159a4cacba8e4d800 (patch) | |
tree | d76de456157f555c9a65b83f426fd805fee1e846 /drivers/ata/pata_it821x.c | |
parent | f0d36efdc624beb3d9e29b9ab9e9537bf0f25d5b (diff) |
libata: update libata LLDs to use devres
Update libata LLDs to use devres. Core layer is already converted to
support managed LLDs. This patch simplifies initialization and fixes
many resource related bugs in init failure and detach path. For
example, all converted drivers now handle ata_device_add() failure
gracefully without excessive resource rollback code.
As most resources are released automatically on driver detach, many
drivers don't need or can do with much simpler ->{port|host}_stop().
In general, stop callbacks are need iff port or host needs to be given
commands to shut it down. Note that freezing is enough in many cases
and ports are automatically frozen before being detached.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/pata_it821x.c')
-rw-r--r-- | drivers/ata/pata_it821x.c | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c index 171fbd206bd5..f23365b92c0f 100644 --- a/drivers/ata/pata_it821x.c +++ b/drivers/ata/pata_it821x.c | |||
@@ -594,14 +594,10 @@ static int it821x_port_start(struct ata_port *ap) | |||
594 | if (ret < 0) | 594 | if (ret < 0) |
595 | return ret; | 595 | return ret; |
596 | 596 | ||
597 | ap->private_data = kmalloc(sizeof(struct it821x_dev), GFP_KERNEL); | 597 | itdev = devm_kzalloc(&pdev->dev, sizeof(struct it821x_dev), GFP_KERNEL); |
598 | if (ap->private_data == NULL) { | 598 | if (itdev == NULL) |
599 | ata_port_stop(ap); | ||
600 | return -ENOMEM; | 599 | return -ENOMEM; |
601 | } | 600 | ap->private_data = itdev; |
602 | |||
603 | itdev = ap->private_data; | ||
604 | memset(itdev, 0, sizeof(struct it821x_dev)); | ||
605 | 601 | ||
606 | pci_read_config_byte(pdev, 0x50, &conf); | 602 | pci_read_config_byte(pdev, 0x50, &conf); |
607 | 603 | ||
@@ -632,20 +628,6 @@ static int it821x_port_start(struct ata_port *ap) | |||
632 | return 0; | 628 | return 0; |
633 | } | 629 | } |
634 | 630 | ||
635 | /** | ||
636 | * it821x_port_stop - port shutdown | ||
637 | * @ap: ATA port being removed | ||
638 | * | ||
639 | * Release the private objects we added in it821x_port_start | ||
640 | */ | ||
641 | |||
642 | static void it821x_port_stop(struct ata_port *ap) { | ||
643 | kfree(ap->private_data); | ||
644 | ap->private_data = NULL; /* We want an OOPS if we reuse this | ||
645 | too late! */ | ||
646 | ata_port_stop(ap); | ||
647 | } | ||
648 | |||
649 | static struct scsi_host_template it821x_sht = { | 631 | static struct scsi_host_template it821x_sht = { |
650 | .module = THIS_MODULE, | 632 | .module = THIS_MODULE, |
651 | .name = DRV_NAME, | 633 | .name = DRV_NAME, |
@@ -698,8 +680,6 @@ static struct ata_port_operations it821x_smart_port_ops = { | |||
698 | .irq_clear = ata_bmdma_irq_clear, | 680 | .irq_clear = ata_bmdma_irq_clear, |
699 | 681 | ||
700 | .port_start = it821x_port_start, | 682 | .port_start = it821x_port_start, |
701 | .port_stop = it821x_port_stop, | ||
702 | .host_stop = ata_host_stop | ||
703 | }; | 683 | }; |
704 | 684 | ||
705 | static struct ata_port_operations it821x_passthru_port_ops = { | 685 | static struct ata_port_operations it821x_passthru_port_ops = { |
@@ -734,8 +714,6 @@ static struct ata_port_operations it821x_passthru_port_ops = { | |||
734 | .irq_handler = ata_interrupt, | 714 | .irq_handler = ata_interrupt, |
735 | 715 | ||
736 | .port_start = it821x_port_start, | 716 | .port_start = it821x_port_start, |
737 | .port_stop = it821x_port_stop, | ||
738 | .host_stop = ata_host_stop | ||
739 | }; | 717 | }; |
740 | 718 | ||
741 | static void __devinit it821x_disable_raid(struct pci_dev *pdev) | 719 | static void __devinit it821x_disable_raid(struct pci_dev *pdev) |