lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri,  9 Jul 2021 11:58:52 -0400
From:   Liam Beguin <liambeguin@...il.com>
To:     liambeguin@...il.com, lars@...afoo.de,
        Michael.Hennerich@...log.com, jic23@...nel.org,
        charles-antoine.couret@...ensium.com, Nuno.Sa@...log.com
Cc:     linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
        devicetree@...r.kernel.org, robh+dt@...nel.org
Subject: [PATCH v1 0/4] AD7949 Fixes

While working on another series[1] I ran into issues where my SPI
controller would fail to handle 14-bit and 16-bit SPI messages. This
addresses that issue and adds support for selecting a different voltage
reference source from the devicetree.

This is base on a series[2] that seems to not have made it all the way,
and was tested on an ad7689.

[1] https://patchwork.kernel.org/project/linux-iio/list/?series=511545
[2] https://patchwork.kernel.org/project/linux-iio/list/?series=116971&state=%2A&archive=both

Changes since v1:
- add default case in read/write size cases
- drop of_node change as the core already takes care of it
- check dt user input in probe
- move description at the top of dt-binding definition
- drop AllOf block in dt-binding

Thanks for your time,
Liam

Liam Beguin (4):
  iio: adc: ad7949: define and use bitfield names
  iio: adc: ad7949: fix spi messages on non 14-bit controllers
  iio: adc: ad7949: add support for internal vref
  dt-bindings: iio: adc: ad7949: add adi,reference-source

 .../bindings/iio/adc/adi,ad7949.yaml          |  21 ++
 drivers/iio/adc/ad7949.c                      | 201 +++++++++++++++---
 2 files changed, 192 insertions(+), 30 deletions(-)

Range-diff against v1:
-:  ------------ > 1:  b8577e93229f iio: adc: ad7949: define and use bitfield names
1:  86bab3bedcf8 ! 2:  a8468391e3d0 iio: adc: ad7949: fix spi messages on non 14-bit controllers
    @@ drivers/iio/adc/ad7949.c: struct ad7949_adc_chip {
     +		ad7949_adc->buffer = ad7949_adc->cfg;
     +		break;
     +	case 8:
    ++	default:
     +		/* Pack 14-bit value into 2 bytes, MSB first */
     +		ad7949_adc->buf8[0] = FIELD_GET(GENMASK(13, 6), ad7949_adc->cfg);
     +		ad7949_adc->buf8[1] = FIELD_GET(GENMASK(5, 0), ad7949_adc->cfg);
    @@ drivers/iio/adc/ad7949.c: static int ad7949_spi_read_channel(struct ad7949_adc_c
     +		*val = ad7949_adc->buffer & GENMASK(13, 0);
     +		break;
     +	case 8:
    ++	default:
     +		/* Convert byte array to u16, MSB first */
     +		*val = (ad7949_adc->buf8[0] << 8) | ad7949_adc->buf8[1];
     +		/* Shift-out padding bits */
2:  5f4dbdd51e1f ! 3:  4b0c11c9a748 iio: adc: ad7949: add support for internal vref
    @@ drivers/iio/adc/ad7949.c: static int ad7949_spi_init(struct ad7949_adc_chip *ad7
      	const struct ad7949_adc_spec *spec;
      	struct ad7949_adc_chip *ad7949_adc;
      	struct iio_dev *indio_dev;
    -@@ drivers/iio/adc/ad7949.c: static int ad7949_spi_probe(struct spi_device *spi)
    - 		return -ENOMEM;
    - 	}
    - 
    -+	indio_dev->dev.of_node = np;
    - 	indio_dev->info = &ad7949_spi_info;
    - 	indio_dev->name = spi_get_device_id(spi)->name;
    - 	indio_dev->modes = INDIO_DIRECT_MODE;
     @@ drivers/iio/adc/ad7949.c: static int ad7949_spi_probe(struct spi_device *spi)
      	ad7949_adc->resolution = spec->resolution;
      	ad7949_set_bits_per_word(ad7949_adc);
    @@ drivers/iio/adc/ad7949.c: static int ad7949_spi_probe(struct spi_device *spi)
     -	if (IS_ERR(ad7949_adc->vref)) {
     -		dev_err(dev, "fail to request regulator\n");
     -		return PTR_ERR(ad7949_adc->vref);
    --	}
     +	/* Set default devicetree parameters */
     +	ad7949_adc->refsel = AD7949_REF_EXT_BUF;
     +	of_property_read_u32(np, "adi,reference-select", &ad7949_adc->refsel);
    ++	switch (ad7949_adc->refsel) {
    ++	case AD7949_REF_INT_2500:
    ++	case AD7949_REF_INT_4096:
    ++	case AD7949_REF_EXT_TEMP:
    ++	case AD7949_REF_EXT_TEMP_BUF:
    ++	case AD7949_REF_EXT:
    ++	case AD7949_REF_EXT_BUF:
    ++		break;
    ++	default:
    ++		dev_err(dev, "invalid adi,reference-select value (%d)\n",
    ++			ad7949_adc->refsel);
    ++		return -EINVAL;
    + 	}
      
     -	ret = regulator_enable(ad7949_adc->vref);
     -	if (ret < 0) {
3:  99367ba6e5f9 ! 4:  a3b6a6ef15fd dt-bindings: iio: adc: ad7949: add adi,reference-source
    @@ Documentation/devicetree/bindings/iio/adc/adi,ad7949.yaml: properties:
          const: 1
      
     +  adi,reference-select:
    -+    allOf:
    -+      - $ref: /schemas/types.yaml#/definitions/uint32
    -+      - enum: [0, 1, 2, 3, 6, 7]
    -+
    -+    default: 7
     +    description: |
     +      Select the reference voltage source to use when converting samples.
     +      Acceptable values are:
    @@ Documentation/devicetree/bindings/iio/adc/adi,ad7949.yaml: properties:
     +           disabled.
     +      - 7: Use external reference, internal buffer enabled.
     +           Internal reference and temperature sensor disabled.
    ++
    ++    $ref: /schemas/types.yaml#/definitions/uint32
    ++    enum: [0, 1, 2, 3, 6, 7]
    ++    default: 7
     +
      required:
        - compatible

base-commit: 6cbb3aa0f9d5d23221df787cf36f74d3866fdb78
-- 
2.30.1.489.g328c10930387

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