summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-12-04 09:44:27 -0800
committerAlexander Amelkin <mocbuhtig@amelkin.msk.ru>2019-02-13 21:28:14 +0300
commit6dcb168442a8a1749fc44433db451b7c755abd39 (patch)
tree9c2785bcc1c307c901b43782c35d38d767c715c6
parent1c4a00d26b4f5485b8055c7ce6cc14ea4c1e7605 (diff)
downloadipmitool-6dcb168442a8a1749fc44433db451b7c755abd39.tar.gz
fru: add fru_cc_rq2big helper method for code checks
Add fru_cc_rq2big helper method to reduce duplicate code checking for specific size-based IPMI response codes. Signed-off-by: Patrick Venture <venture@google.com>
-rw-r--r--lib/ipmi_fru.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c
index bc26191..918ddda 100644
--- a/lib/ipmi_fru.c
+++ b/lib/ipmi_fru.c
@@ -101,6 +101,12 @@ static const char * chassis_type_desc[] = {
"Blade Enclosure"
};
+static inline bool fru_cc_rq2big(int code) {
+ return (code == IPMI_CC_REQ_DATA_INV_LENGTH
+ || code == IPMI_CC_REQ_DATA_FIELD_EXCEED
+ || code == IPMI_CC_CANT_RET_NUM_REQ_BYTES);
+}
+
/* From lib/dimm_spd.c: */
int
ipmi_spd_print_fru(struct ipmi_intf * intf, uint8_t id);
@@ -598,16 +604,14 @@ write_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
break;
}
- if (rsp->ccode == IPMI_CC_REQ_DATA_INV_LENGTH
- || rsp->ccode == IPMI_CC_REQ_DATA_FIELD_EXCEED
- || rsp->ccode == IPMI_CC_CANT_RET_NUM_REQ_BYTES) {
+ if (fru_cc_rq2big(rsp->ccode)) {
if (fru->max_write_size > 8) {
fru->max_write_size -= 8;
lprintf(LOG_INFO, "Retrying FRU write with request size %d",
fru->max_write_size);
continue;
}
- } else if(rsp->ccode == 0x80) {
+ } else if (rsp->ccode == 0x80) {
rsp->ccode = 0;
// Write protected section
protected_bloc = 1;
@@ -732,9 +736,7 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
if (rsp->ccode) {
/* if we get C7h or C8h or CAh return code then we requested too
* many bytes at once so try again with smaller size */
- if ((rsp->ccode == IPMI_CC_REQ_DATA_INV_LENGTH
- || rsp->ccode == IPMI_CC_REQ_DATA_FIELD_EXCEED
- || rsp->ccode == IPMI_CC_CANT_RET_NUM_REQ_BYTES)
+ if (fru_cc_rq2big(rsp->ccode)
&& fru->max_read_size > 8) {
if (fru->max_read_size > 32) {
/* subtract read length more aggressively */
@@ -840,10 +842,7 @@ read_fru_area_section(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id,
if (rsp->ccode) {
/* if we get C7 or C8 or CA return code then we requested too
* many bytes at once so try again with smaller size */
- if ((rsp->ccode == IPMI_CC_REQ_DATA_INV_LENGTH
- || rsp->ccode == IPMI_CC_REQ_DATA_FIELD_EXCEED
- || rsp->ccode == IPMI_CC_CANT_RET_NUM_REQ_BYTES)
- && (--fru_data_rqst_size > 8)) {
+ if (fru_cc_rq2big(rsp->ccode) && (--fru_data_rqst_size > 8)) {
lprintf(LOG_INFO,
"Retrying FRU read with request size %d",
fru_data_rqst_size);