aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_legacy.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-01-20 02:00:28 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-09 17:39:37 -0500
commit24dc5f33ea4b504cfbd23fa159a4cacba8e4d800 (patch)
treed76de456157f555c9a65b83f426fd805fee1e846 /drivers/ata/pata_legacy.c
parentf0d36efdc624beb3d9e29b9ab9e9537bf0f25d5b (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_legacy.c')
-rw-r--r--drivers/ata/pata_legacy.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index 581cb33c6f45..9532b9bb6d2f 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -170,8 +170,6 @@ static struct ata_port_operations simple_port_ops = {
170 .irq_clear = ata_bmdma_irq_clear, 170 .irq_clear = ata_bmdma_irq_clear,
171 171
172 .port_start = ata_port_start, 172 .port_start = ata_port_start,
173 .port_stop = ata_port_stop,
174 .host_stop = ata_host_stop
175}; 173};
176 174
177static struct ata_port_operations legacy_port_ops = { 175static struct ata_port_operations legacy_port_ops = {
@@ -195,8 +193,6 @@ static struct ata_port_operations legacy_port_ops = {
195 .irq_clear = ata_bmdma_irq_clear, 193 .irq_clear = ata_bmdma_irq_clear,
196 194
197 .port_start = ata_port_start, 195 .port_start = ata_port_start,
198 .port_stop = ata_port_stop,
199 .host_stop = ata_host_stop
200}; 196};
201 197
202/* 198/*
@@ -305,8 +301,6 @@ static struct ata_port_operations pdc20230_port_ops = {
305 .irq_clear = ata_bmdma_irq_clear, 301 .irq_clear = ata_bmdma_irq_clear,
306 302
307 .port_start = ata_port_start, 303 .port_start = ata_port_start,
308 .port_stop = ata_port_stop,
309 .host_stop = ata_host_stop
310}; 304};
311 305
312/* 306/*
@@ -357,8 +351,6 @@ static struct ata_port_operations ht6560a_port_ops = {
357 .irq_clear = ata_bmdma_irq_clear, 351 .irq_clear = ata_bmdma_irq_clear,
358 352
359 .port_start = ata_port_start, 353 .port_start = ata_port_start,
360 .port_stop = ata_port_stop,
361 .host_stop = ata_host_stop
362}; 354};
363 355
364/* 356/*
@@ -420,8 +412,6 @@ static struct ata_port_operations ht6560b_port_ops = {
420 .irq_clear = ata_bmdma_irq_clear, 412 .irq_clear = ata_bmdma_irq_clear,
421 413
422 .port_start = ata_port_start, 414 .port_start = ata_port_start,
423 .port_stop = ata_port_stop,
424 .host_stop = ata_host_stop
425}; 415};
426 416
427/* 417/*
@@ -538,8 +528,6 @@ static struct ata_port_operations opti82c611a_port_ops = {
538 .irq_clear = ata_bmdma_irq_clear, 528 .irq_clear = ata_bmdma_irq_clear,
539 529
540 .port_start = ata_port_start, 530 .port_start = ata_port_start,
541 .port_stop = ata_port_stop,
542 .host_stop = ata_host_stop
543}; 531};
544 532
545/* 533/*
@@ -668,8 +656,6 @@ static struct ata_port_operations opti82c46x_port_ops = {
668 .irq_clear = ata_bmdma_irq_clear, 656 .irq_clear = ata_bmdma_irq_clear,
669 657
670 .port_start = ata_port_start, 658 .port_start = ata_port_start,
671 .port_stop = ata_port_stop,
672 .host_stop = ata_host_stop
673}; 659};
674 660
675 661
@@ -689,21 +675,19 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
689 struct legacy_data *ld = &legacy_data[nr_legacy_host]; 675 struct legacy_data *ld = &legacy_data[nr_legacy_host];
690 struct ata_probe_ent ae; 676 struct ata_probe_ent ae;
691 struct platform_device *pdev; 677 struct platform_device *pdev;
692 int ret = -EBUSY;
693 struct ata_port_operations *ops = &legacy_port_ops; 678 struct ata_port_operations *ops = &legacy_port_ops;
694 int pio_modes = pio_mask; 679 int pio_modes = pio_mask;
695 u32 mask = (1 << port); 680 u32 mask = (1 << port);
696 681 int ret;
697 if (request_region(io, 8, "pata_legacy") == NULL)
698 return -EBUSY;
699 if (request_region(ctrl, 1, "pata_legacy") == NULL)
700 goto fail_io;
701 682
702 pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0); 683 pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0);
703 if (IS_ERR(pdev)) { 684 if (IS_ERR(pdev))
704 ret = PTR_ERR(pdev); 685 return PTR_ERR(pdev);
705 goto fail_dev; 686
706 } 687 ret = -EBUSY;
688 if (devm_request_region(&pdev->dev, io, 8, "pata_legacy") == NULL ||
689 devm_request_region(&pdev->dev, ctrl, 1, "pata_legacy") == NULL)
690 goto fail;
707 691
708 if (ht6560a & mask) { 692 if (ht6560a & mask) {
709 ops = &ht6560a_port_ops; 693 ops = &ht6560a_port_ops;
@@ -776,21 +760,16 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl
776 ata_std_ports(&ae.port[0]); 760 ata_std_ports(&ae.port[0]);
777 ae.private_data = ld; 761 ae.private_data = ld;
778 762
779 ret = ata_device_add(&ae); 763 ret = -ENODEV;
780 if (ret == 0) { 764 if (!ata_device_add(&ae))
781 ret = -ENODEV;
782 goto fail; 765 goto fail;
783 } 766
784 legacy_host[nr_legacy_host++] = dev_get_drvdata(&pdev->dev); 767 legacy_host[nr_legacy_host++] = dev_get_drvdata(&pdev->dev);
785 ld->platform_dev = pdev; 768 ld->platform_dev = pdev;
786 return 0; 769 return 0;
787 770
788fail: 771fail:
789 platform_device_unregister(pdev); 772 platform_device_unregister(pdev);
790fail_dev:
791 release_region(ctrl, 1);
792fail_io:
793 release_region(io, 8);
794 return ret; 773 return ret;
795} 774}
796 775
@@ -923,15 +902,11 @@ static __exit void legacy_exit(void)
923 902
924 for (i = 0; i < nr_legacy_host; i++) { 903 for (i = 0; i < nr_legacy_host; i++) {
925 struct legacy_data *ld = &legacy_data[i]; 904 struct legacy_data *ld = &legacy_data[i];
926 struct ata_port *ap =legacy_host[i]->ports[0]; 905
927 unsigned long io = ap->ioaddr.cmd_addr; 906 ata_host_detach(legacy_host[i]);
928 unsigned long ctrl = ap->ioaddr.ctl_addr;
929 ata_host_remove(legacy_host[i]);
930 platform_device_unregister(ld->platform_dev); 907 platform_device_unregister(ld->platform_dev);
931 if (ld->timing) 908 if (ld->timing)
932 release_region(ld->timing, 2); 909 release_region(ld->timing, 2);
933 release_region(io, 8);
934 release_region(ctrl, 1);
935 } 910 }
936} 911}
937 912