aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc/trf7970a.c
diff options
context:
space:
mode:
authorMark A. Greer <mgreer@animalcreek.com>2014-09-02 18:12:33 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2014-09-07 17:13:44 -0400
commit0a1de84205d3fe7baa3d013ebf703416b1919ecc (patch)
treef2312b0147d6be8c0d988f589efa9afb8e0365a8 /drivers/nfc/trf7970a.c
parentafa5b5f13e0e2372e440f3ab44620d4e10fca496 (diff)
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: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc/trf7970a.c')
-rw-r--r--drivers/nfc/trf7970a.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index 2b1573fb6e9f..8c2fb62982c4 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -869,7 +869,7 @@ static void trf7970a_switch_rf_off(struct trf7970a *trf)
869 pm_runtime_put_autosuspend(trf->dev); 869 pm_runtime_put_autosuspend(trf->dev);
870} 870}
871 871
872static void trf7970a_switch_rf_on(struct trf7970a *trf) 872static int trf7970a_switch_rf_on(struct trf7970a *trf)
873{ 873{
874 int ret; 874 int ret;
875 875
@@ -880,15 +880,18 @@ static void trf7970a_switch_rf_on(struct trf7970a *trf)
880 ret = trf7970a_init(trf); 880 ret = trf7970a_init(trf);
881 if (ret) { 881 if (ret) {
882 dev_err(trf->dev, "%s - Can't initialize: %d\n", __func__, ret); 882 dev_err(trf->dev, "%s - Can't initialize: %d\n", __func__, ret);
883 return; 883 return ret;
884 } 884 }
885 885
886 trf->state = TRF7970A_ST_IDLE; 886 trf->state = TRF7970A_ST_IDLE;
887
888 return 0;
887} 889}
888 890
889static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on) 891static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
890{ 892{
891 struct trf7970a *trf = nfc_digital_get_drvdata(ddev); 893 struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
894 int ret = 0;
892 895
893 dev_dbg(trf->dev, "Switching RF - state: %d, on: %d\n", trf->state, on); 896 dev_dbg(trf->dev, "Switching RF - state: %d, on: %d\n", trf->state, on);
894 897
@@ -897,7 +900,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
897 if (on) { 900 if (on) {
898 switch (trf->state) { 901 switch (trf->state) {
899 case TRF7970A_ST_OFF: 902 case TRF7970A_ST_OFF:
900 trf7970a_switch_rf_on(trf); 903 ret = trf7970a_switch_rf_on(trf);
901 break; 904 break;
902 case TRF7970A_ST_IDLE: 905 case TRF7970A_ST_IDLE:
903 case TRF7970A_ST_IDLE_RX_BLOCKED: 906 case TRF7970A_ST_IDLE_RX_BLOCKED:
@@ -906,6 +909,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
906 dev_err(trf->dev, "%s - Invalid request: %d %d\n", 909 dev_err(trf->dev, "%s - Invalid request: %d %d\n",
907 __func__, trf->state, on); 910 __func__, trf->state, on);
908 trf7970a_switch_rf_off(trf); 911 trf7970a_switch_rf_off(trf);
912 ret = -EINVAL;
909 } 913 }
910 } else { 914 } else {
911 switch (trf->state) { 915 switch (trf->state) {
@@ -914,6 +918,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
914 default: 918 default:
915 dev_err(trf->dev, "%s - Invalid request: %d %d\n", 919 dev_err(trf->dev, "%s - Invalid request: %d %d\n",
916 __func__, trf->state, on); 920 __func__, trf->state, on);
921 ret = -EINVAL;
917 /* FALLTHROUGH */ 922 /* FALLTHROUGH */
918 case TRF7970A_ST_IDLE: 923 case TRF7970A_ST_IDLE:
919 case TRF7970A_ST_IDLE_RX_BLOCKED: 924 case TRF7970A_ST_IDLE_RX_BLOCKED:
@@ -922,7 +927,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
922 } 927 }
923 928
924 mutex_unlock(&trf->lock); 929 mutex_unlock(&trf->lock);
925 return 0; 930 return ret;
926} 931}
927 932
928static int trf7970a_config_rf_tech(struct trf7970a *trf, int tech) 933static 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 1045
1041 mutex_lock(&trf->lock); 1046 mutex_lock(&trf->lock);
1042 1047
1043 if (trf->state == TRF7970A_ST_OFF) 1048 if (trf->state == TRF7970A_ST_OFF) {
1044 trf7970a_switch_rf_on(trf); 1049 ret = trf7970a_switch_rf_on(trf);
1050 if (ret)
1051 goto err_unlock;
1052 }
1045 1053
1046 switch (type) { 1054 switch (type) {
1047 case NFC_DIGITAL_CONFIG_RF_TECH: 1055 case NFC_DIGITAL_CONFIG_RF_TECH:
@@ -1055,6 +1063,7 @@ static int trf7970a_in_configure_hw(struct nfc_digital_dev *ddev, int type,
1055 ret = -EINVAL; 1063 ret = -EINVAL;
1056 } 1064 }
1057 1065
1066err_unlock:
1058 mutex_unlock(&trf->lock); 1067 mutex_unlock(&trf->lock);
1059 return ret; 1068 return ret;
1060} 1069}