From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B17733BBBB for ; Tue, 18 Nov 2025 11:02:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763463724; cv=none; b=a7OFP8RV1obakLdWQvZXbs5AlRSjvA40tPZ8JPrq5VIfkAsrK60yryNEBEQU/509NAEOprSwbeiRHRDSOU/ioyQprLADSnUDf/OGvtq2VbAPz5zryYDxPGZkAkKzC+IW17aScBSeeooiOMfhYhGBW/zMoUxnZ4HQ5BvyuGeb3tQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763463724; c=relaxed/simple; bh=dL91RMvArCj2oifh85PvRYipSwRchrvGh47W7uDfdvQ=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=TtA4383dfeAJh7FjlW8mCikygbfCBUrhkTtenqQ2eSpvMaDHToyENxEgsfTfvhCyJfpAzO7GJ8bv9OCtzgPIQp8Fi7Fr66vdfxwUqIPe+kwNThn0fICynye85WQqBkQea1NKrGOh+PjGnwC98D4CoLqDGeKZhoiMNucSj4GCbvU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=ZAtqTs4G; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="ZAtqTs4G" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-6418b55f86dso8554016a12.1 for ; Tue, 18 Nov 2025 03:02:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1763463720; x=1764068520; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:organization :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to; bh=dL91RMvArCj2oifh85PvRYipSwRchrvGh47W7uDfdvQ=; b=ZAtqTs4GeZdYTQ6pbX//tbLd0SBSXZvnGEKg7RZ0bYBC2lKJPt53pqTeDBWh+BWv4I TyKHAZofwAQbcy+s6DLefwTgT9mtS1JodREBBto1pjUGwQ2GoMcE9E8CHPXFh2wWwCm1 KWIwucdeXO5r+2TfQhLlVs7cmSv9icZhz+lcVGtgV92QvXTx7FieamFt0qSvdbP8WsjL dzR2k0yFIRcqYFwGF64ygobeCowaatTVH4mbCvE8lkr5Syk35khj8HM347RWpkVYeYvP 4Wpbm/SgHRiKGqsdW/0uYrU6M6mKmxmdmk28M7L6qgSu5urUghb3PTd5cy1Ei0BBg8QZ /GJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763463720; x=1764068520; h=mime-version:user-agent:content-transfer-encoding:organization :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dL91RMvArCj2oifh85PvRYipSwRchrvGh47W7uDfdvQ=; b=SwSUjOm9S59HwTUZ3bUWnxYhWcmfE0HiKLW8u9gBO7fqr/vLvKTUNL/JNFyq/swX56 ANXnQV6D8tI580tKVnFqn2FsmYjIpeIPnrS8LE+q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P64x/d7RD9bbU12Q== X-Received: by 2002:a17:907:94d6:b0:b65:b9fb:e4a7 with SMTP id a640c23a62f3a-b73677ed936mr1493042866b.9.1763463719592; Tue, 18 Nov 2025 03:01:59 -0800 (PST) Received: from [10.203.83.177] (mob-176-247-42-155.net.vodafone.it. [176.247.42.155]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b734fdaf30dsm1329665166b.60.2025.11.18.03.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 03:01:59 -0800 (PST) Message-ID: <82bf13fd5ada664d9e4fdbc3ee453204e55d318b.camel@baylibre.com> Subject: Re: [PATCH 8/9] iio: imu: st_lsm6dsx: add event configurability on a per axis basis From: Francesco Lavra To: Andy Shevchenko Cc: Lorenzo Bianconi , Jonathan Cameron , David Lechner , Nuno =?ISO-8859-1?Q?S=E1?= , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 18 Nov 2025 12:01:57 +0100 In-Reply-To: References: <20251030072752.349633-1-flavra@baylibre.com> <20251030072752.349633-9-flavra@baylibre.com> <5b23d077d8882d6b2a2e66817b1b6bcebc6bb5a2.camel@baylibre.com> Organization: BayLibre Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Tue, 2025-11-18 at 11:44 +0100, Andy Shevchenko wrote: > On Mon, Nov 17, 2025 at 08:23:35PM +0100, Francesco Lavra wrote: > > On Thu, 2025-10-30 at 15:56 +0200, Andy Shevchenko wrote: > > > On Thu, Oct 30, 2025 at 12:23:19PM +0100, Francesco Lavra wrote: > > > > On Thu, 2025-10-30 at 10:24 +0200, Andy Shevchenko wrote: > > > > > On Thu, Oct 30, 2025 at 08:27:51AM +0100, Francesco Lavra wrote: >=20 > ... >=20 > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0old_enable =3D hw->e= nable_event[event]; > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0new_enable =3D state= ? (old_enable | BIT(axis)) : > > > > > > (old_enable > > > > > > & > > > > > > ~BIT(axis)); > > > > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!!old_enable =3D= =3D !!new_enable) > > > > >=20 > > > > > This is an interesting check. So, old_enable and new_enable are > > > > > _not_ > > > > > booleans, right? > > > > > So, this means the check test if _any_ of the bit was set and > > > > > kept > > > > > set or > > > > > none were set > > > > > and non is going to be set. Correct? I think a short comment > > > > > would be > > > > > good to have. > > > >=20 > > > > old_enable and new_enable are bit masks, but we are only interested > > > > in > > > > whether any bit is set, to catch the cases where the bit mask goes > > > > from > > > > zero to non-zero and vice versa. Will add a comment. > > >=20 > > > If it's a true bitmask (assuming unsigned long type) then all this > > > can be > > > done > > > via bitmap API calls. Otherwise you can also compare a Hamming > > > weights of > > > them > > > (probably that gives even the same size of the object file, but !! > > > instructions > > > =C2=A0will be changed to hweight() calls (still a single assembly ins= tr on > > > modern > > > =C2=A0architectures). > >=20 > > These are u8 variables, so we can't use the bitmap API. >=20 > OK. But hweight8() can still be used. >=20 > > And I don't > > understand the reason for using hweight(), given that the !! operators > > would still be needed. >=20 > No, you won't need !! with that. I still don't understand. Are you proposing to replace `if (!!old_enable = =3D=3D !!new_enable)` with `if (hweight8(old_enable) =3D=3D hweight8(new_enable))`= ? That won't work, because we only need to check whether the Hamming weight goes from zero to non-zero and vice versa.