From ab3df79782e7d8a27a58576c9b4e8c6c4879ad79 Mon Sep 17 00:00:00 2001 From: Nuno Sa Date: Thu, 22 Apr 2021 12:19:04 +0200 Subject: iio: adis16400: do not return ints in irq handlers On an IRQ handler we should not return normal error codes as 'irqreturn_t' is expected. Not necessary to apply to stable as the original check cannot fail and as such the bug cannot actually occur. Fixes: 5eda3550a3cc1 ("staging:iio:adis16400: Preallocate transfer message") Reviewed-by: Alexandru Ardelean Signed-off-by: Nuno Sa Link: https://lore.kernel.org/r/20210422101911.135630-3-nuno.sa@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/imu/adis16400.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/iio/imu/adis16400.c') diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c index 768aa493a1a6..b2f92b55b910 100644 --- a/drivers/iio/imu/adis16400.c +++ b/drivers/iio/imu/adis16400.c @@ -645,9 +645,6 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p) void *buffer; int ret; - if (!adis->buffer) - return -ENOMEM; - if (!(st->variant->flags & ADIS16400_NO_BURST) && st->adis.spi->max_speed_hz > ADIS16400_SPI_BURST) { st->adis.spi->max_speed_hz = ADIS16400_SPI_BURST; -- cgit From b27e1970aa1ed94135cd185d50c3d34b9114d547 Mon Sep 17 00:00:00 2001 From: Nuno Sa Date: Tue, 27 Apr 2021 10:54:54 +0200 Subject: iio: adis16400: do not directly change spi 'max_speed_hz' With commit 3ba10e37371d ("iio: adis: add burst_max_speed_hz variable"), we just need to define 'burst_max_speed_hz' and the adis core will take care of setting up the spi transfers for burst mode. Hence, we fix a potential race with the spi core where we could be left witn an invalid 'max_speed_hz'. Reviewed-by: Alexandru Ardelean Fixes: 5eda3550a3cc1 ("staging:iio:adis16400: Preallocate transfer message") Signed-off-by: Nuno Sa Link: https://lore.kernel.org/r/20210427085454.30616-7-nuno.sa@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/imu/adis16400.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'drivers/iio/imu/adis16400.c') diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c index b2f92b55b910..cb8d3ffab6fc 100644 --- a/drivers/iio/imu/adis16400.c +++ b/drivers/iio/imu/adis16400.c @@ -641,25 +641,13 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p) struct iio_dev *indio_dev = pf->indio_dev; struct adis16400_state *st = iio_priv(indio_dev); struct adis *adis = &st->adis; - u32 old_speed_hz = st->adis.spi->max_speed_hz; void *buffer; int ret; - if (!(st->variant->flags & ADIS16400_NO_BURST) && - st->adis.spi->max_speed_hz > ADIS16400_SPI_BURST) { - st->adis.spi->max_speed_hz = ADIS16400_SPI_BURST; - spi_setup(st->adis.spi); - } - ret = spi_sync(adis->spi, &adis->msg); if (ret) dev_err(&adis->spi->dev, "Failed to read data: %d\n", ret); - if (!(st->variant->flags & ADIS16400_NO_BURST)) { - st->adis.spi->max_speed_hz = old_speed_hz; - spi_setup(st->adis.spi); - } - if (st->variant->flags & ADIS16400_BURST_DIAG_STAT) buffer = adis->buffer + sizeof(u16); else @@ -965,7 +953,8 @@ static const char * const adis16400_status_error_msgs[] = { BIT(ADIS16400_DIAG_STAT_POWER_LOW), \ .timeouts = (_timeouts), \ .burst_reg_cmd = ADIS16400_GLOB_CMD, \ - .burst_len = (_burst_len) \ + .burst_len = (_burst_len), \ + .burst_max_speed_hz = ADIS16400_SPI_BURST \ } static const struct adis_timeout adis16300_timeouts = { -- cgit From 9654c414bfdca1a62d17e8ae1085a5a2703b6a89 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Thu, 3 Jun 2021 20:36:16 +0100 Subject: iio: adis: Cleanout unused headers 0-day recently added the include-what-you-use header checker and it gave a warning on an adis patch. As such I decided to run it on all the adis drivers and see if it made sensible suggestions. Note this doesn't represent a complete list of what it suggested changing as I filtered out a few on the basis they are standard headers used to effectively include a bunch of other headers. Could split this into a patch per driver if people prefer. Note to anyone else trying this tool is that it is somewhat of a loose cannon so you will be wanting to carefully check any suggestions before proposing patches! I thought about also reorganising the headers whilst here, but that would make this patch harder to read, or lead to another rather noisy patch across most of the files. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210603193616.3708447-1-jic23@kernel.org --- drivers/iio/imu/adis16400.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers/iio/imu/adis16400.c') diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c index cb8d3ffab6fc..641b4f7d066d 100644 --- a/drivers/iio/imu/adis16400.c +++ b/drivers/iio/imu/adis16400.c @@ -10,22 +10,15 @@ * Copyright (c) 2011 Analog Devices Inc. */ -#include #include -#include -#include #include #include #include -#include -#include -#include #include #include #include #include -#include #include #include #include -- cgit From 21fd77afa113bef69c0982a7203a471a11c76b80 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 13 May 2021 15:25:12 +0300 Subject: iio: imu: remove unused private data assigned with spi_set_drvdata() These were usually used before the conversion to devm_ functions, so that the remove hook would be able to retrieve the pointer and do cleanups on remove. When the conversion happened, they should have been removed, but were omitted. Some drivers were copied from drivers that fit the criteria described above. In any case, in order to prevent more drivers from being used as example (and have spi_set_drvdata() needlessly set), this change removes it from the IIO IMU group. Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210513122512.93187-1-aardelean@deviqon.com Signed-off-by: Jonathan Cameron --- drivers/iio/imu/adis16400.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/iio/imu/adis16400.c') diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c index 641b4f7d066d..b12917a7cb60 100644 --- a/drivers/iio/imu/adis16400.c +++ b/drivers/iio/imu/adis16400.c @@ -1157,8 +1157,6 @@ static int adis16400_probe(struct spi_device *spi) return -ENOMEM; st = iio_priv(indio_dev); - /* this is only used for removal purposes */ - spi_set_drvdata(spi, indio_dev); /* setup the industrialio driver allocated elements */ st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data]; -- cgit