Merge tag 'iio-fixes-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Jun 2022 07:49:52 +0000 (09:49 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Jun 2022 07:49:52 +0000 (09:49 +0200)
Jonathan writes:

1st set of IIO fixes for the 5.19 cycle.

Most of these have been in next for a long time. Unfortunately there
was one stray patch in the branch (wasn't a fix), so I've just rebased
to remove that.

* testing
  - Fix a missing MODULE_LICENSE() warning by restricting possible build
    configs.
* Various drivers
  - Fix ordering of iio_get_trigger() being called before
    iio_trigger_register()
* adi,admv1014
  - Fix dubious x & !y warning.
* adi,axi-adc
  - Fix missing of_node_put() in error and normal paths.
* aspeed,adc
  - Add missing of_node_put()
* fsl,mma8452
  - Fix broken probing from device tree.
  - Drop check on return value of i2c write to device to cause reset as
    ACK will be missing (device reset before sending it).
* fsl,vf610
  - Fix documentation of in_conversion_mode ABI.
* iio-trig-sysfs
  - Ensure irq work has finished before freeing the trigger.
* invensense,mpu3050
 - Disable regulators in error path.
* invensense,icm42600
  - Fix collision of enum value of 0 with error path where 0 is no match.
* renesas,rzg2l_Adc
  - Add missing fwnode_handle_put() in error path.
* rescale
  - Fix a boolean logic bug for detection of raw + scale affecting an
    obscure corner case.
* semtech,sx9324
  - Check return value of read of pin_defs
* st,stm32-adc:
  - Fix interaction across ADC instances for some supported devices.
  - Drop false spurious IRQ messages.
  - Fix calibration value handling.  If we can't calibrate don't expose the
    vref_int channel.
  - Fix maximum clock rate for stm32pm15x
* ti,ads131e08
  - Add missing fwnode_handle_put() in error paths.
* xilinx,ams
  - Fix variable checked for error from platform_get_irq()
* x-powers,axp288
  - Overide TS_PIN bias current for boards where it is not correctly
    initialized.
* yamaha,yas530
  - Fix inverted check on calibration data being all zeros.

* tag 'iio-fixes-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (26 commits)
  iio:proximity:sx9324: Check ret value of device_property_read_u32_array()
  iio: accel: mma8452: ignore the return value of reset operation
  iio: adc: stm32: fix maximum clock rate for stm32mp15x
  iio: adc: stm32: fix vrefint wrong calibration value handling
  iio: imu: inv_icm42600: Fix broken icm42600 (chip id 0 value)
  iio: adc: vf610: fix conversion mode sysfs node name
  iio: adc: adi-axi-adc: Fix refcount leak in adi_axi_adc_attach_client
  iio: test: fix missing MODULE_LICENSE for IIO_RESCALE=m
  iio:humidity:hts221: rearrange iio trigger get and register
  iio:chemical:ccs811: rearrange iio trigger get and register
  iio:accel:mxc4005: rearrange iio trigger get and register
  iio:accel:kxcjk-1013: rearrange iio trigger get and register
  iio:accel:bma180: rearrange iio trigger get and register
  iio: afe: rescale: Fix boolean logic bug
  iio: adc: aspeed: Fix refcount leak in aspeed_adc_set_trim_data
  iio: adc: stm32: Fix IRQs on STM32F4 by removing custom spurious IRQs message
  iio: adc: stm32: Fix ADCs iteration in irq handler
  iio: adc: ti-ads131e08: add missing fwnode_handle_put() in ads131e08_alloc_channels()
  iio: adc: rzg2l_adc: add missing fwnode_handle_put() in rzg2l_adc_parse_properties()
  iio: trigger: sysfs: fix use-after-free on remove
  ...

1  2 
drivers/iio/accel/mma8452.c
drivers/iio/afe/iio-rescale.c
drivers/iio/gyro/mpu3050-core.c
drivers/iio/trigger/iio-trig-sysfs.c

@@@ -166,7 -166,6 +166,7 @@@ static const struct mma8452_event_regs 
  
  /**
   * struct mma_chip_info - chip specific data
 + * @name:                     part number of device reported via 'name' attr
   * @chip_id:                  WHO_AM_I register's value
   * @channels:                 struct iio_chan_spec matching the device's
   *                            capabilities
@@@ -1511,10 -1510,14 +1511,14 @@@ static int mma8452_reset(struct i2c_cli
        int i;
        int ret;
  
-       ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG2,
+       /*
+        * Find on fxls8471, after config reset bit, it reset immediately,
+        * and will not give ACK, so here do not check the return value.
+        * The following code will read the reset register, and check whether
+        * this reset works.
+        */
+       i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG2,
                                        MMA8452_CTRL_REG2_RST);
-       if (ret < 0)
-               return ret;
  
        for (i = 0; i < 10; i++) {
                usleep_range(100, 200);
@@@ -1557,11 -1560,13 +1561,13 @@@ static int mma8452_probe(struct i2c_cli
        mutex_init(&data->lock);
  
        data->chip_info = device_get_match_data(&client->dev);
-       if (!data->chip_info && id) {
-               data->chip_info = &mma_chip_info_table[id->driver_data];
-       } else {
-               dev_err(&client->dev, "unknown device model\n");
-               return -ENODEV;
+       if (!data->chip_info) {
+               if (id) {
+                       data->chip_info = &mma_chip_info_table[id->driver_data];
+               } else {
+                       dev_err(&client->dev, "unknown device model\n");
+                       return -ENODEV;
+               }
        }
  
        ret = iio_read_mount_matrix(&client->dev, &data->orientation);
@@@ -10,8 -10,9 +10,8 @@@
  
  #include <linux/err.h>
  #include <linux/gcd.h>
 +#include <linux/mod_devicetable.h>
  #include <linux/module.h>
 -#include <linux/of.h>
 -#include <linux/of_device.h>
  #include <linux/platform_device.h>
  #include <linux/property.h>
  
@@@ -277,7 -278,7 +277,7 @@@ static int rescale_configure_channel(st
        chan->ext_info = rescale->ext_info;
        chan->type = rescale->cfg->type;
  
-       if (iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) ||
+       if (iio_channel_has_info(schan, IIO_CHAN_INFO_RAW) &&
            iio_channel_has_info(schan, IIO_CHAN_INFO_SCALE)) {
                dev_info(dev, "using raw+scale source channel\n");
        } else if (iio_channel_has_info(schan, IIO_CHAN_INFO_PROCESSED)) {
@@@ -535,7 -536,7 +535,7 @@@ static int rescale_probe(struct platfor
  
        rescale = iio_priv(indio_dev);
  
 -      rescale->cfg = of_device_get_match_data(dev);
 +      rescale->cfg = device_get_match_data(dev);
        rescale->numerator = 1;
        rescale->denominator = 1;
        rescale->offset = 0;
@@@ -26,7 -26,6 +26,7 @@@
  #include <linux/interrupt.h>
  #include <linux/module.h>
  #include <linux/pm_runtime.h>
 +#include <linux/property.h>
  #include <linux/random.h>
  #include <linux/slab.h>
  
@@@ -875,6 -874,7 +875,7 @@@ static int mpu3050_power_up(struct mpu3
        ret = regmap_update_bits(mpu3050->map, MPU3050_PWR_MGM,
                                 MPU3050_PWR_MGM_SLEEP, 0);
        if (ret) {
+               regulator_bulk_disable(ARRAY_SIZE(mpu3050->regs), mpu3050->regs);
                dev_err(mpu3050->dev, "error setting power mode\n");
                return ret;
        }
@@@ -1051,7 -1051,6 +1052,7 @@@ static const struct iio_trigger_ops mpu
  static int mpu3050_trigger_probe(struct iio_dev *indio_dev, int irq)
  {
        struct mpu3050 *mpu3050 = iio_priv(indio_dev);
 +      struct device *dev = mpu3050->dev;
        unsigned long irq_trig;
        int ret;
  
                return -ENOMEM;
  
        /* Check if IRQ is open drain */
 -      if (of_property_read_bool(mpu3050->dev->of_node, "drive-open-drain"))
 -              mpu3050->irq_opendrain = true;
 +      mpu3050->irq_opendrain = device_property_read_bool(dev, "drive-open-drain");
  
        irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
        /*
                                   mpu3050->trig->name,
                                   mpu3050->trig);
        if (ret) {
 -              dev_err(mpu3050->dev,
 -                      "can't get IRQ %d, error %d\n", irq, ret);
 +              dev_err(dev, "can't get IRQ %d, error %d\n", irq, ret);
                return ret;
        }
  
        mpu3050->irq = irq;
 -      mpu3050->trig->dev.parent = mpu3050->dev;
 +      mpu3050->trig->dev.parent = dev;
        mpu3050->trig->ops = &mpu3050_trigger_ops;
        iio_trigger_set_drvdata(mpu3050->trig, indio_dev);
  
@@@ -1263,7 -1264,7 +1264,7 @@@ err_power_down
  }
  EXPORT_SYMBOL(mpu3050_common_probe);
  
 -int mpu3050_common_remove(struct device *dev)
 +void mpu3050_common_remove(struct device *dev)
  {
        struct iio_dev *indio_dev = dev_get_drvdata(dev);
        struct mpu3050 *mpu3050 = iio_priv(indio_dev);
                free_irq(mpu3050->irq, mpu3050);
        iio_device_unregister(indio_dev);
        mpu3050_power_down(mpu3050);
 -
 -      return 0;
  }
  EXPORT_SYMBOL(mpu3050_common_remove);
  
@@@ -176,20 -176,22 +176,21 @@@ out1
  
  static int iio_sysfs_trigger_remove(int id)
  {
 -      bool foundit = false;
 -      struct iio_sysfs_trig *t;
 +      struct iio_sysfs_trig *t = NULL, *iter;
  
        mutex_lock(&iio_sysfs_trig_list_mut);
 -      list_for_each_entry(t, &iio_sysfs_trig_list, l)
 -              if (id == t->id) {
 -                      foundit = true;
 +      list_for_each_entry(iter, &iio_sysfs_trig_list, l)
 +              if (id == iter->id) {
 +                      t = iter;
                        break;
                }
 -      if (!foundit) {
 +      if (!t) {
                mutex_unlock(&iio_sysfs_trig_list_mut);
                return -EINVAL;
        }
  
        iio_trigger_unregister(t->trig);
+       irq_work_sync(&t->work);
        iio_trigger_free(t->trig);
  
        list_del(&t->l);