From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (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 0BD4C2DB7BE for ; Mon, 1 Jun 2026 16:52:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780332759; cv=none; b=GHF3dzeduUIr1DhQl9Hp/ejya0I98pcaeBVZhYDUVNrZOHRlMiD8G8MRTXlFDYiMi//VacxWQBBi4zQEOTpkQsov5a3zIUbIyj3HQalo93NpxoUD8wHGwKKNJEcgYYwYOVbtOMgpSHJW5sb6grSqGFvQGEQ5hZpFJCk42oox3A4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780332759; c=relaxed/simple; bh=nu+PU2gUjB9x+fLthGFREovw4Q33RRbgNLncpeP4XWc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nwl5R4nZBTIEE0Xf36Ty4DLHApyyMMrBLZYEByeHecPsDLjteZh8/AoXT+qCNCuzCdp6hkMdzmqvoor8Gr6FIoMfy8rC1Xc8iQ1rttaAM8RSS0eW0NkIoxrEibJ6ATBxEF9YpGC5LqJhYOBDqALT2PtRA5Qw+WsUVcYjMlbUebo= 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=GCmja8Zw; arc=none smtp.client-ip=209.85.167.179 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="GCmja8Zw" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-4855003fa6cso6501593b6e.3 for ; Mon, 01 Jun 2026 09:52:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780332757; x=1780937557; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=N9MsqFhxLpLjUS+B+U5UhID4RTVWC4OiYp1NX3pQYBM=; b=GCmja8ZwlRUIHm5dCk6TiQ/DT75WTp9cvMCR2SBy+uccsx3/q/JbDRxss2XGyYh+zU 9ySw1/bnxPlck+5AphwA0N84Rx+9nLR2ed4sLhDha2nXXdyjOP1OhoXifg43ofkMrzRn Gewjp/EoUYEyZJF5WLfq01IW2NVLD0cOinBMRKSzV/0J68O3Nk7+JSMjNIzzRUnr7bFk SflulRXCwRLj1W6Ta5/61Hdb0m+iqhWA7IR1L5RRpK8gD7gtiY6UPqU7+sRoDF/zawAY Eee6u4j0XGMt37AlUSuUKs/p3MBwsc0igXmEG0Y4Ao0yvONr5wMllLt0kn3MqR2zPl6U iiOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780332757; x=1780937557; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=N9MsqFhxLpLjUS+B+U5UhID4RTVWC4OiYp1NX3pQYBM=; b=syGGYhX9QPnkS49Ox93bO8IsCaydwIqcCrKFpqlSkIAwH++SX3gVp9JfWEQLmInDkl lgE4Y3LrSimXxwOnks+K4gGmuo0ir2isFVPM2ZNEgfu3VO/5FVnvLHETUfYRxP7Kl9Co 10XjxJoJb6vQsv1VdTGV1bVXX8V31eMkTL2nY4dEpOwqE13r1icjudZuK8ODwsBMJbQ+ 8Uu1PTKu535/lHaUt5viS+y8aElymmkVub/3AMP5jrKHr4OuPogXeTc5z4/spFtay3et EbQHj8ZlehLTUarHUY6k+HNzGRuoHVGk+XoV/yCOGtBawAlLbHG41q0EtOZ7FD09F++q 8KzQ== X-Forwarded-Encrypted: i=1; AFNElJ+zwTNiuzbrYanXNCGDAmsvXRa+2LZmsFWZt40hA2b0htow4c811KgGxMFj170IjGGkIOkgKpB+HBx/5M0=@vger.kernel.org X-Gm-Message-State: AOJu0YyIJIG3xpSGhDxl1qlBlVYs5YeRUwR9K+cgR1iPS/Ddk4DruUF/ FZzvtzBppSvycMGsdb69zdqA5wsexSzOEEoJqVBeYaDOyBmn18Guxz51 X-Gm-Gg: Acq92OEjlgXPJfyLgyzxdhDmYMgawTKPLfeMluWZ+yDcBy3v/sLqL8DSy3By3ZQbpXP dhj+Xyr1qJ3ei3ntDtYXWXmrAN6sMw6a0kw9nHIK7gCTL4S3VRTrn351KREopU2DKLm7/FQbL3i +x4rPi/WDE7afnyB0gWaz+Z26eCgUyzy4aibUXsvlCC39Yx5tbffAHZqXlaZr8i6lSNI7IREsKk D/2hA+Ioubs8IyjXYIa7uKNBZmFlIMy5i2yc2gmPlSaZL0RojWGSOIv+EUNDC4/norX+idID8q1 ckpeB2/sMKxVvFlxM6plFwRTc5nZT5ITLfHGdHFuJ8z+11ZlTgbkyHlA965hQZqrwqCws1K6aJG NpOgXPLIhxykcvATnARtuXRhBFCKOudAOjWZ4aJXH7RTV1c4b297f1miP/2yoDdeS8jGZ/8wIjs ho7moG80bE1PgghrZwKjZDQVtKNpan1Lw74TWbB8+4cmL5RtjQzzmRObD19UiafC0= X-Received: by 2002:a05:6808:c1a6:b0:467:1a69:d0be with SMTP id 5614622812f47-485fb47f366mr6604182b6e.32.1780332756955; Mon, 01 Jun 2026 09:52:36 -0700 (PDT) Received: from linuxescape (23-88-128-2.fttp.usinternet.com. [23.88.128.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-48606166287sm4481012b6e.12.2026.06.01.09.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2026 09:52:36 -0700 (PDT) Date: Mon, 1 Jun 2026 11:52:34 -0500 From: Maxwell Doose To: Markus Elfring Cc: linux-iio@vger.kernel.org, Jonathan Cameron , Joshua Crofts , LKML , Andy Shevchenko , David Lechner , Nuno =?UTF-8?B?U8Oh?= , Tomasz Duszynski Subject: Re: [PATCH v6] iio: chemical: scd30: Replace manual locking with RAII locking Message-ID: <20260601115234.36867d97@linuxescape> In-Reply-To: References: <20260531233828.60697-1-m32285159@gmail.com> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Markus, On Mon, 1 Jun 2026 17:38:44 +0200 Markus Elfring wrote: > > scd30_core.c currently uses manual mutex_lock() and mutex_unlock() > > calls. Replace them with the newer guard(mutex)() for cleaner RAII > > patterns and to improve maintainability. =20 > =E2=80=A6 > > In addition, small refactor to replace "?:" operator with regular > > if/else returns. =20 >=20 > How does such an information fit to a known patch requirement? > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/D= ocumentation/process/submitting-patches.rst?h=3Dv7.1-rc5#n81 >=20 Good point. However, I think that it's such a small change that nobody is going to care that much. We'll see what Jonathan has to say, I suppose. >=20 > =E2=80=A6 > > +++ b/drivers/iio/chemical/scd30_core.c > > @@ -368,11 +368,13 @@ static ssize_t calibration_auto_enable_show(struc= t device *dev, struct device_at > > int ret; > > u16 val; > > =20 > > - mutex_lock(&state->lock); > > - ret =3D scd30_command_read(state, CMD_ASC, &val); > > - mutex_unlock(&state->lock); > > + guard(mutex)(&state->lock); > > =20 > > - return ret ?: sysfs_emit(buf, "%d\n", val); =20 > =E2=80=A6 >=20 > How do you think about to preserve lock scopes by using scoped_guard() ca= lls? >=20 Generally scoped_guard() (at least in my experience in iio) is frowned upon because of the hidden for loop that can make normal things (e.g., break, continue) really weird, plus guard()() with {} is also (in my experience) more popular over scoped_guard(). In the past helpers have also been liked over both as well. --=20 best regards, max