From patchwork Mon Mar 31 12:13:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 14033549 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 29CD713B59B for ; Mon, 31 Mar 2025 12:17:09 +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=1743423430; cv=none; b=Gk+8dke6HovXK+cQR9+Wf7sAhpeblb2QIPHFtuf9ue7Z2GjKM29pzRSxTAIPz3xthDNpqBpXU5fbuHcFMSuuA7sVIWiiFPnA2KV0yYo3Sv+K2/loDTvWWOf5xil6q0aSsZ6dHD16QZq91Q8HMiyWvfZp3/546ib0oUM5OURm5eY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743423430; c=relaxed/simple; bh=xblcPfOMh6aAs8TN16Jsn6pxnoWcn5GCCb3XLYu3Bsk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M25WPhOz2lPS0EdwZbfJvSUS5/V/EDXLy7b5CvZ/vBnxHD27ySSWo9LLyDPqRsSWWrborwNzeJKoKhEjvUF61ADU8s9bHZyUH8qRcGEutBYxnAQWTbhEQ1GqA5/tJD5iZ4yg5WieJIqC9nKcb/v1rCa7woRbnwObvD2oBnGC13o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KeiMFdPt; 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="KeiMFdPt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7F95C4CEE3; Mon, 31 Mar 2025 12:17:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743423429; bh=xblcPfOMh6aAs8TN16Jsn6pxnoWcn5GCCb3XLYu3Bsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KeiMFdPtcgUBM8DGK17oYRvA2RW/3hxkClHoVJZ2f3FmvUet3kkkUDHoNE9p9SZoO KsARWnvwCcPbDYjZGMPDTYgtrw3o/58A8JixWhifEcVy6GqmQlxZLnv67KiGVPHgD4 msk4Ie4iOYDFNw6QgtiZMdTqeVS427ZSrieqxL/NC8y4tzPlL5UKO4Rw0mKOvuA4qq 9esVAS6w1b0zS0c5PRJGMdk1nHJ59T4E0RfyzIKasqgVRgiXQ/W+jLgfC8MMjQKNRT lSQ+QfgmrOk0SAPh8kZ2Ff95CVFm/+lnSITcuSWjKlo6T8zElHot6NvXkjvpa7UUB5 l/oUFCBJYC6kA== 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 34/37] iio: temp: maxim_thermocouple: Switch to sparse friendly iio_device_claim/release_direct() Date: Mon, 31 Mar 2025 13:13:14 +0100 Message-ID: <20250331121317.1694135-35-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. Tidy up a few direct returns whilst here. Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/maxim_thermocouple.c | 29 ++++++++------------ 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c index c28a7a6dea5f..a1c213d5c469 100644 --- a/drivers/iio/temperature/maxim_thermocouple.c +++ b/drivers/iio/temperature/maxim_thermocouple.c @@ -183,40 +183,35 @@ static int maxim_thermocouple_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct maxim_thermocouple_data *data = iio_priv(indio_dev); - int ret = -EINVAL; + int ret; switch (mask) { case IIO_CHAN_INFO_RAW: - ret = iio_device_claim_direct_mode(indio_dev); - if (ret) - return ret; + if (!iio_device_claim_direct(indio_dev)) + return -EBUSY; ret = maxim_thermocouple_read(data, chan, val); - iio_device_release_direct_mode(indio_dev); - - if (!ret) - return IIO_VAL_INT; + iio_device_release_direct(indio_dev); + if (ret) + return ret; - break; + return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: switch (chan->channel2) { case IIO_MOD_TEMP_AMBIENT: *val = 62; *val2 = 500000; /* 1000 * 0.0625 */ - ret = IIO_VAL_INT_PLUS_MICRO; - break; + return IIO_VAL_INT_PLUS_MICRO; default: *val = 250; /* 1000 * 0.25 */ - ret = IIO_VAL_INT; + return IIO_VAL_INT; } - break; case IIO_CHAN_INFO_THERMOCOUPLE_TYPE: *val = data->tc_type; - ret = IIO_VAL_CHAR; - break; + return IIO_VAL_CHAR; + default: + return -EINVAL; } - - return ret; } static const struct iio_info maxim_thermocouple_info = {