Skip to content

Commit 7437700

Browse files
committed
iio: adc: ad4130: Fix clock init and GPIO init.
There is an error while probing the AD4130. The clk_init_data has to be initialized as an empty struct otherwise the probe will fail. There is an error assigning the functions of GPIO pins. Before setting the GPIO as an output, the GPIO has to be verified if it does not already has a function. Signed-off-by: Aron Kis <kis.aron@analog.com>
1 parent e2648f8 commit 7437700

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/iio/adc/ad4130.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ static int ad4130_setup_int_clk(struct ad4130_state *st)
18631863
{
18641864
struct device *dev = &st->spi->dev;
18651865
struct device_node *of_node = dev_of_node(dev);
1866-
struct clk_init_data init;
1866+
struct clk_init_data init = {};
18671867
const char *clk_name;
18681868
struct clk *clk;
18691869
int ret;
@@ -1940,7 +1940,12 @@ static int ad4130_setup(struct iio_dev *indio_dev)
19401940
* Configure all GPIOs for output. If configured, the interrupt function
19411941
* of P2 takes priority over the GPIO out function.
19421942
*/
1943-
val = AD4130_IO_CONTROL_GPIO_CTRL_MASK;
1943+
val = 0;
1944+
for (i = 0; i < AD4130_MAX_GPIOS; i++) {
1945+
if (st->pins_fn[i + AD4130_AIN2_P1] != AD4130_PIN_FN_NONE)
1946+
continue;
1947+
val |= FIELD_PREP(AD4130_IO_CONTROL_GPIO_CTRL_MASK, BIT);
1948+
}
19441949
val |= FIELD_PREP(AD4130_IO_CONTROL_INT_PIN_SEL_MASK, st->int_pin_sel);
19451950

19461951
ret = regmap_write(st->regmap, AD4130_IO_CONTROL_REG, val);

0 commit comments

Comments
 (0)