net: rfkill: Do not ignore errors from regulator_enable() 59/158359/1
authorLuis Henriques <luis.henriques@canonical.com>
Wed, 14 Aug 2013 22:10:06 +0000 (23:10 +0100)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 31 Oct 2017 08:05:47 +0000 (17:05 +0900)
commit dee08ab83d0378d922b67e7cf10bbec3e4ea343b upstream.

Function regulator_enable() may return an error that has to be checked.
This patch changes function rfkill_regulator_set_block() so that it checks
for the return code.  Also, rfkill_data->reg_enabled is set to 'true' only
if there is no error.

This fixes the following compilation warning:

net/rfkill/rfkill-regulator.c:43:20: warning: ignoring return value of 'regulator_enable', declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
[sw0312.kim: cherry-pick from linux-3.10.y to remove build warning]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I5d8067d57941fc25945a04e10b093109d92080a0

net/rfkill/rfkill-regulator.c

index d11ac79..cf5b145 100644 (file)
@@ -30,6 +30,7 @@ struct rfkill_regulator_data {
 static int rfkill_regulator_set_block(void *data, bool blocked)
 {
        struct rfkill_regulator_data *rfkill_data = data;
+       int ret = 0;
 
        pr_debug("%s: blocked: %d\n", __func__, blocked);
 
@@ -40,15 +41,16 @@ static int rfkill_regulator_set_block(void *data, bool blocked)
                }
        } else {
                if (!rfkill_data->reg_enabled) {
-                       regulator_enable(rfkill_data->vcc);
-                       rfkill_data->reg_enabled = true;
+                       ret = regulator_enable(rfkill_data->vcc);
+                       if (!ret)
+                               rfkill_data->reg_enabled = true;
                }
        }
 
        pr_debug("%s: regulator_is_enabled after set_block: %d\n", __func__,
                regulator_is_enabled(rfkill_data->vcc));
 
-       return 0;
+       return ret;
 }
 
 static struct rfkill_ops rfkill_regulator_ops = {