aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_mv.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/sata_mv.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/sata_mv.c')
-rw-r--r--drivers/ata/sata_mv.c66
1 files changed, 10 insertions, 56 deletions
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 52d41edadb72..f341a82d27bf 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -526,23 +526,16 @@ static struct scsi_host_template mv6_sht = {
526 .dma_boundary = MV_DMA_BOUNDARY, 526 .dma_boundary = MV_DMA_BOUNDARY,
527}; 527};
528 528
529static const struct ata_port_operations mv5_ops = { 529static struct ata_port_operations mv5_ops = {
530 .tf_load = ata_tf_load, 530 .inherits = &ata_sff_port_ops,
531 .tf_read = ata_tf_read,
532 .check_status = ata_check_status,
533 .exec_command = ata_exec_command,
534 .dev_select = ata_std_dev_select,
535 531
536 .qc_prep = mv_qc_prep, 532 .qc_prep = mv_qc_prep,
537 .qc_issue = mv_qc_issue, 533 .qc_issue = mv_qc_issue,
538 .data_xfer = ata_data_xfer,
539 534
540 .irq_clear = ata_noop_irq_clear,
541 .irq_on = ata_irq_on,
542
543 .error_handler = mv_error_handler,
544 .freeze = mv_eh_freeze, 535 .freeze = mv_eh_freeze,
545 .thaw = mv_eh_thaw, 536 .thaw = mv_eh_thaw,
537 .error_handler = mv_error_handler,
538 .post_internal_cmd = ATA_OP_NULL,
546 539
547 .scr_read = mv5_scr_read, 540 .scr_read = mv5_scr_read,
548 .scr_write = mv5_scr_write, 541 .scr_write = mv5_scr_write,
@@ -551,57 +544,18 @@ static const struct ata_port_operations mv5_ops = {
551 .port_stop = mv_port_stop, 544 .port_stop = mv_port_stop,
552}; 545};
553 546
554static const struct ata_port_operations mv6_ops = { 547static struct ata_port_operations mv6_ops = {
555 .dev_config = mv6_dev_config, 548 .inherits = &mv5_ops,
556 .tf_load = ata_tf_load,
557 .tf_read = ata_tf_read,
558 .check_status = ata_check_status,
559 .exec_command = ata_exec_command,
560 .dev_select = ata_std_dev_select,
561
562 .qc_prep = mv_qc_prep,
563 .qc_issue = mv_qc_issue,
564 .data_xfer = ata_data_xfer,
565
566 .irq_clear = ata_noop_irq_clear,
567 .irq_on = ata_irq_on,
568
569 .error_handler = mv_error_handler,
570 .freeze = mv_eh_freeze,
571 .thaw = mv_eh_thaw,
572 .qc_defer = ata_std_qc_defer, 549 .qc_defer = ata_std_qc_defer,
573 550 .dev_config = mv6_dev_config,
574 .scr_read = mv_scr_read, 551 .scr_read = mv_scr_read,
575 .scr_write = mv_scr_write, 552 .scr_write = mv_scr_write,
576
577 .port_start = mv_port_start,
578 .port_stop = mv_port_stop,
579}; 553};
580 554
581static const struct ata_port_operations mv_iie_ops = { 555static struct ata_port_operations mv_iie_ops = {
582 .tf_load = ata_tf_load, 556 .inherits = &mv6_ops,
583 .tf_read = ata_tf_read, 557 .dev_config = ATA_OP_NULL,
584 .check_status = ata_check_status,
585 .exec_command = ata_exec_command,
586 .dev_select = ata_std_dev_select,
587
588 .qc_prep = mv_qc_prep_iie, 558 .qc_prep = mv_qc_prep_iie,
589 .qc_issue = mv_qc_issue,
590 .data_xfer = ata_data_xfer,
591
592 .irq_clear = ata_noop_irq_clear,
593 .irq_on = ata_irq_on,
594
595 .error_handler = mv_error_handler,
596 .freeze = mv_eh_freeze,
597 .thaw = mv_eh_thaw,
598 .qc_defer = ata_std_qc_defer,
599
600 .scr_read = mv_scr_read,
601 .scr_write = mv_scr_write,
602
603 .port_start = mv_port_start,
604 .port_stop = mv_port_stop,
605}; 559};
606 560
607static const struct ata_port_info mv_port_info[] = { 561static const struct ata_port_info mv_port_info[] = {