* [PATCH] staging: unisys: visorchipset: Use common error handling code in setup_crash_devices_work_qu
@ 2017-11-03 19:50 SF Markus Elfring
2017-11-04 1:26 ` [PATCH] staging: unisys: visorchipset: Use common error handling code in setup_crash_devices_wor Kershner, David A
0 siblings, 1 reply; 2+ messages in thread
From: SF Markus Elfring @ 2017-11-03 19:50 UTC (permalink / raw)
To: devel, sparmaintainer, Bryan Thompson, David Binder,
David Kershner, Greg Kroah-Hartman, Sameer Wadgaonkar, Tim Sell
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 3 Nov 2017 20:37:03 +0100
* Add a jump target so that a specific error message is stored only once
at the end of this function implementation.
* Replace four calls of the function "dev_err" by goto statements.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/unisys/visorbus/visorchipset.c | 36 ++++++++++++--------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c
index fed554a43151..1d54821dd7b6 100644
--- a/drivers/staging/unisys/visorbus/visorchipset.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -1231,11 +1231,9 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
if (visorchannel_read(chipset_dev->controlvm_channel,
offsetof(struct visor_controlvm_channel,
saved_crash_message_count),
- &local_crash_msg_count, sizeof(u16)) < 0) {
- dev_err(&chipset_dev->acpi_device->dev,
- "failed to read channel\n");
- return;
- }
+ &local_crash_msg_count, sizeof(u16)) < 0)
+ goto report_read_failure;
+
if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
dev_err(&chipset_dev->acpi_device->dev, "invalid count\n");
return;
@@ -1244,30 +1242,24 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
if (visorchannel_read(chipset_dev->controlvm_channel,
offsetof(struct visor_controlvm_channel,
saved_crash_message_offset),
- &local_crash_msg_offset, sizeof(u32)) < 0) {
- dev_err(&chipset_dev->acpi_device->dev,
- "failed to read channel\n");
- return;
- }
+ &local_crash_msg_offset, sizeof(u32)) < 0)
+ goto report_read_failure;
+
/* read create device message for storage bus offset */
if (visorchannel_read(chipset_dev->controlvm_channel,
local_crash_msg_offset,
&local_crash_bus_msg,
- sizeof(struct controlvm_message)) < 0) {
- dev_err(&chipset_dev->acpi_device->dev,
- "failed to read channel\n");
- return;
- }
+ sizeof(struct controlvm_message)) < 0)
+ goto report_read_failure;
+
/* read create device message for storage device */
if (visorchannel_read(chipset_dev->controlvm_channel,
local_crash_msg_offset +
sizeof(struct controlvm_message),
&local_crash_dev_msg,
- sizeof(struct controlvm_message)) < 0) {
- dev_err(&chipset_dev->acpi_device->dev,
- "failed to read channel\n");
- return;
- }
+ sizeof(struct controlvm_message)) < 0)
+ goto report_read_failure;
+
/* reuse IOVM create bus message */
if (!local_crash_bus_msg.cmd.create_bus.channel_addr) {
dev_err(&chipset_dev->acpi_device->dev,
@@ -1282,6 +1274,10 @@ static void setup_crash_devices_work_queue(struct work_struct *work)
return;
}
visorbus_device_create(&local_crash_dev_msg);
+ return;
+
+report_read_failure:
+ dev_err(&chipset_dev->acpi_device->dev, "failed to read channel\n");
}
void visorbus_response(struct visor_device *bus_info, int response,
--
2.15.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH] staging: unisys: visorchipset: Use common error handling code in setup_crash_devices_wor
2017-11-03 19:50 [PATCH] staging: unisys: visorchipset: Use common error handling code in setup_crash_devices_work_qu SF Markus Elfring
@ 2017-11-04 1:26 ` Kershner, David A
0 siblings, 0 replies; 2+ messages in thread
From: Kershner, David A @ 2017-11-04 1:26 UTC (permalink / raw)
To: SF Markus Elfring, devel, *S-Par-Maintainer, Thompson, Bryan E.,
Binder, David Anthony, Greg Kroah-Hartman, Sameer Wadgaonkar,
Sell, Timothy C
Cc: LKML, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 4166 bytes --]
> -----Original Message-----
> From: SF Markus Elfring [mailto:elfring@users.sourceforge.net]
> Sent: Friday, November 3, 2017 3:50 PM
> To: devel@driverdev.osuosl.org; *S-Par-Maintainer
> <SParMaintainer@unisys.com>; Thompson, Bryan E.
> <bryan.thompson@unisys.com>; Binder, David Anthony
> <David.Binder@unisys.com>; Kershner, David A
> <David.Kershner@unisys.com>; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>; Sameer Wadgaonkar
> <sameer.wadgaonkar@unisys.com>; Sell, Timothy C
> <Timothy.Sell@unisys.com>
> Cc: LKML <linux-kernel@vger.kernel.org>; kernel-janitors@vger.kernel.org
> Subject: [PATCH] staging: unisys: visorchipset: Use common error handling
> code in setup_crash_devices_work_queue()
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 3 Nov 2017 20:37:03 +0100
>
> * Add a jump target so that a specific error message is stored only once
> at the end of this function implementation.
>
> * Replace four calls of the function "dev_err" by goto statements.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Thanks for the catch!
Acked-by: David Kershner <david.kershner@unisys.com>
> ---
> drivers/staging/unisys/visorbus/visorchipset.c | 36
> ++++++++++++------------
> --
> 1 file changed, 16 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/staging/unisys/visorbus/visorchipset.c
> b/drivers/staging/unisys/visorbus/visorchipset.c
> index fed554a43151..1d54821dd7b6 100644
> --- a/drivers/staging/unisys/visorbus/visorchipset.c
> +++ b/drivers/staging/unisys/visorbus/visorchipset.c
> @@ -1231,11 +1231,9 @@ static void
> setup_crash_devices_work_queue(struct work_struct *work)
> if (visorchannel_read(chipset_dev->controlvm_channel,
> offsetof(struct visor_controlvm_channel,
> saved_crash_message_count),
> - &local_crash_msg_count, sizeof(u16)) < 0) {
> - dev_err(&chipset_dev->acpi_device->dev,
> - "failed to read channel\n");
> - return;
> - }
> + &local_crash_msg_count, sizeof(u16)) < 0)
> + goto report_read_failure;
> +
> if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
> dev_err(&chipset_dev->acpi_device->dev, "invalid
> count\n");
> return;
> @@ -1244,30 +1242,24 @@ static void
> setup_crash_devices_work_queue(struct work_struct *work)
> if (visorchannel_read(chipset_dev->controlvm_channel,
> offsetof(struct visor_controlvm_channel,
> saved_crash_message_offset),
> - &local_crash_msg_offset, sizeof(u32)) < 0) {
> - dev_err(&chipset_dev->acpi_device->dev,
> - "failed to read channel\n");
> - return;
> - }
> + &local_crash_msg_offset, sizeof(u32)) < 0)
> + goto report_read_failure;
> +
> /* read create device message for storage bus offset */
> if (visorchannel_read(chipset_dev->controlvm_channel,
> local_crash_msg_offset,
> &local_crash_bus_msg,
> - sizeof(struct controlvm_message)) < 0) {
> - dev_err(&chipset_dev->acpi_device->dev,
> - "failed to read channel\n");
> - return;
> - }
> + sizeof(struct controlvm_message)) < 0)
> + goto report_read_failure;
> +
> /* read create device message for storage device */
> if (visorchannel_read(chipset_dev->controlvm_channel,
> local_crash_msg_offset +
> sizeof(struct controlvm_message),
> &local_crash_dev_msg,
> - sizeof(struct controlvm_message)) < 0) {
> - dev_err(&chipset_dev->acpi_device->dev,
> - "failed to read channel\n");
> - return;
> - }
> + sizeof(struct controlvm_message)) < 0)
> + goto report_read_failure;
> +
> /* reuse IOVM create bus message */
> if (!local_crash_bus_msg.cmd.create_bus.channel_addr) {
> dev_err(&chipset_dev->acpi_device->dev,
> @@ -1282,6 +1274,10 @@ static void
> setup_crash_devices_work_queue(struct work_struct *work)
> return;
> }
> visorbus_device_create(&local_crash_dev_msg);
> + return;
> +
> +report_read_failure:
> + dev_err(&chipset_dev->acpi_device->dev, "failed to read
> channel\n");
> }
>
> void visorbus_response(struct visor_device *bus_info, int response,
> --
> 2.15.0
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 7862 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-04 1:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-03 19:50 [PATCH] staging: unisys: visorchipset: Use common error handling code in setup_crash_devices_work_qu SF Markus Elfring
2017-11-04 1:26 ` [PATCH] staging: unisys: visorchipset: Use common error handling code in setup_crash_devices_wor Kershner, David A
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).