power: qcom: Fix return value for iio get function for smb

Fix return values in iio read functions for smb1398 and smb1355

Change-Id: I258582c937735f6a6c70b368268ad161b35b7746
Signed-off-by: Ashish Chavan <ashichav@codeaurora.org>
This commit is contained in:
Ashish Chavan 2020-09-24 09:37:41 +05:30
commit bcc613a498
2 changed files with 13 additions and 18 deletions

View file

@ -672,9 +672,8 @@ done:
return rc;
}
static int smb1355_get_prop_constant_charge_current_max(
struct smb1355 *chip,
int *val)
static int smb1355_get_prop_constant_charge_current_max(struct smb1355 *chip,
int *val)
{
int rc = 0;
@ -1038,18 +1037,18 @@ static int smb1355_iio_read_raw(struct iio_dev *indio_dev,
*val1 = 0;
break;
default:
pr_err_ratelimited("SMB1355 IIO channel %d not supported\n",
pr_err_ratelimited("SMB1355 IIO channel %x not supported\n",
chan->channel);
return -EINVAL;
}
if (rc < 0) {
pr_debug("Couldn't read channel %d rc = %d\n",
pr_debug("Couldn't read channel %x rc = %d\n",
chan->channel, rc);
return -ENODATA;
}
return rc ? rc : IIO_VAL_INT;
return IIO_VAL_INT;
}
static int smb1355_iio_write_raw(struct iio_dev *indio_dev,
@ -1093,10 +1092,12 @@ static int smb1355_iio_write_raw(struct iio_dev *indio_dev,
rc = smb1355_clk_request(chip, false);
break;
default:
pr_debug("SMB1355 IIO write channel %d not supported\n",
chan->channel);
rc = -EINVAL;
}
if (rc < 0)
pr_debug("Couldn't write to channel %x rc = %d\n",
chan->channel, rc);
done:
mutex_unlock(&chip->suspend_lock);
return rc;

View file

@ -2450,8 +2450,6 @@ static const struct cp_iio_prop_channels cp_master_chans[] = {
static int cp_master_iio_set_prop(struct smb1398_chip *chip,
int channel, int val)
{
int rc = 0;
switch (channel) {
case PSY_IIO_CP_ENABLE:
vote(chip->div2_cp_disable_votable,
@ -2471,8 +2469,7 @@ static int cp_master_iio_set_prop(struct smb1398_chip *chip,
break;
default:
pr_err("get prop %d is not supported\n", channel);
rc = -EINVAL;
break;
return -EINVAL;
}
return 0;
@ -2526,11 +2523,11 @@ static int cp_master_iio_get_prop(struct smb1398_chip *chip,
* Return the cached values when the system is in suspend state
* instead of reading the registers to avoid read failures.
*/
if (chip->in_suspend) {
rc = cp_master_iio_get_prop_in_suspend(chip, channel, val);
if (!rc)
return rc;
return IIO_VAL_INT;
rc = 0;
}
switch (channel) {
@ -2697,8 +2694,6 @@ static int cp_slave_iio_set_prop(struct smb1398_chip *chip,
static int cp_slave_iio_get_prop(struct smb1398_chip *chip,
int channel, int *val)
{
int rc = 0;
switch (channel) {
case PSY_IIO_CP_ENABLE:
*val = chip->switcher_en;
@ -2716,8 +2711,7 @@ static int cp_slave_iio_get_prop(struct smb1398_chip *chip,
break;
default:
pr_err("get prop %d is not supported\n", channel);
rc = -EINVAL;
break;
return -EINVAL;
}
return IIO_VAL_INT;