From patchwork Sun Feb 9 18:06:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13967055 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 6E796243368 for ; Sun, 9 Feb 2025 18:09:04 +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=1739124544; cv=none; b=VorLvHKnYkho4Lv+RXDlruwoAEK36h16Pmo4sbSTpSe0pfbiciQ0yVoVfFfkAKe2sCX+cHmiBvE1pMuiSaxkwuJHolCXw/TuwGgGeDsFTC4RmT9jV/jhIA8ND7ar3OQX4vT3RaysUWn4CPOahNIBBP/YjW6xmgIb9ylh12jOA0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739124544; c=relaxed/simple; bh=Ilw3bhepF3JuY6FM1vMKHMhrhwxF5uDqtVL265Ma1vI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OCExtYcTEYa0avXniEW0aQOyVonBrTtPk3RImLjvDInDk6w+LyGX1Vo/xNc2VkA9qooGQEWO68NWODXeyfNTojITtV1+fG+2RFYww9oqqaaKf+HDaySBUZbdGu40nUr0HLMiUE86zpNSe+XNFrfA8bnTU3B432DLAo5jdftd810= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d912ebs1; 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="d912ebs1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F9E3C4CEDD; Sun, 9 Feb 2025 18:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739124544; bh=Ilw3bhepF3JuY6FM1vMKHMhrhwxF5uDqtVL265Ma1vI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d912ebs11BXcjOMbL2/waIi8x1RwepMDlx5lzPCYnM3gGA3IwmHG6jpfuztrY7V0a ouSCeKhIEmeT4UbRWv9zq+a3DZB/660nng6QFPt2RVODQPll5MVm0CJYtMTgUaopuX VIyn5ymUiSHYp1TFv8fnMs4m2iHCjfHEuTuLTP7YH7DzCEEk7i+BO8ADTzzqzVTYVw DHMBi4mapmr/PyzdfpAy8eWDbXJEMZgFS2PqrKrCR7LFIk0ZgAPXNuEaiMyx2UYcir GWKBR8BZSQf67o/nI2lCag3UUyzM3P2USx8ghTsahI/7wQkuLTjHCOMhTwo4/GA2CQ hW/hNfWfUAHrA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mudit Sharma , Julien Stephan , Mariel Tinaco , Angelo Dureghello , Gustavo Silva , Nuno Sa , =?utf-8?q?Jo=C3=A3o_Paulo_Gon=C3=A7alves?= , ChiYuan Huang , Ramona Alexandra Nechita , Trevor Gamblin , Guillaume Stols , David Lechner , Cosmin Tanislav , Marcelo Schmitt , Gwendal Grignou , Antoni Pokusinski , Tomasz Duszynski , Jonathan Cameron Subject: [PATCH v2 19/27] iio: adc: ti-ads1119: Stop using iio_device_claim_direct_scoped() Date: Sun, 9 Feb 2025 18:06:16 +0000 Message-ID: <20250209180624.701140-20-jic23@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250209180624.701140-1-jic23@kernel.org> References: <20250209180624.701140-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. Cc: João Paulo Gonçalves Reviewed-by: David Lechner Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-ads1119.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ti-ads1119.c b/drivers/iio/adc/ti-ads1119.c index de019b3faa48..f120e7e21cff 100644 --- a/drivers/iio/adc/ti-ads1119.c +++ b/drivers/iio/adc/ti-ads1119.c @@ -336,19 +336,24 @@ static int ads1119_read_raw(struct iio_dev *indio_dev, { struct ads1119_state *st = iio_priv(indio_dev); unsigned int index = chan->address; + int ret; if (index >= st->num_channels_cfg) return -EINVAL; switch (mask) { case IIO_CHAN_INFO_RAW: - iio_device_claim_direct_scoped(return -EBUSY, indio_dev) - return ads1119_single_conversion(st, chan, val, false); - unreachable(); + if (!iio_device_claim_direct(indio_dev)) + return -EBUSY; + ret = ads1119_single_conversion(st, chan, val, false); + iio_device_release_direct(indio_dev); + return ret; case IIO_CHAN_INFO_OFFSET: - iio_device_claim_direct_scoped(return -EBUSY, indio_dev) - return ads1119_single_conversion(st, chan, val, true); - unreachable(); + if (!iio_device_claim_direct(indio_dev)) + return -EBUSY; + ret = ads1119_single_conversion(st, chan, val, true); + iio_device_release_direct(indio_dev); + return ret; case IIO_CHAN_INFO_SCALE: *val = st->vref_uV / 1000; *val /= st->channels_cfg[index].gain;