From nobody Tue Dec 2 00:44:26 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B833285CB8 for ; Mon, 24 Nov 2025 14:48:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995723; cv=none; b=PfzTa9o/plXKUjoEUhimRUMnzIYr9+OaG/6And+10vWa6wvnhRn2HPj/YmrHuhXURU911q7imydA38aRaAmH1HDcLwHWegqzRqHhL0+mHUmk6CKsRE2pryVMKVLg24rHUJUcRvMY0fbuqhn8tKH82ZgmReISX4rEQOMQqETZp90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995723; c=relaxed/simple; bh=OrkO7y9qnE72/Ku9E8D+eF1uBBKEPB6QSQT57rMvsiA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O4IMDbDTXI4LhbZRcdgIBLa85FlOcKR9DWZXozEkzcl6g7Vax9oJZTYxdKRx3hJ2APFqZDRKuxSALsZfwYUajphw7QChVj9Fz/s7sLDgQaDUzXLR4RWumH61iThWggK2iOvVHLPn0+N6r13SUG+TI/LXmsB2TlYjtK7QGEErjZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=iTAdJRrF; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="iTAdJRrF" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 47BFF4E4189F; Mon, 24 Nov 2025 14:48:40 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 18FD6606FC; Mon, 24 Nov 2025 14:48:40 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7610610371CD0; Mon, 24 Nov 2025 15:48:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763995718; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=F8s8iUypkLbmb7E4q/ez8SIGqplwHRkz5HZEnqvCcrQ=; b=iTAdJRrFz6tB5yGxtMdAXwwPA7rHaRL8aNQ9IZoj1ztl1GN3shjCEHg1eNYRP4wy3OqPc6 Lfft3bmKUOpt9SOdk89sXRNtOgkpefkuMWr+WTZK7YbGZg/LM//PSQ0P0zgSbqpzvkEizM CQyRYiGkYAR4nySLeoALu2Q4cVTm7aygel7Y6DXpJpcjYIURNsg8kdH22MT/3nOqwn8yXO WtRvvEfheJocg8q900i8GGHh9j88mUoOl3iHmvKjzktGZMMMh3RMMl+oQF/KWsxBSmOQKt 6Yt/AJOhIBJM/l/SO6U0LUuiEibx55TE/2oWGMARuVZ9vlPqRM5jrL0VU0+Muw== From: Romain Gantois Date: Mon, 24 Nov 2025 15:48:05 +0100 Subject: [PATCH v4 1/6] regulator: dt-bindings: Add Linear Technology LTM8054 regulator Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251124-ltm8054-driver-v4-1-107a8a814abe@bootlin.com> References: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> In-Reply-To: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Romain Gantois , Conor Dooley X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The Linear Technology LTM8054 is a Buck-Boost voltage regulator with an input range of 5V to 36V and an output range of 1.2V to 36V. The LTM8054's output voltage level is typically set using a voltage divider between the Vout and FB pins, the FB pin being constantly regulated to 1.2V. The output current limit of the LTM8054 may be statically set by placing a sense resistor on a dedicated pin. This limit can then be lowered by controlling the voltage level on the CTL pin. Describe the LTM8054 voltage regulator. Reviewed-by: Conor Dooley Signed-off-by: Romain Gantois --- .../devicetree/bindings/regulator/adi,ltm8054.yaml | 71 ++++++++++++++++++= ++++ MAINTAINERS | 5 ++ 2 files changed, 76 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/adi,ltm8054.yaml b= /Documentation/devicetree/bindings/regulator/adi,ltm8054.yaml new file mode 100644 index 000000000000..a982daecb4cf --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/adi,ltm8054.yaml @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/adi,ltm8054.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices LTM8054 buck-boost regulator + +maintainers: + - Romain Gantois + +description: + This regulator operates over an input voltage range of 5V to 36V, and can + output from 1.2V to 36V. The output voltage level is typically set with a + voltage divider between the Vout pin and the FB pin which is internally + regulated to 1.2V. + + The output current of the LTM8054 can be limited by tying the Iout pin t= o a + current sense resistor. This limit can be further lowered by applying a + voltage below 1.2V to the CTL pin. + +allOf: + - $ref: /schemas/regulator/regulator.yaml# + +properties: + compatible: + const: adi,ltm8054 + + enable-gpios: + description: GPIO connected to the RUN pin. + maxItems: 1 + + regulator-fb-voltage-divider-ohms: + description: Feedback voltage divider resistor values, in Ohms. + items: + - description: Top resistor value. + - description: Bottom resistor value. + + adi,iout-rsense-micro-ohms: + description: + Value of the output current sense resistor, in micro Ohms. + + io-channels: + items: + - description: DAC controlling the voltage level of the CTL pin. + + io-channel-names: + items: + - const: ctl + +required: + - compatible + - regulator-fb-voltage-divider-ohms + +additionalProperties: false + +examples: + - | + #include + regulator { + compatible =3D "adi,ltm8054"; + + enable-gpios =3D <&gpio0 1 GPIO_ACTIVE_HIGH>; + + regulator-fb-voltage-divider-ohms =3D <1000000 68000>; + + adi,iout-rsense-micro-ohms =3D <20000>; + + io-channels =3D <&dac 1>; + io-channel-names =3D "ctl"; + }; diff --git a/MAINTAINERS b/MAINTAINERS index b30cdbc270aa..01949aab8240 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14790,6 +14790,11 @@ W: https://ez.analog.com/linux-software-drivers F: Documentation/devicetree/bindings/i2c/i2c-mux-ltc4306.txt F: drivers/i2c/muxes/i2c-mux-ltc4306.c =20 +LTM8054 REGULATOR DRIVER +M: Romain Gantois +S: Maintained +F: Documentation/devicetree/bindings/regulator/adi,ltm8054.yaml + LTP (Linux Test Project) M: Andrea Cervesato M: Cyril Hrubis --=20 2.51.2 From nobody Tue Dec 2 00:44:26 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33825286422; Mon, 24 Nov 2025 14:48:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995734; cv=none; b=cX+YZJn9zKC8H58fd4WK5NDyE7+3bSWUtzwFFn3FNKWvyT0uwhAJvxFvwn5A+I5TSvv5PnlCyemT0eePfiK4nQ68rOi3hSOObM/+dVzUA5R7QWAvIRSn3ahDWGx+Q7c1Qk/aUcgtUPHBgeN5ZuUWuu9Ye4aXvsPyHOIHLlhvKpc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995734; c=relaxed/simple; bh=MfH+ba5rFK7YbxMJEgpK5w/53Z+k4FjMO/0FPjrOEco=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d19rAlmNhJgr/jPS+8db5zOJ5j9B2exD76b8UTFkUUMvFFqBvCJJdEYrmZoegxPfktVKB5eWni+JNoz7bR1QlJWLiQ88e9u0WIM4EoR+lby/I5yKD2guTobZef0ew17yCsfb+oMkATOixi9WGbe9N4/r3u2Sm3pHMGAwUp9wiV4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=hSOWr1+C; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="hSOWr1+C" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id AE2344E4189F; Mon, 24 Nov 2025 14:48:49 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 7DC0A60705; Mon, 24 Nov 2025 14:48:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 10B8410371DB6; Mon, 24 Nov 2025 15:48:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763995727; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=zX99y+3jl2A+hrrR+L5dM1jzTA4IKR5hV0mzPQKWS/M=; b=hSOWr1+CX0hzl9O6/wt8PZ3OTqbXB3IMETfc6tAB5tPn0k+t0o5DA2EeKa+RaL44lPWsgf gWZhUnCLraIhep2mIXv7U7hH+qzsLgbmj5cCZy1nsqBHJ/4gVgCWVPcSrheqIjDnlbikSk 3ygzZI9L35OQbaxdAkHW6PcjjTeM987wrUK9AP5HDiPwW6676ETLvt0fZO5+pBJUU4rQI5 LEx3y5eoI/yXp0CFg3Pu/5IjokDlml5egAdF0ZQqgcOPfGLHx+viH9cjEbLzYC9tddSANH B10rBSs8jEJgN2jyqKLn79wU1gO81aKsXfpXtErrCV9kmBjmmADgXK472Jojjg== From: Romain Gantois Date: Mon, 24 Nov 2025 15:48:06 +0100 Subject: [PATCH v4 2/6] iio: inkern: Use namespaced exports Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251124-ltm8054-driver-v4-2-107a8a814abe@bootlin.com> References: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> In-Reply-To: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Romain Gantois , MyungJoo Ham , Chanwoo Choi , Guenter Roeck , Peter Rosin , Mariel Tinaco , Lars-Peter Clausen , Michael Hennerich , Kevin Tsai , Linus Walleij , Dmitry Torokhov , Eugen Hristev , Vinod Koul , Kishon Vijay Abraham I , Sebastian Reichel , Chen-Yu Tsai , Support Opensource , Paul Cercueil , Iskren Chernev , Marek Szyprowski , Matheus Castello , Saravanan Sekar , Matthias Brugger , AngeloGioacchino Del Regno , Casey Connolly , =?utf-8?q?Pali_Roh=C3=A1r?= , Orson Zhai , Baolin Wang , Chunyan Zhang , Amit Kucheria , Thara Gopinath , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Claudiu Beznea , Jaroslav Kysela , Takashi Iwai , Sylwester Nawrocki , Olivier Moysan , Arnaud Pouliquen , Maxime Coquelin , Alexandre Torgue , Dixit Parmar , linux-hwmon@vger.kernel.org, linux-input@vger.kernel.org, linux-phy@lists.infradead.org, linux-pm@vger.kernel.org, linux-mips@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Use namespaced exports for IIO consumer API functions. To: MyungJoo Ham To: Chanwoo Choi To: Guenter Roeck To: Peter Rosin To: David Lechner To: Mariel Tinaco To: Lars-Peter Clausen To: Michael Hennerich To: Kevin Tsai To: Linus Walleij To: Dmitry Torokhov To: Eugen Hristev To: Vinod Koul To: Kishon Vijay Abraham I To: Sebastian Reichel To: Chen-Yu Tsai To: Support Opensource To: Paul Cercueil To: Iskren Chernev To: Marek Szyprowski To: Matheus Castello To: Saravanan Sekar To: Matthias Brugger To: AngeloGioacchino Del Regno To: Casey Connolly To: "Pali Roh=C3=A1r" To: Orson Zhai To: Baolin Wang To: Chunyan Zhang To: Amit Kucheria To: Thara Gopinath To: "Rafael J. Wysocki" To: Daniel Lezcano To: Zhang Rui To: Lukasz Luba To: Claudiu Beznea To: Jaroslav Kysela To: Takashi Iwai To: Sylwester Nawrocki To: Olivier Moysan To: Arnaud Pouliquen To: Maxime Coquelin To: Alexandre Torgue To: Dixit Parmar Cc: linux-kernel@vger.kernel.org Cc: linux-hwmon@vger.kernel.org Cc: linux-input@vger.kernel.org Cc: linux-phy@lists.infradead.org Cc: linux-pm@vger.kernel.org Cc: linux-mips@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org Cc: linux-arm-msm@vger.kernel.org Cc: linux-sound@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com Signed-off-by: Romain Gantois --- drivers/extcon/extcon-adc-jack.c | 1 + drivers/hwmon/iio_hwmon.c | 1 + drivers/hwmon/ntc_thermistor.c | 1 + drivers/iio/adc/envelope-detector.c | 1 + drivers/iio/afe/iio-rescale.c | 1 + drivers/iio/buffer/industrialio-buffer-cb.c | 1 + drivers/iio/buffer/industrialio-hw-consumer.c | 1 + drivers/iio/dac/ad8460.c | 1 + drivers/iio/dac/dpot-dac.c | 1 + drivers/iio/dac/ds4424.c | 1 + drivers/iio/inkern.c | 60 ++++++++++++---------= ---- drivers/iio/light/cm3605.c | 1 + drivers/iio/light/gp2ap002.c | 1 + drivers/iio/multiplexer/iio-mux.c | 1 + drivers/iio/potentiostat/lmp91000.c | 1 + drivers/iio/test/iio-test-multiply.c | 1 + drivers/input/joystick/adc-joystick.c | 1 + drivers/input/keyboard/adc-keys.c | 1 + drivers/input/touchscreen/colibri-vf50-ts.c | 1 + drivers/input/touchscreen/resistive-adc-touch.c | 1 + drivers/phy/motorola/phy-cpcap-usb.c | 1 + drivers/power/supply/ab8500_btemp.c | 1 + drivers/power/supply/ab8500_charger.c | 1 + drivers/power/supply/ab8500_fg.c | 1 + drivers/power/supply/axp20x_ac_power.c | 1 + drivers/power/supply/axp20x_battery.c | 1 + drivers/power/supply/axp20x_usb_power.c | 1 + drivers/power/supply/axp288_fuel_gauge.c | 1 + drivers/power/supply/cpcap-battery.c | 1 + drivers/power/supply/cpcap-charger.c | 1 + drivers/power/supply/da9150-charger.c | 1 + drivers/power/supply/generic-adc-battery.c | 1 + drivers/power/supply/ingenic-battery.c | 1 + drivers/power/supply/intel_dc_ti_battery.c | 1 + drivers/power/supply/lego_ev3_battery.c | 1 + drivers/power/supply/lp8788-charger.c | 1 + drivers/power/supply/max17040_battery.c | 1 + drivers/power/supply/mp2629_charger.c | 1 + drivers/power/supply/mt6370-charger.c | 1 + drivers/power/supply/qcom_smbx.c | 1 + drivers/power/supply/rn5t618_power.c | 1 + drivers/power/supply/rx51_battery.c | 1 + drivers/power/supply/sc27xx_fuel_gauge.c | 1 + drivers/power/supply/twl4030_charger.c | 1 + drivers/power/supply/twl4030_madc_battery.c | 1 + drivers/power/supply/twl6030_charger.c | 1 + drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 1 + drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 1 + drivers/thermal/renesas/rzg3s_thermal.c | 1 + drivers/thermal/thermal-generic-adc.c | 1 + sound/soc/codecs/audio-iio-aux.c | 1 + sound/soc/samsung/aries_wm8994.c | 1 + sound/soc/samsung/midas_wm1811.c | 1 + sound/soc/stm/stm32_adfsdm.c | 1 + 54 files changed, 83 insertions(+), 30 deletions(-) diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-j= ack.c index 7e3c9f38297b..e735f43dcdeb 100644 --- a/drivers/extcon/extcon-adc-jack.c +++ b/drivers/extcon/extcon-adc-jack.c @@ -210,3 +210,4 @@ module_platform_driver(adc_jack_driver); MODULE_AUTHOR("MyungJoo Ham "); MODULE_DESCRIPTION("ADC Jack extcon driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c index e376d4cde5ad..4c7843fbcc50 100644 --- a/drivers/hwmon/iio_hwmon.c +++ b/drivers/hwmon/iio_hwmon.c @@ -222,3 +222,4 @@ module_platform_driver(iio_hwmon_driver); MODULE_AUTHOR("Jonathan Cameron "); MODULE_DESCRIPTION("IIO to hwmon driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index d21f7266c411..417807fad80b 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c @@ -706,3 +706,4 @@ MODULE_DESCRIPTION("NTC Thermistor Driver"); MODULE_AUTHOR("MyungJoo Ham "); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:ntc-thermistor"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/adc/envelope-detector.c b/drivers/iio/adc/envelope= -detector.c index 5b16fe737659..fea20e7e6cd9 100644 --- a/drivers/iio/adc/envelope-detector.c +++ b/drivers/iio/adc/envelope-detector.c @@ -406,3 +406,4 @@ module_platform_driver(envelope_detector_driver); MODULE_DESCRIPTION("Envelope detector using a DAC and a comparator"); MODULE_AUTHOR("Peter Rosin "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c index ecaf59278c6f..d7f55109af3e 100644 --- a/drivers/iio/afe/iio-rescale.c +++ b/drivers/iio/afe/iio-rescale.c @@ -609,3 +609,4 @@ module_platform_driver(rescale_driver); MODULE_DESCRIPTION("IIO rescale driver"); MODULE_AUTHOR("Peter Rosin "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buff= er/industrialio-buffer-cb.c index 3e27385069ed..608ea9afc15a 100644 --- a/drivers/iio/buffer/industrialio-buffer-cb.c +++ b/drivers/iio/buffer/industrialio-buffer-cb.c @@ -153,3 +153,4 @@ EXPORT_SYMBOL_GPL(iio_channel_cb_get_iio_dev); MODULE_AUTHOR("Jonathan Cameron "); MODULE_DESCRIPTION("Industrial I/O callback buffer"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/buffer/industrialio-hw-consumer.c b/drivers/iio/bu= ffer/industrialio-hw-consumer.c index 526b2a8d725d..d7ff086ed783 100644 --- a/drivers/iio/buffer/industrialio-hw-consumer.c +++ b/drivers/iio/buffer/industrialio-hw-consumer.c @@ -211,3 +211,4 @@ EXPORT_SYMBOL_GPL(iio_hw_consumer_disable); MODULE_AUTHOR("Lars-Peter Clausen "); MODULE_DESCRIPTION("Hardware consumer buffer the IIO framework"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/dac/ad8460.c b/drivers/iio/dac/ad8460.c index 6e45686902dd..ad654819ca22 100644 --- a/drivers/iio/dac/ad8460.c +++ b/drivers/iio/dac/ad8460.c @@ -955,3 +955,4 @@ MODULE_AUTHOR("Mariel Tinaco "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index a8198ba4f98a..cfafee3159b1 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -321,3 +321,4 @@ MODULE_AUTHOR("Ismail H. Kose "); MODULE_AUTHOR("Vishal Sood "); MODULE_AUTHOR("David Jung "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 1e5eb5a41271..70b6f589f37a 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -71,7 +71,7 @@ int iio_map_array_register(struct iio_dev *indio_dev, con= st struct iio_map *maps iio_map_array_unregister_locked(indio_dev); return ret; } -EXPORT_SYMBOL_GPL(iio_map_array_register); +EXPORT_SYMBOL_NS_GPL(iio_map_array_register, "IIO_CONSUMER"); =20 /* * Remove all map entries associated with the given iio device @@ -81,7 +81,7 @@ int iio_map_array_unregister(struct iio_dev *indio_dev) guard(mutex)(&iio_map_list_lock); return iio_map_array_unregister_locked(indio_dev); } -EXPORT_SYMBOL_GPL(iio_map_array_unregister); +EXPORT_SYMBOL_NS_GPL(iio_map_array_unregister, "IIO_CONSUMER"); =20 static void iio_map_array_unregister_cb(void *indio_dev) { @@ -99,7 +99,7 @@ int devm_iio_map_array_register(struct device *dev, struc= t iio_dev *indio_dev, =20 return devm_add_action_or_reset(dev, iio_map_array_unregister_cb, indio_d= ev); } -EXPORT_SYMBOL_GPL(devm_iio_map_array_register); +EXPORT_SYMBOL_NS_GPL(devm_iio_map_array_register, "IIO_CONSUMER"); =20 static const struct iio_chan_spec *iio_chan_spec_from_name(const struct iio_dev *indio_dev, const char *name) @@ -281,7 +281,7 @@ struct iio_channel *fwnode_iio_channel_get_by_name(stru= ct fwnode_handle *fwnode, =20 return ERR_PTR(-ENODEV); } -EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name); +EXPORT_SYMBOL_NS_GPL(fwnode_iio_channel_get_by_name, "IIO_CONSUMER"); =20 static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev) { @@ -386,7 +386,7 @@ struct iio_channel *iio_channel_get(struct device *dev, =20 return iio_channel_get_sys(name, channel_name); } -EXPORT_SYMBOL_GPL(iio_channel_get); +EXPORT_SYMBOL_NS_GPL(iio_channel_get, "IIO_CONSUMER"); =20 void iio_channel_release(struct iio_channel *channel) { @@ -395,7 +395,7 @@ void iio_channel_release(struct iio_channel *channel) iio_device_put(channel->indio_dev); kfree(channel); } -EXPORT_SYMBOL_GPL(iio_channel_release); +EXPORT_SYMBOL_NS_GPL(iio_channel_release, "IIO_CONSUMER"); =20 static void devm_iio_channel_free(void *iio_channel) { @@ -418,7 +418,7 @@ struct iio_channel *devm_iio_channel_get(struct device = *dev, =20 return channel; } -EXPORT_SYMBOL_GPL(devm_iio_channel_get); +EXPORT_SYMBOL_NS_GPL(devm_iio_channel_get, "IIO_CONSUMER"); =20 struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev, struct fwnode_handle *fwnode, @@ -437,7 +437,7 @@ struct iio_channel *devm_fwnode_iio_channel_get_by_name= (struct device *dev, =20 return channel; } -EXPORT_SYMBOL_GPL(devm_fwnode_iio_channel_get_by_name); +EXPORT_SYMBOL_NS_GPL(devm_fwnode_iio_channel_get_by_name, "IIO_CONSUMER"); =20 struct iio_channel *iio_channel_get_all(struct device *dev) { @@ -506,7 +506,7 @@ struct iio_channel *iio_channel_get_all(struct device *= dev) iio_device_put(chans[i].indio_dev); return ERR_PTR(ret); } -EXPORT_SYMBOL_GPL(iio_channel_get_all); +EXPORT_SYMBOL_NS_GPL(iio_channel_get_all, "IIO_CONSUMER"); =20 void iio_channel_release_all(struct iio_channel *channels) { @@ -518,7 +518,7 @@ void iio_channel_release_all(struct iio_channel *channe= ls) } kfree(channels); } -EXPORT_SYMBOL_GPL(iio_channel_release_all); +EXPORT_SYMBOL_NS_GPL(iio_channel_release_all, "IIO_CONSUMER"); =20 static void devm_iio_channel_free_all(void *iio_channels) { @@ -541,7 +541,7 @@ struct iio_channel *devm_iio_channel_get_all(struct dev= ice *dev) =20 return channels; } -EXPORT_SYMBOL_GPL(devm_iio_channel_get_all); +EXPORT_SYMBOL_NS_GPL(devm_iio_channel_get_all, "IIO_CONSUMER"); =20 static int iio_channel_read(struct iio_channel *chan, int *val, int *val2, enum iio_chan_info_enum info) @@ -585,7 +585,7 @@ int iio_read_channel_raw(struct iio_channel *chan, int = *val) =20 return iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_RAW); } -EXPORT_SYMBOL_GPL(iio_read_channel_raw); +EXPORT_SYMBOL_NS_GPL(iio_read_channel_raw, "IIO_CONSUMER"); =20 int iio_read_channel_average_raw(struct iio_channel *chan, int *val) { @@ -597,7 +597,7 @@ int iio_read_channel_average_raw(struct iio_channel *ch= an, int *val) =20 return iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_AVERAGE_RAW); } -EXPORT_SYMBOL_GPL(iio_read_channel_average_raw); +EXPORT_SYMBOL_NS_GPL(iio_read_channel_average_raw, "IIO_CONSUMER"); =20 int iio_multiply_value(int *result, s64 multiplier, unsigned int type, int val, int val2) @@ -701,7 +701,7 @@ int iio_convert_raw_to_processed(struct iio_channel *ch= an, int raw, return iio_convert_raw_to_processed_unlocked(chan, raw, processed, scale); } -EXPORT_SYMBOL_GPL(iio_convert_raw_to_processed); +EXPORT_SYMBOL_NS_GPL(iio_convert_raw_to_processed, "IIO_CONSUMER"); =20 int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *va= l2, enum iio_chan_info_enum attribute) @@ -714,13 +714,13 @@ int iio_read_channel_attribute(struct iio_channel *ch= an, int *val, int *val2, =20 return iio_channel_read(chan, val, val2, attribute); } -EXPORT_SYMBOL_GPL(iio_read_channel_attribute); +EXPORT_SYMBOL_NS_GPL(iio_read_channel_attribute, "IIO_CONSUMER"); =20 int iio_read_channel_offset(struct iio_channel *chan, int *val, int *val2) { return iio_read_channel_attribute(chan, val, val2, IIO_CHAN_INFO_OFFSET); } -EXPORT_SYMBOL_GPL(iio_read_channel_offset); +EXPORT_SYMBOL_NS_GPL(iio_read_channel_offset, "IIO_CONSUMER"); =20 int iio_read_channel_processed_scale(struct iio_channel *chan, int *val, unsigned int scale) @@ -748,20 +748,20 @@ int iio_read_channel_processed_scale(struct iio_chann= el *chan, int *val, scale); } } -EXPORT_SYMBOL_GPL(iio_read_channel_processed_scale); +EXPORT_SYMBOL_NS_GPL(iio_read_channel_processed_scale, "IIO_CONSUMER"); =20 int iio_read_channel_processed(struct iio_channel *chan, int *val) { /* This is just a special case with scale factor 1 */ return iio_read_channel_processed_scale(chan, val, 1); } -EXPORT_SYMBOL_GPL(iio_read_channel_processed); +EXPORT_SYMBOL_NS_GPL(iio_read_channel_processed, "IIO_CONSUMER"); =20 int iio_read_channel_scale(struct iio_channel *chan, int *val, int *val2) { return iio_read_channel_attribute(chan, val, val2, IIO_CHAN_INFO_SCALE); } -EXPORT_SYMBOL_GPL(iio_read_channel_scale); +EXPORT_SYMBOL_NS_GPL(iio_read_channel_scale, "IIO_CONSUMER"); =20 static int iio_channel_read_avail(struct iio_channel *chan, const int **vals, int *type, int *length, @@ -790,7 +790,7 @@ int iio_read_avail_channel_attribute(struct iio_channel= *chan, =20 return iio_channel_read_avail(chan, vals, type, length, attribute); } -EXPORT_SYMBOL_GPL(iio_read_avail_channel_attribute); +EXPORT_SYMBOL_NS_GPL(iio_read_avail_channel_attribute, "IIO_CONSUMER"); =20 int iio_read_avail_channel_raw(struct iio_channel *chan, const int **vals, int *length) @@ -807,7 +807,7 @@ int iio_read_avail_channel_raw(struct iio_channel *chan, =20 return ret; } -EXPORT_SYMBOL_GPL(iio_read_avail_channel_raw); +EXPORT_SYMBOL_NS_GPL(iio_read_avail_channel_raw, "IIO_CONSUMER"); =20 static int iio_channel_read_max(struct iio_channel *chan, int *val, int *val2, int *type, @@ -863,7 +863,7 @@ int iio_read_max_channel_raw(struct iio_channel *chan, = int *val) =20 return iio_channel_read_max(chan, val, NULL, &type, IIO_CHAN_INFO_RAW); } -EXPORT_SYMBOL_GPL(iio_read_max_channel_raw); +EXPORT_SYMBOL_NS_GPL(iio_read_max_channel_raw, "IIO_CONSUMER"); =20 static int iio_channel_read_min(struct iio_channel *chan, int *val, int *val2, int *type, @@ -919,7 +919,7 @@ int iio_read_min_channel_raw(struct iio_channel *chan, = int *val) =20 return iio_channel_read_min(chan, val, NULL, &type, IIO_CHAN_INFO_RAW); } -EXPORT_SYMBOL_GPL(iio_read_min_channel_raw); +EXPORT_SYMBOL_NS_GPL(iio_read_min_channel_raw, "IIO_CONSUMER"); =20 int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *typ= e) { @@ -933,7 +933,7 @@ int iio_get_channel_type(struct iio_channel *chan, enum= iio_chan_type *type) =20 return 0; } -EXPORT_SYMBOL_GPL(iio_get_channel_type); +EXPORT_SYMBOL_NS_GPL(iio_get_channel_type, "IIO_CONSUMER"); =20 static int iio_channel_write(struct iio_channel *chan, int val, int val2, enum iio_chan_info_enum info) @@ -957,13 +957,13 @@ int iio_write_channel_attribute(struct iio_channel *c= han, int val, int val2, =20 return iio_channel_write(chan, val, val2, attribute); } -EXPORT_SYMBOL_GPL(iio_write_channel_attribute); +EXPORT_SYMBOL_NS_GPL(iio_write_channel_attribute, "IIO_CONSUMER"); =20 int iio_write_channel_raw(struct iio_channel *chan, int val) { return iio_write_channel_attribute(chan, val, 0, IIO_CHAN_INFO_RAW); } -EXPORT_SYMBOL_GPL(iio_write_channel_raw); +EXPORT_SYMBOL_NS_GPL(iio_write_channel_raw, "IIO_CONSUMER"); =20 unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan) { @@ -978,7 +978,7 @@ unsigned int iio_get_channel_ext_info_count(struct iio_= channel *chan) =20 return i; } -EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count); +EXPORT_SYMBOL_NS_GPL(iio_get_channel_ext_info_count, "IIO_CONSUMER"); =20 static const struct iio_chan_spec_ext_info * iio_lookup_ext_info(const struct iio_channel *chan, const char *attr) @@ -1013,7 +1013,7 @@ ssize_t iio_read_channel_ext_info(struct iio_channel = *chan, return ext_info->read(chan->indio_dev, ext_info->private, chan->channel, buf); } -EXPORT_SYMBOL_GPL(iio_read_channel_ext_info); +EXPORT_SYMBOL_NS_GPL(iio_read_channel_ext_info, "IIO_CONSUMER"); =20 ssize_t iio_write_channel_ext_info(struct iio_channel *chan, const char *a= ttr, const char *buf, size_t len) @@ -1027,7 +1027,7 @@ ssize_t iio_write_channel_ext_info(struct iio_channel= *chan, const char *attr, return ext_info->write(chan->indio_dev, ext_info->private, chan->channel, buf, len); } -EXPORT_SYMBOL_GPL(iio_write_channel_ext_info); +EXPORT_SYMBOL_NS_GPL(iio_write_channel_ext_info, "IIO_CONSUMER"); =20 ssize_t iio_read_channel_label(struct iio_channel *chan, char *buf) { @@ -1038,4 +1038,4 @@ ssize_t iio_read_channel_label(struct iio_channel *ch= an, char *buf) =20 return do_iio_read_channel_label(chan->indio_dev, chan->channel, buf); } -EXPORT_SYMBOL_GPL(iio_read_channel_label); +EXPORT_SYMBOL_NS_GPL(iio_read_channel_label, "IIO_CONSUMER"); diff --git a/drivers/iio/light/cm3605.c b/drivers/iio/light/cm3605.c index 0c17378e27d1..1bd11292d005 100644 --- a/drivers/iio/light/cm3605.c +++ b/drivers/iio/light/cm3605.c @@ -325,3 +325,4 @@ module_platform_driver(cm3605_driver); MODULE_AUTHOR("Linus Walleij "); MODULE_DESCRIPTION("CM3605 ambient light and proximity sensor driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c index a0d8a58f2704..04b1f6eade0e 100644 --- a/drivers/iio/light/gp2ap002.c +++ b/drivers/iio/light/gp2ap002.c @@ -717,3 +717,4 @@ module_i2c_driver(gp2ap002_driver); MODULE_AUTHOR("Linus Walleij "); MODULE_DESCRIPTION("GP2AP002 ambient light and proximity sensor driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/ii= o-mux.c index b742ca9a99d1..e193913f5af7 100644 --- a/drivers/iio/multiplexer/iio-mux.c +++ b/drivers/iio/multiplexer/iio-mux.c @@ -464,3 +464,4 @@ module_platform_driver(mux_driver); MODULE_DESCRIPTION("IIO multiplexer driver"); MODULE_AUTHOR("Peter Rosin "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/potentiostat/lmp91000.c b/drivers/iio/potentiostat= /lmp91000.c index eccc2a34358f..7d993f2acda4 100644 --- a/drivers/iio/potentiostat/lmp91000.c +++ b/drivers/iio/potentiostat/lmp91000.c @@ -423,3 +423,4 @@ module_i2c_driver(lmp91000_driver); MODULE_AUTHOR("Matt Ranostay "); MODULE_DESCRIPTION("LMP91000 digital potentiostat"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/iio/test/iio-test-multiply.c b/drivers/iio/test/iio-te= st-multiply.c index 432e279ffe5b..e4c497db4c79 100644 --- a/drivers/iio/test/iio-test-multiply.c +++ b/drivers/iio/test/iio-test-multiply.c @@ -210,3 +210,4 @@ MODULE_AUTHOR("Hans de Goede "); MODULE_DESCRIPTION("Test IIO multiply functions"); MODULE_LICENSE("GPL"); MODULE_IMPORT_NS("IIO_UNIT_TEST"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick= /adc-joystick.c index ff44f9978b71..4fa42f88bcfa 100644 --- a/drivers/input/joystick/adc-joystick.c +++ b/drivers/input/joystick/adc-joystick.c @@ -329,3 +329,4 @@ module_platform_driver(adc_joystick_driver); MODULE_DESCRIPTION("Input driver for joysticks connected over ADC"); MODULE_AUTHOR("Artur Rojek "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/input/keyboard/adc-keys.c b/drivers/input/keyboard/adc= -keys.c index f1753207429d..d687459a0c80 100644 --- a/drivers/input/keyboard/adc-keys.c +++ b/drivers/input/keyboard/adc-keys.c @@ -202,3 +202,4 @@ module_platform_driver(adc_keys_driver); MODULE_AUTHOR("Alexandre Belloni "); MODULE_DESCRIPTION("Input driver for resistor ladder connected on ADC"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/input/touchscreen/colibri-vf50-ts.c b/drivers/input/to= uchscreen/colibri-vf50-ts.c index 98d5b2ba63fb..89c4d7b2b89e 100644 --- a/drivers/input/touchscreen/colibri-vf50-ts.c +++ b/drivers/input/touchscreen/colibri-vf50-ts.c @@ -372,3 +372,4 @@ module_platform_driver(vf50_touch_driver); MODULE_AUTHOR("Sanchayan Maity"); MODULE_DESCRIPTION("Colibri VF50 Touchscreen driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/input/touchscreen/resistive-adc-touch.c b/drivers/inpu= t/touchscreen/resistive-adc-touch.c index 7e761ec73273..2fefd652864c 100644 --- a/drivers/input/touchscreen/resistive-adc-touch.c +++ b/drivers/input/touchscreen/resistive-adc-touch.c @@ -301,3 +301,4 @@ module_platform_driver(grts_driver); MODULE_AUTHOR("Eugen Hristev "); MODULE_DESCRIPTION("Generic ADC Resistive Touch Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/phy/motorola/phy-cpcap-usb.c b/drivers/phy/motorola/ph= y-cpcap-usb.c index 7cb020dd3423..9591672b0511 100644 --- a/drivers/phy/motorola/phy-cpcap-usb.c +++ b/drivers/phy/motorola/phy-cpcap-usb.c @@ -717,3 +717,4 @@ MODULE_ALIAS("platform:cpcap_usb"); MODULE_AUTHOR("Tony Lindgren "); MODULE_DESCRIPTION("CPCAP usb phy driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8= 500_btemp.c index e5202a7b6209..36b0c52a4b8b 100644 --- a/drivers/power/supply/ab8500_btemp.c +++ b/drivers/power/supply/ab8500_btemp.c @@ -829,3 +829,4 @@ MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Johan Palsson, Karl Komierowski, Arun R Murthy"); MODULE_ALIAS("platform:ab8500-btemp"); MODULE_DESCRIPTION("AB8500 battery temperature driver"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/a= b8500_charger.c index 5f4537766e5b..6e49d1b28254 100644 --- a/drivers/power/supply/ab8500_charger.c +++ b/drivers/power/supply/ab8500_charger.c @@ -3751,3 +3751,4 @@ MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Johan Palsson, Karl Komierowski, Arun R Murthy"); MODULE_ALIAS("platform:ab8500-charger"); MODULE_DESCRIPTION("AB8500 charger management driver"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500= _fg.c index 9dd99722667a..5fa559f796aa 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -3252,3 +3252,4 @@ MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Johan Palsson, Karl Komierowski"); MODULE_ALIAS("platform:ab8500-fg"); MODULE_DESCRIPTION("AB8500 Fuel Gauge driver"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/axp20x_ac_power.c b/drivers/power/supply/= axp20x_ac_power.c index 5f6ea416fa30..e9049d6229df 100644 --- a/drivers/power/supply/axp20x_ac_power.c +++ b/drivers/power/supply/axp20x_ac_power.c @@ -421,3 +421,4 @@ module_platform_driver(axp20x_ac_power_driver); MODULE_AUTHOR("Quentin Schulz "); MODULE_DESCRIPTION("AXP20X and AXP22X PMICs' AC power supply driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/a= xp20x_battery.c index 50ca8e110085..ee8701a6e907 100644 --- a/drivers/power/supply/axp20x_battery.c +++ b/drivers/power/supply/axp20x_battery.c @@ -1155,3 +1155,4 @@ module_platform_driver(axp20x_batt_driver); MODULE_DESCRIPTION("Battery power supply driver for AXP20X and AXP22X PMIC= s"); MODULE_AUTHOR("Quentin Schulz "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply= /axp20x_usb_power.c index e75d1e377ac1..599adcf84968 100644 --- a/drivers/power/supply/axp20x_usb_power.c +++ b/drivers/power/supply/axp20x_usb_power.c @@ -1080,3 +1080,4 @@ module_platform_driver(axp20x_usb_power_driver); MODULE_AUTHOR("Hans de Goede "); MODULE_DESCRIPTION("AXP20x PMIC USB power supply status driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/suppl= y/axp288_fuel_gauge.c index a3d71fc72064..c6897dd808fc 100644 --- a/drivers/power/supply/axp288_fuel_gauge.c +++ b/drivers/power/supply/axp288_fuel_gauge.c @@ -817,3 +817,4 @@ MODULE_AUTHOR("Ramakrishna Pallala "); MODULE_AUTHOR("Todd Brandt "); MODULE_DESCRIPTION("Xpower AXP288 Fuel Gauge Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/cpcap-battery.c b/drivers/power/supply/cp= cap-battery.c index 8106d1edcbc2..542c3c70e3cb 100644 --- a/drivers/power/supply/cpcap-battery.c +++ b/drivers/power/supply/cpcap-battery.c @@ -1176,3 +1176,4 @@ module_platform_driver(cpcap_battery_driver); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Tony Lindgren "); MODULE_DESCRIPTION("CPCAP PMIC Battery Driver"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/cpcap-charger.c b/drivers/power/supply/cp= cap-charger.c index d0c3008db534..89bc0fc3c9f8 100644 --- a/drivers/power/supply/cpcap-charger.c +++ b/drivers/power/supply/cpcap-charger.c @@ -977,3 +977,4 @@ MODULE_AUTHOR("Tony Lindgren "); MODULE_DESCRIPTION("CPCAP Battery Charger Interface driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:cpcap-charger"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/da9150-charger.c b/drivers/power/supply/d= a9150-charger.c index 27f36ef5b88d..58449df6068c 100644 --- a/drivers/power/supply/da9150-charger.c +++ b/drivers/power/supply/da9150-charger.c @@ -644,3 +644,4 @@ module_platform_driver(da9150_charger_driver); MODULE_DESCRIPTION("Charger Driver for DA9150"); MODULE_AUTHOR("Adam Thomson "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/sup= ply/generic-adc-battery.c index f5f2566b3a32..d18c8ee40405 100644 --- a/drivers/power/supply/generic-adc-battery.c +++ b/drivers/power/supply/generic-adc-battery.c @@ -298,3 +298,4 @@ module_platform_driver(gab_driver); MODULE_AUTHOR("anish kumar "); MODULE_DESCRIPTION("generic battery driver using IIO"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/ingenic-battery.c b/drivers/power/supply/= ingenic-battery.c index b111c7ce2be3..5be269f17bff 100644 --- a/drivers/power/supply/ingenic-battery.c +++ b/drivers/power/supply/ingenic-battery.c @@ -190,3 +190,4 @@ module_platform_driver(ingenic_battery_driver); MODULE_DESCRIPTION("Battery driver for Ingenic JZ47xx SoCs"); MODULE_AUTHOR("Artur Rojek "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/intel_dc_ti_battery.c b/drivers/power/sup= ply/intel_dc_ti_battery.c index 56b0c92e9d28..1a16ded563bc 100644 --- a/drivers/power/supply/intel_dc_ti_battery.c +++ b/drivers/power/supply/intel_dc_ti_battery.c @@ -387,3 +387,4 @@ MODULE_ALIAS("platform:" DEV_NAME); MODULE_AUTHOR("Hans de Goede "); MODULE_DESCRIPTION("Intel Dollar Cove (TI) battery driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/lego_ev3_battery.c b/drivers/power/supply= /lego_ev3_battery.c index 28454de05761..414816662b06 100644 --- a/drivers/power/supply/lego_ev3_battery.c +++ b/drivers/power/supply/lego_ev3_battery.c @@ -231,3 +231,4 @@ module_platform_driver(lego_ev3_battery_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("David Lechner "); MODULE_DESCRIPTION("LEGO MINDSTORMS EV3 Battery Driver"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/l= p8788-charger.c index f0a680c155c4..8c6ec98362d0 100644 --- a/drivers/power/supply/lp8788-charger.c +++ b/drivers/power/supply/lp8788-charger.c @@ -727,3 +727,4 @@ MODULE_DESCRIPTION("TI LP8788 Charger Driver"); MODULE_AUTHOR("Milo Kim"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:lp8788-charger"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply= /max17040_battery.c index c1640bc6accd..1fe658bfecc1 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -635,3 +635,4 @@ module_i2c_driver(max17040_i2c_driver); MODULE_AUTHOR("Minkyu Kang "); MODULE_DESCRIPTION("MAX17040 Fuel Gauge"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/mp2629_charger.c b/drivers/power/supply/m= p2629_charger.c index d281c1059629..ed49f9a04c8c 100644 --- a/drivers/power/supply/mp2629_charger.c +++ b/drivers/power/supply/mp2629_charger.c @@ -660,3 +660,4 @@ module_platform_driver(mp2629_charger_driver); MODULE_AUTHOR("Saravanan Sekar "); MODULE_DESCRIPTION("MP2629 Charger driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/mt6370-charger.c b/drivers/power/supply/m= t6370-charger.c index e6db961d5818..2d02fdf37d70 100644 --- a/drivers/power/supply/mt6370-charger.c +++ b/drivers/power/supply/mt6370-charger.c @@ -941,3 +941,4 @@ module_platform_driver(mt6370_chg_driver); MODULE_AUTHOR("ChiaEn Wu "); MODULE_DESCRIPTION("MediaTek MT6370 Charger Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/qcom_smbx.c b/drivers/power/supply/qcom_s= mbx.c index b1cb925581ec..63b88754155c 100644 --- a/drivers/power/supply/qcom_smbx.c +++ b/drivers/power/supply/qcom_smbx.c @@ -1050,3 +1050,4 @@ module_platform_driver(qcom_spmi_smb); MODULE_AUTHOR("Casey Connolly "); MODULE_DESCRIPTION("Qualcomm SMB2 Charger Driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/rn5t618_power.c b/drivers/power/supply/rn= 5t618_power.c index 40dec55a9f73..a3f30e390c11 100644 --- a/drivers/power/supply/rn5t618_power.c +++ b/drivers/power/supply/rn5t618_power.c @@ -821,3 +821,4 @@ module_platform_driver(rn5t618_power_driver); MODULE_ALIAS("platform:rn5t618-power"); MODULE_DESCRIPTION("Power supply driver for RICOH RN5T618"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/rx51_battery.c b/drivers/power/supply/rx5= 1_battery.c index b0220ec2d926..57266921dc8e 100644 --- a/drivers/power/supply/rx51_battery.c +++ b/drivers/power/supply/rx51_battery.c @@ -246,3 +246,4 @@ MODULE_ALIAS("platform:rx51-battery"); MODULE_AUTHOR("Pali Roh=C3=A1r "); MODULE_DESCRIPTION("Nokia RX-51 battery driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/suppl= y/sc27xx_fuel_gauge.c index a7ed9de8a289..1719ec4173e6 100644 --- a/drivers/power/supply/sc27xx_fuel_gauge.c +++ b/drivers/power/supply/sc27xx_fuel_gauge.c @@ -1350,3 +1350,4 @@ module_platform_driver(sc27xx_fgu_driver); =20 MODULE_DESCRIPTION("Spreadtrum SC27XX PMICs Fual Gauge Unit Driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/= twl4030_charger.c index 04216b2bfb6c..151f7b24e9b9 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -1144,3 +1144,4 @@ MODULE_AUTHOR("Gra=C5=BEvydas Ignotas"); MODULE_DESCRIPTION("TWL4030 Battery Charger Interface driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:twl4030_bci"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/twl4030_madc_battery.c b/drivers/power/su= pply/twl4030_madc_battery.c index 3935162e350b..9b3785d1643c 100644 --- a/drivers/power/supply/twl4030_madc_battery.c +++ b/drivers/power/supply/twl4030_madc_battery.c @@ -237,3 +237,4 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Lukas M=C3=A4rdian "); MODULE_DESCRIPTION("twl4030_madc battery driver"); MODULE_ALIAS("platform:twl4030_madc_battery"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/power/supply/twl6030_charger.c b/drivers/power/supply/= twl6030_charger.c index b4ec26ff257c..82911a811f4e 100644 --- a/drivers/power/supply/twl6030_charger.c +++ b/drivers/power/supply/twl6030_charger.c @@ -579,3 +579,4 @@ module_platform_driver(twl6030_charger_driver); =20 MODULE_DESCRIPTION("TWL6030 Battery Charger Interface driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qco= m/qcom-spmi-adc-tm5.c index d7f2e6ca92c2..bb6222c8cc5f 100644 --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c @@ -1069,3 +1069,4 @@ module_platform_driver(adc_tm5_driver); =20 MODULE_DESCRIPTION("SPMI PMIC Thermal Monitor ADC driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c b/drivers/thermal/= qcom/qcom-spmi-temp-alarm.c index f39ca0ddd17b..fb003ca96454 100644 --- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c +++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c @@ -904,3 +904,4 @@ module_platform_driver(qpnp_tm_driver); MODULE_ALIAS("platform:spmi-temp-alarm"); MODULE_DESCRIPTION("QPNP PMIC Temperature Alarm driver"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/thermal/renesas/rzg3s_thermal.c b/drivers/thermal/rene= sas/rzg3s_thermal.c index e25e36c99a88..7ced8f76a0ec 100644 --- a/drivers/thermal/renesas/rzg3s_thermal.c +++ b/drivers/thermal/renesas/rzg3s_thermal.c @@ -270,3 +270,4 @@ module_platform_driver(rzg3s_thermal_driver); MODULE_DESCRIPTION("Renesas RZ/G3S Thermal Sensor Unit Driver"); MODULE_AUTHOR("Claudiu Beznea "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/therma= l-generic-adc.c index 7c844589b153..cfdb8e674dd2 100644 --- a/drivers/thermal/thermal-generic-adc.c +++ b/drivers/thermal/thermal-generic-adc.c @@ -228,3 +228,4 @@ module_platform_driver(gadc_thermal_driver); MODULE_AUTHOR("Laxman Dewangan "); MODULE_DESCRIPTION("Generic ADC thermal driver using IIO framework with DT= "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/sound/soc/codecs/audio-iio-aux.c b/sound/soc/codecs/audio-iio-= aux.c index 588e48044c13..864a5a676495 100644 --- a/sound/soc/codecs/audio-iio-aux.c +++ b/sound/soc/codecs/audio-iio-aux.c @@ -312,3 +312,4 @@ module_platform_driver(audio_iio_aux_driver); MODULE_AUTHOR("Herve Codina "); MODULE_DESCRIPTION("IIO ALSA SoC aux driver"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/sound/soc/samsung/aries_wm8994.c b/sound/soc/samsung/aries_wm8= 994.c index 3723329b266d..b6f0f3c0d393 100644 --- a/sound/soc/samsung/aries_wm8994.c +++ b/sound/soc/samsung/aries_wm8994.c @@ -700,3 +700,4 @@ module_platform_driver(aries_audio_driver); MODULE_DESCRIPTION("ALSA SoC ARIES WM8994"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:aries-audio-wm8994"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/sound/soc/samsung/midas_wm1811.c b/sound/soc/samsung/midas_wm1= 811.c index 239e958b88d3..12c4962f901d 100644 --- a/sound/soc/samsung/midas_wm1811.c +++ b/sound/soc/samsung/midas_wm1811.c @@ -773,3 +773,4 @@ module_platform_driver(midas_driver); MODULE_AUTHOR("Simon Shields "); MODULE_DESCRIPTION("ASoC support for Midas"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS("IIO_CONSUMER"); diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c index c914d1c46850..dabcd2759187 100644 --- a/sound/soc/stm/stm32_adfsdm.c +++ b/sound/soc/stm/stm32_adfsdm.c @@ -407,3 +407,4 @@ MODULE_DESCRIPTION("stm32 DFSDM DAI driver"); MODULE_AUTHOR("Arnaud Pouliquen "); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" STM32_ADFSDM_DRV_NAME); +MODULE_IMPORT_NS("IIO_CONSUMER"); --=20 2.51.2 From nobody Tue Dec 2 00:44:26 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 733F6287276; Mon, 24 Nov 2025 14:48:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995733; cv=none; b=oHtuaSlFM1PKFPprb2114RFkykFgCS40H6cCEOdlcYOEX9BcGUwsrRhH2PAXAypnEwGPvHKWExaaKfNSwNfP/lh1kX4KhkyOZ68YtXplUs1aRlzvmUMAxLakaQciTgyFFh5oaC9+vEneAdFNNsyXXsTZUU7ne8JS3jJpZ+f9oXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995733; c=relaxed/simple; bh=2OU3XBZR/ypvsRf32D7ISP6bwNiqrP+3DRPVvliThS0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FbjnpsHMeR55rvxLhFrSDczn+mv4myoSEoWJXPo3kwlvmOaTj2rSRGCwW9+gRQ0IeZiYMyNW0d0OpXesX5ztUzW1ZeQavUUbV6NUoapnlnkb1XRjDs7EXPEx+d9Emwbk7WS5V6z5QOehjTtShxOC1Gkkk1YLe2And7ZsCH7lnW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=qC1F0Fx6; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="qC1F0Fx6" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 608E1C139AF; Mon, 24 Nov 2025 14:48:27 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 022A2606FC; Mon, 24 Nov 2025 14:48:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7B030103719DA; Mon, 24 Nov 2025 15:48:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763995728; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=zyUY+UF5WbIzqUe+eO/QgydzfxczM+858fxLCRThNrk=; b=qC1F0Fx6OVEFK/bZgOsQxDo2NwZyakJsBlpujOS3JFXQ6ZUutFuzSwTU6UXOQJ75JlnwKl e21tI+MfDcN4RMYY37xSjntPgbP080IM3c+6kUNkM8rNQkNMEXkz7ozzHygi8pdx5RmRVP 5cWiAswwIu+8DcgLS2KwMkI2l2Y1n2tIraGhYjI3xx/37EicW1sDtgF1W5uTxl4kYwMp58 t7vXFliVE5+d4rCfS1ckV9kL8/TiAXZbQ76k6+BFjq6Jt7LP3+2Mk8YOfz5pKE0Z1WL5Ow a6VfYE6xUdMlCRYb6JF4K07HE3hkopiX74+3Lp09SkTfSd9q7aqagICAcC1zTQ== From: Romain Gantois Date: Mon, 24 Nov 2025 15:48:07 +0100 Subject: [PATCH v4 3/6] iio: add processed write API Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251124-ltm8054-driver-v4-3-107a8a814abe@bootlin.com> References: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> In-Reply-To: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Romain Gantois X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Add a function to allow IIO consumers to write a processed value to a channel. Signed-off-by: Romain Gantois --- drivers/iio/inkern.c | 127 +++++++++++++++++++++++++++++++++++++++= ++++ include/linux/iio/consumer.h | 36 ++++++++++++ 2 files changed, 163 insertions(+) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 70b6f589f37a..6667e8e7648b 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -635,6 +635,54 @@ int iio_multiply_value(int *result, s64 multiplier, } EXPORT_SYMBOL_NS_GPL(iio_multiply_value, "IIO_UNIT_TEST"); =20 +int iio_divide_by_value(int *result, s64 numerator, + unsigned int type, int val, int val2) +{ + s64 tmp_num, tmp_den; + + switch (type) { + case IIO_VAL_INT: + tmp_num =3D numerator; + tmp_den =3D val; + break; + case IIO_VAL_INT_PLUS_MICRO: + tmp_num =3D numerator * MICRO; + /* Cast inside abs() to avoid undefined behavior if val* =3D=3D -INT_MIN= . */ + tmp_den =3D abs((s64)val) * MICRO + abs((s64)val2); + + if (val < 0 || val2 < 0) + tmp_num *=3D -1; + + break; + case IIO_VAL_INT_PLUS_NANO: + tmp_num =3D numerator * NANO; + tmp_den =3D abs((s64)val) * NANO + abs((s64)val2); + + if (val < 0 || val2 < 0) + tmp_num *=3D -1; + + break; + case IIO_VAL_FRACTIONAL: + tmp_num =3D (s64)numerator * (s64)val2; + tmp_den =3D val; + break; + case IIO_VAL_FRACTIONAL_LOG2: + tmp_num =3D (s64)numerator << val2; + tmp_den =3D val; + break; + default: + return -EINVAL; + } + + if (!tmp_den) + return -EDOM; + + *result =3D div64_s64(tmp_num, tmp_den); + + return IIO_VAL_INT; +} +EXPORT_SYMBOL_NS_GPL(iio_divide_by_value, "IIO_UNIT_TEST"); + static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, int raw, int *processed, unsigned int scale) @@ -703,6 +751,66 @@ int iio_convert_raw_to_processed(struct iio_channel *c= han, int raw, } EXPORT_SYMBOL_NS_GPL(iio_convert_raw_to_processed, "IIO_CONSUMER"); =20 +static int iio_convert_processed_to_raw_unlocked(struct iio_channel *chan, + int processed, int *raw, + unsigned int scale) +{ + int scale_type, scale_val, scale_val2; + int offset_type, offset_val, offset_val2; + int ret, half_step =3D 0; + + scale_type =3D iio_channel_read(chan, &scale_val, &scale_val2, + IIO_CHAN_INFO_SCALE); + if (scale_type >=3D 0) { + ret =3D iio_divide_by_value(raw, processed, scale_type, scale_val, scale= _val2); + if (ret < 0) + return ret; + } else { + *raw =3D processed; + } + + if (!scale) + return -EDOM; + + *raw =3D div_s64(*raw, scale); + + offset_type =3D iio_channel_read(chan, &offset_val, &offset_val2, + IIO_CHAN_INFO_OFFSET); + + switch (offset_type) { + case IIO_VAL_INT: + case IIO_VAL_INT_PLUS_MICRO: + half_step =3D MICRO / 2; + break; + case IIO_VAL_INT_PLUS_NANO: + half_step =3D NANO / 2; + break; + case IIO_VAL_FRACTIONAL: + offset_val =3D DIV_ROUND_CLOSEST(offset_val, offset_val2); + break; + case IIO_VAL_FRACTIONAL_LOG2: + offset_val >>=3D offset_val2; + break; + default: + if (offset_type >=3D 0) + return -EINVAL; + + offset_val =3D 0; + } + + /* Round fractional part to closest to reduce rounding bias. */ + if (half_step) { + if (offset_val2 >=3D half_step) + *raw -=3D 1; + else if (offset_val2 <=3D -half_step) + *raw +=3D 1; + } + + *raw -=3D offset_val; + + return 0; +} + int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *va= l2, enum iio_chan_info_enum attribute) { @@ -1039,3 +1147,22 @@ ssize_t iio_read_channel_label(struct iio_channel *c= han, char *buf) return do_iio_read_channel_label(chan->indio_dev, chan->channel, buf); } EXPORT_SYMBOL_NS_GPL(iio_read_channel_label, "IIO_CONSUMER"); + +int iio_write_channel_processed_scale(struct iio_channel *chan, int val, + unsigned int scale) +{ + struct iio_dev_opaque *iio_dev_opaque =3D to_iio_dev_opaque(chan->indio_d= ev); + int ret, processed; + + guard(mutex)(&iio_dev_opaque->info_exist_lock); + + if (!chan->indio_dev->info) + return -ENODEV; + + ret =3D iio_convert_processed_to_raw_unlocked(chan, val, &processed, scal= e); + if (ret) + return ret; + + return iio_channel_write(chan, processed, 0, IIO_CHAN_INFO_RAW); +} +EXPORT_SYMBOL_NS_GPL(iio_write_channel_processed_scale, "IIO_CONSUMER"); diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index a38b277c2c02..f80ab1b80234 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h @@ -399,6 +399,24 @@ int iio_read_channel_scale(struct iio_channel *chan, i= nt *val, int iio_multiply_value(int *result, s64 multiplier, unsigned int type, int val, int val2); =20 +/** + * iio_divide_by_value() - Divide by an IIO value + * @result: Destination pointer for the division result + * @numerator: Numerator. + * @type: One of the %IIO_VAL_* constants. This decides how the @val + * and @val2 parameters are interpreted. + * @val: Denominator. + * @val2: Denominator. @val2 use depends on type. + * + * Divide @numerator by an IIO value, storing the result as + * %IIO_VAL_INT. This is typically used for scaling. + * + * Returns: + * %IIO_VAL_INT on success or a negative error-number on failure. + */ +int iio_divide_by_value(int *result, s64 numerator, + unsigned int type, int val, int val2); + /** * iio_convert_raw_to_processed() - Converts a raw value to a processed va= lue * @chan: The channel being queried @@ -469,4 +487,22 @@ ssize_t iio_write_channel_ext_info(struct iio_channel = *chan, const char *attr, */ ssize_t iio_read_channel_label(struct iio_channel *chan, char *buf); =20 +/** + * iio_write_channel_processed_scale() - scale and write processed value t= o a given channel + * @chan: The channel being queried. + * @val: Value to write. + * @scale: Processed value is divided by this scale factor during the con= version. + * + * This function writes a processed value to a channel. A processed value = means + * that this value will have the correct unit and not some device internal + * representation. If the device does not support writing a processed valu= e, the + * function will query the channel's scale and offset and write an appropr= iately + * transformed raw value. + * + * Returns: + * 0 or a negative error-number on failure. + */ +int iio_write_channel_processed_scale(struct iio_channel *chan, int val, + unsigned int scale); + #endif --=20 2.51.2 From nobody Tue Dec 2 00:44:26 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0E3D284689; Mon, 24 Nov 2025 14:48:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995735; cv=none; b=CQLnWNBnHwbiQ+VyCbQtHPSNt9q5HFKhHNezX+59nTrWBaNgGMSY9sQwliM9amoTnDtfpRrd+9yQQNEWSVgYXSg/7O3WKn3VA+35MHAGIpQDmZCKLMC2Hv0gPIXiVJ5xPrdAV30/SaTCs1xCQTw0w1xTW2tH+19GUbC3hRi1n0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995735; c=relaxed/simple; bh=bvJnokLaOrHe39FFL+BmrzEKu3k2XcOLXxMeVHRy9t8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P4YtVBwryE0yncqXZec4MtuNt+lePKVujKEJ0WV/AL0NY3HL71NYVOh1fhYOZMG42TfO5pCCHZg+ySvNOjSL9AgEKJVOMTcSR85m8e1qayiFfo+lG5wBU1c1O+UlGRgaMU9t5XKjb24VXyFxnqJqpoYASQx+6SkRhzwdvPOMZks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=WU8lT8+b; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="WU8lT8+b" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id C8F03C139B0; Mon, 24 Nov 2025 14:48:28 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 69AD0606FC; Mon, 24 Nov 2025 14:48:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1DDB810371DB3; Mon, 24 Nov 2025 15:48:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763995730; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=H63DS5Qyocea77wCyQDu0pCJbvkP2TzyMGYozs1+550=; b=WU8lT8+biSXxVPcwa76IzJS8QFSzKZZikNL/OXw8xQgNfCjx1JZEjYNHxU2bgzwFDm5Yjg V4hlG6ZCSiC6oA+BbSrQgKahbxVFHTBacYp3i5wM8xC2JJ472zEAv3tbapWYrDUMopLg4p L0B6YcMSYjh/y16av7a5cAeD33vGqz20ZrACeZr0y1jom+j61O7KTYHGv+frP+qTs345ba kt7o8rjDiHyLHKHVIgfraInWEuBbMcJl3Imb+/CQf6X8DlKTzh8eGkphUowtLWyUw6KRJ5 TKFWQl9c9n474jxY2rdfV/q3UDEXKxYjQXFpezyy1RUa5uXQ+izRfFdVoLnazg== From: Romain Gantois Date: Mon, 24 Nov 2025 15:48:08 +0100 Subject: [PATCH v4 4/6] iio: test: Add kunit tests for iio_divide_by_value() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251124-ltm8054-driver-v4-4-107a8a814abe@bootlin.com> References: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> In-Reply-To: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Romain Gantois X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Add kunit tests for iio_divide_by_value(), these are similar to the existing tests for iio_multiply_value(), but the operand values used differ slightly. Signed-off-by: Romain Gantois --- drivers/iio/test/Kconfig | 12 ++ drivers/iio/test/Makefile | 1 + drivers/iio/test/iio-test-divide.c | 247 +++++++++++++++++++++++++++++++++= ++++ 3 files changed, 260 insertions(+) diff --git a/drivers/iio/test/Kconfig b/drivers/iio/test/Kconfig index 6e65e929791c..3aa1fc78966c 100644 --- a/drivers/iio/test/Kconfig +++ b/drivers/iio/test/Kconfig @@ -4,6 +4,18 @@ # =20 # Keep in alphabetical order +config IIO_DIVIDE_KUNIT_TEST + tristate "Test IIO division functions" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + build unit tests for the IIO division functions. + + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N. + config IIO_GTS_KUNIT_TEST tristate "Test IIO gain-time-scale helpers" if !KUNIT_ALL_TESTS depends on KUNIT diff --git a/drivers/iio/test/Makefile b/drivers/iio/test/Makefile index 0c846bc21acd..16344eedc46a 100644 --- a/drivers/iio/test/Makefile +++ b/drivers/iio/test/Makefile @@ -5,6 +5,7 @@ =20 # Keep in alphabetical order obj-$(CONFIG_IIO_RESCALE_KUNIT_TEST) +=3D iio-test-rescale.o +obj-$(CONFIG_IIO_DIVIDE_KUNIT_TEST) +=3D iio-test-divide.o obj-$(CONFIG_IIO_FORMAT_KUNIT_TEST) +=3D iio-test-format.o obj-$(CONFIG_IIO_GTS_KUNIT_TEST) +=3D iio-test-gts.o obj-$(CONFIG_IIO_MULTIPLY_KUNIT_TEST) +=3D iio-test-multiply.o diff --git a/drivers/iio/test/iio-test-divide.c b/drivers/iio/test/iio-test= -divide.c new file mode 100644 index 000000000000..99d759bd9591 --- /dev/null +++ b/drivers/iio/test/iio-test-divide.c @@ -0,0 +1,247 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Unit tests for IIO division functions + * + * Copyright (c) 2025 Bootlin + * Based on iio-test-multiply.c which is: + * Copyright (c) 2025 Hans de Goede + * Based on iio-test-format.c which is: + * Copyright (c) 2020 Lars-Peter Clausen + */ + +#include +#include +#include +#include + +static void __iio_test_iio_divide_by_integer(struct kunit *test, s64 numer= ator) +{ + int ret, result, val; + + val =3D 42; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT, val, 0); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator, val)); + + val =3D -23; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT, val, 0); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator, val)); + + val =3D 0; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT, val, 0); + KUNIT_EXPECT_EQ(test, ret, -EDOM); +} + +static void iio_test_iio_divide_by_integer(struct kunit *test) +{ + __iio_test_iio_divide_by_integer(test, 2000); + __iio_test_iio_divide_by_integer(test, -2000); +} + +static void __iio_test_iio_divide_by_fixedpoint(struct kunit *test, s64 nu= merator) +{ + int ret, result, val, val2; + + /* positive >=3D 1 (1.5) */ + val =3D 1; + val2 =3D 500000; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_MICRO, v= al, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * 10, 15)); + + val =3D 1; + val2 =3D 500000000; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_NANO, va= l, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * 10, 15)); + + /* positive < 1 (0.5) */ + val =3D 0; + val2 =3D 500000; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_MICRO, v= al, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * 10, 5)); + + val =3D 0; + val2 =3D 500000000; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_NANO, va= l, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * 10, 5)); + + /* negative <=3D -1 (-1.5) */ + val =3D -1; + val2 =3D 500000; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_MICRO, v= al, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * -10, 15)); + + val =3D -1; + val2 =3D 500000000; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_NANO, va= l, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * -10, 15)); + + /* negative > -1 (-0.5) */ + val =3D 0; + val2 =3D -500000; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_MICRO, v= al, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * -10, 5)); + + val =3D 0; + val2 =3D -500000000; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_NANO, va= l, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * -10, 5)); + + /* Zero */ + val =3D 0; + val2 =3D 0; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_MICRO, v= al, val2); + KUNIT_EXPECT_EQ(test, ret, -EDOM); + + val =3D 0; + val2 =3D 0; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_NANO, va= l, val2); + KUNIT_EXPECT_EQ(test, ret, -EDOM); + + /* Limits */ + val =3D INT_MIN; + val2 =3D 0; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_MICRO, v= al, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator, INT_MIN)); + + val =3D INT_MIN; + val2 =3D 0; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_NANO, va= l, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator, INT_MIN)); + + val =3D 0; + val2 =3D INT_MIN; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_MICRO, v= al, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(MICRO * numerator, INT_MIN)); + + val =3D 0; + val2 =3D INT_MIN; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_INT_PLUS_NANO, va= l, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(NANO * numerator, INT_MIN)); +} + +static void iio_test_iio_divide_by_fixedpoint(struct kunit *test) +{ + __iio_test_iio_divide_by_fixedpoint(test, 2000); + __iio_test_iio_divide_by_fixedpoint(test, -2000); +} + +static void __iio_test_iio_divide_by_fractional(struct kunit *test, s64 nu= merator) +{ + int ret, result, val, val2; + + /* positive < 1 (1/10)*/ + val =3D 1; + val2 =3D 10; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_FRACTIONAL, val, = val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * val2, val)); + + /* positive >=3D 1 (100/3)*/ + val =3D 100; + val2 =3D 3; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_FRACTIONAL, val, = val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * val2, val)); + + /* negative > -1 (-1/10) */ + val =3D -1; + val2 =3D 10; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_FRACTIONAL, val, = val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * val2, val)); + + /* negative <=3D -1 (-200/3)*/ + val =3D -200; + val2 =3D 3; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_FRACTIONAL, val, = val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64(numerator * val2, val)); + + /* Zero */ + val =3D 0; + val2 =3D 0; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_FRACTIONAL, val, = val2); + KUNIT_EXPECT_EQ(test, ret, -EDOM); +} + +static void iio_test_iio_divide_by_fractional(struct kunit *test) +{ + __iio_test_iio_divide_by_fractional(test, 2000); + __iio_test_iio_divide_by_fractional(test, -2000); +} + +static void __iio_test_iio_divide_by_fractional_log2(struct kunit *test, s= 64 numerator) +{ + int ret, result, val, val2; + + /* positive < 1 (123/1024) */ + val =3D 123; + val2 =3D 10; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_FRACTIONAL_LOG2, = val, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64((numerator * 1024), val)); + + /* positive >=3D 1 (1234567/1024) */ + val =3D 1234567; + val2 =3D 10; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_FRACTIONAL_LOG2, = val, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64((numerator * 1024), val)); + + /* negative > -1 (-123/1024) */ + val =3D -123; + val2 =3D 10; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_FRACTIONAL_LOG2, = val, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64((numerator * 1024), val)); + + /* negative <=3D -1 (-1234567/1024) */ + val =3D -1234567; + val2 =3D 10; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_FRACTIONAL_LOG2, = val, val2); + KUNIT_EXPECT_EQ(test, ret, IIO_VAL_INT); + KUNIT_EXPECT_EQ(test, result, div_s64((numerator * 1024), val)); + + /* Zero */ + val =3D 0; + val2 =3D 0; + ret =3D iio_divide_by_value(&result, numerator, IIO_VAL_FRACTIONAL_LOG2, = val, val2); + KUNIT_EXPECT_EQ(test, ret, -EDOM); +} + +static void iio_test_iio_divide_by_fractional_log2(struct kunit *test) +{ + __iio_test_iio_divide_by_fractional_log2(test, 2000); + __iio_test_iio_divide_by_fractional_log2(test, -2000); +} + +static struct kunit_case iio_divide_test_cases[] =3D { + KUNIT_CASE(iio_test_iio_divide_by_integer), + KUNIT_CASE(iio_test_iio_divide_by_fixedpoint), + KUNIT_CASE(iio_test_iio_divide_by_fractional), + KUNIT_CASE(iio_test_iio_divide_by_fractional_log2), + { } +}; + +static struct kunit_suite iio_divide_test_suite =3D { + .name =3D "iio-divide", + .test_cases =3D iio_divide_test_cases, +}; + +kunit_test_suite(iio_divide_test_suite); + +MODULE_AUTHOR("Romain Gantois "); +MODULE_DESCRIPTION("Test IIO division functions"); +MODULE_LICENSE("GPL"); --=20 2.51.2 From nobody Tue Dec 2 00:44:26 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4BF22D4B6D; Mon, 24 Nov 2025 14:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995737; cv=none; b=QRqwX5wv1Q8Qi/akudIHkD0dJfpZpIPDHMRIushbsjnEC7DOGUIsr5ZwkrlyN+FayK2N60WgxfhxvkLz3ijCzoJ4dLN98O70eXvXyESRrMjrnQJ8Q/skKyl7nrG9e13L0YW2FKux39JRJUm2Bhw9BMLTDmLCYB7NdzlxPvCw8Rc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995737; c=relaxed/simple; bh=0XXtFH5JTRu9GjlvApke3LBXNZd41+3sp9DO1muAbzk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ISUiL2XKAMDtL6o0ddRAfuG1a0mGLqthEXGV88bqgT/8FkE0vJJgBtrelw5eCGFWLJooYnJMlfEVDNjVj/sGUxNoFpBkqWYUoDeON+WqFE1GorKB8WW5Me4vWQ6U1SEVU6WlgA31hPSPyyclUQ5b4FvT+bwKaQvbMZme0TRmlno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ZwCjZDzH; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ZwCjZDzH" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id B3081C139B1; Mon, 24 Nov 2025 14:48:30 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 542B6606FC; Mon, 24 Nov 2025 14:48:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0988510371DA2; Mon, 24 Nov 2025 15:48:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763995732; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=61cfthlfsbdCdnzz/AbceXADf0E+18fSp8Ri+Oo2Qb0=; b=ZwCjZDzHomN+kRis1qXgWgXS/wKCVUhmF9RxzHi6SbeGZ308ZLdEG8Z58JRAF6LTW+4rzC nNbI5pN3SFjTG688OxB4xbfzgxNlH/8BStO37d0UuiSNaKhu1zdxKbQheLXGwXpOvynxqv ScW31K84CtB9lo9zFT8AimxCFgsndhGDU3ujN9oCXoMsVstu8dUoH1hwc3Pkc5D4xfYh7C OgnZXsiX8z33AX2eWEuCpXPzv7nWcUNwSZbrMlp+cDW8+uPRNgbCCvK0p6Lm0C/aMhXPA5 WVtiIqh5eGOrTdF/jCaBuozn+5VefavhuI/ylol1DZQL8fjhdhPVCJvK2jW0yw== From: Romain Gantois Date: Mon, 24 Nov 2025 15:48:09 +0100 Subject: [PATCH v4 5/6] regulator: Support the LTM8054 voltage regulator Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251124-ltm8054-driver-v4-5-107a8a814abe@bootlin.com> References: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> In-Reply-To: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Romain Gantois , Andy Shevchenko X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Add a stub driver for the Linear Technology LTM8054 Buck-Boost voltage regulator. This version only supports enabling/disabling the regulator via a GPIO, and reporting the output voltage level from the resistor divider values given in the device tree. Reviewed-by: Andy Shevchenko Signed-off-by: Romain Gantois --- MAINTAINERS | 1 + drivers/regulator/Kconfig | 8 +++ drivers/regulator/Makefile | 1 + drivers/regulator/ltm8054-regulator.c | 123 ++++++++++++++++++++++++++++++= ++++ 4 files changed, 133 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 01949aab8240..f8dfa965c11b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14794,6 +14794,7 @@ LTM8054 REGULATOR DRIVER M: Romain Gantois S: Maintained F: Documentation/devicetree/bindings/regulator/adi,ltm8054.yaml +F: drivers/regulator/ltm8054-regulator.c =20 LTP (Linux Test Project) M: Andrea Cervesato diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 0b2dac6f66ad..ab97025c8f94 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -595,6 +595,14 @@ config REGULATOR_LTC3676 This enables support for the LTC3676 8-output regulators controlled via I2C. =20 +config REGULATOR_LTM8054 + tristate "LTM8054 Buck-Boost voltage regulator" + help + This driver provides support for the Analog Devices LTM8054 + Buck-Boost micromodule regulator. The LTM8054 has an adjustable + output current limitation and a feedback pin for setting the + output voltage level. + config REGULATOR_MAX14577 tristate "Maxim 14577/77836 regulator" depends on MFD_MAX14577 diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 316a84ea92d4..f494a963e5de 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -72,6 +72,7 @@ obj-$(CONFIG_REGULATOR_LP8788) +=3D lp8788-ldo.o obj-$(CONFIG_REGULATOR_LP8755) +=3D lp8755.o obj-$(CONFIG_REGULATOR_LTC3589) +=3D ltc3589.o obj-$(CONFIG_REGULATOR_LTC3676) +=3D ltc3676.o +obj-$(CONFIG_REGULATOR_LTM8054) +=3D ltm8054-regulator.o obj-$(CONFIG_REGULATOR_MAX14577) +=3D max14577-regulator.o obj-$(CONFIG_REGULATOR_MAX1586) +=3D max1586.o obj-$(CONFIG_REGULATOR_MAX5970) +=3D max5970-regulator.o diff --git a/drivers/regulator/ltm8054-regulator.c b/drivers/regulator/ltm8= 054-regulator.c new file mode 100644 index 000000000000..c432b00d75a4 --- /dev/null +++ b/drivers/regulator/ltm8054-regulator.c @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Analog Devices LTM8054 Buck-Boost regulator driver + * + * Copyright (C) 2025 Bootlin + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* The LTM8054 regulates its FB pin to 1.2V */ +#define LTM8054_FB_uV 1200000 + +struct ltm8054_priv { + struct regulator_desc rdesc; +}; + +static int ltm8054_scale(unsigned int uV, u32 r1, u32 r2) +{ + u64 tmp; + + tmp =3D (u64)uV * r1; + do_div(tmp, r2); + + return uV + tmp; +} + +static const struct regulator_ops ltm8054_regulator_ops =3D { }; + +static int ltm8054_of_parse(struct device *dev, struct ltm8054_priv *priv, + struct regulator_config *config) +{ + u32 r[2]; + int ret; + + ret =3D device_property_read_u32_array(dev, "regulator-fb-voltage-divider= -ohms", + r, ARRAY_SIZE(r)); + if (ret) + return ret; + + priv->rdesc.fixed_uV =3D ltm8054_scale(LTM8054_FB_uV, r[0], r[1]); + priv->rdesc.min_uV =3D priv->rdesc.fixed_uV; + priv->rdesc.n_voltages =3D 1; + + config->of_node =3D dev_of_node(dev); + config->init_data =3D of_get_regulator_init_data(dev, + config->of_node, + &priv->rdesc); + if (!config->init_data) + return -EINVAL; + + config->ena_gpiod =3D devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LO= W); + if (IS_ERR(config->ena_gpiod)) + return PTR_ERR(config->ena_gpiod); + + return 0; +} + +static int ltm8054_probe(struct platform_device *pdev) +{ + struct regulator_config config =3D { }; + struct device *dev =3D &pdev->dev; + struct regulator_dev *rdev; + struct ltm8054_priv *priv; + int ret; + + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->rdesc.name =3D "ltm8054-regulator"; + priv->rdesc.ops =3D <m8054_regulator_ops; + priv->rdesc.type =3D REGULATOR_VOLTAGE; + priv->rdesc.owner =3D THIS_MODULE; + + config.dev =3D dev; + config.driver_data =3D priv; + + ret =3D ltm8054_of_parse(dev, priv, &config); + if (ret) + return dev_err_probe(dev, ret, "failed to parse device tree\n"); + + rdev =3D devm_regulator_register(dev, &priv->rdesc, &config); + if (IS_ERR(rdev)) + return dev_err_probe(dev, PTR_ERR(rdev), "failed to register regulator\n= "); + + return 0; +} + +static const struct of_device_id ltm8054_of_match[] =3D { + { .compatible =3D "adi,ltm8054" }, + {} +}; +MODULE_DEVICE_TABLE(of, ltm8054_of_match); + +static struct platform_driver ltm8054_driver =3D { + .probe =3D ltm8054_probe, + .driver =3D { + .name =3D "ltm8054", + .of_match_table =3D ltm8054_of_match, + }, +}; +module_platform_driver(ltm8054_driver); + +MODULE_DESCRIPTION("LTM8054 regulator driver"); +MODULE_AUTHOR("Romain Gantois "); +MODULE_LICENSE("GPL"); --=20 2.51.2 From nobody Tue Dec 2 00:44:26 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B42D26F2AD for ; Mon, 24 Nov 2025 14:48:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995738; cv=none; b=C7ZctuD+Ys5FDuZMMBQ6xXYjCyCqOhWqGdyAym2kMAzuXwwdS3HYhcL8QjoexphGq09XSBdJSmrU0LEdjgTILjwYSwt4mysT7XItBCcd0x9zyvFpPrhD38meZOqKS6rFYJJosD9vXCxfGjTKvnKfvigmDxPtcZzc15X+LWxBIFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763995738; c=relaxed/simple; bh=oep1bdWFRbFW7rlKaUYj86LsnLto/9YhZ3F1OTo86zk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JE+Qrq52x8kdZdDlxCycojQ8fq23aHgEgeVaHAIvIJF+3PcQbOnH8FckPn6jzihzQdRHfS/w8I0RTl2Z9UA1es6pp+RpkJRQO9hM2A5REYz/Fom/gKLu8Xz5nWlfp7cG+AERpJgK7EmwL4xOL/aXeYbZWyMgjJP+GwUds1/z5Mw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=a+Ore6GW; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="a+Ore6GW" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id C11C54E418A5 for ; Mon, 24 Nov 2025 14:48:54 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 938EA606FC; Mon, 24 Nov 2025 14:48:54 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D8CDF10371DB5; Mon, 24 Nov 2025 15:48:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763995733; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=E65SZmiDoU6jgob3AdJWifHU8CJmVyqhN7mABheg6DU=; b=a+Ore6GWJnT6PuoOWGUyrIBBpwetMqj+niV1fB//nICmsG/TAk48IonEARWIqoEr36/QDP 7PmsZJ1+uNEmW8eEmbbMYb4qBZlppqSRacrqbWBDMuvNlhQWMBhLD0Ec9RMt7N3DLjgpfW zpGjoI4MXS3Ux3FiyxujIRBr1mUM5x4+ynhslX8YQ9RMP0ApmGnY9PwGrawSv85UVuD4uy 3VQDklA2fekypOyObmxxGkB0ljKkbc/GXCtvGsFNs/+DIY0zvAP9TngW/zkxirAL4Gt4yl rz6dL+3QOdaKfGznYOEyhKWNdVRDMoMCV3UVdq6iXpawf71gsD0QJfCtBXRWIA== From: Romain Gantois Date: Mon, 24 Nov 2025 15:48:10 +0100 Subject: [PATCH v4 6/6] regulator: ltm8054: Support output current limit control Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251124-ltm8054-driver-v4-6-107a8a814abe@bootlin.com> References: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> In-Reply-To: <20251124-ltm8054-driver-v4-0-107a8a814abe@bootlin.com> To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: Thomas Petazzoni , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Romain Gantois X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The LTM8054 supports setting a fixed output current limit using a sense resistor connected to a dedicated pin. This limit can then be lowered dynamically by varying the voltage level of the CTL pin. Support controlling the LTM8054's output current limit. Signed-off-by: Romain Gantois --- drivers/regulator/Kconfig | 1 + drivers/regulator/ltm8054-regulator.c | 260 ++++++++++++++++++++++++++++++= +++- 2 files changed, 259 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index ab97025c8f94..7b70f640ba25 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -597,6 +597,7 @@ config REGULATOR_LTC3676 =20 config REGULATOR_LTM8054 tristate "LTM8054 Buck-Boost voltage regulator" + depends on IIO help This driver provides support for the Analog Devices LTM8054 Buck-Boost micromodule regulator. The LTM8054 has an adjustable diff --git a/drivers/regulator/ltm8054-regulator.c b/drivers/regulator/ltm8= 054-regulator.c index c432b00d75a4..4613f3f57860 100644 --- a/drivers/regulator/ltm8054-regulator.c +++ b/drivers/regulator/ltm8054-regulator.c @@ -6,6 +6,7 @@ */ =20 #include +#include #include #include #include @@ -13,12 +14,20 @@ #include #include #include +#include +#include +#include #include +#include #include +#include #include #include #include +#include #include +#include +#include =20 #include #include @@ -27,7 +36,36 @@ /* The LTM8054 regulates its FB pin to 1.2V */ #define LTM8054_FB_uV 1200000 =20 +/* Threshold voltage between the Vout and Iout pins which triggers current + * limiting. + */ +#define LTM8054_VOUT_IOUT_MAX_uV 58000 + +#define LTM8054_MAX_CTL_uV 1200000 +#define LTM8054_MIN_CTL_uV 50000 + +#define LTM8054_CTL_RW_TIMEOUT msecs_to_jiffies(500) + +/* CTL pin read/write transaction */ +struct ltm8054_ctl_pin_work { + struct work_struct work; + unsigned int ctl_val; + int ret; + bool write; +}; + struct ltm8054_priv { + struct device *dev; + + struct iio_channel *ctl_dac; + struct ltm8054_ctl_pin_work ctl_work; + /* Lock for ctl_work. */ + struct mutex ctl_work_lock; + struct completion ctl_rw_done; + + int min_uA; + int max_uA; + struct regulator_desc rdesc; }; =20 @@ -41,14 +79,198 @@ static int ltm8054_scale(unsigned int uV, u32 r1, u32 = r2) return uV + tmp; } =20 -static const struct regulator_ops ltm8054_regulator_ops =3D { }; +static void ltm8054_do_ctl_work(struct work_struct *work) +{ + struct ltm8054_ctl_pin_work *ctl_work =3D + container_of_const(work, struct ltm8054_ctl_pin_work, work); + struct ltm8054_priv *priv =3D + container_of_const(ctl_work, struct ltm8054_priv, ctl_work); + unsigned int val; + bool write; + int ret; + + lockdep_assert_not_held(&priv->ctl_work_lock); + + scoped_guard(mutex, &priv->ctl_work_lock) { + val =3D ctl_work->ctl_val; + write =3D ctl_work->write; + } + + /* Standard IIO voltage unit is mV, scale accordingly. */ + if (write) + ret =3D iio_write_channel_processed_scale(priv->ctl_dac, val, KILO); + else + ret =3D iio_read_channel_processed_scale(priv->ctl_dac, &val, KILO); + + dev_dbg(priv->dev, "%s CTL IO channel, val: %duV\n", str_write_read(write= ), val); + + scoped_guard(mutex, &priv->ctl_work_lock) { + ctl_work->ret =3D ret; + ctl_work->ctl_val =3D val; + } + + complete(&priv->ctl_rw_done); +} + +static int ltm8054_ctl_pin_rw(struct ltm8054_priv *priv, bool write, unsig= ned int *ctl_val) +{ + struct ltm8054_ctl_pin_work *ctl_work =3D &priv->ctl_work; + int ret; + + lockdep_assert_not_held(&priv->ctl_work_lock); + + /* + * The get/set_current_limit() callbacks have an active regulator core + * reservation ID (obtained with ww_acquire_init()). + * + * Or, the IO channel driver may call something like + * regulator_enable(), meaning this thread would acquire a new + * regulator core reservation ID before the current one is dropped + * (using ww_acquire_fini()). This is forbidden. + * + * Thus, perform the IO channel read/write in a different thread, and + * wait for it to complete, with a timeout to avoid deadlocking. + */ + + scoped_guard(mutex, &priv->ctl_work_lock) { + if (work_busy(&ctl_work->work)) + return -EBUSY; + + if (write) { + ctl_work->ctl_val =3D *ctl_val; + ctl_work->write =3D 1; + } else { + ctl_work->write =3D 0; + } + + schedule_work(&ctl_work->work); + } + + ret =3D wait_for_completion_timeout(&priv->ctl_rw_done, LTM8054_CTL_RW_TI= MEOUT); + reinit_completion(&priv->ctl_rw_done); + + if (unlikely(!ret)) + return -ETIMEDOUT; + + scoped_guard(mutex, &priv->ctl_work_lock) { + ret =3D ctl_work->ret; + + if (ret) + return ret; + + if (!write) + *ctl_val =3D ctl_work->ctl_val; + } + + return 0; +} + +static int ltm8054_set_current_limit(struct regulator_dev *rdev, int min_u= A, int max_uA) +{ + struct ltm8054_priv *priv =3D rdev_get_drvdata(rdev); + unsigned int ctl_val; + u64 vdac_uV; + + min_uA =3D clamp_t(int, min_uA, priv->min_uA, priv->max_uA); + + /* adjusted current limit =3D Rsense current limit * CTL pin voltage / ma= x CTL pin voltage */ + vdac_uV =3D (u64)min_uA * LTM8054_MAX_CTL_uV; + do_div(vdac_uV, priv->max_uA); + + dev_dbg(&rdev->dev, + "Setting current limit to %duA, CTL pin to %lluuV\n", min_uA, vdac_uV); + + ctl_val =3D vdac_uV; + + return ltm8054_ctl_pin_rw(priv, 1, &ctl_val); +} + +static int ltm8054_get_current_limit(struct regulator_dev *rdev) +{ + struct ltm8054_priv *priv =3D rdev_get_drvdata(rdev); + unsigned int ctl_val; + int ret; + u64 uA; + + ret =3D ltm8054_ctl_pin_rw(priv, 0, &ctl_val); + if (ret) + return ret; + + uA =3D (u64)ctl_val * priv->max_uA; + do_div(uA, LTM8054_MAX_CTL_uV); + + return uA; +} + +static const struct regulator_ops ltm8054_no_ctl_ops =3D { }; + +static const struct regulator_ops ltm8054_ctl_ops =3D { + .set_current_limit =3D ltm8054_set_current_limit, + .get_current_limit =3D ltm8054_get_current_limit, +}; + +static struct iio_channel *ltm8054_init_ctl_dac(struct platform_device *pd= ev) +{ + struct iio_channel *ctl_dac; + enum iio_chan_type type; + int ret; + + ctl_dac =3D devm_iio_channel_get(&pdev->dev, "ctl"); + if (IS_ERR(ctl_dac)) { + /* + * If the IO channel is not available yet, request probe retry. + * + * devm_iio_channel_get() will return ENODEV if it can't find + * the channel, which will happen if the channel's driver + * hasn't probed yet. If it returned any other error code, + * then something went wrong with the IO channel, don't retry. + */ + if (PTR_ERR(ctl_dac) =3D=3D -ENODEV) + return ERR_PTR(-EPROBE_DEFER); + + return ctl_dac; + } + + ret =3D iio_get_channel_type(ctl_dac, &type); + if (ret) + return ERR_PTR(ret); + + if (type !=3D IIO_VOLTAGE) + return ERR_PTR(-EINVAL); + + return ctl_dac; +} =20 static int ltm8054_of_parse(struct device *dev, struct ltm8054_priv *priv, struct regulator_config *config) { + u32 rsense; u32 r[2]; + u64 tmp; int ret; =20 + ret =3D device_property_read_u32(dev, "adi,iout-rsense-micro-ohms", &rsen= se); + if (ret) + return ret; + + if (rsense =3D=3D 0) + return -EINVAL; + + /* The maximum output current limit is the one set by the Rsense resistor= */ + tmp =3D (u64)LTM8054_VOUT_IOUT_MAX_uV * MICRO; + do_div(tmp, rsense); + priv->max_uA =3D tmp; + + /* + * Applying a voltage below LTM8054_MAX_CTL_uV on the CTL pin reduces + * the output current limit. If this level drops below + * LTM8054_MIN_CTL_uV the regulator stops switching. + */ + + tmp =3D (u64)priv->max_uA * LTM8054_MIN_CTL_uV; + do_div(tmp, LTM8054_MAX_CTL_uV); + priv->min_uA =3D tmp; + ret =3D device_property_read_u32_array(dev, "regulator-fb-voltage-divider= -ohms", r, ARRAY_SIZE(r)); if (ret) @@ -58,6 +280,9 @@ static int ltm8054_of_parse(struct device *dev, struct l= tm8054_priv *priv, priv->rdesc.min_uV =3D priv->rdesc.fixed_uV; priv->rdesc.n_voltages =3D 1; =20 + dev_dbg(dev, "max_uA: %d min_uA: %d fixed_uV: %d\n", + priv->max_uA, priv->min_uA, priv->rdesc.fixed_uV); + config->of_node =3D dev_of_node(dev); config->init_data =3D of_get_regulator_init_data(dev, config->of_node, @@ -72,23 +297,53 @@ static int ltm8054_of_parse(struct device *dev, struct= ltm8054_priv *priv, return 0; } =20 +static void ltm8054_cancel_ctl_work(void *ctl_work) +{ + cancel_work_sync(ctl_work); +} + static int ltm8054_probe(struct platform_device *pdev) { struct regulator_config config =3D { }; + struct iio_channel *ctl_dac =3D NULL; struct device *dev =3D &pdev->dev; struct regulator_dev *rdev; struct ltm8054_priv *priv; int ret; =20 + /* Do this first, as it might defer. */ + if (device_property_match_string(dev, "io-channel-names", "ctl") >=3D 0) { + ctl_dac =3D ltm8054_init_ctl_dac(pdev); + if (IS_ERR(ctl_dac)) + return dev_err_probe(dev, PTR_ERR(ctl_dac), + "failed to initialize CTL DAC\n"); + } + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; =20 + priv->dev =3D dev; priv->rdesc.name =3D "ltm8054-regulator"; - priv->rdesc.ops =3D <m8054_regulator_ops; + priv->rdesc.ops =3D <m8054_no_ctl_ops; priv->rdesc.type =3D REGULATOR_VOLTAGE; priv->rdesc.owner =3D THIS_MODULE; =20 + if (ctl_dac) { + priv->ctl_dac =3D ctl_dac; + + INIT_WORK(&priv->ctl_work.work, ltm8054_do_ctl_work); + init_completion(&priv->ctl_rw_done); + + devm_add_action_or_reset(priv->dev, ltm8054_cancel_ctl_work, &priv->ctl_= work.work); + + ret =3D devm_mutex_init(priv->dev, &priv->ctl_work_lock); + if (ret) + return ret; + + priv->rdesc.ops =3D <m8054_ctl_ops; + } + config.dev =3D dev; config.driver_data =3D priv; =20 @@ -121,3 +376,4 @@ module_platform_driver(ltm8054_driver); MODULE_DESCRIPTION("LTM8054 regulator driver"); MODULE_AUTHOR("Romain Gantois "); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS("IIO_CONSUMER"); --=20 2.51.2