From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-scsi@vger.kernel.org, aacraid@adaptec.com,
"James E. J. Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] SCSI-dpt_i2o: Use common error handling code in adpt_hba_reset()
Date: Thu, 2 Nov 2017 18:04:04 +0100 [thread overview]
Message-ID: <373ac00e-099e-2ced-37aa-194541eef3d8@users.sourceforge.net> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 2 Nov 2017 17:45:14 +0100
* Adjust five function calls together with a variable assignment.
* Add a jump target so that a bit of exception handling can be better
reused at the end of this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/scsi/dpt_i2o.c | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index fd172b0890d3..cbe1a36fb531 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -832,37 +832,40 @@ static int adpt_hba_reset(adpt_hba* pHba)
pHba->state |= DPTI_STATE_RESET;
// Activate does get status , init outbound, and get hrt
- if ((rcode=adpt_i2o_activate_hba(pHba)) < 0) {
+ rcode = adpt_i2o_activate_hba(pHba);
+ if (rcode < 0) {
printk(KERN_ERR "%s: Could not activate\n", pHba->name);
- adpt_i2o_delete_hba(pHba);
- return rcode;
+ goto delete_hba;
}
- if ((rcode=adpt_i2o_build_sys_table()) < 0) {
- adpt_i2o_delete_hba(pHba);
- return rcode;
- }
+ rcode = adpt_i2o_build_sys_table();
+ if (rcode < 0)
+ goto delete_hba;
+
PDEBUG("%s: in HOLD state\n",pHba->name);
- if ((rcode=adpt_i2o_online_hba(pHba)) < 0) {
- adpt_i2o_delete_hba(pHba);
- return rcode;
- }
+ rcode = adpt_i2o_online_hba(pHba);
+ if (rcode < 0)
+ goto delete_hba;
+
PDEBUG("%s: in OPERATIONAL state\n",pHba->name);
- if ((rcode=adpt_i2o_lct_get(pHba)) < 0){
- adpt_i2o_delete_hba(pHba);
- return rcode;
- }
+ rcode = adpt_i2o_lct_get(pHba);
+ if (rcode < 0)
+ goto delete_hba;
+
+ rcode = adpt_i2o_reparse_lct(pHba);
+ if (rcode < 0)
+ goto delete_hba;
- if ((rcode=adpt_i2o_reparse_lct(pHba)) < 0){
- adpt_i2o_delete_hba(pHba);
- return rcode;
- }
pHba->state &= ~DPTI_STATE_RESET;
adpt_fail_posted_scbs(pHba);
return 0; /* return success */
+
+delete_hba:
+ adpt_i2o_delete_hba(pHba);
+ return rcode;
}
/*===========================================================================
--
2.15.0
reply other threads:[~2017-11-02 17:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=373ac00e-099e-2ced-37aa-194541eef3d8@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=aacraid@adaptec.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).