* [PATCH] [media] bt8xx: Use common error handling code in two functions
@ 2017-09-25 20:18 SF Markus Elfring
2017-09-27 9:58 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: SF Markus Elfring @ 2017-09-25 20:18 UTC (permalink / raw)
To: linux-media, Daniele Nicolodi, Mauro Carvalho Chehab, Max Kellermann
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 25 Sep 2017 22:10:17 +0200
Adjust jump targets so that a bit of exception handling can be better
reused at the end of these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/pci/bt8xx/dst.c | 19 +++++++++++--------
drivers/media/pci/bt8xx/dst_ca.c | 30 +++++++++++++++---------------
2 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/drivers/media/pci/bt8xx/dst.c b/drivers/media/pci/bt8xx/dst.c
index 7166d2279465..1290419aca0b 100644
--- a/drivers/media/pci/bt8xx/dst.c
+++ b/drivers/media/pci/bt8xx/dst.c
@@ -134,17 +134,20 @@ EXPORT_SYMBOL(rdc_reset_state);
static int rdc_8820_reset(struct dst_state *state)
{
dprintk(3, "Resetting DST\n");
- if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) {
- pr_err("dst_gpio_outb ERROR !\n");
- return -1;
- }
+ if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY)
+ < 0)
+ goto report_failure;
+
udelay(1000);
- if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) {
- pr_err("dst_gpio_outb ERROR !\n");
- return -1;
- }
+ if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET,
+ RDC_8820_RESET, DELAY) < 0)
+ goto report_failure;
return 0;
+
+report_failure:
+ pr_err("dst_gpio_outb ERROR !\n");
+ return -1;
}
static int dst_pio_enable(struct dst_state *state)
diff --git a/drivers/media/pci/bt8xx/dst_ca.c b/drivers/media/pci/bt8xx/dst_ca.c
index 90f4263452d3..5ea0a9c9a590 100644
--- a/drivers/media/pci/bt8xx/dst_ca.c
+++ b/drivers/media/pci/bt8xx/dst_ca.c
@@ -97,33 +97,33 @@ static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8
if (write_dst(state, data, len)) {
dprintk(verbose, DST_CA_INFO, 1, " Write not successful, trying to recover");
- dst_error_recovery(state);
- goto error;
+ goto error_recovery;
}
if ((dst_pio_disable(state)) < 0) {
dprintk(verbose, DST_CA_ERROR, 1, " DST PIO disable failed.");
- goto error;
- }
- if (read_dst(state, &reply, GET_ACK) < 0) {
- dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover");
- dst_error_recovery(state);
- goto error;
+ goto unlock;
}
+ if (read_dst(state, &reply, GET_ACK) < 0)
+ goto report_read_failure;
+
if (read) {
if (! dst_wait_dst_ready(state, LONG_DELAY)) {
dprintk(verbose, DST_CA_NOTICE, 1, " 8820 not ready");
- goto error;
- }
- if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */
- dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover");
- dst_error_recovery(state);
- goto error;
+ goto unlock;
}
+ /* Try to make this dynamic */
+ if (read_dst(state, ca_string, 128) < 0)
+ goto report_read_failure;
}
mutex_unlock(&state->dst_mutex);
return 0;
-error:
+report_read_failure:
+ dprintk(verbose, DST_CA_INFO, 1,
+ " Read not successful, trying to recover");
+error_recovery:
+ dst_error_recovery(state);
+unlock:
mutex_unlock(&state->dst_mutex);
return -EIO;
}
--
2.14.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [media] bt8xx: Use common error handling code in two functions
2017-09-25 20:18 [PATCH] [media] bt8xx: Use common error handling code in two functions SF Markus Elfring
@ 2017-09-27 9:58 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2017-09-27 9:58 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-media, Daniele Nicolodi, Mauro Carvalho Chehab,
Max Kellermann, LKML, kernel-janitors
On Mon, Sep 25, 2017 at 10:18:29PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 25 Sep 2017 22:10:17 +0200
>
> Adjust jump targets so that a bit of exception handling can be better
> reused at the end of these functions.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/media/pci/bt8xx/dst.c | 19 +++++++++++--------
> drivers/media/pci/bt8xx/dst_ca.c | 30 +++++++++++++++---------------
> 2 files changed, 26 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/media/pci/bt8xx/dst.c b/drivers/media/pci/bt8xx/dst.c
> index 7166d2279465..1290419aca0b 100644
> --- a/drivers/media/pci/bt8xx/dst.c
> +++ b/drivers/media/pci/bt8xx/dst.c
> @@ -134,17 +134,20 @@ EXPORT_SYMBOL(rdc_reset_state);
> static int rdc_8820_reset(struct dst_state *state)
> {
> dprintk(3, "Resetting DST\n");
> - if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) {
> - pr_err("dst_gpio_outb ERROR !\n");
> - return -1;
> - }
> + if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY)
> + < 0)
> + goto report_failure;
> +
> udelay(1000);
> - if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) {
> - pr_err("dst_gpio_outb ERROR !\n");
> - return -1;
> - }
> + if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET,
> + RDC_8820_RESET, DELAY) < 0)
> + goto report_failure;
>
> return 0;
> +
> +report_failure:
> + pr_err("dst_gpio_outb ERROR !\n");
> + return -1;
This code is ugly and this patch doesn't improve it; it just shuffles
it around.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-27 9:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25 20:18 [PATCH] [media] bt8xx: Use common error handling code in two functions SF Markus Elfring
2017-09-27 9:58 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®