mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
iio: adc: rockchip_saradc: Just get referenced voltage once at probe
The referenced voltage is not changed after initiation, so just only get referenced voltage once. Change-Id: I1eeab03f68855fafe010db328ec7bbcfa7d52310 Signed-off-by: David Wu <david.wu@rock-chips.com>
This commit is contained in:
@@ -55,6 +55,7 @@ struct rockchip_saradc {
|
||||
struct clk *clk;
|
||||
struct completion completion;
|
||||
struct regulator *vref;
|
||||
int uv_vref;
|
||||
struct reset_control *reset;
|
||||
const struct rockchip_saradc_data *data;
|
||||
u16 last_val;
|
||||
@@ -65,7 +66,6 @@ static int rockchip_saradc_read_raw(struct iio_dev *indio_dev,
|
||||
int *val, int *val2, long mask)
|
||||
{
|
||||
struct rockchip_saradc *info = iio_priv(indio_dev);
|
||||
int ret;
|
||||
|
||||
switch (mask) {
|
||||
case IIO_CHAN_INFO_RAW:
|
||||
@@ -93,13 +93,7 @@ static int rockchip_saradc_read_raw(struct iio_dev *indio_dev,
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
return IIO_VAL_INT;
|
||||
case IIO_CHAN_INFO_SCALE:
|
||||
ret = regulator_get_voltage(info->vref);
|
||||
if (ret < 0) {
|
||||
dev_err(&indio_dev->dev, "failed to get voltage\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
*val = ret / 1000;
|
||||
*val = info->uv_vref / 1000;
|
||||
*val2 = info->data->num_bits;
|
||||
return IIO_VAL_FRACTIONAL_LOG2;
|
||||
default:
|
||||
@@ -298,6 +292,13 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
info->uv_vref = regulator_get_voltage(info->vref);
|
||||
if (info->uv_vref < 0) {
|
||||
dev_err(&pdev->dev, "failed to get voltage\n");
|
||||
ret = info->uv_vref;
|
||||
goto err_reg_voltage;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(info->pclk);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "failed to enable pclk\n");
|
||||
|
||||
Reference in New Issue
Block a user