[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241002-iio-must-check-claim-direct-v1-1-ab94ce728731@baylibre.com>
Date: Wed, 02 Oct 2024 10:34:56 -0500
From: David Lechner <dlechner@...libre.com>
To: Jonathan Cameron <jic23@...nel.org>
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
Dan Williams <dan.j.williams@...el.com>,
David Lechner <dlechner@...libre.com>
Subject: [PATCH] iio: core: make iio_device_claim_direct_mode()
__must_check
Add __must_check attribute to iio_device_claim_direct_mode().
Since we have now DEFINE_GUARD(iio_claim_direct, ...,
iio_device_claim_direct_mode, ...), it is possible to write:
guard(iio_claim_direct)(indio_dev);
This would be a bug, since the return value is not checked. Adding
__must_check to iio_device_claim_direct_mode() makes the compiler emit
a warning for the above code.
Suggested-by: Dan Williams <dan.j.williams@...el.com>
Signed-off-by: David Lechner <dlechner@...libre.com>
---
This comes from the suggestion at the end of [1]. It seems like a
reasonable thing to do regardless if the other series works out or not,
so submitting it separately.
[1]: https://lore.kernel.org/all/66fcac2dbde60_964f229426@dwillia2-xfh.jf.intel.com.notmuch/
---
include/linux/iio/iio.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 18779b631e90..2dc6470d20a4 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -659,7 +659,7 @@ void iio_device_unregister(struct iio_dev *indio_dev);
int __devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev,
struct module *this_mod);
int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp);
-int iio_device_claim_direct_mode(struct iio_dev *indio_dev);
+__must_check int iio_device_claim_direct_mode(struct iio_dev *indio_dev);
void iio_device_release_direct_mode(struct iio_dev *indio_dev);
/*
---
base-commit: 431c39f6d3edbab14f48dbf37a58ccdc0ac3be1e
change-id: 20241002-iio-must-check-claim-direct-e6988a195368
Best regards,
--
David Lechner <dlechner@...libre.com>
Powered by blists - more mailing lists