add AD8460 DAC driver
Mariel Tinaco
maintainerv4 cover add AD8460 DAC driver
Apply comments for adding support to AD8460 Waveform Generator DAC
changes in v4
ad8460:
* Fixed spacing issues and tab format of includes.
* Changed data type of spi_tx_buffer to __le16. Then used le16_to_cpu and cpu_to_le16 functions for bulk read and write access.
* Changed print format in sysfs_emit for unsigned int.
* Added comments on powerdown write function to describe logic.
* Omitted "_shared" parameter in AD8460_CHAN_EXT_INFO.
* Applied further changes to channel definition (endianness = IIO_CPU and
AD8460_CURRENT_CHAN output = 1).
* Reformatted section that reads REFIO_1P2V voltage.
* Fixed upper and lower limits for checking of REFIO_1P2V.
* Removed comment for arming the device in probe function.
* Created a section for IIO related includes.
* Replaced mutex_init with devm_mutex_init.
* Added and enabled the other supplies using regulator bulk enable
* Handled devm_iio_channel_get error -EPROBE_DEFER by returning -EPROBE_DEFER
Bindings:
* Removed description on clocks
* Reverted GPIO pin name to shutdown-reset-GPIO
* Added minimum, maximum and default for setting voltage, current and temperature
* Added required supplies
* Changed additionalProperties to unevaluatedProperties
Mariel Tinaco (2):
dt-bindings: iio: dac: add docs for ad8460
iio: dac: support the ad8460 Waveform DAC
.../bindings/iio/dac/adi,ad8460.yaml | 164 +++ MAINTAINERS | 8 + drivers/iio/dac/Kconfig | 13 + drivers/iio/dac/Makefile | 1 + drivers/iio/dac/ad8460.c | 947 ++++++++++++++++++ 5 files changed, 1133 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad8460.yaml create mode 100644 drivers/iio/dac/ad8460.c
base-commit: fec496684388685647652ab4213454fbabdab099
Signature · 1 line
2.34.1
Mariel Tinaco
maintainerPATCH v4 1/2 dt-bindings: iio: dac: add docs for ad8460
This adds the bindings documentation for the 14-bit High Voltage, High Current, Waveform Generator Digital-to-Analog converter.
--- .../bindings/iio/dac/adi,ad8460.yaml | 164 ++++++++++++++++++ MAINTAINERS | 7 + 2 files changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad8460.yaml
Documentation/devicetree/bindings/iio/dac/adi,ad8460.yaml new file +164 -0
@@ -0,0 +1,164 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2024 Analog Devices Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/adi,ad8460.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD8460 DAC + +maintainers: + - Mariel Tinaco <[email protected]> + +description: | + Analog Devices AD8460 110 V High Voltage, 1 A High Current, + Arbitrary Waveform Generator with Integrated 14-Bit High Speed DAC + https://www.analog.com/media/en/technical-documentation/data-sheets/ad8460.pdf + +properties: + compatible: + enum: + - adi,ad8460 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + dmas: + maxItems: 1 + + dma-names: + items: + - const: tx + + spi-max-frequency: + maximum: 20000000 + + hvcc-supply: + description: Positive high voltage power supply line + + hvee-supply: + description: Negative high voltage power supply line + + vcc-5v-supply: + description: Low voltage power supply + + vref-5v-supply: + description: Reference voltage for analog low voltage + + dvdd-3p3v-supply: + description: Digital supply bypass + + avdd-3p3v-supply: + description: Analog supply bypass + + refio-1p2v-supply: + description: Drive voltage in the range of 1.2V maximum to as low as + low as 0.12V through the REF_IO pin to adjust full scale output span + + adi,external-resistor-ohms: + description: Specify value of external resistor connected to FS_ADJ pin + to establish internal HVDAC's reference current I_REF + minimum: 2000 + maximum: 20000 + default: 2000 + + adi,range-microvolt: + description: Voltage output range specified as <minimum, maximum> + items: + - minimum: -55000000 + maximum: 0 + default: 0 + - minimum: 0 + maximum: 55000000 + default: 0 + + adi,range-microamp: + description: Current output range specified as <minimum, maximum> + items: + - minimum: -1000000 + maximum: 0 + default: 0 + - minimum: 0 + maximum: 1000000 + default: 0 + + adi,max-millicelsius: + description: Overtemperature threshold + minimum: 0 + maximum: 150000 + default: 0 + + shutdown-reset-gpios: + description: Corresponds to SDN_RESET pin. To exit shutdown + or sleep mode, pulse SDN_RESET HIGH, then leave LOW. + maxItems: 1 + + reset-gpios: + description: Manual Power On Reset (POR). Pull this GPIO pin + LOW and then HIGH to reset all digital registers to default + maxItems: 1 + + shutdown-gpios: + description: Corresponds to SDN_IO pin. Shutdown may be + initiated by the user, by pulsing SDN_IO high. To exit shutdown, + pulse SDN_IO low, then float. + maxItems: 1 + +required: + - compatible + - reg + - clocks + - hvcc-supply + - hvee-supply + - vcc-5v-supply + - vref-5v-supply + - dvdd-3p3v-supply + - avdd-3p3v-supply + - refio-1p2v-supply + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + spi { + #address-cells = <1>; + #size-cells = <0>; + + dac@0 { + compatible = "adi,ad8460"; + reg = <0>; + spi-max-frequency = <8000000>; + + dmas = <&tx_dma 0>; + dma-names = "tx"; + + shutdown-reset-gpios = <&gpio 86 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio 91 GPIO_ACTIVE_LOW>; + shutdown-gpios = <&gpio 88 GPIO_ACTIVE_HIGH>; + + clocks = <&sync_ext_clk>; + + hvcc-supply = <&hvcc>; + hvee-supply = <&hvee>; + vcc-5v-supply = <&vcc_5>; + vref-5v-supply = <&vref_5>; + dvdd-3p3v-supply = <&dvdd_3_3>; + avdd-3p3v-supply = <&avdd_3_3>; + refio-1p2v-supply = <&refio_1_2>; + + adi,external-resistor-ohms = <2000>; + adi,range-microvolt = <(-40000000) 40000000>; + adi,range-microamp = <0 50000>; + adi,max-millicelsius = <50000>; + }; + }; + +...
MAINTAINERS +7 -0
@@ -1320,6 +1320,13 @@ F: Documentation/ABI/testing/debugfs-iio-ad9467 F: Documentation/devicetree/bindings/iio/adc/adi,ad9467.yaml F: drivers/iio/adc/ad9467.c +ANALOG DEVICES INC AD8460 DRIVER +M: Mariel Tinaco <[email protected]> +L: [email protected] +S: Supported +W: https://ez.analog.com/linux-software-drivers +F: Documentation/devicetree/bindings/iio/dac/adi,ad8460.yaml + ANALOG DEVICES INC AD9739a DRIVER M: Nuno Sa <[email protected]> M: Dragos Bogdan <[email protected]>
Signature · 1 line
2.34.1
Re: [PATCH v4 1/2] dt-bindings: iio: dac: add docs for ad8460
Quoted 10 lines · Mariel Tinaco
This adds the bindings documentation for the 14-bit High Voltage, High Current, Waveform Generator Digital-to-Analog converter.
Signed-off-by Mariel Tinaco <[email protected]>--- .../bindings/iio/dac/adi,ad8460.yaml | 164 ++++++++++++++++++ MAINTAINERS | 7 + 2 files changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad8460.yaml
Best regards,
Krzysztof
Mariel Tinaco
maintainerPATCH v4 2/2 iio: dac: support the ad8460 Waveform DAC
In reply to Mariel TinacoThe AD8460 is a “bits in, power out” high voltage, high-power, high-speed driver optimized for large output current (up to ±1 A) and high slew rate (up to ±1800 V/μs) at high voltage (up to ±40 V) into capacitive loads.
A digital engine implements user-configurable features: modes for digital input, programmable supply current, and fault monitoring and programmable protection settings for output current, output voltage, and junction temperature. The AD8460 operates on high voltage dual supplies up to ±55 V and a single low voltage supply of 5 V.
--- MAINTAINERS | 1 + drivers/iio/dac/Kconfig | 13 + drivers/iio/dac/Makefile | 1 + drivers/iio/dac/ad8460.c | 947 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 962 insertions(+) create mode 100644 drivers/iio/dac/ad8460.c
MAINTAINERS +1 -0
@@ -1326,6 +1326,7 @@ L: [email protected] S: Supported W: https://ez.analog.com/linux-software-drivers F: Documentation/devicetree/bindings/iio/dac/adi,ad8460.yaml +F: drivers/iio/dac/ad8460.c ANALOG DEVICES INC AD9739a DRIVER M: Nuno Sa <[email protected]>
drivers/iio/dac/Kconfig +13 -0
@@ -301,6 +301,19 @@ config AD7303 To compile this driver as module choose M here: the module will be called ad7303. +config AD8460 + tristate "Analog Devices AD8460 DAC driver" + depends on SPI + select REGMAP_SPI + select IIO_BUFFER + select IIO_BUFFER_DMAENGINE + help + Say yes here to build support for Analog Devices AD8460 Digital to + Analog Converters (DAC). + + To compile this driver as a module choose M here: the module will be called + ad8460. + config AD8801 tristate "Analog Devices AD8801/AD8803 DAC driver" depends on SPI_MASTER
drivers/iio/dac/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_AD5686_SPI) += ad5686-spi.o obj-$(CONFIG_AD5696_I2C) += ad5696-i2c.o obj-$(CONFIG_AD7293) += ad7293.o obj-$(CONFIG_AD7303) += ad7303.o +obj-$(CONFIG_AD8460) += ad8460.o obj-$(CONFIG_AD8801) += ad8801.o obj-$(CONFIG_AD9739A) += ad9739a.o obj-$(CONFIG_ADI_AXI_DAC) += adi-axi-dac.o
drivers/iio/dac/ad8460.c new file +947 -0
947 lines not on this page · raw message
Signature · 1 line
2.34.1
Jonathan Cameron
maintainerRe: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC
Quoted 5 lines · On Thu, 12 Sep 2024 17:54:35 +0800 Mariel Tinaco <[email protected]>…
The AD8460 is a “bits in, power out” high voltage, high-power, high-speed driver optimized for large output current (up to ±1 A) and high slew rate (up to ±1800 V/μs) at high voltage (up to ±40 V) into capacitive loads.
Quoted 8 lines
A digital engine implements user-configurable features: modes for digital input, programmable supply current, and fault monitoring and programmable protection settings for output current, output voltage, and junction temperature. The AD8460 operates on high voltage dual supplies up to ±55 V and a single low voltage supply of 5 V.
Signed-off-by Mariel Tinaco <[email protected]>
Hi Mariel
A few minor comments from me. I'd like it to sit on the list a while longer, but if there is nothing else I can make minor tweaks whilst applying.
Jonathan
Quoted 41 lines
drivers/iio/dac/ad8460.c new file +33
-0@@ -0,0 +1,947 @@ +static struct iio_chan_spec_ext_info ad8460_ext_info[] = { +AD8460_CHAN_EXT_INFO ("raw0" ,0 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw1" ,1 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw2" ,2 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw3" ,3 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw4" ,4 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw5" ,5 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw6" ,6 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw7" ,7 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw8" ,8 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw9" ,9 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw10" ,10 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw11" ,11 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw12" ,12 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw13" ,13 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw14" ,14 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw15" ,15 , ad8460_dac_input_read, + ad8460_dac_input_write),
drivers/iio/dac/ad8460.c line 712
Quoted 10 lines
drivers/iio/dac/ad8460.c new file +10
-0+AD8460_CHAN_EXT_INFO ("toggle_en" ,0 , ad8460_read_toggle_en, + ad8460_write_toggle_en), +AD8460_CHAN_EXT_INFO ("symbol" ,0 , ad8460_read_symbol, + ad8460_write_symbol), +AD8460_CHAN_EXT_INFO ("powerdown" ,0 , ad8460_read_powerdown, + ad8460_write_powerdown), +IIO_ENUM ("powerdown_mode" ,IIO_SEPARATE , &ad8460_powerdown_mode_enum), +IIO_ENUM_AVAILABLE ("powerdown_mode" ,IIO_SHARED_BY_TYPE , + &ad8460_powerdown_mode_enum), + {}
{ }is my style preference. Mostly I want consistency and happened to pick this for IIO.
drivers/iio/dac/ad8460.c line 764
Quoted 6 lines
drivers/iio/dac/ad8460.c new file +5
-0+}; +#define AD8460_TEMP_CHAN { \ + .type = IIO_TEMP, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .output = 1, \
An output temperature channel? That's a heater which seems unlikely on this device.
Quoted 16 lines
drivers/iio/dac/ad8460.c new file +15
-0+ .indexed = 1, \ + .channel = 0, \ + .scan_index = -1, \ + .event_spec = ad8460_events, \ + .num_event_specs = 1, \ +} +static int ad8460_probe (struct spi_device *spi) +{ +struct ad8460_state *state; +struct iio_dev *indio_dev; +struct device *dev; +u32 tmp[2 ], temp; +int ret; + + indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*state));
drivers/iio/dac/ad8460.c line 811
Quoted 10 lines
drivers/iio/dac/ad8460.c new file +10
-0+if (!indio_dev) +return -ENOMEM ; + + state =iio_priv (indio_dev); + + indio_dev->name ="ad8460" ; + indio_dev->info = &ad8460_info; + + state->spi = spi; + dev = &spi->dev;
Might as well do this one where you declare above.
struct device *dev = &spi->dev;
drivers/iio/dac/ad8460.c line 818
Quoted 7 lines
drivers/iio/dac/ad8460.c new file +7
-0+ + state->regmap =devm_regmap_init_spi (spi, &ad8460_regmap_config); +if (IS_ERR (state->regmap)) +return dev_err_probe (dev,PTR_ERR (state->regmap), +"Failed to initialize regmap" ); + +devm_mutex_init (dev, &state->lock);
Check return value. devm registration can potentially fail.
...
drivers/iio/dac/ad8460.c line 913
Quoted 5 lines
drivers/iio/dac/ad8460.c new file +5
-0+ +/* Enables DAC by default */ + ret =regmap_update_bits (state->regmap,AD8460_CTRL_REG (0x01 ), +AD8460_HVDAC_SLEEP_MSK , +FIELD_PREP (AD8460_HVDAC_SLEEP_MSK ,0 ));
regmap_clear_bits() perhaps.
Quoted 14 lines
drivers/iio/dac/ad8460.c new file +14
-0+if (ret) +return ret; + + indio_dev->modes =INDIO_DIRECT_MODE ; + indio_dev->setup_ops = &ad8460_buffer_setup_ops; + + ret =devm_iio_dmaengine_buffer_setup_ext (dev, indio_dev,"tx" , +IIO_BUFFER_DIRECTION_OUT ); +if (ret) +return dev_err_probe (dev, ret, +"Failed to get DMA buffer\n" ); + +return devm_iio_device_register (dev, indio_dev); +}
Re: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC
In reply to Mariel TinacoLe 12/09/2024 à 11:54, Mariel Tinaco a écrit :
Quoted 12 lines
The AD8460 is a “bits in, power out” high voltage, high-power, high-speed driver optimized for large output current (up to ±1 A) and high slew rate (up to ±1800 V/μs) at high voltage (up to ±40 V) into capacitive loads.
A digital engine implements user-configurable features: modes for digital input, programmable supply current, and fault monitoring and programmable protection settings for output current, output voltage, and junction temperature. The AD8460 operates on high voltage dual supplies up to ±55 V and a single low voltage supply of 5 V.
Quoted 2 lines
Signed-off-by Mariel Tinaco <[email protected]>---
Hi,
...
drivers/iio/dac/ad8460.c line 666
Quoted 5 lines
drivers/iio/dac/ad8460.c new file +5
-0+#define AD8460_CHAN_EXT_INFO (_name, _what, _read, _write) { \ + .name = _name, \ + .read = (_read), \ + .write = (_write), \ + .private = (_what), \
Why () for _read, _write, _what?
(or why no () for _name?)
drivers/iio/dac/ad8460.c line 670
Quoted 4 lines
drivers/iio/dac/ad8460.c new file +4
-0+ .shared = IIO_SEPARATE, \ +} + +static struct iio_chan_spec_ext_info ad8460_ext_info[] = {
I think this can be static const struct.
Quoted 43 lines
drivers/iio/dac/ad8460.c new file +43
-0+AD8460_CHAN_EXT_INFO ("raw0" ,0 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw1" ,1 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw2" ,2 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw3" ,3 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw4" ,4 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw5" ,5 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw6" ,6 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw7" ,7 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw8" ,8 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw9" ,9 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw10" ,10 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw11" ,11 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw12" ,12 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw13" ,13 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw14" ,14 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("raw15" ,15 , ad8460_dac_input_read, + ad8460_dac_input_write), +AD8460_CHAN_EXT_INFO ("toggle_en" ,0 , ad8460_read_toggle_en, + ad8460_write_toggle_en), +AD8460_CHAN_EXT_INFO ("symbol" ,0 , ad8460_read_symbol, + ad8460_write_symbol), +AD8460_CHAN_EXT_INFO ("powerdown" ,0 , ad8460_read_powerdown, + ad8460_write_powerdown), +IIO_ENUM ("powerdown_mode" ,IIO_SEPARATE , &ad8460_powerdown_mode_enum), +IIO_ENUM_AVAILABLE ("powerdown_mode" ,IIO_SHARED_BY_TYPE , + &ad8460_powerdown_mode_enum), + {} +};
...
Quoted 38 lines
drivers/iio/dac/ad8460.c new file +38
-0+static int ad8460_probe (struct spi_device *spi) +{ +struct ad8460_state *state; +struct iio_dev *indio_dev; +struct device *dev; +u32 tmp[2 ], temp; +int ret; + + indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*state)); +if (!indio_dev) +return -ENOMEM ; + + state =iio_priv (indio_dev); + + indio_dev->name ="ad8460" ; + indio_dev->info = &ad8460_info; + + state->spi = spi; + dev = &spi->dev; + + state->regmap =devm_regmap_init_spi (spi, &ad8460_regmap_config); +if (IS_ERR (state->regmap)) +return dev_err_probe (dev,PTR_ERR (state->regmap), +"Failed to initialize regmap" ); + +devm_mutex_init (dev, &state->lock); + + state->sync_clk =devm_clk_get_enabled (dev,NULL ); +if (IS_ERR (state->sync_clk)) +return dev_err_probe (dev,PTR_ERR (state->sync_clk), +"Failed to get sync clk\n" ); + + state->tmp_adc_channel =devm_iio_channel_get (dev,"ad8460-tmp" ); +if (IS_ERR (state->tmp_adc_channel)) { +if (PTR_ERR (state->tmp_adc_channel) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + indio_dev->channels = ad8460_channels; + indio_dev->num_channels =ARRAY_SIZE (ad8460_channels);
drivers/iio/dac/ad8460.c line 840
Quoted 10 lines
drivers/iio/dac/ad8460.c new file +10
-0+ }else { + indio_dev->channels = ad8460_channels_with_tmp_adc; + indio_dev->num_channels =ARRAY_SIZE (ad8460_channels_with_tmp_adc); + } + + ret =devm_regulator_bulk_get_enable (dev,ARRAY_SIZE (ad8460_supplies), + ad8460_supplies); +if (ret) { +dev_err (dev,"Failed to enable power supplies\n" ); +return ret;
Nitpick: return dev_err_probe() as done in other places?
drivers/iio/dac/ad8460.c line 847
Quoted 7 lines
drivers/iio/dac/ad8460.c new file +7
-0+ } + + ret =devm_regulator_get_enable_read_voltage (dev,"refio_1p2v" ); +if (ret <0 && ret != -ENODEV ) +return dev_err_probe (dev, ret,"Failed to get reference voltage\n" ); + + state->refio_1p2v_mv = ret == -ENODEV ?1200 : ret /1000 ;
...
CJ
Jonathan Cameron
maintainerRe: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC
Quoted 15 lines · On Sat, 14 Sep 2024 20:21:56 +0200 Christophe JAILLET…
Le 12/09/2024 à 11:54, Mariel Tinaco a écrit :
Quoted 14 lines
The AD8460 is a “bits in, power out” high voltage, high-power, high-speed driver optimized for large output current (up to ±1 A) and high slew rate (up to ±1800 V/μs) at high voltage (up to ±40 V) into capacitive loads.
A digital engine implements user-configurable features: modes for digital input, programmable supply current, and fault monitoring and programmable protection settings for output current, output voltage, and junction temperature. The AD8460 operates on high voltage dual supplies up to ±55 V and a single low voltage supply of 5 V.
Signed-off-by Mariel Tinaco <[email protected]>---
Rather than go around again, I fixed up all the comments made and the autobuilder issues then applied this.
Diff follows. The only bit I'm not 100% sure on was your intent with the temperature channel. I've made it an input but shout if I'm missing something.
With this diff applied on top, applied to the togreg branch of iio.git which is only pushed out as testing for now as I'll rebase on rc1 once available.
Thanks,
Jonathan
drivers/iio/dac/ad8460.c +16 -19
@@ -533,7 +533,7 @@ static int ad8460_write_event_value(struct iio_dev *indio_dev, enum iio_event_info info, int val, int val2) { struct ad8460_state *state = iio_priv(indio_dev); -unsigned int fault; +int fault;if (type !=IIO_EV_TYPE_THRESH )return -EINVAL ;
@@ -555,7 +555,7 @@ static int ad8460_read_event_value(struct iio_dev *indio_dev, enum iio_event_info info, int *val, int *val2) { struct ad8460_state *state = iio_priv(indio_dev); -unsigned int fault; +int fault;if (type !=IIO_EV_TYPE_THRESH )return -EINVAL ;
@@ -576,7 +576,7 @@ static int ad8460_write_event_config(struct iio_dev *indio_dev, enum iio_event_direction dir, int val) {struct ad8460_state *state =iio_priv (indio_dev); -unsigned int fault; +int fault;if (type !=IIO_EV_TYPE_THRESH )return -EINVAL ;
@@ -594,9 +594,8 @@ static int ad8460_read_event_config(struct iio_dev *indio_dev, enum iio_event_direction dir) {struct ad8460_state *state =iio_priv (indio_dev); -unsigned int fault; +int fault, ret;bool en; -int ret;if (type !=IIO_EV_TYPE_THRESH )return -EINVAL ;
@@ -660,14 +659,14 @@ static const struct iio_enum ad8460_powerdown_mode_enum = { };#define AD8460_CHAN_EXT_INFO (_name, _what, _read, _write) { \ - .name = _name, \ + .name = (_name), \ .read = (_read), \ .write = (_write), \ .private = (_what), \ .shared = IIO_SEPARATE, \ } -static struct iio_chan_spec_ext_info ad8460_ext_info[] = { +static const struct iio_chan_spec_ext_info ad8460_ext_info[] = {AD8460_CHAN_EXT_INFO ("raw0" ,0 , ad8460_dac_input_read, ad8460_dac_input_write), AD8460_CHAN_EXT_INFO("raw1", 1, ad8460_dac_input_read,
@@ -709,7 +708,7 @@ static struct iio_chan_spec_ext_info ad8460_ext_info[] = {IIO_ENUM ("powerdown_mode" ,IIO_SEPARATE , &ad8460_powerdown_mode_enum),IIO_ENUM_AVAILABLE ("powerdown_mode" ,IIO_SHARED_BY_TYPE , &ad8460_powerdown_mode_enum), - {} + { } }; static const struct iio_event_spec ad8460_events[] = {
@@ -761,7 +760,6 @@ static const struct iio_event_spec ad8460_events[] = {#define AD8460_TEMP_CHAN { \ .type = IIO_TEMP, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .output = 1, \ .indexed = 1, \ .channel = 0, \ .scan_index = -1, \
@@ -792,9 +790,9 @@ static const char * const ad8460_supplies[] = {static int ad8460_probe (struct spi_device *spi) { +struct device *dev = &spi->dev;struct ad8460_state *state;struct iio_dev *indio_dev; -struct device *dev;u32 tmp[2 ], temp;int ret;
@@ -808,14 +806,15 @@ static int ad8460_probe(struct spi_device *spi) indio_dev->info = &ad8460_info; state->spi = spi; - dev = &spi->dev; state->regmap =devm_regmap_init_spi (spi, &ad8460_regmap_config);if (IS_ERR (state->regmap))return dev_err_probe (dev,PTR_ERR (state->regmap),"Failed to initialize regmap" ); -devm_mutex_init (dev, &state->lock); + ret =devm_mutex_init (dev, &state->lock); +if (ret) +return ret; state->sync_clk =devm_clk_get_enabled (dev,NULL );if (IS_ERR (state->sync_clk))
@@ -835,10 +834,9 @@ static int ad8460_probe(struct spi_device *spi) ret =devm_regulator_bulk_get_enable (dev,ARRAY_SIZE (ad8460_supplies), ad8460_supplies); -if (ret) { -dev_err (dev,"Failed to enable power supplies\n" ); -return ret; - } +if (ret) +return dev_err_probe (dev, ret, +"Failed to enable power supplies\n" ); ret =devm_regulator_get_enable_read_voltage (dev,"refio_1p2v" );if (ret <0 && ret != -ENODEV )
@@ -908,9 +906,8 @@ static int ad8460_probe(struct spi_device *spi)return ret;/* Enables DAC by default */ - ret =regmap_update_bits (state->regmap,AD8460_CTRL_REG (0x01 ), -AD8460_HVDAC_SLEEP_MSK , -FIELD_PREP (AD8460_HVDAC_SLEEP_MSK ,0 )); + ret =regmap_clear_bits (state->regmap,AD8460_CTRL_REG (0x01 ), +AD8460_HVDAC_SLEEP_MSK );if (ret)return ret;
Quoted 129 lines
Hi,
...
Review
Quoted 5 lines
(quoted diff) +5
-0+#define AD8460_CHAN_EXT_INFO(_name, _what, _read, _write) { \ + .name = _name, \ + .read = (_read), \ + .write = (_write), \ + .private = (_what), \Why () for
_read,_write,_what?
(or why no () for_name?)Review
Quoted 4 lines
(quoted diff) +4
-0+ .shared = IIO_SEPARATE, \ +} + +static struct iio_chan_spec_ext_info ad8460_ext_info[] = {I think this can be static const struct.
Quoted 43 lines
(quoted diff) +43
-0+ AD8460_CHAN_EXT_INFO("raw0", 0, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw1", 1, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw2", 2, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw3", 3, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw4", 4, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw5", 5, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw6", 6, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw7", 7, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw8", 8, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw9", 9, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw10", 10, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw11", 11, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw12", 12, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw13", 13, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw14", 14, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("raw15", 15, ad8460_dac_input_read, + ad8460_dac_input_write), + AD8460_CHAN_EXT_INFO("toggle_en", 0, ad8460_read_toggle_en, + ad8460_write_toggle_en), + AD8460_CHAN_EXT_INFO("symbol", 0, ad8460_read_symbol, + ad8460_write_symbol), + AD8460_CHAN_EXT_INFO("powerdown", 0, ad8460_read_powerdown, + ad8460_write_powerdown), + IIO_ENUM("powerdown_mode", IIO_SEPARATE, &ad8460_powerdown_mode_enum), + IIO_ENUM_AVAILABLE("powerdown_mode", IIO_SHARED_BY_TYPE, + &ad8460_powerdown_mode_enum), + {} +};...
Quoted 38 lines
(quoted diff) +38
-0+static int ad8460_probe(struct spi_device *spi) +{ + struct ad8460_state *state; + struct iio_dev *indio_dev; + struct device *dev; + u32 tmp[2], temp; + int ret; + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*state)); + if (!indio_dev) + return -ENOMEM; + + state = iio_priv(indio_dev); + + indio_dev->name = "ad8460"; + indio_dev->info = &ad8460_info; + + state->spi = spi; + dev = &spi->dev; + + state->regmap = devm_regmap_init_spi(spi, &ad8460_regmap_config); + if (IS_ERR(state->regmap)) + return dev_err_probe(dev, PTR_ERR(state->regmap), + "Failed to initialize regmap"); + + devm_mutex_init(dev, &state->lock); + + state->sync_clk = devm_clk_get_enabled(dev, NULL); + if (IS_ERR(state->sync_clk)) + return dev_err_probe(dev, PTR_ERR(state->sync_clk), + "Failed to get sync clk\n"); + + state->tmp_adc_channel = devm_iio_channel_get(dev, "ad8460-tmp"); + if (IS_ERR(state->tmp_adc_channel)) { + if (PTR_ERR(state->tmp_adc_channel) == -EPROBE_DEFER) + return -EPROBE_DEFER; + indio_dev->channels = ad8460_channels; + indio_dev->num_channels = ARRAY_SIZE(ad8460_channels);Review
Quoted 10 lines
(quoted diff) +10
-0+ } else { + indio_dev->channels = ad8460_channels_with_tmp_adc; + indio_dev->num_channels = ARRAY_SIZE(ad8460_channels_with_tmp_adc); + } + + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(ad8460_supplies), + ad8460_supplies); + if (ret) { + dev_err(dev, "Failed to enable power supplies\n"); + return ret;Nitpick: return
dev_err_probe()as done in other places?Review
Quoted 7 lines
(quoted diff) +7
-0+ } + + ret = devm_regulator_get_enable_read_voltage(dev, "refio_1p2v"); + if (ret < 0 && ret != -ENODEV) + return dev_err_probe(dev, ret, "Failed to get reference voltage\n"); + + state->refio_1p2v_mv = ret == -ENODEV ? 1200 : ret / 1000;...
CJ
Tinaco, Mariel
maintainerRE: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC
Quoted 43 lines
-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Saturday, September 28, 2024 10:20 PM
To: Christophe JAILLET <[email protected]>
Cc: Tinaco, Mariel <[email protected]>; [email protected]; [email protected]; [email protected]; Lars-Peter Clausen <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Hennerich, Michael <[email protected]>; Conor Dooley <[email protected]>; Marcelo Schmitt <[email protected]>; Dimitri Fedrau <[email protected]>; David Lechner <[email protected]>; Nuno Sá <[email protected]>
Subject: Re: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC[External]
Quoted 15 lines · On Sat, 14 Sep 2024 20:21:56 +0200 Christophe JAILLET…
Le 12/09/2024 à 11:54, Mariel Tinaco a écrit :
Quoted 14 lines
The AD8460 is a “bits in, power out” high voltage, high-power, high-speed driver optimized for large output current (up to ±1 A) and high slew rate (up to ±1800 V/μs) at high voltage (up to ±40 V) into capacitive loads.
A digital engine implements user-configurable features: modes for digital input, programmable supply current, and fault monitoring and programmable protection settings for output current, output voltage, and junction temperature. The AD8460 operates on high voltage dual supplies up to ±55 V and a single low voltage supply of 5 V.
Signed-off-by: Mariel Tinaco <[email protected]>
---Rather than go around again, I fixed up all the comments made and the autobuilder issues then applied this.
Diff follows. The only bit I'm not 100% sure on was your intent with the temperature channel. I've made it an input but shout if I'm missing something.
Quoted 7 lines
With this diff applied on top, applied to the togreg branch of iio.git which is only pushed out as testing for now as I'll rebase on rc1 once available.
Thanks,
Jonathan
Hi Jonathan,
Thank you for finding the time to fix up the inline comments from the previous rounds! I have created a patch for that but was unable to send it yet because I'm still clueless about the temp channel. Apologies about that
About the temperature channel, it does make sense to set it as input since the value is read-only. About the implementation of the channel, I'm wondering what would happen if the consumer-get-channel would throw -EPROBE_DEFER half the time? Is it not possible to skip it over since the channel is optional anyway? Or does this defer error from the consumer mean that the other configurations for the succeeding attributes will be blocked, which is why we have to return probe instantly?
state->tmp_adc_channel = devm_iio_channel_get(dev, "ad8460-tmp");
if (IS_ERR(state->tmp_adc_channel)) {
state->tmp_adc_channel = NULL;
indio_dev->channels = ad8460_channels;
indio_dev->num_channels = ARRAY_SIZE(ad8460_channels);
} else {
ret = iio_get_channel_type(state->tmp_adc_channel, &temp);
if (ret < 0)
return ret;
if (temp != IIO_TEMP)
return dev_err_probe(dev, -EINVAL,
"Incompatible channel type %d\n", temp);
indio_dev->channels = ad8460_channels_with_tmp_adc;
indio_dev->num_channels = ARRAY_SIZE(ad8460_channels_with_tmp_adc);
}I also found other implementations where the type of channel is checked. Thought That maybe it's a good addition for security.
Thanks,
Mariel
Jonathan Cameron
maintainerRe: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC
Quoted 49 lines · Mariel
Quoted 41 lines
-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Saturday, September 28, 2024 10:20 PM
To: Christophe JAILLET <[email protected]>
Cc: Tinaco, Mariel <[email protected]>; [email protected]; [email protected]; [email protected]; Lars-Peter Clausen <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Hennerich, Michael <[email protected]>; Conor Dooley <[email protected]>; Marcelo Schmitt <[email protected]>; Dimitri Fedrau <[email protected]>; David Lechner <[email protected]>; Nuno Sá <[email protected]>
Subject: Re: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC[External]
Quoted 15 lines · On Sat, 14 Sep 2024 20:21:56 +0200 Christophe JAILLET…
Le 12/09/2024 à 11:54, Mariel Tinaco a écrit :
Quoted 14 lines
The AD8460 is a “bits in, power out” high voltage, high-power, high-speed driver optimized for large output current (up to ±1 A) and high slew rate (up to ±1800 V/μs) at high voltage (up to ±40 V) into capacitive loads.
A digital engine implements user-configurable features: modes for digital input, programmable supply current, and fault monitoring and programmable protection settings for output current, output voltage, and junction temperature. The AD8460 operates on high voltage dual supplies up to ±55 V and a single low voltage supply of 5 V.
Signed-off-by: Mariel Tinaco <[email protected]>
---Rather than go around again, I fixed up all the comments made and the autobuilder issues then applied this.
Diff follows. The only bit I'm not 100% sure on was your intent with the temperature channel. I've made it an input but shout if I'm missing something.
Quoted 7 lines
With this diff applied on top, applied to the togreg branch of iio.git which is only pushed out as testing for now as I'll rebase on rc1 once available.
Thanks,
Jonathan
Quoted 8 lines
Hi Jonathan,
Thank you for finding the time to fix up the inline comments from the previous rounds! I have created a patch for that but was unable to send it yet because I'm still clueless about the temp channel. Apologies about that
About the temperature channel, it does make sense to set it as input since the value is read-only.
Input means that we are measuring a signal from the outside world. As you can read the temperature it should be an input (doesn't matter that it comes from elsewhere - in this case an ADC channel is providing the service of reading that voltage for us).
Quoted 3 lines
About the implementation of the channel, I'm wondering
what would happen if the consumer-get-channel would throw -EPROBE_DEFER half the time?
It will return -EPROBE_DEFER, it then later the driver providing the ADC channel will probe and we will go around again with it succeeding. Roughly speaking every
time a driver is successfully bound (probe finishes) the kernel tries again for any deferred instances.
The only nasty corner is the DT supplies the channel but we don't have the driver for the ADC built. I'd argue that is a kernel miss configuration where the right approach is to fix that and provide the ADC driver.
Quoted 4 lines
Is it not possible to skip it over since the channel is optional anyway? Or does this defer error from the consumer mean that the other configurations for the succeeding attributes will be blocked, which is why we have to return probe instantly?
If we don't defer then we never try again and succeed.
We could skip it but that would effectively be so unreliable we would be better off not providing that feature at all as it will be the source of lots of bug reports.
Quoted 19 lines
state->tmp_adc_channel = devm_iio_channel_get(dev, "ad8460-tmp");
if (IS_ERR(state->tmp_adc_channel)) {
state->tmp_adc_channel = NULL;
indio_dev->channels = ad8460_channels;
indio_dev->num_channels = ARRAY_SIZE(ad8460_channels);
} else {
ret = iio_get_channel_type(state->tmp_adc_channel, &temp);
if (ret < 0)
return ret;
if (temp != IIO_TEMP)
return dev_err_probe(dev, -EINVAL,
"Incompatible channel type %d\n", temp);
indio_dev->channels = ad8460_channels_with_tmp_adc;
indio_dev->num_channels = ARRAY_SIZE(ad8460_channels_with_tmp_adc);
}Quoted 2 lines
I also found other implementations where the type of channel is checked. Thought That maybe it's a good addition for security.
in this case it would be a DT bug on a very simple binding so I'm not sure we care. It is also very unlikely to be a temperature channel given we need to read the voltage from this chips output pin
Jonathan
Quoted 4 lines
Thanks,
Mariel
Tinaco, Mariel
maintainerRE: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC
In reply to Jonathan CameronQuoted 43 lines
-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Saturday, September 28, 2024 10:20 PM
To: Christophe JAILLET <[email protected]>
Cc: Tinaco, Mariel <[email protected]>; [email protected]; [email protected]; [email protected]; Lars-Peter Clausen <[email protected]>; Rob Herring <[email protected]>; Krzysztof Kozlowski <[email protected]>; Hennerich, Michael <[email protected]>; Conor Dooley <[email protected]>; Marcelo Schmitt <[email protected]>; Dimitri Fedrau <[email protected]>; David Lechner <[email protected]>; Nuno Sá <[email protected]>
Subject: Re: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC[External]
Quoted 15 lines · On Sat, 14 Sep 2024 20:21:56 +0200 Christophe JAILLET…
Le 12/09/2024 à 11:54, Mariel Tinaco a écrit :
Quoted 14 lines
The AD8460 is a “bits in, power out” high voltage, high-power, high-speed driver optimized for large output current (up to ±1 A) and high slew rate (up to ±1800 V/μs) at high voltage (up to ±40 V) into capacitive loads.
A digital engine implements user-configurable features: modes for digital input, programmable supply current, and fault monitoring and programmable protection settings for output current, output voltage, and junction temperature. The AD8460 operates on high voltage dual supplies up to ±55 V and a single low voltage supply of 5 V.
Signed-off-by: Mariel Tinaco <[email protected]>
---Rather than go around again, I fixed up all the comments made and the autobuilder issues then applied this.
Diff follows. The only bit I'm not 100% sure on was your intent with the temperature channel. I've made it an input but shout if I'm missing something.
Quoted 7 lines
With this diff applied on top, applied to the togreg branch of iio.git which is only pushed out as testing for now as I'll rebase on rc1 once available.
Thanks,
Jonathan
Hi Jonathan,
Thank you for finding the time to fix up the inline comments from the previous rounds! I have created a patch for that but was unable to send it yet because I'm still clueless about the temp channel. Apologies about that
About the temperature channel, it does make sense to set it as input since the value is read-only. About the implementation of the channel, I'm wondering what would happen if the consumer-get-channel would throw -EPROBE_DEFER half the time? Is it not possible to skip it over since the channel is optional anyway? Or does this defer error from the consumer mean that the other configurations for the succeeding attributes will be blocked, which is why we have to return probe instantly?
Or perhaps we can throw a warning instead if a defer error is thrown?
state->tmp_adc_channel = devm_iio_channel_get(dev, "ad8460-tmp");
if (IS_ERR(state->tmp_adc_channel)) {
state->tmp_adc_channel = NULL;
indio_dev->channels = ad8460_channels;
indio_dev->num_channels = ARRAY_SIZE(ad8460_channels);
} else {
ret = iio_get_channel_type(state->tmp_adc_channel, &temp);
if (ret < 0)
return ret;
if (temp != IIO_TEMP)
return dev_err_probe(dev, -EINVAL,
"Incompatible channel type %d\n", temp);
indio_dev->channels = ad8460_channels_with_tmp_adc;
indio_dev->num_channels = ARRAY_SIZE(ad8460_channels_with_tmp_adc);
}I also found other implementations where the type of channel is checked. Thought That maybe it's a good addition for security.
Thanks,
Mariel
kernel test robot
build botRe: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC
In reply to Mariel Tinacokernel test robot noticed the following build warnings:
Hi Mariel,
kernel test robot noticed the following build warnings:
[auto build test WARNING on fec496684388685647652ab4213454fbabdab099]
url: https://github.com/intel-lab-lkp/linux/commits/Mariel-Tinaco/dt-bindings-iio-dac-add-docs-for-ad8460/20240912-175718 base: fec496684388685647652ab4213454fbabdab099 patch link: https://lore.kernel.org/r/20240912095435.18639-3-Mariel.Tinaco%40analog.com patch subject: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC config: sparc-randconfig-r071-20240921 (https://download.01.org/0day-ci/archive/20240921/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 14.1.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
smatch warnings:drivers/iio/dac/ad8460.c:545 ad8460_write_event_value() warn: unsigned 'fault' is never less than zero. drivers/iio/dac/ad8460.c:545 ad8460_write_event_value() warn: error code type promoted to positive: 'fault' drivers/iio/dac/ad8460.c:567 ad8460_read_event_value() warn: unsigned 'fault' is never less than zero. drivers/iio/dac/ad8460.c:567 ad8460_read_event_value() warn: error code type promoted to positive: 'fault' drivers/iio/dac/ad8460.c:585 ad8460_write_event_config() warn: unsigned 'fault' is never less than zero. drivers/iio/dac/ad8460.c:585 ad8460_write_event_config() warn: error code type promoted to positive: 'fault' drivers/iio/dac/ad8460.c:605 ad8460_read_event_config() warn: unsigned 'fault' is never less than zero. drivers/iio/dac/ad8460.c:605 ad8460_read_event_config() warn: error code type promoted to positive: 'fault'
vim +/fault +545 drivers/iio/dac/ad8460.c
528
529 static int ad8460_write_event_value(struct iio_dev *indio_dev,
530 const struct iio_chan_spec *chan,
531 enum iio_event_type type,
532 enum iio_event_direction dir,
533 enum iio_event_info info, int val, int val2)
534 {
535 struct ad8460_state *state = iio_priv(indio_dev);
536 unsigned int fault;
537
538 if (type != IIO_EV_TYPE_THRESH)
539 return -EINVAL;
540
541 if (info != IIO_EV_INFO_VALUE)
542 return -EINVAL;
543
544 fault = ad8460_select_fault_type(chan->type, dir);
> 545 if (fault < 0)
546 return fault;
547
548 return ad8460_set_fault_threshold(state, fault, val);
549 }
550
551 static int ad8460_read_event_value(struct iio_dev *indio_dev,
552 const struct iio_chan_spec *chan,
553 enum iio_event_type type,
554 enum iio_event_direction dir,
555 enum iio_event_info info, int *val, int *val2)
556 {
557 struct ad8460_state *state = iio_priv(indio_dev);
558 unsigned int fault;
559
560 if (type != IIO_EV_TYPE_THRESH)
561 return -EINVAL;
562
563 if (info != IIO_EV_INFO_VALUE)
564 return -EINVAL;
565
566 fault = ad8460_select_fault_type(chan->type, dir);
> 567 if (fault < 0)
568 return fault;
569
570 return ad8460_get_fault_threshold(state, fault, val);
571 }
572
573 static int ad8460_write_event_config(struct iio_dev *indio_dev,
574 const struct iio_chan_spec *chan,
575 enum iio_event_type type,
576 enum iio_event_direction dir, int val)
577 {
578 struct ad8460_state *state = iio_priv(indio_dev);
579 unsigned int fault;
580
581 if (type != IIO_EV_TYPE_THRESH)
582 return -EINVAL;
583
584 fault = ad8460_select_fault_type(chan->type, dir);
> 585 if (fault < 0)
586 return fault;
587
588 return ad8460_set_fault_threshold_en(state, fault, val);
589 }
590
591 static int ad8460_read_event_config(struct iio_dev *indio_dev,
592 const struct iio_chan_spec *chan,
593 enum iio_event_type type,
594 enum iio_event_direction dir)
595 {
596 struct ad8460_state *state = iio_priv(indio_dev);
597 unsigned int fault;
598 bool en;
599 int ret;
600
601 if (type != IIO_EV_TYPE_THRESH)
602 return -EINVAL;
603
604 fault = ad8460_select_fault_type(chan->type, dir);
> 605 if (fault < 0) 606 return fault;
607
608 ret = ad8460_get_fault_threshold_en(state, fault, &en);
609 if (ret)
610 return ret;
611
612 return en;
613 }
614
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Jonathan Cameron
maintainerRe: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC
Quoted 30 lines · On Sat, 21 Sep 2024 09:11:12 +0800 kernel test robot <[email protected]> wrote:
Hi Mariel,
kernel test robot noticed the following build warnings:
[auto build test WARNING on
fec496684388685647652ab4213454fbabdab099]url: https://github.com/intel-lab-lkp/linux/commits/Mariel-Tinaco/dt-bindings-iio-dac-add-docs-for-ad8460/20240912-175718 base: fec496684388685647652ab4213454fbabdab099 patch link: https://lore.kernel.org/r/20240912095435.18639-3-Mariel.Tinaco%40analog.com patch subject: [PATCH v4 2/2] iio: dac: support the ad8460 Waveform DAC config: sparc-randconfig-r071-20240921 (https://download.01.org/0day-ci/archive/20240921/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 14.1.0If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/smatch warnings:
drivers/iio/dac/ad8460.c:545ad8460_write_event_value()warn: unsigned 'fault' is never less than zero.drivers/iio/dac/ad8460.c:545ad8460_write_event_value()warn: error code type promoted to positive: 'fault'drivers/iio/dac/ad8460.c:567ad8460_read_event_value()warn: unsigned 'fault' is never less than zero.drivers/iio/dac/ad8460.c:567ad8460_read_event_value()warn: error code type promoted to positive: 'fault'drivers/iio/dac/ad8460.c:585ad8460_write_event_config()warn: unsigned 'fault' is never less than zero.drivers/iio/dac/ad8460.c:585ad8460_write_event_config()warn: error code type promoted to positive: 'fault'drivers/iio/dac/ad8460.c:605ad8460_read_event_config()warn: unsigned 'fault' is never less than zero.drivers/iio/dac/ad8460.c:605ad8460_read_event_config()warn: error code type promoted to positive: 'fault'vim +/fault +545
drivers/iio/dac/ad8460.c
Quoted 9 lines
528
529 static int ad8460_write_event_value(struct iio_dev *indio_dev,
530 const struct iio_chan_spec *chan,
531 enum iio_event_type type,
532 enum iio_event_direction dir,
533 enum iio_event_info info, int val, int val2)
534 {
535 struct ad8460_state *state = iio_priv(indio_dev);
536 unsigned int fault;I fixed this up by making all the local fault variables int instead.
Jonathan
Quoted 79 lines
537 538 if (type != IIO_EV_TYPE_THRESH) 539 return -EINVAL; 540 541 if (info != IIO_EV_INFO_VALUE) 542 return -EINVAL; 543 544 fault = ad8460_select_fault_type(chan->type, dir);Quoted 1 line
545 if (fault < 0)
546 return fault; 547 548 return ad8460_set_fault_threshold(state, fault, val); 549 } 550 551 static int ad8460_read_event_value(struct iio_dev *indio_dev, 552 const struct iio_chan_spec *chan, 553 enum iio_event_type type, 554 enum iio_event_direction dir, 555 enum iio_event_info info, int *val, int *val2) 556 { 557 struct ad8460_state *state = iio_priv(indio_dev); 558 unsigned int fault; 559 560 if (type != IIO_EV_TYPE_THRESH) 561 return -EINVAL; 562 563 if (info != IIO_EV_INFO_VALUE) 564 return -EINVAL; 565 566 fault = ad8460_select_fault_type(chan->type, dir);Quoted 1 line
567 if (fault < 0)
568 return fault; 569 570 return ad8460_get_fault_threshold(state, fault, val); 571 } 572 573 static int ad8460_write_event_config(struct iio_dev *indio_dev, 574 const struct iio_chan_spec *chan, 575 enum iio_event_type type, 576 enum iio_event_direction dir, int val) 577 { 578 struct ad8460_state *state = iio_priv(indio_dev); 579 unsigned int fault; 580 581 if (type != IIO_EV_TYPE_THRESH) 582 return -EINVAL; 583 584 fault = ad8460_select_fault_type(chan->type, dir);Quoted 1 line
585 if (fault < 0)
586 return fault; 587 588 return ad8460_set_fault_threshold_en(state, fault, val); 589 } 590 591 static int ad8460_read_event_config(struct iio_dev *indio_dev, 592 const struct iio_chan_spec *chan, 593 enum iio_event_type type, 594 enum iio_event_direction dir) 595 { 596 struct ad8460_state *state = iio_priv(indio_dev); 597 unsigned int fault; 598 bool en; 599 int ret; 600 601 if (type != IIO_EV_TYPE_THRESH) 602 return -EINVAL; 603 604 fault = ad8460_select_fault_type(chan->type, dir);Quoted 1 line
605 if (fault < 0)
606 return fault; 607 608 ret = ad8460_get_fault_threshold_en(state, fault, &en); 609 if (ret) 610 return ret; 611 612 return en; 613 } 614