From patchwork Mon Mar 31 12:12:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14033527 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 42E5E1E377F for ; Mon, 31 Mar 2025 12:14:50 +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=1743423291; cv=none; b=qiG9onkr5wJ3u07fxdebnStwy72VmUgnMrAdlt7NtNk12JV5d886FEwzuewD3ZjhstTrAr/dYqpIvIHievZc2twSCTfIZkJDZSSdyPBin64w9Ho+ubtxIvuzrFXjkxTdNHm9DzYN9sqt/ZhQBKuSNAXDKBdblLTzzQ3X1Cy65Xs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743423291; c=relaxed/simple; bh=XHdwhv0AaXUg1kPAk8S0qAkPHuUhiza78tbUhyE/d/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jxD5UdyOFsjllzHtkQiJgZkVNH238RHOVc3ae3dE3QWF02nB0uSWJ1mvANH07CbNjHi2I0hozGPRaCWXQF0/hJU33PNAtFFT1YzrM3BoKjmtN6spZKA3EvJGApoIq2DM9RK/gXv3gr8RbROalTA+vqWZHcICb8p5QE7ZdqzACZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uTHBaHIv; 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="uTHBaHIv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F17AC4CEE3; Mon, 31 Mar 2025 12:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743423290; bh=XHdwhv0AaXUg1kPAk8S0qAkPHuUhiza78tbUhyE/d/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uTHBaHIvddWblmAKVPLWTR4wEhaVvcepc5zcLM6vEhBYQ4IPjJ2vHg92jW85k+tiq bTAoQ2JrNYIa7LuUgplyEhEcFgsO4UMSKPVjLk0vWd34Fxmky/yIE56mjOEF1yYw8j MVOJkffYEwXskIl2wRo4HNWKiX28S6iK67OU3pbdyQmaYFCNoAsfcT6Gukno2d6DD+ q+Bi0uycs8v0cmQBLWIZk61fQcpVr3JR1HYH0Bcipy6xvL5HZEK8CJrYfDpbzM06sz aQZv2iVX9b/Ar7H+DPuzjR59f+OClY0tKXaSlgaUwZvndYAOQ1bxHdDpDfFggR9wsA qjxWmyaibMr9A== 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 12/37] iio: humidity: hdc2010: Switch to sparse friendly iio_device_claim/release_direct() Date: Mon, 31 Mar 2025 13:12:52 +0100 Message-ID: <20250331121317.1694135-13-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: Eugene Zaikonnikov Acked-by: Eugene Zaikonnikov --- drivers/iio/humidity/hdc2010.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/iio/humidity/hdc2010.c b/drivers/iio/humidity/hdc2010.c index f5867659e00f..894a8b4ab193 100644 --- a/drivers/iio/humidity/hdc2010.c +++ b/drivers/iio/humidity/hdc2010.c @@ -169,13 +169,12 @@ static int hdc2010_read_raw(struct iio_dev *indio_dev, *val = hdc2010_get_heater_status(data); return IIO_VAL_INT; } - ret = iio_device_claim_direct_mode(indio_dev); - if (ret) - return ret; + if (!iio_device_claim_direct(indio_dev)) + return -EBUSY; mutex_lock(&data->lock); ret = hdc2010_get_prim_measurement_word(data, chan); mutex_unlock(&data->lock); - iio_device_release_direct_mode(indio_dev); + iio_device_release_direct(indio_dev); if (ret < 0) return ret; *val = ret; @@ -184,13 +183,12 @@ static int hdc2010_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_PEAK: { int ret; - ret = iio_device_claim_direct_mode(indio_dev); - if (ret) - return ret; + if (!iio_device_claim_direct(indio_dev)) + return -EBUSY; mutex_lock(&data->lock); ret = hdc2010_get_peak_measurement_byte(data, chan); mutex_unlock(&data->lock); - iio_device_release_direct_mode(indio_dev); + iio_device_release_direct(indio_dev); if (ret < 0) return ret; /* Scaling up the value so we can use same offset as RAW */