From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9BCCB19D8BC; Sat, 12 Sep 2026 09:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789207077; cv=none; b=aGJfwRKayKgYk+Ssb54NCdBlR0//oate9YIPkGU2cmLu9Z0Bqi075fGT+J5DPxM/vAPB5pOhPwKHFstL2HLi+yOoQFv6hzbey5scBfN7lJHiFxDVfmwWBOgvPyLjvVn9Uc0vTVdcMLB3UhbGuKXtExZRrU9OU2DlcXAODiOdyYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789207077; c=relaxed/simple; bh=1eve+qJUOhBfcqjLypuVn1mgHXGM3e5KLiVAB6PBxBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q5fJYRMzqcPcOwt1MiI9JhSCqXPIGdASGBdp+m8XdQ8FmTBsq3dHXF1LosY2ZfLA9+9S4bnOCk+ICBq9wngcbynkMUOrWijGGwrRsZmozu42SR4pZUa7w91aoWMSayAOrK94mcf4qHFqgLxwNnS7QvU+uUsiklT3XKWKRZzqd6U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Geyhpwz6; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Geyhpwz6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFE331F000FF; Sat, 12 Sep 2026 09:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789207076; bh=A8hIULJocadGqmqSyQPESyjcrvaLMZpeyCG7YH+3BOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Geyhpwz66bCnlhDc1HYplFm8BDQJbiSeUvn6ZcUzbxGGYJ+Iyf2LdpCQRMsBO+yyk dpkQ7HQT6cj1T4UBGjaTyPl/nxo0OiBzqrW3w8tU6TyXdHj33Xvfcj9pHxQmDetP/k dXtlkjIzLq203dU98EoxulHAxcpi+rAvRkar5w2o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mert Seftali , Joshua Crofts , Jonathan Cameron , Sasha Levin Subject: [PATCH 6.18 0339/1518] iio: accel: dmard09: Implement IIO_CHAN_INFO_SCALE Date: Sat, 12 Sep 2026 08:41:48 +0200 Message-ID: <20260912065631.142340069@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065623.398859879@linuxfoundation.org> References: <20260912065623.398859879@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mert Seftali [ Upstream commit aa58ecc73466d0cb8c418de98e2225490bf600e3 ] Reading the in_accel_scale attribute on the DMARD09 has always returned -EINVAL: the channels advertise scale via info_mask_shared_by_type so the IIO core exposes the attribute, but dmard09_read_raw() only handles IIO_CHAN_INFO_RAW, so a SCALE read falls through to 'default: return -EINVAL': $ cat .../iio:deviceX/in_accel_scale cat: in_accel_scale: Invalid argument leaving userspace with raw counts it cannot convert to m/s^2. The driver was written from a vendor source [1] without a datasheet, and the scale was declared but never implemented. The vendor source carries the sensitivity: its conversion is acc = raw * GRAVITY_EARTH_1000 / sensitivity (then / 1000 -> m/s^2) with sensitivity = 32 and GRAVITY_EARTH_1000 = 9807 ("about (9.80665)*1000"), i.e. 32 counts correspond to 1 g. That sensitivity applies to the value this driver already reports as raw: the vendor reduces each 16-bit sample to a signed 9-bit value, and the preparation in dmard09_read_raw() yields the same value. It is self-consistent: 256 counts / 32 = 8 g full scale, matching the +/-8g range. Implement the scale derived from that sensitivity using standard gravity: scale = 9.80665 / 32 = 0.3064578125 m/s^2 per LSB Link: https://github.com/minstrelsy/mediatek/blob/1f49d8c87b839651bc89afc870277e8e0f2e2d55/custom/common/kernel/accelerometer/dmard09/dmard09.c [1] Fixes: a4fa6509dda4 ("iio: accel: add support for the Domintech DMARD09 3-axis accelerometer") Signed-off-by: Mert Seftali Reviewed-by: Joshua Crofts Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/accel/dmard09.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/accel/dmard09.c b/drivers/iio/accel/dmard09.c index d9290e3b9c464..5297ab2ee0bbe 100644 --- a/drivers/iio/accel/dmard09.c +++ b/drivers/iio/accel/dmard09.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #define DMARD09_DRV_NAME "dmard09" @@ -79,6 +80,12 @@ static int dmard09_read_raw(struct iio_dev *indio_dev, *val = accel; return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 0; + /* 1 g / 32 LSB, in m/s^2 */ + *val2 = IIO_G_TO_M_S_2(NANO / 32); + + return IIO_VAL_INT_PLUS_NANO; default: return -EINVAL; } -- 2.53.0