[PATCH 1/2] staging: iio: ad2s1210: Destroy mutex at remove

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ensure the mutex will be destroyed on drive removal.
Also adds mutex comment description.

Signed-off-by: Tallys Martins <tallysmartins@xxxxxxxxx>
Signed-off-by: Souza Guilherme <gdsdsilva@xxxxxxxxxxxxxxxx>
Co-developed-by: Souza Guilherme <gdsdsilva@xxxxxxxxxxxxxxxx>
---
 drivers/staging/iio/resolver/ad2s1210.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c
index b6be0bc202f5..b91cf57c5e57 100644
--- a/drivers/staging/iio/resolver/ad2s1210.c
+++ b/drivers/staging/iio/resolver/ad2s1210.c
@@ -86,7 +86,7 @@ static const struct ad2s1210_gpio gpios[] = {
 static const unsigned int ad2s1210_resolution_value[] = { 10, 12, 14, 16 };
 
 struct ad2s1210_state {
-	struct mutex lock;
+	struct mutex lock; /* lock to protect the state on r/w operations */
 	struct spi_device *sdev;
 	struct gpio_desc *gpios[5];
 	unsigned int fclkin;
@@ -689,8 +689,10 @@ static int ad2s1210_probe(struct spi_device *spi)
 static int ad2s1210_remove(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev = spi_get_drvdata(spi);
+	struct ad2s1210_state *ad2s1210_ad = iio_priv(indio_dev);
 
 	iio_device_unregister(indio_dev);
+	mutex_destroy(&ad2s1210_ad->lock);
 
 	return 0;
 }
-- 
2.21.0

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux