diff options
author | Tejun Heo <htejun@gmail.com> | 2008-03-24 23:22:50 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-04-17 15:44:18 -0400 |
commit | a1efdaba2dbd6fb89e23a87b66d3f4dd92c9f5af (patch) | |
tree | 6197c537892e0d887b2a90e369b74abf0500b9ac /drivers/ata/libata-pmp.c | |
parent | 959471936241bd83da7d0a76411cef6772140fe6 (diff) |
libata: make reset related methods proper port operations
Currently reset methods are not specified directly in the
ata_port_operations table. If a LLD wants to use custom reset
methods, it should construct and use a error_handler which uses those
reset methods. It's done this way for two reasons.
First, the ops table already contained too many methods and adding
four more of them would noticeably increase the amount of necessary
boilerplate code all over low level drivers.
Second, as ->error_handler uses those reset methods, it can get
confusing. ie. By overriding ->error_handler, those reset ops can be
made useless making layering a bit hazy.
Now that ops table uses inheritance, the first problem doesn't exist
anymore. The second isn't completely solved but is relieved by
providing default values - most drivers can just override what it has
implemented and don't have to concern itself about higher level
callbacks. In fact, there currently is no driver which actually
modifies error handling behavior. Drivers which override
->error_handler just wraps the standard error handler only to prepare
the controller for EH. I don't think making ops layering strict has
any noticeable benefit.
This patch makes ->prereset, ->softreset, ->hardreset, ->postreset and
their PMP counterparts propoer ops. Default ops are provided in the
base ops tables and drivers are converted to override individual reset
methods instead of creating custom error_handler.
* ata_std_error_handler() doesn't use sata_std_hardreset() if SCRs
aren't accessible. sata_promise doesn't need to use separate
error_handlers for PATA and SATA anymore.
* softreset is broken for sata_inic162x and sata_sx4. As libata now
always prefers hardreset, this doesn't really matter but the ops are
forced to NULL using ATA_OP_NULL for documentation purpose.
* pata_hpt374 needs to use different prereset for the first and second
PCI functions. This used to be done by branching from
hpt374_error_handler(). The proper way to do this is to use
separate ops and port_info tables for each function. Converted.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Diffstat (limited to 'drivers/ata/libata-pmp.c')
-rw-r--r-- | drivers/ata/libata-pmp.c | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c index 39e036c8a2bc..a7cb1498c9b2 100644 --- a/drivers/ata/libata-pmp.c +++ b/drivers/ata/libata-pmp.c | |||
@@ -962,14 +962,6 @@ static int sata_pmp_handle_link_fail(struct ata_link *link, int *link_tries) | |||
962 | /** | 962 | /** |
963 | * sata_pmp_eh_recover - recover PMP-enabled port | 963 | * sata_pmp_eh_recover - recover PMP-enabled port |
964 | * @ap: ATA port to recover | 964 | * @ap: ATA port to recover |
965 | * @prereset: prereset method (can be NULL) | ||
966 | * @softreset: softreset method | ||
967 | * @hardreset: hardreset method | ||
968 | * @postreset: postreset method (can be NULL) | ||
969 | * @pmp_prereset: PMP prereset method (can be NULL) | ||
970 | * @pmp_softreset: PMP softreset method (can be NULL) | ||
971 | * @pmp_hardreset: PMP hardreset method (can be NULL) | ||
972 | * @pmp_postreset: PMP postreset method (can be NULL) | ||
973 | * | 965 | * |
974 | * Drive EH recovery operation for PMP enabled port @ap. This | 966 | * Drive EH recovery operation for PMP enabled port @ap. This |
975 | * function recovers host and PMP ports with proper retrials and | 967 | * function recovers host and PMP ports with proper retrials and |
@@ -982,12 +974,9 @@ static int sata_pmp_handle_link_fail(struct ata_link *link, int *link_tries) | |||
982 | * RETURNS: | 974 | * RETURNS: |
983 | * 0 on success, -errno on failure. | 975 | * 0 on success, -errno on failure. |
984 | */ | 976 | */ |
985 | static int sata_pmp_eh_recover(struct ata_port *ap, | 977 | static int sata_pmp_eh_recover(struct ata_port *ap) |
986 | ata_prereset_fn_t prereset, ata_reset_fn_t softreset, | ||
987 | ata_reset_fn_t hardreset, ata_postreset_fn_t postreset, | ||
988 | ata_prereset_fn_t pmp_prereset, ata_reset_fn_t pmp_softreset, | ||
989 | ata_reset_fn_t pmp_hardreset, ata_postreset_fn_t pmp_postreset) | ||
990 | { | 978 | { |
979 | struct ata_port_operations *ops = ap->ops; | ||
991 | int pmp_tries, link_tries[SATA_PMP_MAX_PORTS]; | 980 | int pmp_tries, link_tries[SATA_PMP_MAX_PORTS]; |
992 | struct ata_link *pmp_link = &ap->link; | 981 | struct ata_link *pmp_link = &ap->link; |
993 | struct ata_device *pmp_dev = pmp_link->device; | 982 | struct ata_device *pmp_dev = pmp_link->device; |
@@ -1005,8 +994,8 @@ static int sata_pmp_eh_recover(struct ata_port *ap, | |||
1005 | retry: | 994 | retry: |
1006 | /* PMP attached? */ | 995 | /* PMP attached? */ |
1007 | if (!ap->nr_pmp_links) { | 996 | if (!ap->nr_pmp_links) { |
1008 | rc = ata_eh_recover(ap, prereset, softreset, hardreset, | 997 | rc = ata_eh_recover(ap, ops->prereset, ops->softreset, |
1009 | postreset, NULL); | 998 | ops->hardreset, ops->postreset, NULL); |
1010 | if (rc) { | 999 | if (rc) { |
1011 | ata_link_for_each_dev(dev, &ap->link) | 1000 | ata_link_for_each_dev(dev, &ap->link) |
1012 | ata_dev_disable(dev); | 1001 | ata_dev_disable(dev); |
@@ -1024,8 +1013,8 @@ static int sata_pmp_eh_recover(struct ata_port *ap, | |||
1024 | } | 1013 | } |
1025 | 1014 | ||
1026 | /* recover pmp */ | 1015 | /* recover pmp */ |
1027 | rc = sata_pmp_eh_recover_pmp(ap, prereset, softreset, hardreset, | 1016 | rc = sata_pmp_eh_recover_pmp(ap, ops->prereset, ops->softreset, |
1028 | postreset); | 1017 | ops->hardreset, ops->postreset); |
1029 | if (rc) | 1018 | if (rc) |
1030 | goto pmp_fail; | 1019 | goto pmp_fail; |
1031 | 1020 | ||
@@ -1035,8 +1024,8 @@ static int sata_pmp_eh_recover(struct ata_port *ap, | |||
1035 | goto pmp_fail; | 1024 | goto pmp_fail; |
1036 | 1025 | ||
1037 | /* recover links */ | 1026 | /* recover links */ |
1038 | rc = ata_eh_recover(ap, pmp_prereset, pmp_softreset, pmp_hardreset, | 1027 | rc = ata_eh_recover(ap, ops->pmp_prereset, ops->pmp_softreset, |
1039 | pmp_postreset, &link); | 1028 | ops->pmp_hardreset, ops->pmp_postreset, &link); |
1040 | if (rc) | 1029 | if (rc) |
1041 | goto link_fail; | 1030 | goto link_fail; |
1042 | 1031 | ||
@@ -1132,16 +1121,8 @@ static int sata_pmp_eh_recover(struct ata_port *ap, | |||
1132 | } | 1121 | } |
1133 | 1122 | ||
1134 | /** | 1123 | /** |
1135 | * sata_pmp_do_eh - do standard error handling for PMP-enabled host | 1124 | * sata_pmp_error_handler - do standard error handling for PMP-enabled host |
1136 | * @ap: host port to handle error for | 1125 | * @ap: host port to handle error for |
1137 | * @prereset: prereset method (can be NULL) | ||
1138 | * @softreset: softreset method | ||
1139 | * @hardreset: hardreset method | ||
1140 | * @postreset: postreset method (can be NULL) | ||
1141 | * @pmp_prereset: PMP prereset method (can be NULL) | ||
1142 | * @pmp_softreset: PMP softreset method (can be NULL) | ||
1143 | * @pmp_hardreset: PMP hardreset method (can be NULL) | ||
1144 | * @pmp_postreset: PMP postreset method (can be NULL) | ||
1145 | * | 1126 | * |
1146 | * Perform standard error handling sequence for PMP-enabled host | 1127 | * Perform standard error handling sequence for PMP-enabled host |
1147 | * @ap. | 1128 | * @ap. |
@@ -1149,16 +1130,10 @@ static int sata_pmp_eh_recover(struct ata_port *ap, | |||
1149 | * LOCKING: | 1130 | * LOCKING: |
1150 | * Kernel thread context (may sleep). | 1131 | * Kernel thread context (may sleep). |
1151 | */ | 1132 | */ |
1152 | void sata_pmp_do_eh(struct ata_port *ap, | 1133 | void sata_pmp_error_handler(struct ata_port *ap) |
1153 | ata_prereset_fn_t prereset, ata_reset_fn_t softreset, | ||
1154 | ata_reset_fn_t hardreset, ata_postreset_fn_t postreset, | ||
1155 | ata_prereset_fn_t pmp_prereset, ata_reset_fn_t pmp_softreset, | ||
1156 | ata_reset_fn_t pmp_hardreset, ata_postreset_fn_t pmp_postreset) | ||
1157 | { | 1134 | { |
1158 | ata_eh_autopsy(ap); | 1135 | ata_eh_autopsy(ap); |
1159 | ata_eh_report(ap); | 1136 | ata_eh_report(ap); |
1160 | sata_pmp_eh_recover(ap, prereset, softreset, hardreset, postreset, | 1137 | sata_pmp_eh_recover(ap); |
1161 | pmp_prereset, pmp_softreset, pmp_hardreset, | ||
1162 | pmp_postreset); | ||
1163 | ata_eh_finish(ap); | 1138 | ata_eh_finish(ap); |
1164 | } | 1139 | } |