Commit 9771330f authored by Luis Henriques's avatar Luis Henriques Committed by Willy Tarreau

net: rfkill: Do not ignore errors from regulator_enable()

commit dee08ab8 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: default avatarLuis Henriques <luis.henriques@canonical.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent c5a8b006
...@@ -30,6 +30,7 @@ struct rfkill_regulator_data { ...@@ -30,6 +30,7 @@ struct rfkill_regulator_data {
static int rfkill_regulator_set_block(void *data, bool blocked) static int rfkill_regulator_set_block(void *data, bool blocked)
{ {
struct rfkill_regulator_data *rfkill_data = data; struct rfkill_regulator_data *rfkill_data = data;
int ret = 0;
pr_debug("%s: blocked: %d\n", __func__, blocked); pr_debug("%s: blocked: %d\n", __func__, blocked);
...@@ -40,15 +41,16 @@ static int rfkill_regulator_set_block(void *data, bool blocked) ...@@ -40,15 +41,16 @@ static int rfkill_regulator_set_block(void *data, bool blocked)
} }
} else { } else {
if (!rfkill_data->reg_enabled) { if (!rfkill_data->reg_enabled) {
regulator_enable(rfkill_data->vcc); ret = regulator_enable(rfkill_data->vcc);
rfkill_data->reg_enabled = true; if (!ret)
rfkill_data->reg_enabled = true;
} }
} }
pr_debug("%s: regulator_is_enabled after set_block: %d\n", __func__, pr_debug("%s: regulator_is_enabled after set_block: %d\n", __func__,
regulator_is_enabled(rfkill_data->vcc)); regulator_is_enabled(rfkill_data->vcc));
return 0; return ret;
} }
static struct rfkill_ops rfkill_regulator_ops = { static struct rfkill_ops rfkill_regulator_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment