From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 6FD4A341649 for ; Tue, 18 Nov 2025 11:02:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763463724; cv=none; b=tnjNRpg19lNU7qY8nkB54pWo3g4l649fNYkpl87OgEDneD8uLQGkeQvfFoXJ/2fhjm/REb4ToZSSptkQYjpDXugZ//qa95jUv/cQ/ZJ6qy/FP3vaRiOghor3EQAF2MMqsR5O15i9i1QxYhuQgxPIMTgnCWzJ0Lc/6f9bapnLl08= 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.42 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-f42.google.com with SMTP id 4fb4d7f45d1cf-640aaa89697so7062161a12.3 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=pHMInYO1Zt8aqx5NcRzFI/k8woqMNdjx+bckyvkclkdt/jvTsbRsLvOXctTg9pNbbJ 0BqNopzEDNkwU7uzLkXdd1/CfnEIZA88HAP5g85xyD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/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-kernel@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.