Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: core: Add and export __iio_dev_mode_lock()

Add unconditional wrappers around the internal IIO mode lock.

As mentioned in the documentation, this is not meant to be used by
drivers, instead this will aid in the eventual addition of cleanup
classes around conditional locks.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Kurt Borja and committed by
Jonathan Cameron
88fd1f90 4296b1fb

+33
+30
drivers/iio/industrialio-core.c
··· 2172 2172 EXPORT_SYMBOL_GPL(__devm_iio_device_register); 2173 2173 2174 2174 /** 2175 + * __iio_dev_mode_lock() - Locks the current IIO device mode 2176 + * @indio_dev: the iio_dev associated with the device 2177 + * 2178 + * If the device is either in direct or buffer mode, it's guaranteed to stay 2179 + * that way until __iio_dev_mode_unlock() is called. 2180 + * 2181 + * This function is not meant to be used directly by drivers to protect internal 2182 + * state; a driver should have it's own mechanisms for that matter. 2183 + * 2184 + * There are very few cases where a driver actually needs to lock the current 2185 + * mode unconditionally. It's recommended to use iio_device_claim_direct() or 2186 + * iio_device_claim_buffer_mode() pairs or related helpers instead. 2187 + */ 2188 + void __iio_dev_mode_lock(struct iio_dev *indio_dev) 2189 + { 2190 + mutex_lock(&to_iio_dev_opaque(indio_dev)->mlock); 2191 + } 2192 + EXPORT_SYMBOL_GPL(__iio_dev_mode_lock); 2193 + 2194 + /** 2195 + * __iio_dev_mode_unlock() - Unlocks the current IIO device mode 2196 + * @indio_dev: the iio_dev associated with the device 2197 + */ 2198 + void __iio_dev_mode_unlock(struct iio_dev *indio_dev) 2199 + { 2200 + mutex_unlock(&to_iio_dev_opaque(indio_dev)->mlock); 2201 + } 2202 + EXPORT_SYMBOL_GPL(__iio_dev_mode_unlock); 2203 + 2204 + /** 2175 2205 * __iio_device_claim_direct - Keep device in direct mode 2176 2206 * @indio_dev: the iio_dev associated with the device 2177 2207 *
+3
include/linux/iio/iio.h
··· 661 661 int __devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev, 662 662 struct module *this_mod); 663 663 int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp); 664 + 665 + void __iio_dev_mode_lock(struct iio_dev *indio_dev) __acquires(indio_dev); 666 + void __iio_dev_mode_unlock(struct iio_dev *indio_dev) __releases(indio_dev); 664 667 bool __iio_device_claim_direct(struct iio_dev *indio_dev); 665 668 void __iio_device_release_direct(struct iio_dev *indio_dev); 666 669