[v4,1/9] iio: adis: add '__adis_enable_irq()' implementation

Message ID 20221121122655.48268-2-ramona.bolboaca@analog.com
State New
Headers
Series Add '__adis_enable_irq()' |

Commit Message

Ramona Bolboaca Nov. 21, 2022, 12:26 p.m. UTC
  Add '__adis_enable_irq()' implementation which is the unlocked
version of 'adis_enable_irq()'.
Call '__adis_enable_irq()' instead of 'adis_enable_irq()' from
'__adis_intial_startup()' to keep the expected unlocked functionality.

Fixes: b600bd7eb3335 ("iio: adis: do not disabe IRQs in 'adis_init()'")
Signed-off-by: Ramona Bolboaca <ramona.bolboaca@analog.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/imu/adis.c       | 28 ++++++++++------------------
 include/linux/iio/imu/adis.h | 12 +++++++++++-
 2 files changed, 21 insertions(+), 19 deletions(-)
  

Comments

kernel test robot Nov. 21, 2022, 2:35 p.m. UTC | #1
Hi Ramona,

I love your patch! Perhaps something to improve:

[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on linus/master v6.1-rc6 next-20221121]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ramona-Bolboaca/Add-__adis_enable_irq/20221121-202938
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link:    https://lore.kernel.org/r/20221121122655.48268-2-ramona.bolboaca%40analog.com
patch subject: [PATCH v4 1/9] iio: adis: add '__adis_enable_irq()' implementation
config: m68k-allyesconfig
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/bfde6674ecc00eb34c2af77e57fdb57cd6c1cf03
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ramona-Bolboaca/Add-__adis_enable_irq/20221121-202938
        git checkout bfde6674ecc00eb34c2af77e57fdb57cd6c1cf03
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/iio/accel/ drivers/iio/imu/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from drivers/iio/imu/adis.c:19:
   include/linux/iio/imu/adis.h: In function 'adis_enable_irq':
   include/linux/iio/imu/adis.h:410:15: error: implicit declaration of function '__adis_enable_irq'; did you mean 'adis_enable_irq'? [-Werror=implicit-function-declaration]
     410 |         ret = __adis_enable_irq(adis);
         |               ^~~~~~~~~~~~~~~~~
         |               adis_enable_irq
   drivers/iio/imu/adis.c: At top level:
>> drivers/iio/imu/adis.c:279:5: warning: no previous prototype for '__adis_enable_irq' [-Wmissing-prototypes]
     279 | int __adis_enable_irq(struct adis *adis, bool enable)
         |     ^~~~~~~~~~~~~~~~~
   drivers/iio/imu/adis.c:279:5: error: conflicting types for '__adis_enable_irq'; have 'int(struct adis *, bool)' {aka 'int(struct adis *, _Bool)'}
   drivers/iio/imu/adis.c:280:1: note: an argument type that has a default promotion cannot match an empty parameter name list declaration
     280 | {
         | ^
   include/linux/iio/imu/adis.h:410:15: note: previous implicit declaration of '__adis_enable_irq' with type 'int()'
     410 |         ret = __adis_enable_irq(adis);
         |               ^~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/__adis_enable_irq +279 drivers/iio/imu/adis.c

   271	
   272	/**
   273	 * __adis_enable_irq() - Enable or disable data ready IRQ (unlocked)
   274	 * @adis: The adis device
   275	 * @enable: Whether to enable the IRQ
   276	 *
   277	 * Returns 0 on success, negative error code otherwise
   278	 */
 > 279	int __adis_enable_irq(struct adis *adis, bool enable)
   280	{
   281		int ret;
   282		u16 msc;
   283	
   284		if (adis->data->enable_irq)
   285			return adis->data->enable_irq(adis, enable);
   286	
   287		if (adis->data->unmasked_drdy) {
   288			if (enable)
   289				enable_irq(adis->spi->irq);
   290			else
   291				disable_irq(adis->spi->irq);
   292	
   293			return 0;
   294		}
   295	
   296		ret = __adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc);
   297		if (ret)
   298			return ret;
   299	
   300		msc |= ADIS_MSC_CTRL_DATA_RDY_POL_HIGH;
   301		msc &= ~ADIS_MSC_CTRL_DATA_RDY_DIO2;
   302		if (enable)
   303			msc |= ADIS_MSC_CTRL_DATA_RDY_EN;
   304		else
   305			msc &= ~ADIS_MSC_CTRL_DATA_RDY_EN;
   306	
   307		return __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc);
   308	}
   309	EXPORT_SYMBOL_NS(__adis_enable_irq, IIO_ADISLIB);
   310
  

Patch

diff --git a/drivers/iio/imu/adis.c b/drivers/iio/imu/adis.c
index f7fcfd04f659..bc40240b29e2 100644
--- a/drivers/iio/imu/adis.c
+++ b/drivers/iio/imu/adis.c
@@ -270,23 +270,19 @@  EXPORT_SYMBOL_NS(adis_debugfs_reg_access, IIO_ADISLIB);
 #endif
 
 /**
- * adis_enable_irq() - Enable or disable data ready IRQ
+ * __adis_enable_irq() - Enable or disable data ready IRQ (unlocked)
  * @adis: The adis device
  * @enable: Whether to enable the IRQ
  *
  * Returns 0 on success, negative error code otherwise
  */
-int adis_enable_irq(struct adis *adis, bool enable)
+int __adis_enable_irq(struct adis *adis, bool enable)
 {
-	int ret = 0;
+	int ret;
 	u16 msc;
 
-	mutex_lock(&adis->state_lock);
-
-	if (adis->data->enable_irq) {
-		ret = adis->data->enable_irq(adis, enable);
-		goto out_unlock;
-	}
+	if (adis->data->enable_irq)
+		return adis->data->enable_irq(adis, enable);
 
 	if (adis->data->unmasked_drdy) {
 		if (enable)
@@ -294,12 +290,12 @@  int adis_enable_irq(struct adis *adis, bool enable)
 		else
 			disable_irq(adis->spi->irq);
 
-		goto out_unlock;
+		return 0;
 	}
 
 	ret = __adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc);
 	if (ret)
-		goto out_unlock;
+		return ret;
 
 	msc |= ADIS_MSC_CTRL_DATA_RDY_POL_HIGH;
 	msc &= ~ADIS_MSC_CTRL_DATA_RDY_DIO2;
@@ -308,13 +304,9 @@  int adis_enable_irq(struct adis *adis, bool enable)
 	else
 		msc &= ~ADIS_MSC_CTRL_DATA_RDY_EN;
 
-	ret = __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc);
-
-out_unlock:
-	mutex_unlock(&adis->state_lock);
-	return ret;
+	return __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc);
 }
-EXPORT_SYMBOL_NS(adis_enable_irq, IIO_ADISLIB);
+EXPORT_SYMBOL_NS(__adis_enable_irq, IIO_ADISLIB);
 
 /**
  * __adis_check_status() - Check the device for error conditions (unlocked)
@@ -445,7 +437,7 @@  int __adis_initial_startup(struct adis *adis)
 	 * with 'IRQF_NO_AUTOEN' anyways.
 	 */
 	if (!adis->data->unmasked_drdy)
-		adis_enable_irq(adis, false);
+		__adis_enable_irq(adis, false);
 
 	if (!adis->data->prod_id_reg)
 		return 0;
diff --git a/include/linux/iio/imu/adis.h b/include/linux/iio/imu/adis.h
index 515ca09764fe..f5432f3b2b22 100644
--- a/include/linux/iio/imu/adis.h
+++ b/include/linux/iio/imu/adis.h
@@ -402,7 +402,17 @@  static inline int adis_update_bits_base(struct adis *adis, unsigned int reg,
 	__adis_update_bits_base(adis, reg, mask, val, sizeof(val));	\
 })
 
-int adis_enable_irq(struct adis *adis, bool enable);
+static inline int adis_enable_irq(struct adis *adis, bool enable)
+{
+	int ret;
+
+	mutex_lock(&adis->state_lock);
+	ret = __adis_enable_irq(adis);
+	mutex_unlock(&adis->state_lock);
+
+	return ret;
+}
+
 int __adis_check_status(struct adis *adis);
 int __adis_initial_startup(struct adis *adis);