* [PATCH 1/2] iio: adc: ad4130: zero-initialize clock init data
@ 2024-02-07 13:20 Cosmin Tanislav
2024-02-07 13:20 ` [PATCH 2/2] iio: adc: ad4130: only set GPIO_CTRL if pin is unused Cosmin Tanislav
2024-02-08 8:15 ` [PATCH 1/2] iio: adc: ad4130: zero-initialize clock init data Nuno Sá
0 siblings, 2 replies; 5+ messages in thread
From: Cosmin Tanislav @ 2024-02-07 13:20 UTC (permalink / raw)
Cc: Cosmin Tanislav, Lars-Peter Clausen, Michael Hennerich,
Jonathan Cameron, Andy Shevchenko, linux-iio, linux-kernel,
Cosmin Tanislav
The clk_init_data struct does not have all its members
initialized, causing issues when trying to expose the internal
clock on the CLK pin.
Fix this by zero-initializing the clk_init_data struct.
Fixes: 62094060cf3a ("iio: adc: ad4130: add AD4130 driver")
Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
drivers/iio/adc/ad4130.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/ad4130.c b/drivers/iio/adc/ad4130.c
index 53e19a863198..c7df499f9775 100644
--- a/drivers/iio/adc/ad4130.c
+++ b/drivers/iio/adc/ad4130.c
@@ -1794,7 +1794,7 @@ static int ad4130_setup_int_clk(struct ad4130_state *st)
{
struct device *dev = &st->spi->dev;
struct device_node *of_node = dev_of_node(dev);
- struct clk_init_data init;
+ struct clk_init_data init = {};
const char *clk_name;
int ret;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] iio: adc: ad4130: only set GPIO_CTRL if pin is unused
2024-02-07 13:20 [PATCH 1/2] iio: adc: ad4130: zero-initialize clock init data Cosmin Tanislav
@ 2024-02-07 13:20 ` Cosmin Tanislav
2024-02-08 8:16 ` Nuno Sá
2024-02-08 8:15 ` [PATCH 1/2] iio: adc: ad4130: zero-initialize clock init data Nuno Sá
1 sibling, 1 reply; 5+ messages in thread
From: Cosmin Tanislav @ 2024-02-07 13:20 UTC (permalink / raw)
Cc: Cosmin Tanislav, Lars-Peter Clausen, Michael Hennerich,
Jonathan Cameron, Andy Shevchenko, linux-iio, linux-kernel,
Cosmin Tanislav
Currently, GPIO_CTRL bits are set even if the pins are used for
measurements.
GPIO_CTRL bits should only be set if the pin is not used for
other functionality.
Fix this by only setting the GPIO_CTRL bits if the pin has no
other function.
Fixes: 62094060cf3a ("iio: adc: ad4130: add AD4130 driver")
Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
drivers/iio/adc/ad4130.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/adc/ad4130.c b/drivers/iio/adc/ad4130.c
index c7df499f9775..febb64e67955 100644
--- a/drivers/iio/adc/ad4130.c
+++ b/drivers/iio/adc/ad4130.c
@@ -1864,10 +1864,14 @@ static int ad4130_setup(struct iio_dev *indio_dev)
return ret;
/*
- * Configure all GPIOs for output. If configured, the interrupt function
- * of P2 takes priority over the GPIO out function.
+ * Configure unused GPIOs for output. If configured, the interrupt
+ * function of P2 takes priority over the GPIO out function.
*/
- val = AD4130_IO_CONTROL_GPIO_CTRL_MASK;
+ val = 0;
+ for (i = 0; i < AD4130_MAX_GPIOS; i++)
+ if (st->pins_fn[i + AD4130_AIN2_P1] == AD4130_PIN_FN_NONE)
+ val |= FIELD_PREP(AD4130_IO_CONTROL_GPIO_CTRL_MASK, BIT(i));
+
val |= FIELD_PREP(AD4130_IO_CONTROL_INT_PIN_SEL_MASK, st->int_pin_sel);
ret = regmap_write(st->regmap, AD4130_IO_CONTROL_REG, val);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] iio: adc: ad4130: only set GPIO_CTRL if pin is unused
2024-02-07 13:20 ` [PATCH 2/2] iio: adc: ad4130: only set GPIO_CTRL if pin is unused Cosmin Tanislav
@ 2024-02-08 8:16 ` Nuno Sá
0 siblings, 0 replies; 5+ messages in thread
From: Nuno Sá @ 2024-02-08 8:16 UTC (permalink / raw)
To: Cosmin Tanislav
Cc: Cosmin Tanislav, Lars-Peter Clausen, Michael Hennerich,
Jonathan Cameron, Andy Shevchenko, linux-iio, linux-kernel
On Wed, 2024-02-07 at 15:20 +0200, Cosmin Tanislav wrote:
> Currently, GPIO_CTRL bits are set even if the pins are used for
> measurements.
>
> GPIO_CTRL bits should only be set if the pin is not used for
> other functionality.
>
> Fix this by only setting the GPIO_CTRL bits if the pin has no
> other function.
>
> Fixes: 62094060cf3a ("iio: adc: ad4130: add AD4130 driver")
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> drivers/iio/adc/ad4130.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/ad4130.c b/drivers/iio/adc/ad4130.c
> index c7df499f9775..febb64e67955 100644
> --- a/drivers/iio/adc/ad4130.c
> +++ b/drivers/iio/adc/ad4130.c
> @@ -1864,10 +1864,14 @@ static int ad4130_setup(struct iio_dev *indio_dev)
> return ret;
>
> /*
> - * Configure all GPIOs for output. If configured, the interrupt
> function
> - * of P2 takes priority over the GPIO out function.
> + * Configure unused GPIOs for output. If configured, the interrupt
> + * function of P2 takes priority over the GPIO out function.
> */
> - val = AD4130_IO_CONTROL_GPIO_CTRL_MASK;
> + val = 0;
> + for (i = 0; i < AD4130_MAX_GPIOS; i++)
> + if (st->pins_fn[i + AD4130_AIN2_P1] == AD4130_PIN_FN_NONE)
> + val |= FIELD_PREP(AD4130_IO_CONTROL_GPIO_CTRL_MASK,
> BIT(i));
> +
> val |= FIELD_PREP(AD4130_IO_CONTROL_INT_PIN_SEL_MASK, st-
> >int_pin_sel);
>
> ret = regmap_write(st->regmap, AD4130_IO_CONTROL_REG, val);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] iio: adc: ad4130: zero-initialize clock init data
2024-02-07 13:20 [PATCH 1/2] iio: adc: ad4130: zero-initialize clock init data Cosmin Tanislav
2024-02-07 13:20 ` [PATCH 2/2] iio: adc: ad4130: only set GPIO_CTRL if pin is unused Cosmin Tanislav
@ 2024-02-08 8:15 ` Nuno Sá
2024-02-10 16:53 ` Jonathan Cameron
1 sibling, 1 reply; 5+ messages in thread
From: Nuno Sá @ 2024-02-08 8:15 UTC (permalink / raw)
To: Cosmin Tanislav
Cc: Cosmin Tanislav, Lars-Peter Clausen, Michael Hennerich,
Jonathan Cameron, Andy Shevchenko, linux-iio, linux-kernel
On Wed, 2024-02-07 at 15:20 +0200, Cosmin Tanislav wrote:
> The clk_init_data struct does not have all its members
> initialized, causing issues when trying to expose the internal
> clock on the CLK pin.
>
> Fix this by zero-initializing the clk_init_data struct.
>
> Fixes: 62094060cf3a ("iio: adc: ad4130: add AD4130 driver")
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> drivers/iio/adc/ad4130.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ad4130.c b/drivers/iio/adc/ad4130.c
> index 53e19a863198..c7df499f9775 100644
> --- a/drivers/iio/adc/ad4130.c
> +++ b/drivers/iio/adc/ad4130.c
> @@ -1794,7 +1794,7 @@ static int ad4130_setup_int_clk(struct ad4130_state *st)
> {
> struct device *dev = &st->spi->dev;
> struct device_node *of_node = dev_of_node(dev);
> - struct clk_init_data init;
> + struct clk_init_data init = {};
> const char *clk_name;
> int ret;
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 1/2] iio: adc: ad4130: zero-initialize clock init data
2024-02-08 8:15 ` [PATCH 1/2] iio: adc: ad4130: zero-initialize clock init data Nuno Sá
@ 2024-02-10 16:53 ` Jonathan Cameron
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2024-02-10 16:53 UTC (permalink / raw)
To: Nuno Sá
Cc: Cosmin Tanislav, Cosmin Tanislav, Lars-Peter Clausen,
Michael Hennerich, Andy Shevchenko, linux-iio, linux-kernel
On Thu, 08 Feb 2024 09:15:08 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Wed, 2024-02-07 at 15:20 +0200, Cosmin Tanislav wrote:
> > The clk_init_data struct does not have all its members
> > initialized, causing issues when trying to expose the internal
> > clock on the CLK pin.
> >
> > Fix this by zero-initializing the clk_init_data struct.
> >
> > Fixes: 62094060cf3a ("iio: adc: ad4130: add AD4130 driver")
> > Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> > ---
>
> Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Both applied to the fixes-togreg branch of iio.git.
Thanks,
Jonathan
>
> > drivers/iio/adc/ad4130.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/ad4130.c b/drivers/iio/adc/ad4130.c
> > index 53e19a863198..c7df499f9775 100644
> > --- a/drivers/iio/adc/ad4130.c
> > +++ b/drivers/iio/adc/ad4130.c
> > @@ -1794,7 +1794,7 @@ static int ad4130_setup_int_clk(struct ad4130_state *st)
> > {
> > struct device *dev = &st->spi->dev;
> > struct device_node *of_node = dev_of_node(dev);
> > - struct clk_init_data init;
> > + struct clk_init_data init = {};
> > const char *clk_name;
> > int ret;
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-10 16:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-07 13:20 [PATCH 1/2] iio: adc: ad4130: zero-initialize clock init data Cosmin Tanislav
2024-02-07 13:20 ` [PATCH 2/2] iio: adc: ad4130: only set GPIO_CTRL if pin is unused Cosmin Tanislav
2024-02-08 8:16 ` Nuno Sá
2024-02-08 8:15 ` [PATCH 1/2] iio: adc: ad4130: zero-initialize clock init data Nuno Sá
2024-02-10 16:53 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox