Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1672292 > unrolled thread

[PATCH] radio: wl1273: add check on core->write() return value

Started by"Gustavo A. R. Silva" <garsilva@embeddedor.com>
First post2017-06-22 06:10 +0200
Last post2017-06-22 07:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] radio: wl1273: add check on core->write() return value "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-06-22 06:10 +0200
    Re: [PATCH] radio: wl1273: add check on core->write() return value Baruch Siach <baruch@tkos.co.il> - 2017-06-22 07:00 +0200

#1672292 — [PATCH] radio: wl1273: add check on core->write() return value

From"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Date2017-06-22 06:10 +0200
Subject[PATCH] radio: wl1273: add check on core->write() return value
Message-ID<tV1Bo-7PL-9@gated-at.bofh.it>
Check return value from call to core->write(), so in case of
error print error message, jump to goto label fail and eventually
return.

Addresses-Coverity-ID: 1226943
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/media/radio/radio-wl1273.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
index 7240223..17e82a9 100644
--- a/drivers/media/radio/radio-wl1273.c
+++ b/drivers/media/radio/radio-wl1273.c
@@ -610,10 +610,21 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode)
 			}
 		}
 
-		if (radio->rds_on)
+		if (radio->rds_on) {
 			r = core->write(core, WL1273_RDS_DATA_ENB, 1);
-		else
+			if (r) {
+				dev_err(dev, "%s: RDS_DATA_ENB ON fails\n",
+					__func__);
+				goto fail;
+			}
+		} else {
 			r = core->write(core, WL1273_RDS_DATA_ENB, 0);
+			if (r) {
+				dev_err(dev, "%s: RDS_DATA_ENB OFF fails\n",
+					__func__);
+				goto fail;
+			}
+		}
 	} else {
 		dev_warn(dev, "%s: Illegal mode.\n", __func__);
 	}
-- 
2.5.0

[toc] | [next] | [standalone]


#1672307

FromBaruch Siach <baruch@tkos.co.il>
Date2017-06-22 07:00 +0200
Message-ID<tV2nL-8cT-3@gated-at.bofh.it>
In reply to#1672292
Hi Gustavi,

On Wed, Jun 21, 2017 at 11:01:22PM -0500, Gustavo A. R. Silva wrote:
> Check return value from call to core->write(), so in case of
> error print error message, jump to goto label fail and eventually
> return.
> 
> Addresses-Coverity-ID: 1226943
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
>  drivers/media/radio/radio-wl1273.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
> index 7240223..17e82a9 100644
> --- a/drivers/media/radio/radio-wl1273.c
> +++ b/drivers/media/radio/radio-wl1273.c
> @@ -610,10 +610,21 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode)
>  			}
>  		}
>  
> -		if (radio->rds_on)
> +		if (radio->rds_on) {
>  			r = core->write(core, WL1273_RDS_DATA_ENB, 1);
> -		else
> +			if (r) {
> +				dev_err(dev, "%s: RDS_DATA_ENB ON fails\n",
> +					__func__);
> +				goto fail;
> +			}
> +		} else {
>  			r = core->write(core, WL1273_RDS_DATA_ENB, 0);
> +			if (r) {
> +				dev_err(dev, "%s: RDS_DATA_ENB OFF fails\n",
> +					__func__);
> +				goto fail;
> +			}
> +		}
>  	} else {
>  		dev_warn(dev, "%s: Illegal mode.\n", __func__);
>  	}

An alternative that duplicates less code (untested):

	r = core->write(core, WL1273_RDS_DATA_ENB, !!radio->rds_on);
	if (r) {
		dev_err(dev, "%s: RDS_DATA_ENB %s fails\n",
		     	__func__, radio->rds_on ? "ON" : "OFF");
		goto fail;
	}

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web