aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_sis.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_sis.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_sis.c')
-rw-r--r--drivers/ata/pata_sis.c177
1 files changed, 16 insertions, 161 deletions
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index dcd8457a8377..3ed628670cd7 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -517,196 +517,51 @@ static struct scsi_host_template sis_sht = {
517 ATA_BMDMA_SHT(DRV_NAME), 517 ATA_BMDMA_SHT(DRV_NAME),
518}; 518};
519 519
520static const struct ata_port_operations sis_133_ops = { 520static struct ata_port_operations sis_133_for_sata_ops = {
521 .inherits = &ata_bmdma_port_ops,
521 .set_piomode = sis_133_set_piomode, 522 .set_piomode = sis_133_set_piomode,
522 .set_dmamode = sis_133_set_dmamode, 523 .set_dmamode = sis_133_set_dmamode,
523 .mode_filter = ata_pci_default_filter,
524
525 .tf_load = ata_tf_load,
526 .tf_read = ata_tf_read,
527 .check_status = ata_check_status,
528 .exec_command = ata_exec_command,
529 .dev_select = ata_std_dev_select,
530
531 .freeze = ata_bmdma_freeze,
532 .thaw = ata_bmdma_thaw,
533 .error_handler = sis_error_handler,
534 .post_internal_cmd = ata_bmdma_post_internal_cmd,
535 .cable_detect = sis_133_cable_detect, 524 .cable_detect = sis_133_cable_detect,
525};
536 526
537 .bmdma_setup = ata_bmdma_setup, 527static struct ata_port_operations sis_base_ops = {
538 .bmdma_start = ata_bmdma_start, 528 .inherits = &ata_bmdma_port_ops,
539 .bmdma_stop = ata_bmdma_stop, 529 .error_handler = sis_error_handler,
540 .bmdma_status = ata_bmdma_status,
541 .qc_prep = ata_qc_prep,
542 .qc_issue = ata_qc_issue_prot,
543 .data_xfer = ata_data_xfer,
544
545 .irq_handler = ata_interrupt,
546 .irq_clear = ata_bmdma_irq_clear,
547 .irq_on = ata_irq_on,
548
549 .port_start = ata_sff_port_start,
550}; 530};
551 531
552static const struct ata_port_operations sis_133_for_sata_ops = { 532static struct ata_port_operations sis_133_ops = {
533 .inherits = &sis_base_ops,
553 .set_piomode = sis_133_set_piomode, 534 .set_piomode = sis_133_set_piomode,
554 .set_dmamode = sis_133_set_dmamode, 535 .set_dmamode = sis_133_set_dmamode,
555 .mode_filter = ata_pci_default_filter,
556
557 .tf_load = ata_tf_load,
558 .tf_read = ata_tf_read,
559 .check_status = ata_check_status,
560 .exec_command = ata_exec_command,
561 .dev_select = ata_std_dev_select,
562
563 .freeze = ata_bmdma_freeze,
564 .thaw = ata_bmdma_thaw,
565 .error_handler = ata_bmdma_error_handler,
566 .post_internal_cmd = ata_bmdma_post_internal_cmd,
567 .cable_detect = sis_133_cable_detect, 536 .cable_detect = sis_133_cable_detect,
568
569 .bmdma_setup = ata_bmdma_setup,
570 .bmdma_start = ata_bmdma_start,
571 .bmdma_stop = ata_bmdma_stop,
572 .bmdma_status = ata_bmdma_status,
573 .qc_prep = ata_qc_prep,
574 .qc_issue = ata_qc_issue_prot,
575 .data_xfer = ata_data_xfer,
576
577 .irq_handler = ata_interrupt,
578 .irq_clear = ata_bmdma_irq_clear,
579 .irq_on = ata_irq_on,
580
581 .port_start = ata_sff_port_start,
582}; 537};
583 538
584static const struct ata_port_operations sis_133_early_ops = { 539static struct ata_port_operations sis_133_early_ops = {
540 .inherits = &sis_base_ops,
585 .set_piomode = sis_100_set_piomode, 541 .set_piomode = sis_100_set_piomode,
586 .set_dmamode = sis_133_early_set_dmamode, 542 .set_dmamode = sis_133_early_set_dmamode,
587 .mode_filter = ata_pci_default_filter,
588
589 .tf_load = ata_tf_load,
590 .tf_read = ata_tf_read,
591 .check_status = ata_check_status,
592 .exec_command = ata_exec_command,
593 .dev_select = ata_std_dev_select,
594
595 .freeze = ata_bmdma_freeze,
596 .thaw = ata_bmdma_thaw,
597 .error_handler = sis_error_handler,
598 .post_internal_cmd = ata_bmdma_post_internal_cmd,
599 .cable_detect = sis_66_cable_detect, 543 .cable_detect = sis_66_cable_detect,
600
601 .bmdma_setup = ata_bmdma_setup,
602 .bmdma_start = ata_bmdma_start,
603 .bmdma_stop = ata_bmdma_stop,
604 .bmdma_status = ata_bmdma_status,
605 .qc_prep = ata_qc_prep,
606 .qc_issue = ata_qc_issue_prot,
607 .data_xfer = ata_data_xfer,
608
609 .irq_handler = ata_interrupt,
610 .irq_clear = ata_bmdma_irq_clear,
611 .irq_on = ata_irq_on,
612
613 .port_start = ata_sff_port_start,
614}; 544};
615 545
616static const struct ata_port_operations sis_100_ops = { 546static struct ata_port_operations sis_100_ops = {
547 .inherits = &sis_base_ops,
617 .set_piomode = sis_100_set_piomode, 548 .set_piomode = sis_100_set_piomode,
618 .set_dmamode = sis_100_set_dmamode, 549 .set_dmamode = sis_100_set_dmamode,
619 .mode_filter = ata_pci_default_filter,
620
621 .tf_load = ata_tf_load,
622 .tf_read = ata_tf_read,
623 .check_status = ata_check_status,
624 .exec_command = ata_exec_command,
625 .dev_select = ata_std_dev_select,
626
627 .freeze = ata_bmdma_freeze,
628 .thaw = ata_bmdma_thaw,
629 .error_handler = sis_error_handler,
630 .post_internal_cmd = ata_bmdma_post_internal_cmd,
631 .cable_detect = sis_66_cable_detect, 550 .cable_detect = sis_66_cable_detect,
632
633 .bmdma_setup = ata_bmdma_setup,
634 .bmdma_start = ata_bmdma_start,
635 .bmdma_stop = ata_bmdma_stop,
636 .bmdma_status = ata_bmdma_status,
637 .qc_prep = ata_qc_prep,
638 .qc_issue = ata_qc_issue_prot,
639 .data_xfer = ata_data_xfer,
640
641 .irq_handler = ata_interrupt,
642 .irq_clear = ata_bmdma_irq_clear,
643 .irq_on = ata_irq_on,
644
645 .port_start = ata_sff_port_start,
646}; 551};
647 552
648static const struct ata_port_operations sis_66_ops = { 553static struct ata_port_operations sis_66_ops = {
554 .inherits = &sis_base_ops,
649 .set_piomode = sis_old_set_piomode, 555 .set_piomode = sis_old_set_piomode,
650 .set_dmamode = sis_66_set_dmamode, 556 .set_dmamode = sis_66_set_dmamode,
651 .mode_filter = ata_pci_default_filter,
652
653 .tf_load = ata_tf_load,
654 .tf_read = ata_tf_read,
655 .check_status = ata_check_status,
656 .exec_command = ata_exec_command,
657 .dev_select = ata_std_dev_select,
658 .cable_detect = sis_66_cable_detect, 557 .cable_detect = sis_66_cable_detect,
659
660 .freeze = ata_bmdma_freeze,
661 .thaw = ata_bmdma_thaw,
662 .error_handler = sis_error_handler,
663 .post_internal_cmd = ata_bmdma_post_internal_cmd,
664
665 .bmdma_setup = ata_bmdma_setup,
666 .bmdma_start = ata_bmdma_start,
667 .bmdma_stop = ata_bmdma_stop,
668 .bmdma_status = ata_bmdma_status,
669 .qc_prep = ata_qc_prep,
670 .qc_issue = ata_qc_issue_prot,
671 .data_xfer = ata_data_xfer,
672
673 .irq_handler = ata_interrupt,
674 .irq_clear = ata_bmdma_irq_clear,
675 .irq_on = ata_irq_on,
676
677 .port_start = ata_sff_port_start,
678}; 558};
679 559
680static const struct ata_port_operations sis_old_ops = { 560static struct ata_port_operations sis_old_ops = {
561 .inherits = &sis_base_ops,
681 .set_piomode = sis_old_set_piomode, 562 .set_piomode = sis_old_set_piomode,
682 .set_dmamode = sis_old_set_dmamode, 563 .set_dmamode = sis_old_set_dmamode,
683 .mode_filter = ata_pci_default_filter,
684
685 .tf_load = ata_tf_load,
686 .tf_read = ata_tf_read,
687 .check_status = ata_check_status,
688 .exec_command = ata_exec_command,
689 .dev_select = ata_std_dev_select,
690
691 .freeze = ata_bmdma_freeze,
692 .thaw = ata_bmdma_thaw,
693 .error_handler = sis_error_handler,
694 .post_internal_cmd = ata_bmdma_post_internal_cmd,
695 .cable_detect = ata_cable_40wire, 564 .cable_detect = ata_cable_40wire,
696
697 .bmdma_setup = ata_bmdma_setup,
698 .bmdma_start = ata_bmdma_start,
699 .bmdma_stop = ata_bmdma_stop,
700 .bmdma_status = ata_bmdma_status,
701 .qc_prep = ata_qc_prep,
702 .qc_issue = ata_qc_issue_prot,
703 .data_xfer = ata_data_xfer,
704
705 .irq_handler = ata_interrupt,
706 .irq_clear = ata_bmdma_irq_clear,
707 .irq_on = ata_irq_on,
708
709 .port_start = ata_sff_port_start,
710}; 565};
711 566
712static const struct ata_port_info sis_info = { 567static const struct ata_port_info sis_info = {