From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (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 0E21626F296 for ; Sun, 18 Jan 2026 19:30:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768764618; cv=none; b=pz6u1JvidPnmSZKWQ+vR8DyZ26sz8q1cE0KVejfGDrhCItd8zbSgOCW3Gzxk6qWubYHCQ0n629gIkswtPPBtZRTCcgSGVHO+p0BY5UNxw9BAUbqlphTM1Ojd062aUE+SQQFDl7QHa1jvanSXDwi/RYuhjaPFPMBy842aydi2E2M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768764618; c=relaxed/simple; bh=XaDBiv5M+RFEv9IJJoFZ/qrG6BEziOBJceL/IH/8v2U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=OHa7N5I0a9HMNHy0U5lEcb7dzhHk9I1cC4MXqj9p8O+0DJta3Eo9hMd5/GQeM59xTimbF9jIAptyP3jqQeBC//9PSEc87Zn7+g0n9Aj+VTl8S6WFb4+ghTz5bvqQ155pLs3qvIf2Si0AIKjecy0gUxIyz0EE6kEeE6N6AGiPI4k= 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=vxSlQKDk; arc=none smtp.client-ip=209.85.161.41 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="vxSlQKDk" Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-65e94e128beso2373997eaf.0 for ; Sun, 18 Jan 2026 11:30:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1768764614; x=1769369414; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=FE91AlC+Wf3fpDTOpQTd2EcMaLnOUTf8XrrOstYz7Jk=; b=vxSlQKDkTk7lETeGBMO4B8ps+6pQeHm3jp/IaJq33J+5iTERlU9XfhmjrxR3aGCql0 z3xbn6vyA74w1NUqkaZW+sVSeBjeEp3BBWIp2xmS/zULhGY4DrmGZPdfRxC4vG+t5kYJ q+XPhe1sBB/mdTKX/iolVMPyyFDAOsZ/O1K/5Kx9m5S/M6uDy9NJs89W3l64eUD7hl3d xTqbC0frifoLq+l8bQAbqImquQJ/Cpi5xUk5u/zznS7ACSySAuTW1mADCDJfCn2NS/kJ Dpp1AVmAVu2090sFsgTDXC/IDbvHK9JNx3GriMM1Gz0JVJNh8LQzM7tPFy5RYjAruCj8 K00g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768764614; x=1769369414; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FE91AlC+Wf3fpDTOpQTd2EcMaLnOUTf8XrrOstYz7Jk=; b=a/EdgJBglUMoAnhFtkWB/+YhPco4QW3pjOIgzeRw9PFhLdvJGkzeyIvU8LsIE/FVbg D+bsbJD6MDIKtzM4d0J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:8ed8 with SMTP id 006d021491bc7-66118020948mr3526334eaf.12.1768764613766; Sun, 18 Jan 2026 11:30:13 -0800 (PST) Received: from ?IPV6:2600:8803:e7e4:500:d542:af69:64b6:f7df? ([2600:8803:e7e4:500:d542:af69:64b6:f7df]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-4044bd5d62csm5629835fac.19.2026.01.18.11.30.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 18 Jan 2026 11:30:12 -0800 (PST) Message-ID: Date: Sun, 18 Jan 2026 13:30:10 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 4/7] iio: core: Add cleanup.h support for iio_device_claim_*() To: Kurt Borja , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Benson Leung , Antoniu Miclaus , Gwendal Grignou , Shrikant Raskar , Per-Daniel Olsson Cc: =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , Guenter Roeck , Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev References: <20260106-lock-impr-v3-0-1db909b192c0@gmail.com> <20260106-lock-impr-v3-4-1db909b192c0@gmail.com> <27cf1ec1-545b-4e44-8229-852f8bdae116@baylibre.com> Content-Language: en-US From: David Lechner In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/18/26 9:23 AM, Kurt Borja wrote: > On Fri Jan 16, 2026 at 5:03 PM -05, David Lechner wrote: >> On 1/6/26 2:06 AM, Kurt Borja wrote: >>> Add guard classes for iio_device_claim_*() conditional locks. This will >>> aid drivers write safer and cleaner code when dealing with some common >>> patterns. >>> >>> 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. >>> >>> Suggested-by: Andy Shevchenko >>> Signed-off-by: Kurt Borja >>> --- >>> include/linux/iio/iio.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ >>> 1 file changed, 71 insertions(+) >>> >>> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h >>> index d8af0456f966..c795f731f2d8 100644 >>> --- a/include/linux/iio/iio.h >>> +++ b/include/linux/iio/iio.h >>> @@ -10,6 +10,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> #include >>> #include >>> #include >>> @@ -740,6 +741,76 @@ static inline bool iio_device_try_claim_buffer_mode(struct iio_dev *indio_dev) >>> */ >>> #define iio_device_release_buffer_mode(indio_dev) __iio_dev_mode_unlock(indio_dev) >>> >>> +/* >>> + * These classes are not meant to be used directly by drivers (hence the >>> + * __priv__ prefix). Instead, documented wrapper macros are provided bellow to >>> + * enforce the use of ACQUIRE() or guard() semantics and avoid the problematic >>> + * scoped guard variants. >>> + */ >>> +DEFINE_GUARD(__priv__iio_dev_mode_lock, struct iio_dev *, >>> + __iio_dev_mode_lock(_T), __iio_dev_mode_unlock(_T)); >>> +DEFINE_GUARD_COND(__priv__iio_dev_mode_lock, _try_direct, >>> + iio_device_claim_direct(_T)); >>> + >>> +/** >>> + * IIO_DEV_ACQUIRE_DIRECT_MODE(_dev, _var) - Tries to acquire the direct mode >>> + * lock with automatic release >> >> I don't think it is usual to put the function parameters in the >> doc comment like this. They don't match the actual names anyway. > > Hi David, > > This format of kernel-doc applies to function-like macros too [1]. I'll > match the name of the variables though. Right. And it has no parameters between the () on the first line in that documentation. /* * function_name() - Brief description of function. So it should be just `IIO_DEV_ACQUIRE_DIRECT_MODE() - ... > >> + * @dev: IIO device instance >> + * @claim: Variable identifier to store acquire result >> + * The parameters go below like this, which is already correct.