aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_via.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_via.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_via.c')
-rw-r--r--drivers/ata/sata_via.c88
1 files changed, 7 insertions, 81 deletions
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 9be877cb7f57..6326bcf8ea5d 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -103,97 +103,23 @@ static struct scsi_host_template svia_sht = {
103 ATA_BMDMA_SHT(DRV_NAME), 103 ATA_BMDMA_SHT(DRV_NAME),
104}; 104};
105 105
106static const struct ata_port_operations vt6420_sata_ops = { 106static struct ata_port_operations vt6420_sata_ops = {
107 .mode_filter = ata_pci_default_filter, 107 .inherits = &ata_bmdma_port_ops,
108
109 .tf_load = ata_tf_load,
110 .tf_read = ata_tf_read,
111 .check_status = ata_check_status,
112 .exec_command = ata_exec_command,
113 .dev_select = ata_std_dev_select,
114
115 .bmdma_setup = ata_bmdma_setup,
116 .bmdma_start = ata_bmdma_start,
117 .bmdma_stop = ata_bmdma_stop,
118 .bmdma_status = ata_bmdma_status,
119
120 .qc_prep = ata_qc_prep,
121 .qc_issue = ata_qc_issue_prot,
122 .data_xfer = ata_data_xfer,
123
124 .freeze = svia_noop_freeze, 108 .freeze = svia_noop_freeze,
125 .thaw = ata_bmdma_thaw,
126 .error_handler = vt6420_error_handler, 109 .error_handler = vt6420_error_handler,
127 .post_internal_cmd = ata_bmdma_post_internal_cmd,
128
129 .irq_clear = ata_bmdma_irq_clear,
130 .irq_on = ata_irq_on,
131
132 .port_start = ata_sff_port_start,
133}; 110};
134 111
135static const struct ata_port_operations vt6421_pata_ops = { 112static struct ata_port_operations vt6421_pata_ops = {
113 .inherits = &ata_bmdma_port_ops,
114 .cable_detect = vt6421_pata_cable_detect,
136 .set_piomode = vt6421_set_pio_mode, 115 .set_piomode = vt6421_set_pio_mode,
137 .set_dmamode = vt6421_set_dma_mode, 116 .set_dmamode = vt6421_set_dma_mode,
138 .mode_filter = ata_pci_default_filter,
139
140 .tf_load = ata_tf_load,
141 .tf_read = ata_tf_read,
142 .check_status = ata_check_status,
143 .exec_command = ata_exec_command,
144 .dev_select = ata_std_dev_select,
145
146 .bmdma_setup = ata_bmdma_setup,
147 .bmdma_start = ata_bmdma_start,
148 .bmdma_stop = ata_bmdma_stop,
149 .bmdma_status = ata_bmdma_status,
150
151 .qc_prep = ata_qc_prep,
152 .qc_issue = ata_qc_issue_prot,
153 .data_xfer = ata_data_xfer,
154
155 .freeze = ata_bmdma_freeze,
156 .thaw = ata_bmdma_thaw,
157 .error_handler = ata_bmdma_error_handler,
158 .post_internal_cmd = ata_bmdma_post_internal_cmd,
159 .cable_detect = vt6421_pata_cable_detect,
160
161 .irq_clear = ata_bmdma_irq_clear,
162 .irq_on = ata_irq_on,
163
164 .port_start = ata_sff_port_start,
165}; 117};
166 118
167static const struct ata_port_operations vt6421_sata_ops = { 119static struct ata_port_operations vt6421_sata_ops = {
168 .mode_filter = ata_pci_default_filter, 120 .inherits = &ata_bmdma_port_ops,
169
170 .tf_load = ata_tf_load,
171 .tf_read = ata_tf_read,
172 .check_status = ata_check_status,
173 .exec_command = ata_exec_command,
174 .dev_select = ata_std_dev_select,
175
176 .bmdma_setup = ata_bmdma_setup,
177 .bmdma_start = ata_bmdma_start,
178 .bmdma_stop = ata_bmdma_stop,
179 .bmdma_status = ata_bmdma_status,
180
181 .qc_prep = ata_qc_prep,
182 .qc_issue = ata_qc_issue_prot,
183 .data_xfer = ata_data_xfer,
184
185 .freeze = ata_bmdma_freeze,
186 .thaw = ata_bmdma_thaw,
187 .error_handler = ata_bmdma_error_handler,
188 .post_internal_cmd = ata_bmdma_post_internal_cmd,
189
190 .irq_clear = ata_bmdma_irq_clear,
191 .irq_on = ata_irq_on,
192
193 .scr_read = svia_scr_read, 121 .scr_read = svia_scr_read,
194 .scr_write = svia_scr_write, 122 .scr_write = svia_scr_write,
195
196 .port_start = ata_sff_port_start,
197}; 123};
198 124
199static const struct ata_port_info vt6420_port_info = { 125static const struct ata_port_info vt6420_port_info = {