aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_it821x.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2008-03-24 23:22:49 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-17 15:44:17 -0400
commit029cfd6b74fc5c517865fad78cf4a3ea8d9b664a (patch)
tree4a40f44f29321e433497a51d2f6cfe1922ae1d58 /drivers/ata/pata_it821x.c
parent68d1d07b510bb57a504588adc2bd2758adea0965 (diff)
libata: implement and use ops inheritance
libata lets low level drivers build ata_port_operations table and register it with libata core layer. This allows low level drivers high level of flexibility but also burdens them with lots of boilerplate entries. This becomes worse for drivers which support related similar controllers which differ slightly. They share most of the operations except for a few. However, the driver still needs to list all operations for each variant. This results in large number of duplicate entries, which is not only inefficient but also error-prone as it becomes very difficult to tell what the actual differences are. This duplicate boilerplates all over the low level drivers also make updating the core layer exteremely difficult and error-prone. When compounded with multi-branched development model, it ends up accumulating inconsistencies over time. Some of those inconsistencies cause immediate problems and fixed. Others just remain there dormant making maintenance increasingly difficult. To rectify the problem, this patch implements ata_port_operations inheritance. To allow LLDs to easily re-use their own ops tables overriding only specific methods, this patch implements poor man's class inheritance. An ops table has ->inherits field which can be set to any ops table as long as it doesn't create a loop. When the host is started, the inheritance chain is followed and any operation which isn't specified is taken from the nearest ancestor which has it specified. This operation is called finalization and done only once per an ops table and the LLD doesn't have to do anything special about it other than making the ops table non-const such that libata can update it. libata provides four base ops tables lower drivers can inherit from - base, sata, pmp, sff and bmdma. To avoid overriding these ops accidentaly, these ops are declared const and LLDs should always inherit these instead of using them directly. After finalization, all the ops table are identical before and after the patch except for setting .irq_handler to ata_interrupt in drivers which didn't use to. The .irq_handler doesn't have any actual effect and the field will soon be removed by later patch. * sata_sx4 is still using old style EH and currently doesn't take advantage of ops inheritance. Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'drivers/ata/pata_it821x.c')
-rw-r--r--drivers/ata/pata_it821x.c57
1 files changed, 8 insertions, 49 deletions
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 7d969c911731..669d224d30ca 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -636,71 +636,30 @@ static struct scsi_host_template it821x_sht = {
636}; 636};
637 637
638static struct ata_port_operations it821x_smart_port_ops = { 638static struct ata_port_operations it821x_smart_port_ops = {
639 .set_mode = it821x_smart_set_mode, 639 .inherits = &ata_bmdma_port_ops,
640 .tf_load = ata_tf_load,
641 .tf_read = ata_tf_read,
642 .mode_filter = ata_pci_default_filter,
643 640
644 .check_status = ata_check_status,
645 .check_atapi_dma= it821x_check_atapi_dma, 641 .check_atapi_dma= it821x_check_atapi_dma,
646 .exec_command = ata_exec_command,
647 .dev_select = ata_std_dev_select,
648 .dev_config = it821x_dev_config,
649
650 .freeze = ata_bmdma_freeze,
651 .thaw = ata_bmdma_thaw,
652 .error_handler = ata_bmdma_error_handler,
653 .post_internal_cmd = ata_bmdma_post_internal_cmd,
654 .cable_detect = it821x_ident_hack,
655
656 .bmdma_setup = ata_bmdma_setup,
657 .bmdma_start = ata_bmdma_start,
658 .bmdma_stop = ata_bmdma_stop,
659 .bmdma_status = ata_bmdma_status,
660
661 .qc_prep = ata_qc_prep,
662 .qc_issue = it821x_smart_qc_issue_prot, 642 .qc_issue = it821x_smart_qc_issue_prot,
663 643
664 .data_xfer = ata_data_xfer, 644 .cable_detect = it821x_ident_hack,
665 645 .set_mode = it821x_smart_set_mode,
666 .irq_handler = ata_interrupt, 646 .dev_config = it821x_dev_config,
667 .irq_clear = ata_bmdma_irq_clear,
668 .irq_on = ata_irq_on,
669 647
670 .port_start = it821x_port_start, 648 .port_start = it821x_port_start,
671}; 649};
672 650
673static struct ata_port_operations it821x_passthru_port_ops = { 651static struct ata_port_operations it821x_passthru_port_ops = {
674 .set_piomode = it821x_passthru_set_piomode, 652 .inherits = &ata_bmdma_port_ops,
675 .set_dmamode = it821x_passthru_set_dmamode,
676 .mode_filter = ata_pci_default_filter,
677 653
678 .tf_load = ata_tf_load,
679 .tf_read = ata_tf_read,
680 .check_status = ata_check_status,
681 .exec_command = ata_exec_command,
682 .check_atapi_dma= it821x_check_atapi_dma, 654 .check_atapi_dma= it821x_check_atapi_dma,
683 .dev_select = it821x_passthru_dev_select, 655 .dev_select = it821x_passthru_dev_select,
684
685 .freeze = ata_bmdma_freeze,
686 .thaw = ata_bmdma_thaw,
687 .error_handler = ata_bmdma_error_handler,
688 .post_internal_cmd = ata_bmdma_post_internal_cmd,
689 .cable_detect = ata_cable_unknown,
690
691 .bmdma_setup = ata_bmdma_setup,
692 .bmdma_start = it821x_passthru_bmdma_start, 656 .bmdma_start = it821x_passthru_bmdma_start,
693 .bmdma_stop = it821x_passthru_bmdma_stop, 657 .bmdma_stop = it821x_passthru_bmdma_stop,
694 .bmdma_status = ata_bmdma_status,
695
696 .qc_prep = ata_qc_prep,
697 .qc_issue = it821x_passthru_qc_issue_prot, 658 .qc_issue = it821x_passthru_qc_issue_prot,
698 659
699 .data_xfer = ata_data_xfer, 660 .cable_detect = ata_cable_unknown,
700 661 .set_piomode = it821x_passthru_set_piomode,
701 .irq_clear = ata_bmdma_irq_clear, 662 .set_dmamode = it821x_passthru_set_dmamode,
702 .irq_handler = ata_interrupt,
703 .irq_on = ata_irq_on,
704 663
705 .port_start = it821x_port_start, 664 .port_start = it821x_port_start,
706}; 665};