mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
iio: core: implement devm_iio_device_alloc/devm_iio_device_free
Add a resource managed devm_iio_device_alloc()/devm_iio_device_free() to automatically clean up any allocations made by IIO drivers, thus leading to simplified IIO drivers code. In addition, this will allow IIO drivers to use other devm_*() API (like devm_request_irq) and don't care about the race between iio_device_free() and the release of resources by Device core during driver removing. Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com> Tested-by: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
60b188f0d6
commit
9dabaf5edd
2 changed files with 72 additions and 0 deletions
|
@ -531,6 +531,31 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv)
|
|||
**/
|
||||
void iio_device_free(struct iio_dev *indio_dev);
|
||||
|
||||
/**
|
||||
* devm_iio_device_alloc - Resource-managed iio_device_alloc()
|
||||
* @dev: Device to allocate iio_dev for
|
||||
* @sizeof_priv: Space to allocate for private structure.
|
||||
*
|
||||
* Managed iio_device_alloc. iio_dev allocated with this function is
|
||||
* automatically freed on driver detach.
|
||||
*
|
||||
* If an iio_dev allocated with this function needs to be freed separately,
|
||||
* devm_iio_device_free() must be used.
|
||||
*
|
||||
* RETURNS:
|
||||
* Pointer to allocated iio_dev on success, NULL on failure.
|
||||
*/
|
||||
struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv);
|
||||
|
||||
/**
|
||||
* devm_iio_device_free - Resource-managed iio_device_free()
|
||||
* @dev: Device this iio_dev belongs to
|
||||
* @indio_dev: the iio_dev associated with the device
|
||||
*
|
||||
* Free indio_dev allocated with devm_iio_device_alloc().
|
||||
*/
|
||||
void devm_iio_device_free(struct device *dev, struct iio_dev *iio_dev);
|
||||
|
||||
/**
|
||||
* iio_buffer_enabled() - helper function to test if the buffer is enabled
|
||||
* @indio_dev: IIO device structure for device
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue