From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) (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 5474318E1F for ; Sat, 27 Dec 2025 17:51:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766857904; cv=none; b=jbGnfRrZphguibondxhISqxsy426+Zg6qM8mUfcK0wVS/Rb+1Mdgp1ecRl+eAZiTS3qy7GqLvM7jWqCtyT5o/Gn8nMOpmAZSR2M9B1NHIUOl4MYyxWDCOEH5yEKi65aqGVyPSkjMR355dyqmCmajR+EFC8L2W8HRFozoIxJzyPE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766857904; c=relaxed/simple; bh=Swu1AsoD2uKVKIsO16rFYanR9wkyI2Uyh69Ficn0+3k=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=eGOhiqxur0KGxa4Bxd9VieYM9yFNOv8HaQ1MqXQUVjtevEV2qyuX88RuR+/ZaTLNy0OfwajZ37MxN+ALDOOVaCDYeWE1fOOx4j/JL0kgs9wcVjnwZb4o+5PbcDUDmZTKAOAWXA3u9zprZ0CmctN+DQ+wKiS4auke15YCrIlD5Lw= 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=XazrX/3C; arc=none smtp.client-ip=209.85.217.43 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="XazrX/3C" Received: by mail-vs1-f43.google.com with SMTP id ada2fe7eead31-5dfaceec8deso5060694137.0 for ; Sat, 27 Dec 2025 09:51:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766857902; x=1767462702; 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=vmFzJPPSFZ71FHxxZJBuKnxU6e6Q71MdYKBIZQXMAjs=; b=XazrX/3CzQMYvbReDqM73WJlsCCM9wqN4jd6B7zfyvpXiiWyGurthpOqDbJoW9/BYE ATahx+qomKphxY0qIL2kI3dlsoFpRO6IUPFHjw0h3yJ45SroLJEEeH3YUA3kK/Y+nPVR 7KQ3DxXqKS7Zb99mPXbkPtIixxSBV/1PoAJDog4MVZZU1jPfGHPUxSFxYqzl1Xg9BXF9 tJ/dBBnYqOHk3WUX3QbP6mGQ0csP4Byzfi9E+ZtJFE/U1Rkc394qe9NY/Yhu6Vw3UzFp beAM67bhftAUXF8l7+vXbRYAXEaUSnaBT1klrRaSuLtryNv4pBtMU/1bJdYVVRQRxgVq 2zZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766857902; x=1767462702; 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=vmFzJPPSFZ71FHxxZJBuKnxU6e6Q71MdYKBIZQXMAjs=; b=WvYmyYaQD1YfNC1RNAJNlgd1IJnsOi8qbW4I3VIWll8wzY2RDZfU0yT/0TlSGK8t8h qwYQnvAE242Zz9rQDxjTsCCIM49kfLJRpgcIiR1IBAFB5OqHAXP6X6QWvg3dd7AVQPFv Fx67YZlhUrRRXiMZaODEqPEKg+rMKb674Yq3OUmk+7qYU0fVy9rD2YyLCxW2JQ76oHZe 2af9BTznJy1Vy+9tUJnVGZmrZWNNhzZo1dx1dITACetBSTiod8zQQvtYDaU8FA3w3qBU KktKs1+xmMDqjB5h5401X/GdgE/+5yrNsw7QvkUtqcUP/+aVc5PDlen+dHNnlwMthWpa kfUQ== X-Forwarded-Encrypted: i=1; AJvYcCWc7BaNudKgQSj/jy1AKe4SYR37OMgMlJEqB5I5M3Bb3t/uyyalf3/6UTMMFrP9aHAud0DVeMCQrNVrTgk=@vger.kernel.org X-Gm-Message-State: AOJu0Yxg3HLlxOU4cor966RWBc8nZrjKNsJNJOUSB+aBPe/+i80eA+sf 23RKcG0mAH7QGsrafRXN/UwYG9ZSYhV4G7JuR0AXxqQrenHkS/iHCr80 X-Gm-Gg: AY/fxX7JMzp2sexEbC4OhXqheSc8/8HlNNN1Aw3+0BRSRJBW1v859NaEw0tMbH6QETg +PGBTWN+DmsfX86fyzkgyayQiZ7392wlMNdpWV4aYjl/VQq0hKgXhv5LYo9B2ZMpzijCD7LM0tq ikV2GY/NefGN4mPPx1+boK3d1kAC6kPEFIbP3Xl2XjDwq3fxai8fo1wPa0oiReFAB3cyVjNOJdW YX21zCs1iApVu2lRnW5wJPmPQhvYkORaFw3+xBOvkYVv2wvik9Z17zw4NVuNujoHBAhV4O3irCe 2EFdU1t+LkM+7ZGbOGW+m6/taoucf2g9XIiTX7tGsz4+yehj6KUlo+mbsFEz/MIhO8FKomJ6Opk 4/Kfd+sMeZ0APKFjbD/JhvMXHOjRpdIZB57cIuytXg1KBt3QY1B+B+1JwLftmB7kvv8tn8B7Bsc KBbA== X-Google-Smtp-Source: AGHT+IGKy3LCwmWTq56Z8fUz0bj3S63XBFyo48A59tnEZ/yi1Ul7cN7lZGg0NVGTKJhH2jVih4glzw== X-Received: by 2002:a05:6102:5113:b0:5d7:dddd:5709 with SMTP id ada2fe7eead31-5eb181a50e7mr8023956137.0.1766857902259; Sat, 27 Dec 2025 09:51:42 -0800 (PST) Received: from localhost ([2800:bf0:82:11a2:7ac4:1f2:947b:2b6]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-5eb1ac64f63sm8447665137.10.2025.12.27.09.51.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 27 Dec 2025 09:51:41 -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 12:51:39 -0500 Message-Id: Cc: =?utf-8?q?Nuno_S=C3=A1?= , "Andy Shevchenko" , "Guenter Roeck" , "Jonathan Cameron" , , , Subject: Re: [PATCH v2 1/7] iio: core: Add and export __iio_dev_mode_lock() From: "Kurt Borja" To: "David Lechner" , "Kurt Borja" , "Andy Shevchenko" , "Lars-Peter Clausen" , "Michael Hennerich" , "Jonathan Cameron" , "Benson Leung" , "Antoniu Miclaus" , "Gwendal Grignou" , "Shrikant Raskar" , "Per-Daniel Olsson" X-Mailer: aerc 0.21.0-0-g5549850facc2 References: <20251211-lock-impr-v2-0-6fb47bdaaf24@gmail.com> <20251211-lock-impr-v2-1-6fb47bdaaf24@gmail.com> <92d07935-b2b5-4cf3-bd45-654d77cdc23b@baylibre.com> In-Reply-To: <92d07935-b2b5-4cf3-bd45-654d77cdc23b@baylibre.com> Hi David, On Tue Dec 23, 2025 at 12:19 PM -05, David Lechner wrote: > On 12/11/25 8:45 PM, Kurt Borja wrote: >> Add infallible wrappers around the internal IIO mode lock. > > Not sure what "infallible" is supposed to mean in this context. Maybe > referring to autocleanup? I meant wrappers that do not fail i.e. return void. Should I word it differently? > >>=20 >> As mentioned in the documentation, this is not meant to be used by >> drivers, instead this will aid in the eventual addition of cleanup >> classes around conditional locks. >>=20 >> Signed-off-by: Kurt Borja >> --- >> drivers/iio/industrialio-core.c | 30 ++++++++++++++++++++++++++++++ >> include/linux/iio/iio.h | 3 +++ >> 2 files changed, 33 insertions(+) >>=20 >> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-= core.c >> index f69deefcfb6f..1cce2d1ecef1 100644 >> --- a/drivers/iio/industrialio-core.c >> +++ b/drivers/iio/industrialio-core.c >> @@ -2171,6 +2171,36 @@ int __devm_iio_device_register(struct device *dev= , struct iio_dev *indio_dev, >> } >> EXPORT_SYMBOL_GPL(__devm_iio_device_register); >> =20 >> +/** >> + * __iio_dev_mode_lock - Locks the current IIO device mode >> + * @indio_dev: the iio_dev associated with the device >> + * >> + * If the device is either in direct or buffer mode, it's guaranteed to= stay >> + * that way until __iio_dev_mode_unlock() is called. >> + * >> + * This function is not meant to be used directly by drivers to protect= internal >> + * state, a driver should have it's own mechanisms for that matter. >> + * >> + * There are very few cases where a driver actually needs to lock any m= ode. It's >> + * *strongly* recommended to use iio_device_claim_direct() or > > I wouldn't even say "strongly recommend". Just say "use these instead". > > In the exceptions, likely the autocleanup version should be used as is > the case currently. Sure! --=20 ~ Kurt