From patchwork Mon Mar 31 12:13:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14033535 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 5D1A513B59B for ; Mon, 31 Mar 2025 12:15:40 +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=1743423340; cv=none; b=Ef3AKvxXwqO4umxBKxTSkj7BZ8QPSrBAzOyowAu02xJLfW8z6EFlB7fnUidFctnZPBDqqFkjlfmuJPaHamoQ/J9XE1gMxjuqbeER5KQP5lnbJO0nCSVPXSH/AsDiBB3j6KeVTufIpmwsaIq1dJYAtPANo6/IYBy81bbLuUK/b8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743423340; c=relaxed/simple; bh=VR++2UOfr364mmXn8Q2zor6eP186CmZ42rR19LJy9Vc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NFKOejC3PJXxXEyFVVVSOSM6CibAZ36Bd5kuriAxPjHNtKLm1M+r/WXDynY7TkYmi+GhFNR9NxXx474mLWiicTMP6Fe+nngG6d0yYcrkKzLDh6DRDp2suvQdljYgtiszBe1L7SSUfv2jLpHV49oHZLiG4DaK/1N2OkdT6i5nYPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZByWwBfo; 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="ZByWwBfo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFFE3C4CEE3; Mon, 31 Mar 2025 12:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743423340; bh=VR++2UOfr364mmXn8Q2zor6eP186CmZ42rR19LJy9Vc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZByWwBfoitwNBET9/22z00D9iUPTwisDA61Sm/P/8fgFgH6jnUybVH+QSRChqhGtk FzI8cDc2WBWBh/r8Q3fuSbIl3Vm9jvpbwgCkvQk0Q1VgoTOElg0aowAFAXyhb4QfIO VezlGR+c+lSHatWpCzIZkToO4bURd/IxZGeM+TXCgNLrowngFcUA4RZ27ad9TVlndu 4ecEdTG1YP6V+S7avVPh4iAVcddtaQw2S1L5KVtF0vrIH8Ac8Pp6GVLF18CoHMyfS6 DgvE63DriZAYOZDTW97d7KyOEalrU7XI9L6kLZ0sbsl+FJVUxrgE8l2vCNoKB9MElz IZb4Fn1KdmuqQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Cosmin Tanislav , Roan van Dijk , Jyoti Bhayana , Nishant Malpani , Eugene Zaikonnikov , Jean-Baptiste Maneyrol , Shen Jianping , Lorenzo Bianconi , Matti Vaittinen , Yasin Lee , Andy Shevchenko , Jonathan Cameron Subject: [PATCH 20/37] iio: imu: st_lsm6dsx: Switch to sparse friendly iio_device_claim/release_direct() Date: Mon, 31 Mar 2025 13:13:00 +0100 Message-ID: <20250331121317.1694135-21-jic23@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250331121317.1694135-1-jic23@kernel.org> References: <20250331121317.1694135-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 These new functions allow sparse to find failures to release direct mode reducing chances of bugs over the claim_direct_mode() functions that are deprecated. Signed-off-by: Jonathan Cameron Cc: Lorenzo Bianconi Acked-by: Lorenzo Bianconi --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c index 17a74f5adfc0..3c5e65dc0f97 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c @@ -558,12 +558,11 @@ st_lsm6dsx_shub_read_raw(struct iio_dev *iio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: - ret = iio_device_claim_direct_mode(iio_dev); - if (ret) - break; + if (!iio_device_claim_direct(iio_dev)) + return -EBUSY; ret = st_lsm6dsx_shub_read_oneshot(sensor, ch, val); - iio_device_release_direct_mode(iio_dev); + iio_device_release_direct(iio_dev); break; case IIO_CHAN_INFO_SAMP_FREQ: *val = sensor->ext_info.slv_odr / 1000; @@ -657,13 +656,12 @@ st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev, { int ret; - ret = iio_device_claim_direct_mode(iio_dev); - if (ret) - return ret; + if (!iio_device_claim_direct(iio_dev)) + return -EBUSY; ret = __st_lsm6dsx_shub_write_raw(iio_dev, chan, val, val2, mask); - iio_device_release_direct_mode(iio_dev); + iio_device_release_direct(iio_dev); return ret; }