From: Radu Sabau Date: Mon, 02 Nov 2026 11:25:38 +0200 Subject: [PATCH v5 2/8] iio: imu: adis: Add optional self_test callback MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20261102-adis16607-v5-2-4f98b0d271ac@analog.com> References: <20261102-adis16607-v5-0-4f98b0d271ac@analog.com> In-Reply-To: <20261102-adis16607-v5-0-4f98b0d271ac@analog.com> To: Lars-Peter Clausen , Michael Hennerich , Nuno Sa , Jonathan Cameron , David Lechner , Andy Shevchenko , Alexandru Ardelean , Radu Sabau , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux@analog.com, Jonathan Cameron X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1793611539; l=2180; i=radu.sabau@analog.com; s=20261001; h=from:subject:message-id; bh=tkzZy4kOyhyn9i1xmuSSgwdCRKGw+8zTfZiJqELNqH0=; b=oVEahSgG4RzTtjv74tBx8WYsbtF8LRQtXnEn7zbRWnRPrMx40EUB8Tps/VQ0ffhhz3OsTae59 ak0yZ5HsOgMBOAdnK/80bv8gbiGfmi1N+oE91aXWeprr/rmZGxK+OdS X-Developer-Key: i=radu.sabau@analog.com; a=ed25519; pk=XOZSO/Ut8qfYw7khL8lUF65Pgl+VLihISyS+Iy9jY8c= X-Endpoint-Received: by B4 Relay for radu.sabau@analog.com/20261001 with auth_id=1094 List-Id: B4 Relay Submissions Add an optional self_test callback to struct adis_data, for devices whose self-test doesn't fit the generic mask-write/sleep/check-status sequence. Purely additive: defaults to NULL, no change for existing drivers. Reviewed-by: Nuno Sá Signed-off-by: Radu Sabau --- drivers/iio/imu/adis.c | 3 +++ include/linux/iio/imu/adis.h | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c index 793e3b6b0ea7..5c3bb7259037 100644 --- a/drivers/iio/imu/adis.c +++ b/drivers/iio/imu/adis.c @@ -357,6 +357,9 @@ static int adis_self_test(struct adis *adis) int ret; const struct adis_timeout *timeouts = adis->data->timeouts; + if (adis->data->self_test) + return adis->data->self_test(adis); + ret = __adis_write_reg_16(adis, adis->data->self_test_reg, adis->data->self_test_mask); if (ret) { diff --git a/include/linux/iio/imu/adis.h b/include/linux/iio/imu/adis.h index 97323b8d1cb3..c09b381eb619 100644 --- a/include/linux/iio/imu/adis.h +++ b/include/linux/iio/imu/adis.h @@ -52,6 +52,12 @@ struct adis_timeout { * @self_test_mask: Bitmask of supported self-test operations * @self_test_reg: Register address to request self test command * @self_test_no_autoclear: True if device's self-test needs clear of ctrl reg + * @self_test: Optional device-specific self-test override. When set, + * it is called instead of the generic mask-write/sleep/ + * check-status sequence. The callback owns its own pass/fail + * determination entirely (it should call __adis_check_status() + * itself if it wants status-register checks). Must return 0 on + * success, a negative error code otherwise. * @status_error_msgs: Array of error messages * @status_error_mask: Bitmask of errors supported by the device * @timeouts: Chip specific delays @@ -82,6 +88,7 @@ struct adis_data { unsigned int self_test_mask; unsigned int self_test_reg; bool self_test_no_autoclear; + int (*self_test)(struct adis *adis); const struct adis_timeout *timeouts; const char * const *status_error_msgs; -- 2.43.0