2022-08-30 11:19:54

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH v1 1/3] dt-bindings: iio: adc: ti,tsc2046: add vref-supply property

Add property for the voltage reference supply.

Signed-off-by: Oleksij Rempel <[email protected]>
---
Documentation/devicetree/bindings/iio/adc/ti,tsc2046.yaml | 3 +++
1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/adc/ti,tsc2046.yaml b/Documentation/devicetree/bindings/iio/adc/ti,tsc2046.yaml
index 601d69971d84a..7faf12b1598b9 100644
--- a/Documentation/devicetree/bindings/iio/adc/ti,tsc2046.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/ti,tsc2046.yaml
@@ -25,6 +25,9 @@ properties:

spi-max-frequency: true

+ vref-supply:
+ description: Optional supply of the reference voltage
+
"#io-channel-cells":
const: 1

--
2.30.2


2022-08-30 12:28:33

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH v1 3/3] iio: adc: tsc2046: silent spi_device_id warning

Add spi_device_id to silent following warning:
SPI driver tsc2046 has no spi_device_id for ti,tsc2046e-adc

Signed-off-by: Oleksij Rempel <[email protected]>
---
drivers/iio/adc/ti-tsc2046.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti-tsc2046.c b/drivers/iio/adc/ti-tsc2046.c
index bbc8b4137b0b1..b9a1fac659d46 100644
--- a/drivers/iio/adc/ti-tsc2046.c
+++ b/drivers/iio/adc/ti-tsc2046.c
@@ -761,7 +761,15 @@ static int tsc2046_adc_probe(struct spi_device *spi)
return -EINVAL;
}

- dcfg = device_get_match_data(dev);
+ if (!dev_fwnode(dev)) {
+ const struct spi_device_id *id;
+
+ id = spi_get_device_id(spi);
+ dcfg = (const struct tsc2046_adc_dcfg *)id->driver_data;
+ } else {
+ dcfg = device_get_match_data(dev);
+ }
+
if (!dcfg)
return -EINVAL;

@@ -878,11 +886,18 @@ static const struct of_device_id ads7950_of_table[] = {
};
MODULE_DEVICE_TABLE(of, ads7950_of_table);

+static const struct spi_device_id tsc2046_adc_spi_ids[] = {
+ { "tsc2046e-adc" },
+ { }
+};
+MODULE_DEVICE_TABLE(spi, tsc2046_adc_spi_ids);
+
static struct spi_driver tsc2046_adc_driver = {
.driver = {
.name = "tsc2046",
.of_match_table = ads7950_of_table,
},
+ .id_table = tsc2046_adc_spi_ids,
.probe = tsc2046_adc_probe,
.remove = tsc2046_adc_remove,
};
--
2.30.2

2022-08-30 13:39:56

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v1 3/3] iio: adc: tsc2046: silent spi_device_id warning

On Tue, 30 Aug 2022 13:07:09 +0200
Oleksij Rempel <[email protected]> wrote:

> Add spi_device_id to silent following warning:
> SPI driver tsc2046 has no spi_device_id for ti,tsc2046e-adc
>
> Signed-off-by: Oleksij Rempel <[email protected]>
> ---
> drivers/iio/adc/ti-tsc2046.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ti-tsc2046.c b/drivers/iio/adc/ti-tsc2046.c
> index bbc8b4137b0b1..b9a1fac659d46 100644
> --- a/drivers/iio/adc/ti-tsc2046.c
> +++ b/drivers/iio/adc/ti-tsc2046.c
> @@ -761,7 +761,15 @@ static int tsc2046_adc_probe(struct spi_device *spi)
> return -EINVAL;
> }
>
> - dcfg = device_get_match_data(dev);
> + if (!dev_fwnode(dev)) {
> + const struct spi_device_id *id;
> +
> + id = spi_get_device_id(spi);
> + dcfg = (const struct tsc2046_adc_dcfg *)id->driver_data;

Driver data not set below.

Otherwise this looks good to me. An alternative more common form (I think...)
is call device_get_match_data() unconditionally and if that is null follow
the driver_data path. Either way is fine though.

Could you add to the patch description where
the warning is coming from? Build time / runtime etc and what tool?

Thanks,

Jonathan


> + } else {
> + dcfg = device_get_match_data(dev);
> + }
> +
> if (!dcfg)
> return -EINVAL;
>
> @@ -878,11 +886,18 @@ static const struct of_device_id ads7950_of_table[] = {
> };
> MODULE_DEVICE_TABLE(of, ads7950_of_table);
>
> +static const struct spi_device_id tsc2046_adc_spi_ids[] = {
> + { "tsc2046e-adc" },
> + { }
> +};
> +MODULE_DEVICE_TABLE(spi, tsc2046_adc_spi_ids);
> +
> static struct spi_driver tsc2046_adc_driver = {
> .driver = {
> .name = "tsc2046",
> .of_match_table = ads7950_of_table,
> },
> + .id_table = tsc2046_adc_spi_ids,
> .probe = tsc2046_adc_probe,
> .remove = tsc2046_adc_remove,
> };

