radio: wl1273: add check on core->write() return value
PATCH 1/1 radio: wl1273: add check on core->write() return value
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 <[email protected]>
--- drivers/media/radio/radio-wl1273.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/media/radio/radio-wl1273.c +13 -2
@@ -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__); }
Signature · 1 line
2.5.0
Hi Gustavi,
Quoted 28 lines · Gustavo A. R. Silva
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 <[email protected]>--- drivers/media/radio/radio-wl1273.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)drivers/media/radio/radio-wl1273.c +7
-2@@ -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 {
drivers/media/radio/radio-wl1273.c static int wl1273_fm_start(struct wl1273_device *radio, int new_mode) · line 630
Quoted 10 lines
drivers/media/radio/radio-wl1273.c +6
-0r = 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
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -