From patchwork Sun Jan 5 17:26:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13926692 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC13C8F6C for ; Sun, 5 Jan 2025 17:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736098053; cv=none; b=RS6ma5vnV8pcWEVGizbHS/muCFaB0XNR2xLzlCGGonDDQVPnlddGVE0Cqcnyl6jsHyHwGRREHrShZfIY15qk3WuhoyQaqqtWT8iKxTJfFuK42d8F8xY8NBK0qTozMHYlzF/K1sUbuxZi9jB+m6oZUcRlaJ/CoxcJV8q+F7TcFds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736098053; c=relaxed/simple; bh=efDmfrqpb35QgZd8qGvw16iYdHkWXdieufTb1POukhk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hHC5OncKWc/fNIf7P1BEFoFRLKtEOLz+3X14FsLP8P5rt6E8UcwwR9hmKjTKDFT0Y2ylZCEG4MP9246ScQwQ1a6acI3SKBkrULifwjJj37XDU+mDmqFx5QxNmJ50z3vynrSi/GkrLm3D2iH7SwPqD2oSZzV64dYUnk9pAx3O2Og= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FkB0j+/8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FkB0j+/8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08B6EC4CEDD; Sun, 5 Jan 2025 17:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736098053; bh=efDmfrqpb35QgZd8qGvw16iYdHkWXdieufTb1POukhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FkB0j+/8Ct9HDOnprcgTAipv6OSm8CU9J7fzn1KYSLhuOhzcnJP3rnM8awSbYR0s0 8Tuznd/pYTtQHm272mlPEvzBaPYAraGvET6IW50V9Y0blr/gvI9CuGIvnjWW+SdQMb dFSANpuooRGW9U7A8MMCQJ/7kdDWZCPTuq48klJAe3MGMchk1+u5q21H3I50bJiBKr t95i+LN2GPufCmbBHwGLV60uzDyoxHpvbAqyzFyX1Yv3wsUHWWcJKdhZq6WVFduLEz zc3siexIZsPncexpFvmIKr8OCoUx6Da7DP1yucyq6R5Y9VM6TrckKWwKA7iNJrvj1V 711aJkv5gymEw== From: Jonathan Cameron To: linux-iio@vger.kernel.org, =?utf-8?b?4oCcTHVjIFZhbiBPb3N0ZW5yeWNr4oCd?= Cc: David Lechner , Jonathan Cameron Subject: [RFC PATCH 27/27] iio: light: bh1745: Stop using iio_device_claim_direct_scoped() Date: Sun, 5 Jan 2025 17:26:12 +0000 Message-ID: <20250105172613.1204781-28-jic23@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250105172613.1204781-1-jic23@kernel.org> References: <20250105172613.1204781-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron This complex cleanup.h use case of conditional guards has proved to be more trouble that it is worth in terms of false positive compiler warnings and hard to read code. Move directly to the new claim/release_direct() that allow sparse to check for unbalanced context. Signed-off-by: Jonathan Cameron --- drivers/iio/light/bh1745.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/iio/light/bh1745.c b/drivers/iio/light/bh1745.c index 00a33760893e..a2f3df7f1818 100644 --- a/drivers/iio/light/bh1745.c +++ b/drivers/iio/light/bh1745.c @@ -426,16 +426,16 @@ static int bh1745_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: - iio_device_claim_direct_scoped(return -EBUSY, indio_dev) { - ret = regmap_bulk_read(data->regmap, chan->address, - &value, 2); - if (ret) - return ret; - *val = value; + if (!iio_device_claim_direct(indio_dev)) + return -EBUSY; - return IIO_VAL_INT; - } - unreachable(); + ret = regmap_bulk_read(data->regmap, chan->address, &value, 2); + iio_device_release_direct(indio_dev); + if (ret) + return ret; + *val = value; + + return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: { guard(mutex)(&data->lock);