2022-08-30 14:54:32

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v1 1/3] dt-bindings: iio: adc: ti,tsc2046: add vref-supply property

On 30/08/2022 14:07, Oleksij Rempel wrote:
> Add property for the voltage reference supply.
>
> Signed-off-by: Oleksij Rempel <[email protected]>


Acked-by: Krzysztof Kozlowski <[email protected]>


Best regards,
Krzysztof

2022-08-30 16:21:03

by Oleksij Rempel

[permalink] [raw]
Subject: Re: [PATCH v1 3/3] iio: adc: tsc2046: silent spi_device_id warning

On Tue, Aug 30, 2022 at 02:02:28PM +0100, Jonathan Cameron wrote:
> On Tue, 30 Aug 2022 13:07:09 +0200
> Oleksij Rempel <[email protected]> wrote:
>
> > Add spi_device_id to silent following warning:
> > SPI driver tsc2046 has no spi_device_id for ti,tsc2046e-adc
> >
> > Signed-off-by: Oleksij Rempel <[email protected]>
> > ---
> > drivers/iio/adc/ti-tsc2046.c | 17 ++++++++++++++++-
> > 1 file changed, 16 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/adc/ti-tsc2046.c b/drivers/iio/adc/ti-tsc2046.c
> > index bbc8b4137b0b1..b9a1fac659d46 100644
> > --- a/drivers/iio/adc/ti-tsc2046.c
> > +++ b/drivers/iio/adc/ti-tsc2046.c
> > @@ -761,7 +761,15 @@ static int tsc2046_adc_probe(struct spi_device *spi)
> > return -EINVAL;
> > }
> >
> > - dcfg = device_get_match_data(dev);
> > + if (!dev_fwnode(dev)) {
> > + const struct spi_device_id *id;
> > +
> > + id = spi_get_device_id(spi);
> > + dcfg = (const struct tsc2046_adc_dcfg *)id->driver_data;
>
> Driver data not set below.

..facepalm..

> Otherwise this looks good to me. An alternative more common form (I think...)
> is call device_get_match_data() unconditionally and if that is null follow
> the driver_data path. Either way is fine though.
>
> Could you add to the patch description where
> the warning is coming from? Build time / runtime etc and what tool?

ack. It is runtime warning in the kernel log.

Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

2022-08-30 20:42:44

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 3/3] iio: adc: tsc2046: silent spi_device_id warning

On Tue, Aug 30, 2022 at 2:19 PM Oleksij Rempel <[email protected]> wrote:
>
> Add spi_device_id to silent following warning:
> SPI driver tsc2046 has no spi_device_id for ti,tsc2046e-adc

Missed period.

...

> - dcfg = device_get_match_data(dev);

Why remove this and duplicate the check below with the inverted conditional?

> + if (!dev_fwnode(dev)) {
> + const struct spi_device_id *id;
> +
> + id = spi_get_device_id(spi);
> + dcfg = (const struct tsc2046_adc_dcfg *)id->driver_data;
> + } else {
> + dcfg = device_get_match_data(dev);
> + }

if (!dcfg) {
...try SPI ID...
}
if (!dfg)
return -E...

--
With Best Regards,
Andy Shevchenko