From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vs1-f53.google.com (mail-vs1-f53.google.com [209.85.217.53]) (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 ABB23322DC2 for ; Sat, 27 Dec 2025 18:08:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766858913; cv=none; b=d/4cx54LfF3Yt7Zs1ekz7C5NRpkZONc3d4datl78+MehIBk2ifz5q7XKGwubIpwyfYOtA6BNJ28Nv+Netnc0/+0P+7d3Cuw9lCDMhfr1ylDIBeurDSFExcyhhxvDzNbSQ7ufjdX29nfOIiXo3jq+vHbAU6ju4gK3gVlQ8G1Pd+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766858913; c=relaxed/simple; bh=b8VNWawuLEv2VOR0aC030ySiJTNbjx5/+mjSevhatXo=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=lPIpmZ9uUAECbMB48X9X78iKYN17Df2hQmQ19QVYXGb5dfjv9zf57g0DevzncG7ZUELXxoS0zAGeouMkv1IbkydpkAZAwz+BuuntgkSBIcC2iMfkcHbKGyvzVvqSWJ/lfHdtAAXc+7VCw5hCGxUD+ga1x6hj+BN25QPPwDKk4C0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HST2yVMk; arc=none smtp.client-ip=209.85.217.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HST2yVMk" Received: by mail-vs1-f53.google.com with SMTP id ada2fe7eead31-5e9d2ce037aso6074041137.0 for ; Sat, 27 Dec 2025 10:08:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766858910; x=1767463710; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=U7CS9a/UP1wGl2+5J10FtNTBbvnTiBPo4mSf3bNivDw=; b=HST2yVMkls/zTycsW/h9hQ6oFLgVauWSpOKIhZIgHlonsN+wOKfOzGdXlyePzttr7+ ry3/Cw4hhAlo/kUJCpF6jOzQzytbTHMjPtaXJDtvQJeqhwNAeMHJtlQxPzOY26ijWn76 lWLxbBzZJZr1iXzetl3un1BrQKWG3qhZAQB6+mIZ2+o/DETHGsaHpsI/5qvcUNwvR6SV Xmaz1OharUcpzNPHKVo+YbpQ4T7gCzHU1OcEJjTV4WmSrqLxfKJPc+sjffIwFbut0cnl Trd3QgEtXTL27+MOKkTjBihwGiO1UwCJxeCc2PP0FrUHteIP2oEo68UB84VRHeshNKG8 0NQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766858910; x=1767463710; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=U7CS9a/UP1wGl2+5J10FtNTBbvnTiBPo4mSf3bNivDw=; b=bAS2hxDXAoNa3zePjozOBAPHhWboDlZZFQbkoGhXR7EAtOkQlEQ13ZXDIEcK6XJA+O ulTzgTEvhpgolne0XASRX8IpOBDqj3s/BpFJ14hRzU3ApERF/2DFJcMJLq3VKmcWdNse nRJwmYxDBtBy1/7UEM2NwVQfTl3k/8LRZHwJOiVRWv9RZY+wMRQCTpOHi84E4wcArOu7 QpyS1ctIMvqHtB3DHnk5FKgkgUzLFI3rtRf6Gugcma2ee/H3j7leDm/X7XvywYxkd4F4 CMh+DaE8qEFq33r0JbotqFVBh0kd+RIzSfb6vg8WzVny6QWyk3A0WjYfMkP6hJh8Mtg6 2WAQ== X-Forwarded-Encrypted: i=1; AJvYcCXqM1js+02WYZvumPOehTVxQvRRdl7SspBM6U6Ip+W1XZ9Xo+TwEq9/GoSnrFmAIMd8lNf1wYqVRMEZhTI=@vger.kernel.org X-Gm-Message-State: AOJu0YytjIT4szH3lTtfoz/vZPKLiLH0qaG0LPV1zVC3o3Tdh8vRl/0R Yj+bscLvtU3jB/DUQzPZ7MJ/bNRAySksUIzm9NYo+XaTvDEXOt8NsLPW X-Gm-Gg: AY/fxX59wbZyElLhR15BbLb8d180HOwFNb6nj1sPhkXSZiQQnJWW+y3tm+hAInN4SuA bKtydqqMBWVDIHTCWYoDt11CaWUfwcKIW91yIzILvNWvQKTuSz3mhyT+/OIkQLR81BDCcbcUFC1 8gA4kwBo3xp8A3s2RofElfPl2Lubj1vgZJURPMoQg99s6Z/DlRV2CjHQNKXDV+K16zqBrYdne+Z /jBsDZZkAaGW5NcvK0MST9CZ7LmHvXu10MJ9RLZ8yHyMZetjEkTgO5nnn9TydnxE3aqgGcJo4QS cQwI1xkJb56T8tXKVFH5zInfS7q9V60+dYAKP8Tan418evBnDacG3HTlGVvj2qh9BIFi7l9nYcc PrZTIR59ydqBTqYy/o5i17e/QQlz1mD1B2FfujlgTE7QmOfwHxyZM67eUCuWbykhtF0L3HXI7RS akdWOU3C24/foY X-Google-Smtp-Source: AGHT+IHW7mZTpijQh1W0Vlb08EDOefDM9YQfhnD645lciF5cqOP+tlMO2IiZxFXvLAGGhdfgkwosEQ== X-Received: by 2002:a67:e702:0:b0:5de:31b1:1ffe with SMTP id ada2fe7eead31-5eb1a827522mr10343377137.32.1766858910355; Sat, 27 Dec 2025 10:08:30 -0800 (PST) Received: from localhost ([2800:bf0:82:11a2:7ac4:1f2:947b:2b6]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-9434176c1d3sm6868920241.9.2025.12.27.10.08.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Dec 2025 10:08:30 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sat, 27 Dec 2025 13:08:27 -0500 Message-Id: Cc: "Kurt Borja" , "Andy Shevchenko" , "Lars-Peter Clausen" , "Michael Hennerich" , "Benson Leung" , "Antoniu Miclaus" , "Gwendal Grignou" , "Shrikant Raskar" , "Per-Daniel Olsson" , =?utf-8?q?Nuno_S=C3=A1?= , "Andy Shevchenko" , "Guenter Roeck" , "Jonathan Cameron" , , , Subject: Re: [PATCH v2 4/7] iio: core: Add cleanup.h support for iio_device_claim_*() From: "Kurt Borja" To: "Jonathan Cameron" , "David Lechner" X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20251211-lock-impr-v2-0-6fb47bdaaf24@gmail.com> <20251211-lock-impr-v2-4-6fb47bdaaf24@gmail.com> <20251227145312.0f1c5f87@jic23-huawei> In-Reply-To: <20251227145312.0f1c5f87@jic23-huawei> On Sat Dec 27, 2025 at 9:53 AM -05, Jonathan Cameron wrote: > On Tue, 23 Dec 2025 11:23:24 -0600 > David Lechner wrote: > >> On 12/11/25 8:45 PM, Kurt Borja wrote: >> > Add guard classes for iio_device_claim_*() conditional locks. This wil= l >> > aid drivers write safer and cleaner code when dealing with some common >> > patterns. >> > =20 >>=20 >>=20 >> > These classes are not meant to be used directly by drivers (hence the >> > __priv__ prefix). Instead, documented wrapper macros are provided to >> > enforce the use of ACQUIRE() or guard() semantics and avoid the >> > problematic scoped guard. =20 >>=20 >> Would be useful to repeat this in a comment in the code. >>=20 > Given David did a much more thorough review than me I've just > added a few comments on top. Hi Jonathan, ... >> > +/** >> > + * IIO_DEV_ACQUIRE_BUFFER_MODE(_dev, _var) - Tries to acquire the buf= fer mode >> > + * lock with automatic rele= ase >> > + * @_dev: IIO device instance >> > + * @_var: Dummy variable identifier to store acquire result >> > + * >> > + * Tries to acquire the direct mode lock and automatically releases i= t at the >> > + * end of the scope. It most be paired with IIO_DEV_ACQUIRE_ERR(), fo= r example:: >> > + * >> > + * IIO_DEV_ACQUIRE_BUFFER_MODE(indio_dev, claim); >> > + * if (IIO_DEV_ACQUIRE_ERR(&claim)) >> > + * return IRQ_HANDLED; >> > + * >> > + * Context: Can sleep >> > + */ >> > +#define IIO_DEV_ACQUIRE_BUFFER_MODE(_dev, _var) \ >> > + ACQUIRE(__priv__iio_dev_mode_lock_try_buffer, _var)(_dev) > > This one doesn't actually have any users I think? Do we want to introduc= e > it without them? I'm not sure we do. I can drop it. I would personally keep it for completeness, but you're right, the buffer variant is very niche in general. --=20 ~ Kurt