* [PATCH] scsi: megaraid_sas: Use common error handling code in megasas_mgmt_ioctl_fw()
@ 2019-10-31 21:35 Markus Elfring
2019-11-05 9:28 ` Sumit Saxena
0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2019-10-31 21:35 UTC (permalink / raw)
To: linux-scsi, megaraidlinux.pdl, James E. J. Bottomley,
Kashyap Desai, Shivasharan S, Sumit Saxena, Martin K. Petersen
Cc: LKML, kernel-janitors, Chandrakanth Patil, YueHaibing
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 31 Oct 2019 22:23:02 +0100
Move the same error code assignments so that such 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/megaraid/megaraid_sas_base.c | 25 ++++++++++-------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index c40fbea06cc5..f2f2a240e5af 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -8272,27 +8272,20 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
return PTR_ERR(ioc);
instance = megasas_lookup_instance(ioc->host_no);
- if (!instance) {
- error = -ENODEV;
- goto out_kfree_ioc;
- }
+ if (!instance)
+ goto e_nodev;
/* Block ioctls in VF mode */
- if (instance->requestorId && !allow_vf_ioctls) {
- error = -ENODEV;
- goto out_kfree_ioc;
- }
+ if (instance->requestorId && !allow_vf_ioctls)
+ goto e_nodev;
if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
dev_err(&instance->pdev->dev, "Controller in crit error\n");
- error = -ENODEV;
- goto out_kfree_ioc;
+ goto e_nodev;
}
- if (instance->unload == 1) {
- error = -ENODEV;
- goto out_kfree_ioc;
- }
+ if (instance->unload == 1)
+ goto e_nodev;
if (down_interruptible(&instance->ioctl_sem)) {
error = -ERESTARTSYS;
@@ -8311,6 +8304,10 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
out_kfree_ioc:
kfree(ioc);
return error;
+
+e_nodev:
+ error = -ENODEV;
+ goto out_kfree_ioc;
}
static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: megaraid_sas: Use common error handling code in megasas_mgmt_ioctl_fw()
2019-10-31 21:35 [PATCH] scsi: megaraid_sas: Use common error handling code in megasas_mgmt_ioctl_fw() Markus Elfring
@ 2019-11-05 9:28 ` Sumit Saxena
2019-11-05 9:36 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Sumit Saxena @ 2019-11-05 9:28 UTC (permalink / raw)
To: Markus Elfring
Cc: Linux SCSI List, PDL,MEGARAIDLINUX, James E. J. Bottomley,
Kashyap Desai, Shivasharan S, Martin K. Petersen, LKML,
kernel-janitors, Chandrakanth Patil, YueHaibing
On Fri, Nov 1, 2019 at 3:06 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 31 Oct 2019 22:23:02 +0100
>
> Move the same error code assignments so that such 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>
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
> ---
> drivers/scsi/megaraid/megaraid_sas_base.c | 25 ++++++++++-------------
> 1 file changed, 11 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
> index c40fbea06cc5..f2f2a240e5af 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -8272,27 +8272,20 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
> return PTR_ERR(ioc);
>
> instance = megasas_lookup_instance(ioc->host_no);
> - if (!instance) {
> - error = -ENODEV;
> - goto out_kfree_ioc;
> - }
> + if (!instance)
> + goto e_nodev;
>
> /* Block ioctls in VF mode */
> - if (instance->requestorId && !allow_vf_ioctls) {
> - error = -ENODEV;
> - goto out_kfree_ioc;
> - }
> + if (instance->requestorId && !allow_vf_ioctls)
> + goto e_nodev;
>
> if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
> dev_err(&instance->pdev->dev, "Controller in crit error\n");
> - error = -ENODEV;
> - goto out_kfree_ioc;
> + goto e_nodev;
> }
>
> - if (instance->unload == 1) {
> - error = -ENODEV;
> - goto out_kfree_ioc;
> - }
> + if (instance->unload == 1)
> + goto e_nodev;
>
> if (down_interruptible(&instance->ioctl_sem)) {
> error = -ERESTARTSYS;
> @@ -8311,6 +8304,10 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
> out_kfree_ioc:
> kfree(ioc);
> return error;
> +
> +e_nodev:
> + error = -ENODEV;
> + goto out_kfree_ioc;
> }
>
> static int megasas_mgmt_ioctl_aen(struct file *file, unsigned long arg)
> --
> 2.23.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: megaraid_sas: Use common error handling code in megasas_mgmt_ioctl_fw()
2019-11-05 9:28 ` Sumit Saxena
@ 2019-11-05 9:36 ` Dan Carpenter
2019-11-05 10:20 ` Julian Calaby
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2019-11-05 9:36 UTC (permalink / raw)
To: Sumit Saxena
Cc: Markus Elfring, Linux SCSI List, PDL,MEGARAIDLINUX,
James E. J. Bottomley, Kashyap Desai, Shivasharan S,
Martin K. Petersen, LKML, kernel-janitors, Chandrakanth Patil,
YueHaibing
On Tue, Nov 05, 2019 at 02:58:35PM +0530, Sumit Saxena wrote:
> On Fri, Nov 1, 2019 at 3:06 AM Markus Elfring <Markus.Elfring@web.de> wrote:
> >
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Thu, 31 Oct 2019 22:23:02 +0100
> >
> > Move the same error code assignments so that such 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>
>
> Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
>
The code was a lot better originally... :(
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: megaraid_sas: Use common error handling code in megasas_mgmt_ioctl_fw()
2019-11-05 9:36 ` Dan Carpenter
@ 2019-11-05 10:20 ` Julian Calaby
0 siblings, 0 replies; 4+ messages in thread
From: Julian Calaby @ 2019-11-05 10:20 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sumit Saxena, Markus Elfring, Linux SCSI List, PDL,MEGARAIDLINUX,
James E. J. Bottomley, Kashyap Desai, Shivasharan S,
Martin K. Petersen, LKML, kernel-janitors, Chandrakanth Patil,
YueHaibing
Hi,
On Tue, Nov 5, 2019 at 8:41 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Tue, Nov 05, 2019 at 02:58:35PM +0530, Sumit Saxena wrote:
> > On Fri, Nov 1, 2019 at 3:06 AM Markus Elfring <Markus.Elfring@web.de> wrote:
> > >
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Thu, 31 Oct 2019 22:23:02 +0100
> > >
> > > Move the same error code assignments so that such 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>
> >
> > Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
> >
>
> The code was a lot better originally... :(
Agreed, this is a lot of stuffing around to save 3 lines.
Thanks,
--
Julian Calaby
Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-05 10:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-31 21:35 [PATCH] scsi: megaraid_sas: Use common error handling code in megasas_mgmt_ioctl_fw() Markus Elfring
2019-11-05 9:28 ` Sumit Saxena
2019-11-05 9:36 ` Dan Carpenter
2019-11-05 10:20 ` Julian Calaby
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).