Commit 0a1de842 authored by Mark A. Greer's avatar Mark A. Greer Committed by Samuel Ortiz

NFC: trf7970a: Return error code when turning on RF fails

trf7970a_switch_rf_on() is currently a void function
but turning on the RF could fail so it should return
a return code.  That return code should also be
propagated back to the entity that initiated the
action.
Signed-off-by: default avatarMark A. Greer <mgreer@animalcreek.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent afa5b5f1
...@@ -869,7 +869,7 @@ static void trf7970a_switch_rf_off(struct trf7970a *trf) ...@@ -869,7 +869,7 @@ static void trf7970a_switch_rf_off(struct trf7970a *trf)
pm_runtime_put_autosuspend(trf->dev); pm_runtime_put_autosuspend(trf->dev);
} }
static void trf7970a_switch_rf_on(struct trf7970a *trf) static int trf7970a_switch_rf_on(struct trf7970a *trf)
{ {
int ret; int ret;
...@@ -880,15 +880,18 @@ static void trf7970a_switch_rf_on(struct trf7970a *trf) ...@@ -880,15 +880,18 @@ static void trf7970a_switch_rf_on(struct trf7970a *trf)
ret = trf7970a_init(trf); ret = trf7970a_init(trf);
if (ret) { if (ret) {
dev_err(trf->dev, "%s - Can't initialize: %d\n", __func__, ret); dev_err(trf->dev, "%s - Can't initialize: %d\n", __func__, ret);
return; return ret;
} }
trf->state = TRF7970A_ST_IDLE; trf->state = TRF7970A_ST_IDLE;
return 0;
} }
static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on) static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
{ {
struct trf7970a *trf = nfc_digital_get_drvdata(ddev); struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
int ret = 0;
dev_dbg(trf->dev, "Switching RF - state: %d, on: %d\n", trf->state, on); dev_dbg(trf->dev, "Switching RF - state: %d, on: %d\n", trf->state, on);
...@@ -897,7 +900,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on) ...@@ -897,7 +900,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
if (on) { if (on) {
switch (trf->state) { switch (trf->state) {
case TRF7970A_ST_OFF: case TRF7970A_ST_OFF:
trf7970a_switch_rf_on(trf); ret = trf7970a_switch_rf_on(trf);
break; break;
case TRF7970A_ST_IDLE: case TRF7970A_ST_IDLE:
case TRF7970A_ST_IDLE_RX_BLOCKED: case TRF7970A_ST_IDLE_RX_BLOCKED:
...@@ -906,6 +909,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on) ...@@ -906,6 +909,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
dev_err(trf->dev, "%s - Invalid request: %d %d\n", dev_err(trf->dev, "%s - Invalid request: %d %d\n",
__func__, trf->state, on); __func__, trf->state, on);
trf7970a_switch_rf_off(trf); trf7970a_switch_rf_off(trf);
ret = -EINVAL;
} }
} else { } else {
switch (trf->state) { switch (trf->state) {
...@@ -914,6 +918,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on) ...@@ -914,6 +918,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
default: default:
dev_err(trf->dev, "%s - Invalid request: %d %d\n", dev_err(trf->dev, "%s - Invalid request: %d %d\n",
__func__, trf->state, on); __func__, trf->state, on);
ret = -EINVAL;
/* FALLTHROUGH */ /* FALLTHROUGH */
case TRF7970A_ST_IDLE: case TRF7970A_ST_IDLE:
case TRF7970A_ST_IDLE_RX_BLOCKED: case TRF7970A_ST_IDLE_RX_BLOCKED:
...@@ -922,7 +927,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on) ...@@ -922,7 +927,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
} }
mutex_unlock(&trf->lock); mutex_unlock(&trf->lock);
return 0; return ret;
} }
static int trf7970a_config_rf_tech(struct trf7970a *trf, int tech) static int trf7970a_config_rf_tech(struct trf7970a *trf, int tech)
...@@ -1040,8 +1045,11 @@ static int trf7970a_in_configure_hw(struct nfc_digital_dev *ddev, int type, ...@@ -1040,8 +1045,11 @@ static int trf7970a_in_configure_hw(struct nfc_digital_dev *ddev, int type,
mutex_lock(&trf->lock); mutex_lock(&trf->lock);
if (trf->state == TRF7970A_ST_OFF) if (trf->state == TRF7970A_ST_OFF) {
trf7970a_switch_rf_on(trf); ret = trf7970a_switch_rf_on(trf);
if (ret)
goto err_unlock;
}
switch (type) { switch (type) {
case NFC_DIGITAL_CONFIG_RF_TECH: case NFC_DIGITAL_CONFIG_RF_TECH:
...@@ -1055,6 +1063,7 @@ static int trf7970a_in_configure_hw(struct nfc_digital_dev *ddev, int type, ...@@ -1055,6 +1063,7 @@ static int trf7970a_in_configure_hw(struct nfc_digital_dev *ddev, int type,
ret = -EINVAL; ret = -EINVAL;
} }
err_unlock:
mutex_unlock(&trf->lock); mutex_unlock(&trf->lock);
return ret; return ret;
} }
......
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