From 17b5a7f65c7db1997252b8313dd03f15fbe1f54f Mon Sep 17 00:00:00 2001 From: Alexander Stein Date: Mon, 13 Jun 2022 14:35:29 +0200 Subject: [PATCH 01/65] dt-bindings: iio: adc: Add imx6ul & imx6sx compatibles Both are already using the vf610 compatible. Signed-off-by: Alexander Stein Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20220613123529.466528-1-alexander.stein@ew.tq-group.com Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/fsl,vf610-adc.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/adc/fsl,vf610-adc.yaml b/Documentation/devicetree/bindings/iio/adc/fsl,vf610-adc.yaml index 925f355cc21f..c770ff4998f5 100644 --- a/Documentation/devicetree/bindings/iio/adc/fsl,vf610-adc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/fsl,vf610-adc.yaml @@ -14,7 +14,14 @@ description: properties: compatible: - const: fsl,vf610-adc + oneOf: + - items: + - enum: + - fsl,imx6sx-adc + - fsl,imx6ul-adc + - const: fsl,vf610-adc + - items: + - const: fsl,vf610-adc reg: maxItems: 1 From bc72d938c149197688ae3b3ecaa25d4aee8653cb Mon Sep 17 00:00:00 2001 From: Dmitry Rokosov Date: Wed, 1 Jun 2022 17:48:32 +0000 Subject: [PATCH 02/65] iio: trigger: move trig->owner init to trigger allocate() stage To provide a new IIO trigger to the IIO core, usually driver executes the following pipeline: allocate()/register()/get(). Before, IIO core assigned trig->owner as a pointer to the module which registered this trigger at the register() stage. But actually the trigger object is owned by the module earlier, on the allocate() stage, when trigger object is successfully allocated for the driver. This patch moves trig->owner initialization from register() stage of trigger initialization pipeline to allocate() stage to eliminate all misunderstandings and time gaps between trigger object creation and owner acquiring. Signed-off-by: Dmitry Rokosov Link: https://lore.kernel.org/r/20220601174837.20292-1-ddrokosov@sberdevices.ru Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-trigger.c | 46 ++++++++++++++++-------------- include/linux/iio/iio.h | 9 ++++-- include/linux/iio/trigger.h | 21 +++++++------- 3 files changed, 41 insertions(+), 35 deletions(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 26d610d4cbb8..efc01584b3f9 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -63,13 +63,10 @@ ATTRIBUTE_GROUPS(iio_trig_dev); static struct iio_trigger *__iio_trigger_find_by_name(const char *name); -int __iio_trigger_register(struct iio_trigger *trig_info, - struct module *this_mod) +int iio_trigger_register(struct iio_trigger *trig_info) { int ret; - trig_info->owner = this_mod; - trig_info->id = ida_alloc(&iio_trigger_ida, GFP_KERNEL); if (trig_info->id < 0) return trig_info->id; @@ -100,7 +97,7 @@ error_unregister_id: ida_free(&iio_trigger_ida, trig_info->id); return ret; } -EXPORT_SYMBOL(__iio_trigger_register); +EXPORT_SYMBOL(iio_trigger_register); void iio_trigger_unregister(struct iio_trigger *trig_info) { @@ -547,8 +544,9 @@ static void iio_trig_subirqunmask(struct irq_data *d) trig->subirqs[d->irq - trig->subirq_base].enabled = true; } -static __printf(2, 0) +static __printf(3, 0) struct iio_trigger *viio_trigger_alloc(struct device *parent, + struct module *this_mod, const char *fmt, va_list vargs) { @@ -578,6 +576,8 @@ struct iio_trigger *viio_trigger_alloc(struct device *parent, INIT_LIST_HEAD(&trig->list); + trig->owner = this_mod; + trig->subirq_chip.name = trig->name; trig->subirq_chip.irq_mask = &iio_trig_subirqmask; trig->subirq_chip.irq_unmask = &iio_trig_subirqunmask; @@ -598,8 +598,9 @@ free_trig: } /** - * iio_trigger_alloc - Allocate a trigger + * __iio_trigger_alloc - Allocate a trigger * @parent: Device to allocate iio_trigger for + * @this_mod: module allocating the trigger * @fmt: trigger name format. If it includes format * specifiers, the additional arguments following * format are formatted and inserted in the resulting @@ -607,18 +608,20 @@ free_trig: * RETURNS: * Pointer to allocated iio_trigger on success, NULL on failure. */ -struct iio_trigger *iio_trigger_alloc(struct device *parent, const char *fmt, ...) +struct iio_trigger *__iio_trigger_alloc(struct device *parent, + struct module *this_mod, + const char *fmt, ...) { struct iio_trigger *trig; va_list vargs; va_start(vargs, fmt); - trig = viio_trigger_alloc(parent, fmt, vargs); + trig = viio_trigger_alloc(parent, this_mod, fmt, vargs); va_end(vargs); return trig; } -EXPORT_SYMBOL(iio_trigger_alloc); +EXPORT_SYMBOL(__iio_trigger_alloc); void iio_trigger_free(struct iio_trigger *trig) { @@ -633,10 +636,11 @@ static void devm_iio_trigger_release(struct device *dev, void *res) } /** - * devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc() + * __devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc() * Managed iio_trigger_alloc. iio_trigger allocated with this function is * automatically freed on driver detach. * @parent: Device to allocate iio_trigger for + * @this_mod: module allocating the trigger * @fmt: trigger name format. If it includes format * specifiers, the additional arguments following * format are formatted and inserted in the resulting @@ -646,7 +650,9 @@ static void devm_iio_trigger_release(struct device *dev, void *res) * RETURNS: * Pointer to allocated iio_trigger on success, NULL on failure. */ -struct iio_trigger *devm_iio_trigger_alloc(struct device *parent, const char *fmt, ...) +struct iio_trigger *__devm_iio_trigger_alloc(struct device *parent, + struct module *this_mod, + const char *fmt, ...) { struct iio_trigger **ptr, *trig; va_list vargs; @@ -658,7 +664,7 @@ struct iio_trigger *devm_iio_trigger_alloc(struct device *parent, const char *fm /* use raw alloc_dr for kmalloc caller tracing */ va_start(vargs, fmt); - trig = viio_trigger_alloc(parent, fmt, vargs); + trig = viio_trigger_alloc(parent, this_mod, fmt, vargs); va_end(vargs); if (trig) { *ptr = trig; @@ -669,7 +675,7 @@ struct iio_trigger *devm_iio_trigger_alloc(struct device *parent, const char *fm return trig; } -EXPORT_SYMBOL_GPL(devm_iio_trigger_alloc); +EXPORT_SYMBOL_GPL(__devm_iio_trigger_alloc); static void devm_iio_trigger_unreg(void *trigger_info) { @@ -677,10 +683,9 @@ static void devm_iio_trigger_unreg(void *trigger_info) } /** - * __devm_iio_trigger_register - Resource-managed iio_trigger_register() + * devm_iio_trigger_register - Resource-managed iio_trigger_register() * @dev: device this trigger was allocated for * @trig_info: trigger to register - * @this_mod: module registering the trigger * * Managed iio_trigger_register(). The IIO trigger registered with this * function is automatically unregistered on driver detach. This function @@ -690,19 +695,18 @@ static void devm_iio_trigger_unreg(void *trigger_info) * RETURNS: * 0 on success, negative error number on failure. */ -int __devm_iio_trigger_register(struct device *dev, - struct iio_trigger *trig_info, - struct module *this_mod) +int devm_iio_trigger_register(struct device *dev, + struct iio_trigger *trig_info) { int ret; - ret = __iio_trigger_register(trig_info, this_mod); + ret = iio_trigger_register(trig_info); if (ret) return ret; return devm_add_action_or_reset(dev, devm_iio_trigger_unreg, trig_info); } -EXPORT_SYMBOL_GPL(__devm_iio_trigger_register); +EXPORT_SYMBOL_GPL(devm_iio_trigger_register); bool iio_trigger_using_own(struct iio_dev *indio_dev) { diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index d9b4a9ca9a0f..5dfbfc991c69 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -727,10 +727,13 @@ static inline void *iio_priv(const struct iio_dev *indio_dev) void iio_device_free(struct iio_dev *indio_dev); struct iio_dev *devm_iio_device_alloc(struct device *parent, int sizeof_priv); -__printf(2, 3) -struct iio_trigger *devm_iio_trigger_alloc(struct device *parent, - const char *fmt, ...); +#define devm_iio_trigger_alloc(parent, fmt, ...) \ + __devm_iio_trigger_alloc((parent), THIS_MODULE, (fmt), ##__VA_ARGS__) +__printf(3, 4) +struct iio_trigger *__devm_iio_trigger_alloc(struct device *parent, + struct module *this_mod, + const char *fmt, ...); /** * iio_get_debugfs_dentry() - helper function to get the debugfs_dentry * @indio_dev: IIO device structure for device diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h index 03b1d6863436..f6360d9a492d 100644 --- a/include/linux/iio/trigger.h +++ b/include/linux/iio/trigger.h @@ -131,16 +131,10 @@ static inline void *iio_trigger_get_drvdata(struct iio_trigger *trig) * iio_trigger_register() - register a trigger with the IIO core * @trig_info: trigger to be registered **/ -#define iio_trigger_register(trig_info) \ - __iio_trigger_register((trig_info), THIS_MODULE) -int __iio_trigger_register(struct iio_trigger *trig_info, - struct module *this_mod); +int iio_trigger_register(struct iio_trigger *trig_info); -#define devm_iio_trigger_register(dev, trig_info) \ - __devm_iio_trigger_register((dev), (trig_info), THIS_MODULE) -int __devm_iio_trigger_register(struct device *dev, - struct iio_trigger *trig_info, - struct module *this_mod); +int devm_iio_trigger_register(struct device *dev, + struct iio_trigger *trig_info); /** * iio_trigger_unregister() - unregister a trigger from the core @@ -168,8 +162,13 @@ void iio_trigger_poll_chained(struct iio_trigger *trig); irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private); -__printf(2, 3) -struct iio_trigger *iio_trigger_alloc(struct device *parent, const char *fmt, ...); +#define iio_trigger_alloc(parent, fmt, ...) \ + __iio_trigger_alloc((parent), THIS_MODULE, (fmt), ##__VA_ARGS__) + +__printf(3, 4) +struct iio_trigger *__iio_trigger_alloc(struct device *parent, + struct module *this_mod, + const char *fmt, ...); void iio_trigger_free(struct iio_trigger *trig); /** From 7008f35c4a7b25ea2e22bcaa14f21ae7aef49f2a Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 15 Jun 2022 14:47:45 +0300 Subject: [PATCH 03/65] iio: proximity: sx_common: Don't use IIO device for properties It's not correct to use artificial device created by IIO core to retrieve device properties. Even ->get_default_reg() callback takes a simple struct device pointer which suggests it wants to operate on the real device. Correct this by replacing pointer to IIO device by a real device pointer in the caller of ->get_default_reg(). Signed-off-by: Andy Shevchenko Reviewed-by: Gwendal Grignou Link: https://lore.kernel.org/r/20220615114746.2767-1-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx_common.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c index 8ad814d96b7e..9f2e47385198 100644 --- a/drivers/iio/proximity/sx_common.c +++ b/drivers/iio/proximity/sx_common.c @@ -434,7 +434,7 @@ static void sx_common_regulator_disable(void *_data) #define SX_COMMON_SOFT_RESET 0xde -static int sx_common_init_device(struct iio_dev *indio_dev) +static int sx_common_init_device(struct device *dev, struct iio_dev *indio_dev) { struct sx_common_data *data = iio_priv(indio_dev); struct sx_common_reg_default tmp; @@ -456,8 +456,7 @@ static int sx_common_init_device(struct iio_dev *indio_dev) /* Program defaults from constant or BIOS. */ for (i = 0; i < data->chip_info->num_default_regs; i++) { - initval = data->chip_info->ops.get_default_reg(&indio_dev->dev, - i, &tmp); + initval = data->chip_info->ops.get_default_reg(dev, i, &tmp); ret = regmap_write(data->regmap, initval->reg, initval->def); if (ret) return ret; @@ -530,7 +529,7 @@ int sx_common_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); - ret = sx_common_init_device(indio_dev); + ret = sx_common_init_device(dev, indio_dev); if (ret) return dev_err_probe(dev, ret, "Unable to initialize sensor\n"); From f1e252c5d2d8e54d60ba9e43b2ec9473f3a1c5b7 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 15 Jun 2022 14:47:46 +0300 Subject: [PATCH 04/65] iio: proximity: sx_common: Allow IIO core to take care of firmware node IIO core correctly will take care of firmware node if it's not set in the driver. Drop ACPI and OF specifics from the driver and allow IIO core to handle this. Signed-off-by: Andy Shevchenko Reviewed-by: Gwendal Grignou Link: https://lore.kernel.org/r/20220615114746.2767-2-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx_common.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c index 9f2e47385198..d70a6b4f0bf8 100644 --- a/drivers/iio/proximity/sx_common.c +++ b/drivers/iio/proximity/sx_common.c @@ -5,7 +5,6 @@ * Common part of most Semtech SAR sensor. */ -#include #include #include #include @@ -519,8 +518,6 @@ int sx_common_probe(struct i2c_client *client, if (ret) return dev_err_probe(dev, ret, "error reading WHOAMI\n"); - ACPI_COMPANION_SET(&indio_dev->dev, ACPI_COMPANION(dev)); - indio_dev->dev.of_node = client->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = data->chip_info->iio_channels; From 98a30ae0b37cfa5f5b07db532c69d787780d6664 Mon Sep 17 00:00:00 2001 From: Marcus Folkesson Date: Sat, 2 Jul 2022 10:50:05 +0200 Subject: [PATCH 05/65] iio: magnetometer: rm3100: do not explicity set INDIO_BUFFER_TRIGGERED mode The core sets INDIO_BUFFER_TRIGGERED as part of devm_iio_triggered_buffer_setup(). Signed-off-by: Marcus Folkesson Link: https://lore.kernel.org/r/20220702085005.31666-1-marcus.folkesson@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/rm3100-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c index 707ba25360b8..69938204456f 100644 --- a/drivers/iio/magnetometer/rm3100-core.c +++ b/drivers/iio/magnetometer/rm3100-core.c @@ -544,7 +544,7 @@ int rm3100_common_probe(struct device *dev, struct regmap *regmap, int irq) indio_dev->info = &rm3100_info; indio_dev->channels = rm3100_channels; indio_dev->num_channels = ARRAY_SIZE(rm3100_channels); - indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_TRIGGERED; + indio_dev->modes = INDIO_DIRECT_MODE; if (!irq) data->use_interrupt = false; From 6cfd14c54b1f42f29097244c1b6208f8268d7d5b Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Thu, 7 Jul 2022 13:21:24 -0400 Subject: [PATCH 06/65] iio: adc: stx104: Implement and utilize register structures Reduce magic numbers and improve code readability by implementing and utilizing named register data structures. Tested-by: Fred Eckert Signed-off-by: William Breathitt Gray Link: https://lore.kernel.org/r/8cb91d5b53e57b066120e42ea07000d6c7ef5543.1657213745.git.william.gray@linaro.org Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stx104.c | 74 +++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c index 7552351bfed9..48a91a95e597 100644 --- a/drivers/iio/adc/stx104.c +++ b/drivers/iio/adc/stx104.c @@ -16,6 +16,7 @@ #include #include #include +#include #define STX104_OUT_CHAN(chan) { \ .type = IIO_VOLTAGE, \ @@ -44,14 +45,36 @@ static unsigned int num_stx104; module_param_hw_array(base, uint, ioport, &num_stx104, 0); MODULE_PARM_DESC(base, "Apex Embedded Systems STX104 base addresses"); +/** + * struct stx104_reg - device register structure + * @ssr_ad: Software Strobe Register and ADC Data + * @achan: ADC Channel + * @dio: Digital I/O + * @dac: DAC Channels + * @cir_asr: Clear Interrupts and ADC Status + * @acr: ADC Control + * @pccr_fsh: Pacer Clock Control and FIFO Status MSB + * @acfg: ADC Configuration + */ +struct stx104_reg { + u16 ssr_ad; + u8 achan; + u8 dio; + u16 dac[2]; + u8 cir_asr; + u8 acr; + u8 pccr_fsh; + u8 acfg; +}; + /** * struct stx104_iio - IIO device private data structure * @chan_out_states: channels' output states - * @base: base port address of the IIO device + * @reg: I/O address offset for the device registers */ struct stx104_iio { unsigned int chan_out_states[STX104_NUM_OUT_CHAN]; - void __iomem *base; + struct stx104_reg __iomem *reg; }; /** @@ -64,7 +87,7 @@ struct stx104_iio { struct stx104_gpio { struct gpio_chip chip; spinlock_t lock; - void __iomem *base; + u8 __iomem *base; unsigned int out_state; }; @@ -72,6 +95,7 @@ static int stx104_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { struct stx104_iio *const priv = iio_priv(indio_dev); + struct stx104_reg __iomem *const reg = priv->reg; unsigned int adc_config; int adbu; int gain; @@ -79,7 +103,7 @@ static int stx104_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_HARDWAREGAIN: /* get gain configuration */ - adc_config = ioread8(priv->base + 11); + adc_config = ioread8(®->acfg); gain = adc_config & 0x3; *val = 1 << gain; @@ -91,24 +115,26 @@ static int stx104_read_raw(struct iio_dev *indio_dev, } /* select ADC channel */ - iowrite8(chan->channel | (chan->channel << 4), priv->base + 2); + iowrite8(chan->channel | (chan->channel << 4), ®->achan); - /* trigger ADC sample capture and wait for completion */ - iowrite8(0, priv->base); - while (ioread8(priv->base + 8) & BIT(7)); + /* trigger ADC sample capture by writing to the 8-bit + * Software Strobe Register and wait for completion + */ + iowrite8(0, ®->ssr_ad); + while (ioread8(®->cir_asr) & BIT(7)); - *val = ioread16(priv->base); + *val = ioread16(®->ssr_ad); return IIO_VAL_INT; case IIO_CHAN_INFO_OFFSET: /* get ADC bipolar/unipolar configuration */ - adc_config = ioread8(priv->base + 11); + adc_config = ioread8(®->acfg); adbu = !(adc_config & BIT(2)); *val = -32768 * adbu; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: /* get ADC bipolar/unipolar and gain configuration */ - adc_config = ioread8(priv->base + 11); + adc_config = ioread8(®->acfg); adbu = !(adc_config & BIT(2)); gain = adc_config & 0x3; @@ -130,16 +156,16 @@ static int stx104_write_raw(struct iio_dev *indio_dev, /* Only four gain states (x1, x2, x4, x8) */ switch (val) { case 1: - iowrite8(0, priv->base + 11); + iowrite8(0, &priv->reg->acfg); break; case 2: - iowrite8(1, priv->base + 11); + iowrite8(1, &priv->reg->acfg); break; case 4: - iowrite8(2, priv->base + 11); + iowrite8(2, &priv->reg->acfg); break; case 8: - iowrite8(3, priv->base + 11); + iowrite8(3, &priv->reg->acfg); break; default: return -EINVAL; @@ -153,7 +179,7 @@ static int stx104_write_raw(struct iio_dev *indio_dev, return -EINVAL; priv->chan_out_states[chan->channel] = val; - iowrite16(val, priv->base + 4 + 2 * chan->channel); + iowrite16(val, &priv->reg->dac[chan->channel]); return 0; } @@ -307,15 +333,15 @@ static int stx104_probe(struct device *dev, unsigned int id) } priv = iio_priv(indio_dev); - priv->base = devm_ioport_map(dev, base[id], STX104_EXTENT); - if (!priv->base) + priv->reg = devm_ioport_map(dev, base[id], STX104_EXTENT); + if (!priv->reg) return -ENOMEM; indio_dev->info = &stx104_info; indio_dev->modes = INDIO_DIRECT_MODE; /* determine if differential inputs */ - if (ioread8(priv->base + 8) & BIT(5)) { + if (ioread8(&priv->reg->cir_asr) & BIT(5)) { indio_dev->num_channels = ARRAY_SIZE(stx104_channels_diff); indio_dev->channels = stx104_channels_diff; } else { @@ -326,14 +352,14 @@ static int stx104_probe(struct device *dev, unsigned int id) indio_dev->name = dev_name(dev); /* configure device for software trigger operation */ - iowrite8(0, priv->base + 9); + iowrite8(0, &priv->reg->acr); /* initialize gain setting to x1 */ - iowrite8(0, priv->base + 11); + iowrite8(0, &priv->reg->acfg); /* initialize DAC output to 0V */ - iowrite16(0, priv->base + 4); - iowrite16(0, priv->base + 6); + iowrite16(0, &priv->reg->dac[0]); + iowrite16(0, &priv->reg->dac[1]); stx104gpio->chip.label = dev_name(dev); stx104gpio->chip.parent = dev; @@ -348,7 +374,7 @@ static int stx104_probe(struct device *dev, unsigned int id) stx104gpio->chip.get_multiple = stx104_gpio_get_multiple; stx104gpio->chip.set = stx104_gpio_set; stx104gpio->chip.set_multiple = stx104_gpio_set_multiple; - stx104gpio->base = priv->base + 3; + stx104gpio->base = &priv->reg->dio; stx104gpio->out_state = 0x0; spin_lock_init(&stx104gpio->lock); From e1d965cebe82e59e6a4c0cf115e5dbd7a9a0d9e5 Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Thu, 7 Jul 2022 13:21:25 -0400 Subject: [PATCH 07/65] iio: dac: cio-dac: Cleanup indexing for DAC writes Simplify DAC write code by defining base member as u16 __iomem *; DAC registers are 16-bit so this allows us to index each DAC channel directly in a loop rather than calculating the offsets by multipling by 2 each time. Signed-off-by: William Breathitt Gray Link: https://lore.kernel.org/r/d9dab6696af7eabb2d46f5cbc7871329f499c1c9.1657213745.git.william.gray@linaro.org Signed-off-by: Jonathan Cameron --- drivers/iio/dac/cio-dac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iio/dac/cio-dac.c b/drivers/iio/dac/cio-dac.c index 8080984dcb03..791dd999cf29 100644 --- a/drivers/iio/dac/cio-dac.c +++ b/drivers/iio/dac/cio-dac.c @@ -16,6 +16,7 @@ #include #include #include +#include #define CIO_DAC_NUM_CHAN 16 @@ -37,11 +38,11 @@ MODULE_PARM_DESC(base, "Measurement Computing CIO-DAC base addresses"); /** * struct cio_dac_iio - IIO device private data structure * @chan_out_states: channels' output states - * @base: base port address of the IIO device + * @base: base memory address of the DAC device */ struct cio_dac_iio { int chan_out_states[CIO_DAC_NUM_CHAN]; - void __iomem *base; + u16 __iomem *base; }; static int cio_dac_read_raw(struct iio_dev *indio_dev, @@ -61,7 +62,6 @@ static int cio_dac_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) { struct cio_dac_iio *const priv = iio_priv(indio_dev); - const unsigned int chan_addr_offset = 2 * chan->channel; if (mask != IIO_CHAN_INFO_RAW) return -EINVAL; @@ -71,7 +71,7 @@ static int cio_dac_write_raw(struct iio_dev *indio_dev, return -EINVAL; priv->chan_out_states[chan->channel] = val; - iowrite16(val, priv->base + chan_addr_offset); + iowrite16(val, priv->base + chan->channel); return 0; } @@ -117,7 +117,7 @@ static int cio_dac_probe(struct device *dev, unsigned int id) indio_dev->name = dev_name(dev); /* initialize DAC outputs to 0V */ - for (i = 0; i < 32; i += 2) + for (i = 0; i < CIO_DAC_NUM_CHAN; i++) iowrite16(0, priv->base + i); return devm_iio_device_register(dev, indio_dev); From 6edac2daa954e9da32f36a6c927a2d2bd956308b Mon Sep 17 00:00:00 2001 From: Thorsten Scherer Date: Fri, 8 Jul 2022 22:17:20 +0200 Subject: [PATCH 08/65] iio: adc: ad7949: Fix error message Signed-off-by: Thorsten Scherer Reviewed-by: Liam Beguin Link: https://lore.kernel.org/r/20220708201720.16523-1-t.scherer@eckelmann.de Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7949.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7949.c b/drivers/iio/adc/ad7949.c index ed4c1656ca75..edd0c3a35ab7 100644 --- a/drivers/iio/adc/ad7949.c +++ b/drivers/iio/adc/ad7949.c @@ -400,7 +400,7 @@ static int ad7949_spi_probe(struct spi_device *spi) ret = ad7949_spi_init(ad7949_adc); if (ret) { - dev_err(dev, "enable to init this device: %d\n", ret); + dev_err(dev, "fail to init this device: %d\n", ret); return ret; } From 53a2a90d5271ed4718a70f8e13faaaf9f9ba9eb6 Mon Sep 17 00:00:00 2001 From: Liam Beguin Date: Sat, 9 Jul 2022 21:31:05 -0400 Subject: [PATCH 09/65] iio: test: rescale: add MODULE_* information In preparation for module support, add missing MODULE_* information. Signed-off-by: Liam Beguin Link: https://lore.kernel.org/r/20220710013109.3349104-2-liambeguin@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/test/iio-test-rescale.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/test/iio-test-rescale.c b/drivers/iio/test/iio-test-rescale.c index 0b6699bfd553..735e2f97af18 100644 --- a/drivers/iio/test/iio-test-rescale.c +++ b/drivers/iio/test/iio-test-rescale.c @@ -708,3 +708,7 @@ static struct kunit_suite iio_rescale_test_suite = { .test_cases = iio_rescale_test_cases, }; kunit_test_suite(iio_rescale_test_suite); + +MODULE_AUTHOR("Liam Beguin "); +MODULE_DESCRIPTION("Test IIO rescale conversion functions"); +MODULE_LICENSE("GPL v2"); From 520f94b6aab1740e88248c218542529a3fac06e8 Mon Sep 17 00:00:00 2001 From: Liam Beguin Date: Sat, 9 Jul 2022 21:31:06 -0400 Subject: [PATCH 10/65] iio: test: format: add MODULE_* information In preparation for module support, add missing MODULE_* information. Signed-off-by: Liam Beguin Link: https://lore.kernel.org/r/20220710013109.3349104-3-liambeguin@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/test/iio-test-format.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/test/iio-test-format.c b/drivers/iio/test/iio-test-format.c index 237321436b83..fc67e6b73df7 100644 --- a/drivers/iio/test/iio-test-format.c +++ b/drivers/iio/test/iio-test-format.c @@ -265,3 +265,7 @@ static struct kunit_suite iio_format_test_suite = { .test_cases = iio_format_test_cases, }; kunit_test_suite(iio_format_test_suite); + +MODULE_AUTHOR("Lars-Peter Clausen "); +MODULE_DESCRIPTION("Test IIO formatting functions"); +MODULE_LICENSE("GPL v2"); From 1c796caff0dba1774f31899170ea18b32768af1f Mon Sep 17 00:00:00 2001 From: Liam Beguin Date: Sat, 9 Jul 2022 21:31:07 -0400 Subject: [PATCH 11/65] iio: test: format: follow CONFIG_ naming convention The KUnit documentation indicates that all KUnit Kconfig entries must match CONFIG__KUNIT_TEST: where is the name of the test suite. Rename the IIO_TEST_FORMAT configuration accordingly. Signed-off-by: Liam Beguin Link: https://lore.kernel.org/r/20220710013109.3349104-4-liambeguin@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/test/Kconfig | 2 +- drivers/iio/test/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/test/Kconfig b/drivers/iio/test/Kconfig index 4c66c3f18c34..7dbf51bc4934 100644 --- a/drivers/iio/test/Kconfig +++ b/drivers/iio/test/Kconfig @@ -14,6 +14,6 @@ config IIO_RESCALE_KUNIT_TEST This takes advantage of ARCH=um to run tests and should be used by developers to tests their changes to the rescaling logic. -config IIO_TEST_FORMAT +config IIO_FORMAT_KUNIT_TEST bool "Test IIO formatting functions" depends on KUNIT=y diff --git a/drivers/iio/test/Makefile b/drivers/iio/test/Makefile index 880360f8d02c..d76eaf36da82 100644 --- a/drivers/iio/test/Makefile +++ b/drivers/iio/test/Makefile @@ -5,5 +5,5 @@ # Keep in alphabetical order obj-$(CONFIG_IIO_RESCALE_KUNIT_TEST) += iio-test-rescale.o -obj-$(CONFIG_IIO_TEST_FORMAT) += iio-test-format.o +obj-$(CONFIG_IIO_FORMAT_KUNIT_TEST) += iio-test-format.o CFLAGS_iio-test-format.o += $(DISABLE_STRUCTLEAK_PLUGIN) From cf9a4b58b56e007d12063f1beaee555fa0d15561 Mon Sep 17 00:00:00 2001 From: Liam Beguin Date: Sat, 9 Jul 2022 21:31:08 -0400 Subject: [PATCH 12/65] iio: afe: rescale: export symbols used during testing In preparation for module support, export symbols use during testing. Signed-off-by: Liam Beguin Link: https://lore.kernel.org/r/20220710013109.3349104-5-liambeguin@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/afe/iio-rescale.c | 2 ++ drivers/iio/test/iio-test-rescale.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c index 6949d2151025..1f280c360701 100644 --- a/drivers/iio/afe/iio-rescale.c +++ b/drivers/iio/afe/iio-rescale.c @@ -107,6 +107,7 @@ int rescale_process_scale(struct rescale *rescale, int scale_type, return -EOPNOTSUPP; } } +EXPORT_SYMBOL_NS_GPL(rescale_process_scale, IIO_RESCALE); int rescale_process_offset(struct rescale *rescale, int scale_type, int scale, int scale2, int schan_off, @@ -140,6 +141,7 @@ int rescale_process_offset(struct rescale *rescale, int scale_type, return -EOPNOTSUPP; } } +EXPORT_SYMBOL_NS_GPL(rescale_process_offset, IIO_RESCALE); static int rescale_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, diff --git a/drivers/iio/test/iio-test-rescale.c b/drivers/iio/test/iio-test-rescale.c index 735e2f97af18..cc782ccff880 100644 --- a/drivers/iio/test/iio-test-rescale.c +++ b/drivers/iio/test/iio-test-rescale.c @@ -712,3 +712,4 @@ kunit_test_suite(iio_rescale_test_suite); MODULE_AUTHOR("Liam Beguin "); MODULE_DESCRIPTION("Test IIO rescale conversion functions"); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(IIO_RESCALE); From 0565d238b9b4abb7b904248d9064bea80ac706fe Mon Sep 17 00:00:00 2001 From: Liam Beguin Date: Sat, 9 Jul 2022 21:31:09 -0400 Subject: [PATCH 13/65] iio: test: rework Kconfig to support modules Rework the IIO test Kconfig to support building KUnit tests as modules. This lets users execute tests at runtime in addition to the usual tools/testing/kunit/kunit.py script. Signed-off-by: Liam Beguin Link: https://lore.kernel.org/r/20220710013109.3349104-6-liambeguin@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/test/Kconfig | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/iio/test/Kconfig b/drivers/iio/test/Kconfig index 7dbf51bc4934..0b6e4e278a2f 100644 --- a/drivers/iio/test/Kconfig +++ b/drivers/iio/test/Kconfig @@ -5,15 +5,25 @@ # Keep in alphabetical order config IIO_RESCALE_KUNIT_TEST - bool "Test IIO rescale conversion functions" - depends on KUNIT=y && IIO_RESCALE=y + tristate "Test IIO rescale conversion functions" if !KUNIT_ALL_TESTS + depends on KUNIT && IIO_RESCALE default KUNIT_ALL_TESTS help - If you want to run tests on the iio-rescale code say Y here. + Build unit tests for the iio-rescale code. - This takes advantage of ARCH=um to run tests and should be used by - developers to tests their changes to the rescaling logic. + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N. config IIO_FORMAT_KUNIT_TEST - bool "Test IIO formatting functions" - depends on KUNIT=y + tristate "Test IIO formatting functions" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + build unit tests for the IIO formatting functions. + + For more information on KUnit and unit tests in general, please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N. From 0b4ae3f6d1210c11f9baf159009c7227eacf90f2 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Mon, 11 Jul 2022 07:47:16 -0700 Subject: [PATCH 14/65] iio: cros: Register FIFO callback after sensor is registered Instead of registering callback to process sensor events right at initialization time, wait for the sensor to be register in the iio subsystem. Events can come at probe time (in case the kernel rebooted abruptly without switching the sensor off for instance), and be sent to IIO core before the sensor is fully registered. Fixes: aa984f1ba4a4 ("iio: cros_ec: Register to cros_ec_sensorhub when EC supports FIFO") Reported-by: Douglas Anderson Signed-off-by: Gwendal Grignou Reviewed-by: Douglas Anderson Link: https://lore.kernel.org/r/20220711144716.642617-1-gwendal@chromium.org Signed-off-by: Jonathan Cameron --- drivers/iio/accel/cros_ec_accel_legacy.c | 4 +- .../cros_ec_sensors/cros_ec_lid_angle.c | 4 +- .../common/cros_ec_sensors/cros_ec_sensors.c | 6 +- .../cros_ec_sensors/cros_ec_sensors_core.c | 58 ++++++++++++++----- drivers/iio/light/cros_ec_light_prox.c | 6 +- drivers/iio/pressure/cros_ec_baro.c | 6 +- .../linux/iio/common/cros_ec_sensors_core.h | 7 ++- 7 files changed, 60 insertions(+), 31 deletions(-) diff --git a/drivers/iio/accel/cros_ec_accel_legacy.c b/drivers/iio/accel/cros_ec_accel_legacy.c index 1c0171f26e99..0f403342b1fc 100644 --- a/drivers/iio/accel/cros_ec_accel_legacy.c +++ b/drivers/iio/accel/cros_ec_accel_legacy.c @@ -215,7 +215,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev) return -ENOMEM; ret = cros_ec_sensors_core_init(pdev, indio_dev, true, - cros_ec_sensors_capture, NULL); + cros_ec_sensors_capture); if (ret) return ret; @@ -235,7 +235,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev) state->sign[CROS_EC_SENSOR_Z] = -1; } - return devm_iio_device_register(dev, indio_dev); + return cros_ec_sensors_core_register(dev, indio_dev, NULL); } static struct platform_driver cros_ec_accel_platform_driver = { diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c index 9f780fafaed9..119acb078af3 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c @@ -98,7 +98,7 @@ static int cros_ec_lid_angle_probe(struct platform_device *pdev) if (!indio_dev) return -ENOMEM; - ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL, NULL); + ret = cros_ec_sensors_core_init(pdev, indio_dev, false, NULL); if (ret) return ret; @@ -114,7 +114,7 @@ static int cros_ec_lid_angle_probe(struct platform_device *pdev) if (ret) return ret; - return devm_iio_device_register(dev, indio_dev); + return cros_ec_sensors_core_register(dev, indio_dev, NULL); } static const struct platform_device_id cros_ec_lid_angle_ids[] = { diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c index 61e07a7bb199..66153b1850f1 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c @@ -236,8 +236,7 @@ static int cros_ec_sensors_probe(struct platform_device *pdev) return -ENOMEM; ret = cros_ec_sensors_core_init(pdev, indio_dev, true, - cros_ec_sensors_capture, - cros_ec_sensors_push_data); + cros_ec_sensors_capture); if (ret) return ret; @@ -298,7 +297,8 @@ static int cros_ec_sensors_probe(struct platform_device *pdev) else state->core.read_ec_sensors_data = cros_ec_sensors_read_cmd; - return devm_iio_device_register(dev, indio_dev); + return cros_ec_sensors_core_register(dev, indio_dev, + cros_ec_sensors_push_data); } static const struct platform_device_id cros_ec_sensors_ids[] = { diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c index e5ccedef13a8..05a28d353e34 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c @@ -228,21 +228,18 @@ static void cros_ec_sensors_core_clean(void *arg) /** * cros_ec_sensors_core_init() - basic initialization of the core structure - * @pdev: platform device created for the sensors + * @pdev: platform device created for the sensor * @indio_dev: iio device structure of the device * @physical_device: true if the device refers to a physical device * @trigger_capture: function pointer to call buffer is triggered, * for backward compatibility. - * @push_data: function to call when cros_ec_sensorhub receives - * a sample for that sensor. * * Return: 0 on success, -errno on failure. */ int cros_ec_sensors_core_init(struct platform_device *pdev, struct iio_dev *indio_dev, bool physical_device, - cros_ec_sensors_capture_t trigger_capture, - cros_ec_sensorhub_push_data_cb_t push_data) + cros_ec_sensors_capture_t trigger_capture) { struct device *dev = &pdev->dev; struct cros_ec_sensors_core_state *state = iio_priv(indio_dev); @@ -340,17 +337,6 @@ int cros_ec_sensors_core_init(struct platform_device *pdev, if (ret) return ret; - ret = cros_ec_sensorhub_register_push_data( - sensor_hub, sensor_platform->sensor_num, - indio_dev, push_data); - if (ret) - return ret; - - ret = devm_add_action_or_reset( - dev, cros_ec_sensors_core_clean, pdev); - if (ret) - return ret; - /* Timestamp coming from FIFO are in ns since boot. */ ret = iio_device_set_clock(indio_dev, CLOCK_BOOTTIME); if (ret) @@ -372,6 +358,46 @@ int cros_ec_sensors_core_init(struct platform_device *pdev, } EXPORT_SYMBOL_GPL(cros_ec_sensors_core_init); +/** + * cros_ec_sensors_core_register() - Register callback to FIFO and IIO when + * sensor is ready. + * It must be called at the end of the sensor probe routine. + * @dev: device created for the sensor + * @indio_dev: iio device structure of the device + * @push_data: function to call when cros_ec_sensorhub receives + * a sample for that sensor. + * + * Return: 0 on success, -errno on failure. + */ +int cros_ec_sensors_core_register(struct device *dev, + struct iio_dev *indio_dev, + cros_ec_sensorhub_push_data_cb_t push_data) +{ + struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev); + struct cros_ec_sensorhub *sensor_hub = dev_get_drvdata(dev->parent); + struct platform_device *pdev = to_platform_device(dev); + struct cros_ec_dev *ec = sensor_hub->ec; + int ret; + + ret = devm_iio_device_register(dev, indio_dev); + if (ret) + return ret; + + if (!push_data || + !cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO)) + return 0; + + ret = cros_ec_sensorhub_register_push_data( + sensor_hub, sensor_platform->sensor_num, + indio_dev, push_data); + if (ret) + return ret; + + return devm_add_action_or_reset( + dev, cros_ec_sensors_core_clean, pdev); +} +EXPORT_SYMBOL_GPL(cros_ec_sensors_core_register); + /** * cros_ec_motion_send_host_cmd() - send motion sense host command * @state: pointer to state information for device diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c index e345e0f71b74..19e529c84e95 100644 --- a/drivers/iio/light/cros_ec_light_prox.c +++ b/drivers/iio/light/cros_ec_light_prox.c @@ -182,8 +182,7 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev) return -ENOMEM; ret = cros_ec_sensors_core_init(pdev, indio_dev, true, - cros_ec_sensors_capture, - cros_ec_sensors_push_data); + cros_ec_sensors_capture); if (ret) return ret; @@ -239,7 +238,8 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev) state->core.read_ec_sensors_data = cros_ec_sensors_read_cmd; - return devm_iio_device_register(dev, indio_dev); + return cros_ec_sensors_core_register(dev, indio_dev, + cros_ec_sensors_push_data); } static const struct platform_device_id cros_ec_light_prox_ids[] = { diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c index 25217279f350..2649c2f89e89 100644 --- a/drivers/iio/pressure/cros_ec_baro.c +++ b/drivers/iio/pressure/cros_ec_baro.c @@ -139,8 +139,7 @@ static int cros_ec_baro_probe(struct platform_device *pdev) return -ENOMEM; ret = cros_ec_sensors_core_init(pdev, indio_dev, true, - cros_ec_sensors_capture, - cros_ec_sensors_push_data); + cros_ec_sensors_capture); if (ret) return ret; @@ -185,7 +184,8 @@ static int cros_ec_baro_probe(struct platform_device *pdev) state->core.read_ec_sensors_data = cros_ec_sensors_read_cmd; - return devm_iio_device_register(dev, indio_dev); + return cros_ec_sensors_core_register(dev, indio_dev, + cros_ec_sensors_push_data); } static const struct platform_device_id cros_ec_baro_ids[] = { diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h index a8259c8822f5..e72167b96d27 100644 --- a/include/linux/iio/common/cros_ec_sensors_core.h +++ b/include/linux/iio/common/cros_ec_sensors_core.h @@ -93,8 +93,11 @@ int cros_ec_sensors_read_cmd(struct iio_dev *indio_dev, unsigned long scan_mask, struct platform_device; int cros_ec_sensors_core_init(struct platform_device *pdev, struct iio_dev *indio_dev, bool physical_device, - cros_ec_sensors_capture_t trigger_capture, - cros_ec_sensorhub_push_data_cb_t push_data); + cros_ec_sensors_capture_t trigger_capture); + +int cros_ec_sensors_core_register(struct device *dev, + struct iio_dev *indio_dev, + cros_ec_sensorhub_push_data_cb_t push_data); irqreturn_t cros_ec_sensors_capture(int irq, void *p); int cros_ec_sensors_push_data(struct iio_dev *indio_dev, From f0b4913ad0e3ce551c2bf6e14f9dddde1cd98176 Mon Sep 17 00:00:00 2001 From: Tomer Maimon Date: Wed, 13 Jul 2022 16:26:39 +0300 Subject: [PATCH 15/65] dt-bindings: iio: adc: npcm: Add npcm845 compatible string Add a compatible string for Nuvoton BMC NPCM845 ADC. Signed-off-by: Tomer Maimon Reviewed-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20220713132640.215916-2-tmaimon77@gmail.com Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/nuvoton,npcm750-adc.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/nuvoton,npcm750-adc.yaml b/Documentation/devicetree/bindings/iio/adc/nuvoton,npcm750-adc.yaml index 001cf263b7d5..fede2aa64092 100644 --- a/Documentation/devicetree/bindings/iio/adc/nuvoton,npcm750-adc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/nuvoton,npcm750-adc.yaml @@ -10,11 +10,14 @@ maintainers: - Tomer Maimon description: - The NPCM ADC is a 10-bit converter for eight channel inputs. + The NPCM7XX ADC is a 10-bit converter and NPCM8XX ADC is a 12-bit converter, + both have eight channel inputs. properties: compatible: - const: nuvoton,npcm750-adc + enum: + - nuvoton,npcm750-adc + - nuvoton,npcm845-adc reg: maxItems: 1 From 3ccb25240012ea0e975e24a199bb1ee9643be743 Mon Sep 17 00:00:00 2001 From: Tomer Maimon Date: Wed, 13 Jul 2022 16:26:40 +0300 Subject: [PATCH 16/65] iio: adc: npcm: Add NPCM8XX support Adding ADC NPCM8XX support to NPCM ADC driver. ADC NPCM8XX uses a different resolution and voltage reference. As part of adding NPCM8XX support: - Add NPCM8XX specific compatible string. - Add data to handle architecture-specific ADC parameters. Signed-off-by: Tomer Maimon Link: https://lore.kernel.org/r/20220713132640.215916-3-tmaimon77@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/npcm_adc.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c index a242e7993476..ba4cd8f49f66 100644 --- a/drivers/iio/adc/npcm_adc.c +++ b/drivers/iio/adc/npcm_adc.c @@ -11,12 +11,19 @@ #include #include #include +#include #include #include #include #include #include +struct npcm_adc_info { + u32 data_mask; + u32 internal_vref; + u32 res_bits; +}; + struct npcm_adc { bool int_status; u32 adc_sample_hz; @@ -35,6 +42,7 @@ struct npcm_adc { * has finished. */ struct mutex lock; + const struct npcm_adc_info *data; }; /* ADC registers */ @@ -53,13 +61,21 @@ struct npcm_adc { #define NPCM_ADCCON_CH(x) ((x) << 24) #define NPCM_ADCCON_DIV_SHIFT 1 #define NPCM_ADCCON_DIV_MASK GENMASK(8, 1) -#define NPCM_ADC_DATA_MASK(x) ((x) & GENMASK(9, 0)) #define NPCM_ADC_ENABLE (NPCM_ADCCON_ADC_EN | NPCM_ADCCON_ADC_INT_EN) /* ADC General Definition */ -#define NPCM_RESOLUTION_BITS 10 -#define NPCM_INT_VREF_MV 2000 +static const struct npcm_adc_info npxm7xx_adc_info = { + .data_mask = GENMASK(9, 0), + .internal_vref = 2048, + .res_bits = 10, +}; + +static const struct npcm_adc_info npxm8xx_adc_info = { + .data_mask = GENMASK(11, 0), + .internal_vref = 1229, + .res_bits = 12, +}; #define NPCM_ADC_CHAN(ch) { \ .type = IIO_VOLTAGE, \ @@ -130,7 +146,8 @@ static int npcm_adc_read(struct npcm_adc *info, int *val, u8 channel) if (ret < 0) return ret; - *val = NPCM_ADC_DATA_MASK(ioread32(info->regs + NPCM_ADCDATA)); + *val = ioread32(info->regs + NPCM_ADCDATA); + *val &= info->data->data_mask; return 0; } @@ -158,9 +175,9 @@ static int npcm_adc_read_raw(struct iio_dev *indio_dev, vref_uv = regulator_get_voltage(info->vref); *val = vref_uv / 1000; } else { - *val = NPCM_INT_VREF_MV; + *val = info->data->internal_vref; } - *val2 = NPCM_RESOLUTION_BITS; + *val2 = info->data->res_bits; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_SAMP_FREQ: *val = info->adc_sample_hz; @@ -177,7 +194,8 @@ static const struct iio_info npcm_adc_iio_info = { }; static const struct of_device_id npcm_adc_match[] = { - { .compatible = "nuvoton,npcm750-adc", }, + { .compatible = "nuvoton,npcm750-adc", .data = &npxm7xx_adc_info}, + { .compatible = "nuvoton,npcm845-adc", .data = &npxm8xx_adc_info}, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, npcm_adc_match); @@ -197,6 +215,10 @@ static int npcm_adc_probe(struct platform_device *pdev) return -ENOMEM; info = iio_priv(indio_dev); + info->data = device_get_match_data(dev); + if (!info->data) + return -EINVAL; + mutex_init(&info->lock); info->dev = &pdev->dev; From ef7ceceeb1fbffff75999ae10f8b7cb4b256a236 Mon Sep 17 00:00:00 2001 From: Joe Simmons-Talbott Date: Sun, 17 Jul 2022 11:34:38 -0400 Subject: [PATCH 17/65] iio: Use parens with sizeof Prefer 'sizeof(var)' over 'sizeof var' as reported by checkpatch.pl. Signed-off-by: Joe Simmons-Talbott Link: https://lore.kernel.org/r/20220717153438.10800-1-joetalbott@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-trigger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index efc01584b3f9..3e1b1fbc66d0 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -364,7 +364,7 @@ struct iio_poll_func va_list vargs; struct iio_poll_func *pf; - pf = kmalloc(sizeof *pf, GFP_KERNEL); + pf = kmalloc(sizeof(*pf), GFP_KERNEL); if (pf == NULL) return NULL; va_start(vargs, fmt); @@ -553,7 +553,7 @@ struct iio_trigger *viio_trigger_alloc(struct device *parent, struct iio_trigger *trig; int i; - trig = kzalloc(sizeof *trig, GFP_KERNEL); + trig = kzalloc(sizeof(*trig), GFP_KERNEL); if (!trig) return NULL; From 295cc4268bb946a84f7681a9f032ade09a4087f8 Mon Sep 17 00:00:00 2001 From: Joe Simmons-Talbott Date: Sun, 17 Jul 2022 22:03:48 -0400 Subject: [PATCH 18/65] iio: Be consistent with allocation result tests. Make both allocation result tests use the same format if (!ptr) Signed-off-by: Joe Simmons-Talbott Link: https://lore.kernel.org/r/20220718020348.32047-1-joetalbott@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 3e1b1fbc66d0..b78814d869b7 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -365,7 +365,7 @@ struct iio_poll_func struct iio_poll_func *pf; pf = kmalloc(sizeof(*pf), GFP_KERNEL); - if (pf == NULL) + if (!pf) return NULL; va_start(vargs, fmt); pf->name = kvasprintf(GFP_KERNEL, fmt, vargs); From 6c6a6ee93999528c989438482e2d5cdcdd6bb688 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 26 Jun 2022 17:55:08 +0100 Subject: [PATCH 19/65] iio: ABI: temperature: Unify documentation for thermocouple fault detection. Kernel documentation for a given ABI element should not be duplicated in multiple files, so pull them into one higher level documentation file. Signed-off-by: Jonathan Cameron Cc: Navin Sankar Velliangiri Cc: Paresh Chaudhary Reviewed-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/20220626165511.602202-2-jic23@kernel.org --- .../sysfs-bus-iio-temperature-max31856 | 31 ------------------- .../sysfs-bus-iio-temperature-max31865 | 12 ------- .../ABI/testing/sysfs-bus-iio-thermocouple | 18 +++++++++++ 3 files changed, 18 insertions(+), 43 deletions(-) delete mode 100644 Documentation/ABI/testing/sysfs-bus-iio-temperature-max31856 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-thermocouple diff --git a/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31856 b/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31856 deleted file mode 100644 index e5ef6d8e5da1..000000000000 --- a/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31856 +++ /dev/null @@ -1,31 +0,0 @@ -What: /sys/bus/iio/devices/iio:deviceX/fault_oc -KernelVersion: 5.1 -Contact: linux-iio@vger.kernel.org -Description: - Open-circuit fault. The detection of open-circuit faults, - such as those caused by broken thermocouple wires. - Reading returns either '1' or '0'. - - === ======================================================= - '1' An open circuit such as broken thermocouple wires - has been detected. - '0' No open circuit or broken thermocouple wires are detected - === ======================================================= - -What: /sys/bus/iio/devices/iio:deviceX/fault_ovuv -KernelVersion: 5.1 -Contact: linux-iio@vger.kernel.org -Description: - Overvoltage or Undervoltage Input Fault. The internal circuitry - is protected from excessive voltages applied to the thermocouple - cables by integrated MOSFETs at the T+ and T- inputs, and the - BIAS output. These MOSFETs turn off when the input voltage is - negative or greater than VDD. - - Reading returns either '1' or '0'. - - === ======================================================= - '1' The input voltage is negative or greater than VDD. - '0' The input voltage is positive and less than VDD (normal - state). - === ======================================================= diff --git a/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31865 b/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31865 index 4b072da92218..349089e4f2d6 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31865 +++ b/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31865 @@ -1,15 +1,3 @@ -What: /sys/bus/iio/devices/iio:deviceX/fault_ovuv -KernelVersion: 5.11 -Contact: linux-iio@vger.kernel.org -Description: - Overvoltage or Undervoltage Input fault. The internal circuitry - is protected from excessive voltages applied to the thermocouple - cables at FORCE+, FORCE2, RTDIN+ & RTDIN-. This circuitry turn - off when the input voltage is negative or greater than VDD. - - Reading returns '1' if input voltage is negative or greater - than VDD, otherwise '0'. - What: /sys/bus/iio/devices/iio:deviceX/in_filter_notch_center_frequency KernelVersion: 5.11 Contact: linux-iio@vger.kernel.org diff --git a/Documentation/ABI/testing/sysfs-bus-iio-thermocouple b/Documentation/ABI/testing/sysfs-bus-iio-thermocouple new file mode 100644 index 000000000000..01259df297ca --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-thermocouple @@ -0,0 +1,18 @@ +What: /sys/bus/iio/devices/iio:deviceX/fault_ovuv +KernelVersion: 5.1 +Contact: linux-iio@vger.kernel.org +Description: + Overvoltage or Undervoltage Input Fault. The internal circuitry + is protected from excessive voltages applied to the thermocouple + cables. The device can also detect if such a condition occurs. + + Reading returns '1' if input voltage is negative or greater + than VDD, otherwise '0'. + +What: /sys/bus/iio/devices/iio:deviceX/fault_oc +KernelVersion: 5.1 +Contact: linux-iio@vger.kernel.org +Description: + Open-circuit fault. The detection of open-circuit faults, + such as those caused by broken thermocouple wires. + Reading returns '1' if fault, '0' otherwise. From c089f6fc4a55527047ae40cb72e841822a47425a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 26 Jun 2022 17:55:09 +0100 Subject: [PATCH 20/65] iio: ABI: max31865: Drop in_filter_notch_centre_frequency as in main docs. As this is the last element in the file, also delete the file. Signed-off-by: Jonathan Cameron Cc: Navin Sankar Velliangiri Reviewed-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/20220626165511.602202-3-jic23@kernel.org --- .../ABI/testing/sysfs-bus-iio-temperature-max31865 | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 Documentation/ABI/testing/sysfs-bus-iio-temperature-max31865 diff --git a/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31865 b/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31865 deleted file mode 100644 index 349089e4f2d6..000000000000 --- a/Documentation/ABI/testing/sysfs-bus-iio-temperature-max31865 +++ /dev/null @@ -1,8 +0,0 @@ -What: /sys/bus/iio/devices/iio:deviceX/in_filter_notch_center_frequency -KernelVersion: 5.11 -Contact: linux-iio@vger.kernel.org -Description: - Notch frequency in Hz for a noise rejection filter. Used i.e for - line noise rejection. - - Valid notch filter values are 50 Hz and 60 Hz. From 41a7d6718b45f216da8bc4e13f812b382f6d21da Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 26 Jun 2022 17:55:10 +0100 Subject: [PATCH 21/65] iio: ABI: stm32-timer-trigger: Fuse unusual ABI into main doc. We can't duplicate the description of sampling_frequency. This device has some unusual requirements which we solved by giving a sampling_frequency of 0 special meaning. As such add a note about this unusual usage to the main documentation. Whilst I don't particularly like this resolution, it is the best I could come up with given earlier discussion on this topic. Link: https://lore.kernel.org/linux-iio/20210315101217.00002c50@Huawei.com/ Signed-off-by: Jonathan Cameron Cc: Fabrice Gasnier Reviewed-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/20220626165511.602202-4-jic23@kernel.org --- Documentation/ABI/testing/sysfs-bus-iio | 3 +++ Documentation/ABI/testing/sysfs-bus-iio-timer-stm32 | 8 -------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 3e00d7f7ee22..e81ba6f5e1c8 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -107,6 +107,9 @@ Description: relevant directories. If it affects all of the above then it is to be found in the base device directory. + The stm32-timer-trigger has the additional characteristic that + a sampling_frequency of 0 is defined to stop sampling. + What: /sys/bus/iio/devices/iio:deviceX/sampling_frequency_available What: /sys/bus/iio/devices/iio:deviceX/in_intensity_sampling_frequency_available What: /sys/bus/iio/devices/iio:deviceX/in_proximity_sampling_frequency_available diff --git a/Documentation/ABI/testing/sysfs-bus-iio-timer-stm32 b/Documentation/ABI/testing/sysfs-bus-iio-timer-stm32 index c4a4497c249a..05074c4a65e2 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-timer-stm32 +++ b/Documentation/ABI/testing/sysfs-bus-iio-timer-stm32 @@ -90,14 +90,6 @@ Description: Reading returns the current master modes. Writing set the master mode -What: /sys/bus/iio/devices/triggerX/sampling_frequency -KernelVersion: 4.11 -Contact: benjamin.gaignard@st.com -Description: - Reading returns the current sampling frequency. - Writing an value different of 0 set and start sampling. - Writing 0 stop sampling. - What: /sys/bus/iio/devices/iio:deviceX/in_count0_preset KernelVersion: 4.12 Contact: benjamin.gaignard@st.com From 81e2445132e74a2590337c62b17aa63046958547 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 26 Jun 2022 16:38:28 +0100 Subject: [PATCH 22/65] iio: adc: ti-ads124s08: Drop unused parameter to ads124s_read() The channel number is never used in this call, so don't pass it in. Signed-off-by: Jonathan Cameron Link: https://lore.kernel.org/r/20220626153828.589664-1-jic23@kernel.org --- drivers/iio/adc/ti-ads124s08.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c index 64833156c199..4ca62121f0d1 100644 --- a/drivers/iio/adc/ti-ads124s08.c +++ b/drivers/iio/adc/ti-ads124s08.c @@ -193,7 +193,7 @@ static int ads124s_reset(struct iio_dev *indio_dev) return 0; }; -static int ads124s_read(struct iio_dev *indio_dev, unsigned int chan) +static int ads124s_read(struct iio_dev *indio_dev) { struct ads124s_private *priv = iio_priv(indio_dev); int ret; @@ -242,7 +242,7 @@ static int ads124s_read_raw(struct iio_dev *indio_dev, goto out; } - ret = ads124s_read(indio_dev, chan->channel); + ret = ads124s_read(indio_dev); if (ret < 0) { dev_err(&priv->spi->dev, "Read ADC failed\n"); goto out; @@ -290,7 +290,7 @@ static irqreturn_t ads124s_trigger_handler(int irq, void *p) if (ret) dev_err(&priv->spi->dev, "Start ADC conversions failed\n"); - priv->buffer[j] = ads124s_read(indio_dev, scan_index); + priv->buffer[j] = ads124s_read(indio_dev); ret = ads124s_write_cmd(indio_dev, ADS124S08_STOP_CONV); if (ret) dev_err(&priv->spi->dev, "Stop ADC conversions failed\n"); From 93a73f6a2604e208b758b2bd8f622fb0b0c9098c Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:44 +0100 Subject: [PATCH 23/65] iio: accel: bma220: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-2-jic23@kernel.org --- drivers/iio/accel/bma220_spi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index b6d9ab8e2054..fcbd695e4654 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -289,20 +289,20 @@ static int bma220_probe(struct spi_device *spi) return devm_iio_device_register(&spi->dev, indio_dev); } -static __maybe_unused int bma220_suspend(struct device *dev) +static int bma220_suspend(struct device *dev) { struct spi_device *spi = to_spi_device(dev); return bma220_power(spi, false); } -static __maybe_unused int bma220_resume(struct device *dev) +static int bma220_resume(struct device *dev) { struct spi_device *spi = to_spi_device(dev); return bma220_power(spi, true); } -static SIMPLE_DEV_PM_OPS(bma220_pm_ops, bma220_suspend, bma220_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(bma220_pm_ops, bma220_suspend, bma220_resume); static const struct spi_device_id bma220_spi_id[] = { {"bma220", 0}, @@ -318,7 +318,7 @@ MODULE_DEVICE_TABLE(spi, bma220_spi_id); static struct spi_driver bma220_driver = { .driver = { .name = "bma220_spi", - .pm = &bma220_pm_ops, + .pm = pm_sleep_ptr(&bma220_pm_ops), .acpi_match_table = bma220_acpi_id, }, .probe = bma220_probe, From 078d37b73f0557ba7b4447037499eb2e03700aff Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:45 +0100 Subject: [PATCH 24/65] iio: adc: ad799x: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Lars-Peter Clausen Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-3-jic23@kernel.org --- drivers/iio/adc/ad799x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 220228c375d3..262bd7665b33 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -896,7 +896,7 @@ static int ad799x_remove(struct i2c_client *client) return 0; } -static int __maybe_unused ad799x_suspend(struct device *dev) +static int ad799x_suspend(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct ad799x_state *st = iio_priv(indio_dev); @@ -908,7 +908,7 @@ static int __maybe_unused ad799x_suspend(struct device *dev) return 0; } -static int __maybe_unused ad799x_resume(struct device *dev) +static int ad799x_resume(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct ad799x_state *st = iio_priv(indio_dev); @@ -941,7 +941,7 @@ static int __maybe_unused ad799x_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(ad799x_pm_ops, ad799x_suspend, ad799x_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(ad799x_pm_ops, ad799x_suspend, ad799x_resume); static const struct i2c_device_id ad799x_id[] = { { "ad7991", ad7991 }, @@ -960,7 +960,7 @@ MODULE_DEVICE_TABLE(i2c, ad799x_id); static struct i2c_driver ad799x_driver = { .driver = { .name = "ad799x", - .pm = &ad799x_pm_ops, + .pm = pm_sleep_ptr(&ad799x_pm_ops), }, .probe = ad799x_probe, .remove = ad799x_remove, From 45dc8c59e1432f464d08643a2d5dba73804453b4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:46 +0100 Subject: [PATCH 25/65] iio: adc: at91-sam5d2: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Eugen Hristev Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Ludovic Desroches Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-4-jic23@kernel.org --- drivers/iio/adc/at91-sama5d2_adc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index fe3131c9593c..279430c1d88c 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -2103,7 +2103,7 @@ static int at91_adc_remove(struct platform_device *pdev) return 0; } -static __maybe_unused int at91_adc_suspend(struct device *dev) +static int at91_adc_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); @@ -2123,7 +2123,7 @@ static __maybe_unused int at91_adc_suspend(struct device *dev) return pinctrl_pm_select_sleep_state(dev); } -static __maybe_unused int at91_adc_resume(struct device *dev) +static int at91_adc_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); @@ -2169,7 +2169,8 @@ resume_failed: return ret; } -static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, + at91_adc_resume); static const struct of_device_id at91_adc_dt_match[] = { { @@ -2190,7 +2191,7 @@ static struct platform_driver at91_adc_driver = { .driver = { .name = "at91-sama5d2_adc", .of_match_table = at91_adc_dt_match, - .pm = &at91_adc_pm_ops, + .pm = pm_sleep_ptr(&at91_adc_pm_ops), }, }; module_platform_driver(at91_adc_driver) From cdb77810590595c5341b5e8b15e4ce28f1eadced Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:47 +0100 Subject: [PATCH 26/65] iio: adc: imx7d_adc: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() In this case we only gain the ability to have the compiler drop the struct dev_pm_ops because the callbacks are called from paths other than suspend and resume. In general the purpose of this new macro is to allow automated removal of the callbacks as well, but that doesn't apply here. Signed-off-by: Jonathan Cameron Cc: Haibo Chen Reviewed-by: Haibo Chen Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-5-jic23@kernel.org --- drivers/iio/adc/imx7d_adc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c index 119217af2bde..86caff1d006b 100644 --- a/drivers/iio/adc/imx7d_adc.c +++ b/drivers/iio/adc/imx7d_adc.c @@ -540,14 +540,15 @@ static int imx7d_adc_probe(struct platform_device *pdev) return 0; } -static SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_disable, imx7d_adc_enable); +static DEFINE_SIMPLE_DEV_PM_OPS(imx7d_adc_pm_ops, imx7d_adc_disable, + imx7d_adc_enable); static struct platform_driver imx7d_adc_driver = { .probe = imx7d_adc_probe, .driver = { .name = "imx7d_adc", .of_match_table = imx7d_adc_match, - .pm = &imx7d_adc_pm_ops, + .pm = pm_sleep_ptr(&imx7d_adc_pm_ops), }, }; From 507379983b105d045e798fbdfe871e824fb6c370 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:48 +0100 Subject: [PATCH 27/65] iio: adc: meson_saradc: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Martin Blumenstingl Acked-by: Martin Blumenstingl Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-6-jic23@kernel.org --- drivers/iio/adc/meson_saradc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index c18be3c519af..1a68b099d323 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -1281,22 +1281,22 @@ static int meson_sar_adc_remove(struct platform_device *pdev) return meson_sar_adc_hw_disable(indio_dev); } -static int __maybe_unused meson_sar_adc_suspend(struct device *dev) +static int meson_sar_adc_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); return meson_sar_adc_hw_disable(indio_dev); } -static int __maybe_unused meson_sar_adc_resume(struct device *dev) +static int meson_sar_adc_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); return meson_sar_adc_hw_enable(indio_dev); } -static SIMPLE_DEV_PM_OPS(meson_sar_adc_pm_ops, - meson_sar_adc_suspend, meson_sar_adc_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(meson_sar_adc_pm_ops, + meson_sar_adc_suspend, meson_sar_adc_resume); static struct platform_driver meson_sar_adc_driver = { .probe = meson_sar_adc_probe, @@ -1304,7 +1304,7 @@ static struct platform_driver meson_sar_adc_driver = { .driver = { .name = "meson-saradc", .of_match_table = meson_sar_adc_of_match, - .pm = &meson_sar_adc_pm_ops, + .pm = pm_sleep_ptr(&meson_sar_adc_pm_ops), }, }; From 7ff1d28cc5f4693c10e5a76d37db04c0cddc3835 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:49 +0100 Subject: [PATCH 28/65] iio: adc: mt6577_auxadc: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Zhiyong Tao Cc: Hui Liu Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-7-jic23@kernel.org --- drivers/iio/adc/mt6577_auxadc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c index e78c96a185db..0e134777bdd2 100644 --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -215,7 +215,7 @@ static const struct iio_info mt6577_auxadc_info = { .read_raw = &mt6577_auxadc_read_raw, }; -static int __maybe_unused mt6577_auxadc_resume(struct device *dev) +static int mt6577_auxadc_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev); @@ -234,7 +234,7 @@ static int __maybe_unused mt6577_auxadc_resume(struct device *dev) return 0; } -static int __maybe_unused mt6577_auxadc_suspend(struct device *dev) +static int mt6577_auxadc_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev); @@ -330,9 +330,9 @@ static int mt6577_auxadc_remove(struct platform_device *pdev) return 0; } -static SIMPLE_DEV_PM_OPS(mt6577_auxadc_pm_ops, - mt6577_auxadc_suspend, - mt6577_auxadc_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(mt6577_auxadc_pm_ops, + mt6577_auxadc_suspend, + mt6577_auxadc_resume); static const struct of_device_id mt6577_auxadc_of_match[] = { { .compatible = "mediatek,mt2701-auxadc", .data = &mt8173_compat }, @@ -349,7 +349,7 @@ static struct platform_driver mt6577_auxadc_driver = { .driver = { .name = "mt6577-auxadc", .of_match_table = mt6577_auxadc_of_match, - .pm = &mt6577_auxadc_pm_ops, + .pm = pm_sleep_ptr(&mt6577_auxadc_pm_ops), }, .probe = mt6577_auxadc_probe, .remove = mt6577_auxadc_remove, From 0b1e58e9ed3c2c007250ece18e1c9f92f1d04c1a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:50 +0100 Subject: [PATCH 29/65] iio: adc: stmpe-adc: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. This one is a little unusual as no suspend callback, but the cleanup is still worthwhile (and eventual aim is to get rid of old macro). Signed-off-by: Jonathan Cameron Cc: Philippe Schenker Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-8-jic23@kernel.org --- drivers/iio/adc/stmpe-adc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 000e5cfecb43..67518e460e05 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -333,7 +333,7 @@ static int stmpe_adc_probe(struct platform_device *pdev) return devm_iio_device_register(&pdev->dev, indio_dev); } -static int __maybe_unused stmpe_adc_resume(struct device *dev) +static int stmpe_adc_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct stmpe_adc *info = iio_priv(indio_dev); @@ -343,7 +343,7 @@ static int __maybe_unused stmpe_adc_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(stmpe_adc_pm_ops, NULL, stmpe_adc_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(stmpe_adc_pm_ops, NULL, stmpe_adc_resume); static const struct of_device_id stmpe_adc_ids[] = { { .compatible = "st,stmpe-adc", }, @@ -355,7 +355,7 @@ static struct platform_driver stmpe_adc_driver = { .probe = stmpe_adc_probe, .driver = { .name = "stmpe-adc", - .pm = &stmpe_adc_pm_ops, + .pm = pm_sleep_ptr(&stmpe_adc_pm_ops), .of_match_table = stmpe_adc_ids, }, }; From 0fda2c652d41012bf4e104f19c2cb6d113f1318b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:51 +0100 Subject: [PATCH 30/65] iio: adc: ti-am335x: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Miquel Raynal Reviewed-by: Miquel Raynal Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-9-jic23@kernel.org --- drivers/iio/adc/ti_am335x_adc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 567d43a30955..642c5c4895e3 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -702,7 +702,7 @@ static int tiadc_remove(struct platform_device *pdev) return 0; } -static int __maybe_unused tiadc_suspend(struct device *dev) +static int tiadc_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct tiadc_device *adc_dev = iio_priv(indio_dev); @@ -715,7 +715,7 @@ static int __maybe_unused tiadc_suspend(struct device *dev) return 0; } -static int __maybe_unused tiadc_resume(struct device *dev) +static int tiadc_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct tiadc_device *adc_dev = iio_priv(indio_dev); @@ -732,7 +732,7 @@ static int __maybe_unused tiadc_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(tiadc_pm_ops, tiadc_suspend, tiadc_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(tiadc_pm_ops, tiadc_suspend, tiadc_resume); static const struct of_device_id ti_adc_dt_ids[] = { { .compatible = "ti,am3359-adc", }, @@ -744,7 +744,7 @@ MODULE_DEVICE_TABLE(of, ti_adc_dt_ids); static struct platform_driver tiadc_driver = { .driver = { .name = "TI-am335x-adc", - .pm = &tiadc_pm_ops, + .pm = pm_sleep_ptr(&tiadc_pm_ops), .of_match_table = ti_adc_dt_ids, }, .probe = tiadc_probe, From 3b4a1bd83908b05b8ddf5c0d73c11cd53d23a7b0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:52 +0100 Subject: [PATCH 31/65] iio: adc: xilinx-ams: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Michal Simek Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-10-jic23@kernel.org --- drivers/iio/adc/xilinx-ams.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c index a7687706012d..9cd2713146e5 100644 --- a/drivers/iio/adc/xilinx-ams.c +++ b/drivers/iio/adc/xilinx-ams.c @@ -1421,7 +1421,7 @@ static int ams_probe(struct platform_device *pdev) return devm_iio_device_register(&pdev->dev, indio_dev); } -static int __maybe_unused ams_suspend(struct device *dev) +static int ams_suspend(struct device *dev) { struct ams *ams = iio_priv(dev_get_drvdata(dev)); @@ -1430,20 +1430,20 @@ static int __maybe_unused ams_suspend(struct device *dev) return 0; } -static int __maybe_unused ams_resume(struct device *dev) +static int ams_resume(struct device *dev) { struct ams *ams = iio_priv(dev_get_drvdata(dev)); return clk_prepare_enable(ams->clk); } -static SIMPLE_DEV_PM_OPS(ams_pm_ops, ams_suspend, ams_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(ams_pm_ops, ams_suspend, ams_resume); static struct platform_driver ams_driver = { .probe = ams_probe, .driver = { .name = "xilinx-ams", - .pm = &ams_pm_ops, + .pm = pm_sleep_ptr(&ams_pm_ops), .of_match_table = ams_of_match_table, }, }; From 479e575aee77d32707989a53d8b17ccd5862f1e9 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:53 +0100 Subject: [PATCH 32/65] iio: chemical: scd4x: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Roan van Dijk Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-11-jic23@kernel.org --- drivers/iio/chemical/scd4x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/chemical/scd4x.c b/drivers/iio/chemical/scd4x.c index 37143b5526ee..54066532ea45 100644 --- a/drivers/iio/chemical/scd4x.c +++ b/drivers/iio/chemical/scd4x.c @@ -551,7 +551,7 @@ static const struct iio_chan_spec scd4x_channels[] = { }, }; -static int __maybe_unused scd4x_suspend(struct device *dev) +static int scd4x_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct scd4x_state *state = iio_priv(indio_dev); @@ -564,7 +564,7 @@ static int __maybe_unused scd4x_suspend(struct device *dev) return regulator_disable(state->vdd); } -static int __maybe_unused scd4x_resume(struct device *dev) +static int scd4x_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct scd4x_state *state = iio_priv(indio_dev); @@ -577,7 +577,7 @@ static int __maybe_unused scd4x_resume(struct device *dev) return scd4x_send_command(state, CMD_START_MEAS); } -static __maybe_unused SIMPLE_DEV_PM_OPS(scd4x_pm_ops, scd4x_suspend, scd4x_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(scd4x_pm_ops, scd4x_suspend, scd4x_resume); static void scd4x_stop_meas(void *state) { @@ -688,7 +688,7 @@ static struct i2c_driver scd4x_i2c_driver = { .driver = { .name = KBUILD_MODNAME, .of_match_table = scd4x_dt_ids, - .pm = &scd4x_pm_ops + .pm = pm_sleep_ptr(&scd4x_pm_ops), }, .probe = scd4x_probe, }; From 46b7116712b2dbf91bc8e3c77e368fb8d7181ba6 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:54 +0100 Subject: [PATCH 33/65] iio: dac: ds4424: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Ismail H. Kose Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-12-jic23@kernel.org --- drivers/iio/dac/ds4424.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index 5a5e967b0be4..509394690bcc 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -171,7 +171,7 @@ static int ds4424_verify_chip(struct iio_dev *indio_dev) return ret; } -static int __maybe_unused ds4424_suspend(struct device *dev) +static int ds4424_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct iio_dev *indio_dev = i2c_get_clientdata(client); @@ -189,7 +189,7 @@ static int __maybe_unused ds4424_suspend(struct device *dev) return ret; } -static int __maybe_unused ds4424_resume(struct device *dev) +static int ds4424_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct iio_dev *indio_dev = i2c_get_clientdata(client); @@ -206,7 +206,7 @@ static int __maybe_unused ds4424_resume(struct device *dev) return ret; } -static SIMPLE_DEV_PM_OPS(ds4424_pm_ops, ds4424_suspend, ds4424_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(ds4424_pm_ops, ds4424_suspend, ds4424_resume); static const struct iio_info ds4424_info = { .read_raw = ds4424_read_raw, @@ -312,7 +312,7 @@ static struct i2c_driver ds4424_driver = { .driver = { .name = "ds4424", .of_match_table = ds4424_of_match, - .pm = &ds4424_pm_ops, + .pm = pm_sleep_ptr(&ds4424_pm_ops), }, .probe = ds4424_probe, .remove = ds4424_remove, From 83a2aa2646e60ea9c7cfd33c81d0491151603690 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:55 +0100 Subject: [PATCH 34/65] iio: dac: ltc1660: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Marcus Folkesson Reviewed-by: Marcus Folkesson Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-13-jic23@kernel.org --- drivers/iio/dac/ltc1660.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/dac/ltc1660.c b/drivers/iio/dac/ltc1660.c index c76233c9bb72..2758fc8a5ad5 100644 --- a/drivers/iio/dac/ltc1660.c +++ b/drivers/iio/dac/ltc1660.c @@ -137,20 +137,21 @@ static const struct iio_info ltc1660_info = { .write_raw = <c1660_write_raw, }; -static int __maybe_unused ltc1660_suspend(struct device *dev) +static int ltc1660_suspend(struct device *dev) { struct ltc1660_priv *priv = iio_priv(spi_get_drvdata( to_spi_device(dev))); return regmap_write(priv->regmap, LTC1660_REG_SLEEP, 0x00); } -static int __maybe_unused ltc1660_resume(struct device *dev) +static int ltc1660_resume(struct device *dev) { struct ltc1660_priv *priv = iio_priv(spi_get_drvdata( to_spi_device(dev))); return regmap_write(priv->regmap, LTC1660_REG_WAKE, 0x00); } -static SIMPLE_DEV_PM_OPS(ltc1660_pm_ops, ltc1660_suspend, ltc1660_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(ltc1660_pm_ops, ltc1660_suspend, + ltc1660_resume); static int ltc1660_probe(struct spi_device *spi) { @@ -233,7 +234,7 @@ static struct spi_driver ltc1660_driver = { .driver = { .name = "ltc1660", .of_match_table = ltc1660_dt_ids, - .pm = <c1660_pm_ops, + .pm = pm_sleep_ptr(<c1660_pm_ops), }, .probe = ltc1660_probe, .remove = ltc1660_remove, From 7b9d3e85d71f3fdf601a802886465358b3793bae Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:56 +0100 Subject: [PATCH 35/65] iio: dac: max517: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Marcus Folkesson Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-14-jic23@kernel.org --- drivers/iio/dac/max517.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c index a6ef555153f4..373ce6ff83b7 100644 --- a/drivers/iio/dac/max517.c +++ b/drivers/iio/dac/max517.c @@ -100,21 +100,21 @@ static int max517_write_raw(struct iio_dev *indio_dev, return ret; } -static int __maybe_unused max517_suspend(struct device *dev) +static int max517_suspend(struct device *dev) { u8 outbuf = COMMAND_PD; return i2c_master_send(to_i2c_client(dev), &outbuf, 1); } -static int __maybe_unused max517_resume(struct device *dev) +static int max517_resume(struct device *dev) { u8 outbuf = 0; return i2c_master_send(to_i2c_client(dev), &outbuf, 1); } -static SIMPLE_DEV_PM_OPS(max517_pm_ops, max517_suspend, max517_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(max517_pm_ops, max517_suspend, max517_resume); static const struct iio_info max517_info = { .read_raw = max517_read_raw, @@ -201,7 +201,7 @@ MODULE_DEVICE_TABLE(i2c, max517_id); static struct i2c_driver max517_driver = { .driver = { .name = MAX517_DRV_NAME, - .pm = &max517_pm_ops, + .pm = pm_sleep_ptr(&max517_pm_ops), }, .probe = max517_probe, .id_table = max517_id, From c9ccad99113d99a0c187f909caa326062db5de55 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:57 +0100 Subject: [PATCH 36/65] iio: dac: max5821: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Philippe Reynes Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-15-jic23@kernel.org --- drivers/iio/dac/max5821.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/dac/max5821.c b/drivers/iio/dac/max5821.c index 540f9ea7cada..e001b594d5b1 100644 --- a/drivers/iio/dac/max5821.c +++ b/drivers/iio/dac/max5821.c @@ -267,7 +267,7 @@ static int max5821_write_raw(struct iio_dev *indio_dev, } } -static int __maybe_unused max5821_suspend(struct device *dev) +static int max5821_suspend(struct device *dev) { u8 outbuf[2] = { MAX5821_EXTENDED_COMMAND_MODE, MAX5821_EXTENDED_DAC_A | @@ -277,7 +277,7 @@ static int __maybe_unused max5821_suspend(struct device *dev) return i2c_master_send(to_i2c_client(dev), outbuf, 2); } -static int __maybe_unused max5821_resume(struct device *dev) +static int max5821_resume(struct device *dev) { u8 outbuf[2] = { MAX5821_EXTENDED_COMMAND_MODE, MAX5821_EXTENDED_DAC_A | @@ -287,7 +287,8 @@ static int __maybe_unused max5821_resume(struct device *dev) return i2c_master_send(to_i2c_client(dev), outbuf, 2); } -static SIMPLE_DEV_PM_OPS(max5821_pm_ops, max5821_suspend, max5821_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(max5821_pm_ops, max5821_suspend, + max5821_resume); static const struct iio_info max5821_info = { .read_raw = max5821_read_raw, @@ -374,7 +375,7 @@ static struct i2c_driver max5821_driver = { .driver = { .name = "max5821", .of_match_table = max5821_of_match, - .pm = &max5821_pm_ops, + .pm = pm_sleep_ptr(&max5821_pm_ops), }, .probe = max5821_probe, .id_table = max5821_id, From bf19b23591afa929f51b861a6c470a9a436df620 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:58 +0100 Subject: [PATCH 37/65] iio: dac: mcp4725: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Philippe Reynes Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-16-jic23@kernel.org --- drivers/iio/dac/mcp4725.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index 7fcb86288823..bb4b85a7b95b 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -42,7 +42,7 @@ struct mcp4725_data { struct regulator *vref_reg; }; -static int __maybe_unused mcp4725_suspend(struct device *dev) +static int mcp4725_suspend(struct device *dev) { struct mcp4725_data *data = iio_priv(i2c_get_clientdata( to_i2c_client(dev))); @@ -55,7 +55,7 @@ static int __maybe_unused mcp4725_suspend(struct device *dev) return i2c_master_send(data->client, outbuf, 2); } -static int __maybe_unused mcp4725_resume(struct device *dev) +static int mcp4725_resume(struct device *dev) { struct mcp4725_data *data = iio_priv(i2c_get_clientdata( to_i2c_client(dev))); @@ -68,7 +68,8 @@ static int __maybe_unused mcp4725_resume(struct device *dev) return i2c_master_send(data->client, outbuf, 2); } -static SIMPLE_DEV_PM_OPS(mcp4725_pm_ops, mcp4725_suspend, mcp4725_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(mcp4725_pm_ops, mcp4725_suspend, + mcp4725_resume); static ssize_t mcp4725_store_eeprom(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) @@ -523,7 +524,7 @@ static struct i2c_driver mcp4725_driver = { .driver = { .name = MCP4725_DRV_NAME, .of_match_table = mcp4725_of_match, - .pm = &mcp4725_pm_ops, + .pm = pm_sleep_ptr(&mcp4725_pm_ops), }, .probe = mcp4725_probe, .remove = mcp4725_remove, From fa55750642d0f4efc2c679ce4c41edf3a5389c9f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:26:59 +0100 Subject: [PATCH 38/65] iio: gyro: itg3200: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-17-jic23@kernel.org --- drivers/iio/gyro/itg3200_core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c index a7f1bbb5f289..0491c64e1b32 100644 --- a/drivers/iio/gyro/itg3200_core.c +++ b/drivers/iio/gyro/itg3200_core.c @@ -364,7 +364,7 @@ static int itg3200_remove(struct i2c_client *client) return 0; } -static int __maybe_unused itg3200_suspend(struct device *dev) +static int itg3200_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct itg3200 *st = iio_priv(indio_dev); @@ -375,14 +375,15 @@ static int __maybe_unused itg3200_suspend(struct device *dev) ITG3200_SLEEP); } -static int __maybe_unused itg3200_resume(struct device *dev) +static int itg3200_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); return itg3200_initial_setup(indio_dev); } -static SIMPLE_DEV_PM_OPS(itg3200_pm_ops, itg3200_suspend, itg3200_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(itg3200_pm_ops, itg3200_suspend, + itg3200_resume); static const struct i2c_device_id itg3200_id[] = { { "itg3200", 0 }, @@ -400,7 +401,7 @@ static struct i2c_driver itg3200_driver = { .driver = { .name = "itg3200", .of_match_table = itg3200_of_match, - .pm = &itg3200_pm_ops, + .pm = pm_sleep_ptr(&itg3200_pm_ops), }, .id_table = itg3200_id, .probe = itg3200_probe, From 3d691c6a9f165fe9b9123a00d10c30227ed59237 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:00 +0100 Subject: [PATCH 39/65] iio: health: afe4403: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-18-jic23@kernel.org --- drivers/iio/health/afe4403.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index 856ec901b091..3bb4028c5d74 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -408,7 +408,7 @@ static const struct of_device_id afe4403_of_match[] = { }; MODULE_DEVICE_TABLE(of, afe4403_of_match); -static int __maybe_unused afe4403_suspend(struct device *dev) +static int afe4403_suspend(struct device *dev) { struct iio_dev *indio_dev = spi_get_drvdata(to_spi_device(dev)); struct afe4403_data *afe = iio_priv(indio_dev); @@ -429,7 +429,7 @@ static int __maybe_unused afe4403_suspend(struct device *dev) return 0; } -static int __maybe_unused afe4403_resume(struct device *dev) +static int afe4403_resume(struct device *dev) { struct iio_dev *indio_dev = spi_get_drvdata(to_spi_device(dev)); struct afe4403_data *afe = iio_priv(indio_dev); @@ -449,7 +449,8 @@ static int __maybe_unused afe4403_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(afe4403_pm_ops, afe4403_suspend, afe4403_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(afe4403_pm_ops, afe4403_suspend, + afe4403_resume); static int afe4403_probe(struct spi_device *spi) { @@ -598,7 +599,7 @@ static struct spi_driver afe4403_spi_driver = { .driver = { .name = AFE4403_DRIVER_NAME, .of_match_table = afe4403_of_match, - .pm = &afe4403_pm_ops, + .pm = pm_sleep_ptr(&afe4403_pm_ops), }, .probe = afe4403_probe, .remove = afe4403_remove, From b220558c0f2c0ee8d3fa915d3a1a32677e183a4b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:01 +0100 Subject: [PATCH 40/65] iio: health: afe4404: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-19-jic23@kernel.org --- drivers/iio/health/afe4404.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 1bb7de60f8ca..dd7800159051 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -415,7 +415,7 @@ static const struct of_device_id afe4404_of_match[] = { }; MODULE_DEVICE_TABLE(of, afe4404_of_match); -static int __maybe_unused afe4404_suspend(struct device *dev) +static int afe4404_suspend(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct afe4404_data *afe = iio_priv(indio_dev); @@ -436,7 +436,7 @@ static int __maybe_unused afe4404_suspend(struct device *dev) return 0; } -static int __maybe_unused afe4404_resume(struct device *dev) +static int afe4404_resume(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct afe4404_data *afe = iio_priv(indio_dev); @@ -456,7 +456,8 @@ static int __maybe_unused afe4404_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(afe4404_pm_ops, afe4404_suspend, afe4404_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(afe4404_pm_ops, afe4404_suspend, + afe4404_resume); static int afe4404_probe(struct i2c_client *client, const struct i2c_device_id *id) @@ -607,7 +608,7 @@ static struct i2c_driver afe4404_i2c_driver = { .driver = { .name = AFE4404_DRIVER_NAME, .of_match_table = afe4404_of_match, - .pm = &afe4404_pm_ops, + .pm = pm_sleep_ptr(&afe4404_pm_ops), }, .probe = afe4404_probe, .remove = afe4404_remove, From dc064f21ea80af2c372e2150f416de07f6461ac2 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:02 +0100 Subject: [PATCH 41/65] iio: light: al3010: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: David Heidelberg Reviewed-by: David Heidelberg Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-20-jic23@kernel.org --- drivers/iio/light/al3010.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/al3010.c b/drivers/iio/light/al3010.c index b4e9924094cd..ce5363845b22 100644 --- a/drivers/iio/light/al3010.c +++ b/drivers/iio/light/al3010.c @@ -200,17 +200,17 @@ static int al3010_probe(struct i2c_client *client, return devm_iio_device_register(&client->dev, indio_dev); } -static int __maybe_unused al3010_suspend(struct device *dev) +static int al3010_suspend(struct device *dev) { return al3010_set_pwr(to_i2c_client(dev), false); } -static int __maybe_unused al3010_resume(struct device *dev) +static int al3010_resume(struct device *dev) { return al3010_set_pwr(to_i2c_client(dev), true); } -static SIMPLE_DEV_PM_OPS(al3010_pm_ops, al3010_suspend, al3010_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(al3010_pm_ops, al3010_suspend, al3010_resume); static const struct i2c_device_id al3010_id[] = { {"al3010", }, @@ -228,7 +228,7 @@ static struct i2c_driver al3010_driver = { .driver = { .name = AL3010_DRV_NAME, .of_match_table = al3010_of_match, - .pm = &al3010_pm_ops, + .pm = pm_sleep_ptr(&al3010_pm_ops), }, .probe = al3010_probe, .id_table = al3010_id, From f3231f912bf478ced5628f808f8b6e0a1e1bd917 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:03 +0100 Subject: [PATCH 42/65] iio: light: al3320a: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: David Heidelberg Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-21-jic23@kernel.org --- drivers/iio/light/al3320a.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/al3320a.c b/drivers/iio/light/al3320a.c index cc1407ccc10a..bc99179728ed 100644 --- a/drivers/iio/light/al3320a.c +++ b/drivers/iio/light/al3320a.c @@ -223,17 +223,18 @@ static int al3320a_probe(struct i2c_client *client, return devm_iio_device_register(&client->dev, indio_dev); } -static int __maybe_unused al3320a_suspend(struct device *dev) +static int al3320a_suspend(struct device *dev) { return al3320a_set_pwr(to_i2c_client(dev), false); } -static int __maybe_unused al3320a_resume(struct device *dev) +static int al3320a_resume(struct device *dev) { return al3320a_set_pwr(to_i2c_client(dev), true); } -static SIMPLE_DEV_PM_OPS(al3320a_pm_ops, al3320a_suspend, al3320a_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(al3320a_pm_ops, al3320a_suspend, + al3320a_resume); static const struct i2c_device_id al3320a_id[] = { {"al3320a", 0}, @@ -251,7 +252,7 @@ static struct i2c_driver al3320a_driver = { .driver = { .name = AL3320A_DRV_NAME, .of_match_table = al3320a_of_match, - .pm = &al3320a_pm_ops, + .pm = pm_sleep_ptr(&al3320a_pm_ops), }, .probe = al3320a_probe, .id_table = al3320a_id, From c422aa418a7ddd3bde04b2c0ad573c34aae53d35 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:04 +0100 Subject: [PATCH 43/65] iio: light: as73211: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Christian Eggers Reviewed-by: Christian Eggers Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-22-jic23@kernel.org --- drivers/iio/light/as73211.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/as73211.c b/drivers/iio/light/as73211.c index 3ba2378df3dd..2307fc531752 100644 --- a/drivers/iio/light/as73211.c +++ b/drivers/iio/light/as73211.c @@ -755,21 +755,22 @@ static int as73211_probe(struct i2c_client *client) return devm_iio_device_register(dev, indio_dev); } -static int __maybe_unused as73211_suspend(struct device *dev) +static int as73211_suspend(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); return as73211_power(indio_dev, false); } -static int __maybe_unused as73211_resume(struct device *dev) +static int as73211_resume(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); return as73211_power(indio_dev, true); } -static SIMPLE_DEV_PM_OPS(as73211_pm_ops, as73211_suspend, as73211_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(as73211_pm_ops, as73211_suspend, + as73211_resume); static const struct of_device_id as73211_of_match[] = { { .compatible = "ams,as73211" }, @@ -787,7 +788,7 @@ static struct i2c_driver as73211_driver = { .driver = { .name = AS73211_DRV_NAME, .of_match_table = as73211_of_match, - .pm = &as73211_pm_ops, + .pm = pm_sleep_ptr(&as73211_pm_ops), }, .probe_new = as73211_probe, .id_table = as73211_id, From 7eff2dcec69c04f60144e2c13f07b21cb66a638d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:05 +0100 Subject: [PATCH 44/65] iio: light: bh1750: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Tomasz Duszynski Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-23-jic23@kernel.org --- drivers/iio/light/bh1750.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/bh1750.c b/drivers/iio/light/bh1750.c index 48484b9401b9..471985c220bb 100644 --- a/drivers/iio/light/bh1750.c +++ b/drivers/iio/light/bh1750.c @@ -277,7 +277,7 @@ static int bh1750_remove(struct i2c_client *client) return 0; } -static int __maybe_unused bh1750_suspend(struct device *dev) +static int bh1750_suspend(struct device *dev) { int ret; struct bh1750_data *data = @@ -294,7 +294,7 @@ static int __maybe_unused bh1750_suspend(struct device *dev) return ret; } -static SIMPLE_DEV_PM_OPS(bh1750_pm_ops, bh1750_suspend, NULL); +static DEFINE_SIMPLE_DEV_PM_OPS(bh1750_pm_ops, bh1750_suspend, NULL); static const struct i2c_device_id bh1750_id[] = { { "bh1710", BH1710 }, @@ -320,7 +320,7 @@ static struct i2c_driver bh1750_driver = { .driver = { .name = "bh1750", .of_match_table = bh1750_of_match, - .pm = &bh1750_pm_ops, + .pm = pm_sleep_ptr(&bh1750_pm_ops), }, .probe = bh1750_probe, .remove = bh1750_remove, From dc0258e33ddb9aef05d212cdbc1a76aa03a5badd Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:06 +0100 Subject: [PATCH 45/65] iio: light: cm3605: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-24-jic23@kernel.org --- drivers/iio/light/cm3605.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/iio/light/cm3605.c b/drivers/iio/light/cm3605.c index 50d34a98839c..c721b69d5095 100644 --- a/drivers/iio/light/cm3605.c +++ b/drivers/iio/light/cm3605.c @@ -278,7 +278,7 @@ static int cm3605_remove(struct platform_device *pdev) return 0; } -static int __maybe_unused cm3605_pm_suspend(struct device *dev) +static int cm3605_pm_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct cm3605 *cm3605 = iio_priv(indio_dev); @@ -289,7 +289,7 @@ static int __maybe_unused cm3605_pm_suspend(struct device *dev) return 0; } -static int __maybe_unused cm3605_pm_resume(struct device *dev) +static int cm3605_pm_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct cm3605 *cm3605 = iio_priv(indio_dev); @@ -302,11 +302,8 @@ static int __maybe_unused cm3605_pm_resume(struct device *dev) return 0; } - -static const struct dev_pm_ops cm3605_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(cm3605_pm_suspend, - cm3605_pm_resume) -}; +static DEFINE_SIMPLE_DEV_PM_OPS(cm3605_dev_pm_ops, cm3605_pm_suspend, + cm3605_pm_resume); static const struct of_device_id cm3605_of_match[] = { {.compatible = "capella,cm3605"}, @@ -318,7 +315,7 @@ static struct platform_driver cm3605_driver = { .driver = { .name = "cm3605", .of_match_table = cm3605_of_match, - .pm = &cm3605_dev_pm_ops, + .pm = pm_sleep_ptr(&cm3605_dev_pm_ops), }, .probe = cm3605_probe, .remove = cm3605_remove, From dc69c61019dcbcc4d8e489db6420812ddc0ceb35 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:07 +0100 Subject: [PATCH 46/65] iio: proximity: cros_ec_mkbp: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Enric Balletbo i Serra Cc: Gwendal Grignou Cc: Stephen Boyd Reviewed-by: Gwendal Grignou Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-25-jic23@kernel.org --- drivers/iio/proximity/cros_ec_mkbp_proximity.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/proximity/cros_ec_mkbp_proximity.c b/drivers/iio/proximity/cros_ec_mkbp_proximity.c index 8213b0081713..571ea1812246 100644 --- a/drivers/iio/proximity/cros_ec_mkbp_proximity.c +++ b/drivers/iio/proximity/cros_ec_mkbp_proximity.c @@ -184,7 +184,7 @@ static const struct iio_info cros_ec_mkbp_proximity_info = { .write_event_config = cros_ec_mkbp_proximity_write_event_config, }; -static __maybe_unused int cros_ec_mkbp_proximity_resume(struct device *dev) +static int cros_ec_mkbp_proximity_resume(struct device *dev) { struct cros_ec_mkbp_proximity_data *data = dev_get_drvdata(dev); struct cros_ec_device *ec = data->ec; @@ -201,8 +201,8 @@ static __maybe_unused int cros_ec_mkbp_proximity_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(cros_ec_mkbp_proximity_pm_ops, NULL, - cros_ec_mkbp_proximity_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(cros_ec_mkbp_proximity_pm_ops, NULL, + cros_ec_mkbp_proximity_resume); static int cros_ec_mkbp_proximity_probe(struct platform_device *pdev) { @@ -260,7 +260,7 @@ static struct platform_driver cros_ec_mkbp_proximity_driver = { .driver = { .name = "cros-ec-mkbp-proximity", .of_match_table = cros_ec_mkbp_proximity_of_match, - .pm = &cros_ec_mkbp_proximity_pm_ops, + .pm = pm_sleep_ptr(&cros_ec_mkbp_proximity_pm_ops), }, .probe = cros_ec_mkbp_proximity_probe, .remove = cros_ec_mkbp_proximity_remove, From fb4e8e2dadc91ea6478045910192e46bc880c32c Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:08 +0100 Subject: [PATCH 47/65] iio: temperature: ltc2983: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Nuno Sá Reviewed-by: Nuno Sá Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-26-jic23@kernel.org --- drivers/iio/temperature/ltc2983.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c index 4b7f2b8a9758..b652d2b39bcf 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -1534,7 +1534,7 @@ static int ltc2983_probe(struct spi_device *spi) return devm_iio_device_register(&spi->dev, indio_dev); } -static int __maybe_unused ltc2983_resume(struct device *dev) +static int ltc2983_resume(struct device *dev) { struct ltc2983_data *st = spi_get_drvdata(to_spi_device(dev)); int dummy; @@ -1545,14 +1545,15 @@ static int __maybe_unused ltc2983_resume(struct device *dev) return ltc2983_setup(st, false); } -static int __maybe_unused ltc2983_suspend(struct device *dev) +static int ltc2983_suspend(struct device *dev) { struct ltc2983_data *st = spi_get_drvdata(to_spi_device(dev)); return regmap_write(st->regmap, LTC2983_STATUS_REG, LTC2983_SLEEP); } -static SIMPLE_DEV_PM_OPS(ltc2983_pm_ops, ltc2983_suspend, ltc2983_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(ltc2983_pm_ops, ltc2983_suspend, + ltc2983_resume); static const struct spi_device_id ltc2983_id_table[] = { { "ltc2983" }, @@ -1570,7 +1571,7 @@ static struct spi_driver ltc2983_driver = { .driver = { .name = "ltc2983", .of_match_table = ltc2983_of_match, - .pm = <c2983_pm_ops, + .pm = pm_sleep_ptr(<c2983_pm_ops), }, .probe = ltc2983_probe, .id_table = ltc2983_id_table, From a79163d19ef7b385f48876898c28a58f35a1df35 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:09 +0100 Subject: [PATCH 48/65] iio: light: us5182: Switch from CONFIG_PM guards to pm_ptr() etc Letting the compiler remove these functions when the kernel is built without CONFIG_PM support is simpler and less error prone than the use of #ifdef based config guards. Removing instances of this approach from IIO also stops them being copied into new drivers. Very likely it would be safe to use DEFINE_RUNTIME_DEV_PM_OPS() here, but that would be a functional change. Signed-off-by: Jonathan Cameron Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-27-jic23@kernel.org --- drivers/iio/light/us5182d.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c index cbd9978540fa..80d2299da561 100644 --- a/drivers/iio/light/us5182d.c +++ b/drivers/iio/light/us5182d.c @@ -922,7 +922,6 @@ static int us5182d_remove(struct i2c_client *client) return 0; } -#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM) static int us5182d_suspend(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); @@ -945,11 +944,10 @@ static int us5182d_resume(struct device *dev) return 0; } -#endif static const struct dev_pm_ops us5182d_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(us5182d_suspend, us5182d_resume) - SET_RUNTIME_PM_OPS(us5182d_suspend, us5182d_resume, NULL) + SYSTEM_SLEEP_PM_OPS(us5182d_suspend, us5182d_resume) + RUNTIME_PM_OPS(us5182d_suspend, us5182d_resume, NULL) }; static const struct acpi_device_id us5182d_acpi_match[] = { @@ -975,7 +973,7 @@ MODULE_DEVICE_TABLE(of, us5182d_of_match); static struct i2c_driver us5182d_driver = { .driver = { .name = US5182D_DRV_NAME, - .pm = &us5182d_pm_ops, + .pm = pm_ptr(&us5182d_pm_ops), .of_match_table = us5182d_of_match, .acpi_match_table = ACPI_PTR(us5182d_acpi_match), }, From 2583f5e828155c2dcacda64c1f42e86d8a4c2d5b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:10 +0100 Subject: [PATCH 49/65] iio: adc: imx8qxp: Switch to DEFINE_RUNTIME_DEV_PM_OPS and pm_ptr() Switching to these newer macros allows the compiler to remove the unused functions and struct dev_pm_ops if !CONFIG_PM without the need to mark anything __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Cai Huoqing Reviewed-by: Haibo Chen Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-28-jic23@kernel.org --- drivers/iio/adc/imx8qxp-adc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/imx8qxp-adc.c b/drivers/iio/adc/imx8qxp-adc.c index e8c9a69e10eb..e48446784a0a 100644 --- a/drivers/iio/adc/imx8qxp-adc.c +++ b/drivers/iio/adc/imx8qxp-adc.c @@ -417,7 +417,7 @@ static int imx8qxp_adc_remove(struct platform_device *pdev) return 0; } -static __maybe_unused int imx8qxp_adc_runtime_suspend(struct device *dev) +static int imx8qxp_adc_runtime_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct imx8qxp_adc *adc = iio_priv(indio_dev); @@ -431,7 +431,7 @@ static __maybe_unused int imx8qxp_adc_runtime_suspend(struct device *dev) return 0; } -static __maybe_unused int imx8qxp_adc_runtime_resume(struct device *dev) +static int imx8qxp_adc_runtime_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct imx8qxp_adc *adc = iio_priv(indio_dev); @@ -468,10 +468,9 @@ err_disable_reg: return ret; } -static const struct dev_pm_ops imx8qxp_adc_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(imx8qxp_adc_runtime_suspend, imx8qxp_adc_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(imx8qxp_adc_pm_ops, + imx8qxp_adc_runtime_suspend, + imx8qxp_adc_runtime_resume, NULL); static const struct of_device_id imx8qxp_adc_match[] = { { .compatible = "nxp,imx8qxp-adc", }, @@ -485,7 +484,7 @@ static struct platform_driver imx8qxp_adc_driver = { .driver = { .name = ADC_DRIVER_NAME, .of_match_table = imx8qxp_adc_match, - .pm = &imx8qxp_adc_pm_ops, + .pm = pm_ptr(&imx8qxp_adc_pm_ops), }, }; From 7b79cda9e297023ad605efaf9a0ae0cf7e27e70d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:11 +0100 Subject: [PATCH 50/65] iio: light: gp2ap002: Switch to DEFINE_RUNTIME_DEV_PM_OPS and pm_ptr() Switching to these newer macros allows use of pm_ptr() to remove the unused functions and structure if !CONFIG_PM without the need to mark anything __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Linus Walleij Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-29-jic23@kernel.org --- drivers/iio/light/gp2ap002.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c index c6d1d88d3775..e2707416f9a8 100644 --- a/drivers/iio/light/gp2ap002.c +++ b/drivers/iio/light/gp2ap002.c @@ -635,7 +635,7 @@ static int gp2ap002_remove(struct i2c_client *client) return 0; } -static int __maybe_unused gp2ap002_runtime_suspend(struct device *dev) +static int gp2ap002_runtime_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct gp2ap002 *gp2ap002 = iio_priv(indio_dev); @@ -660,7 +660,7 @@ static int __maybe_unused gp2ap002_runtime_suspend(struct device *dev) return 0; } -static int __maybe_unused gp2ap002_runtime_resume(struct device *dev) +static int gp2ap002_runtime_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct gp2ap002 *gp2ap002 = iio_priv(indio_dev); @@ -691,12 +691,8 @@ static int __maybe_unused gp2ap002_runtime_resume(struct device *dev) return 0; } -static const struct dev_pm_ops gp2ap002_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(gp2ap002_runtime_suspend, - gp2ap002_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(gp2ap002_dev_pm_ops, gp2ap002_runtime_suspend, + gp2ap002_runtime_resume, NULL); static const struct i2c_device_id gp2ap002_id_table[] = { { "gp2ap002", 0 }, @@ -715,7 +711,7 @@ static struct i2c_driver gp2ap002_driver = { .driver = { .name = "gp2ap002", .of_match_table = gp2ap002_of_match, - .pm = &gp2ap002_dev_pm_ops, + .pm = pm_ptr(&gp2ap002_dev_pm_ops), }, .probe = gp2ap002_probe, .remove = gp2ap002_remove, From 9ec91dd4e9444ead21cc07a9b7a99a9e96a47801 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:12 +0100 Subject: [PATCH 51/65] iio: light: isl29028: Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() Using these new macros allows removal of unused pm_ops structure and functions if !CONFIG_PM without the need to mark the functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Brian Masney Reviewed-by: Brian Masney Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-30-jic23@kernel.org --- drivers/iio/light/isl29028.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/iio/light/isl29028.c b/drivers/iio/light/isl29028.c index 720fa83d44e0..4dde9707a52d 100644 --- a/drivers/iio/light/isl29028.c +++ b/drivers/iio/light/isl29028.c @@ -651,7 +651,7 @@ static int isl29028_remove(struct i2c_client *client) return 0; } -static int __maybe_unused isl29028_suspend(struct device *dev) +static int isl29028_suspend(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct isl29028_chip *chip = iio_priv(indio_dev); @@ -666,7 +666,7 @@ static int __maybe_unused isl29028_suspend(struct device *dev) return ret; } -static int __maybe_unused isl29028_resume(struct device *dev) +static int isl29028_resume(struct device *dev) { /** * The specific component (ALS/IR or proximity) will enable itself as @@ -676,11 +676,8 @@ static int __maybe_unused isl29028_resume(struct device *dev) return 0; } -static const struct dev_pm_ops isl29028_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(isl29028_suspend, isl29028_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(isl29028_pm_ops, isl29028_suspend, + isl29028_resume, NULL); static const struct i2c_device_id isl29028_id[] = { {"isl29028", 0}, @@ -700,7 +697,7 @@ MODULE_DEVICE_TABLE(of, isl29028_of_match); static struct i2c_driver isl29028_driver = { .driver = { .name = "isl29028", - .pm = &isl29028_pm_ops, + .pm = pm_ptr(&isl29028_pm_ops), .of_match_table = isl29028_of_match, }, .probe = isl29028_probe, From f541541a37e4887f89b5b5473d41cf88671eb1a4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:13 +0100 Subject: [PATCH 52/65] iio: light: tsl2583: Use DEFINE_RUNTIME_DEV_PM_OPS and pm_ptr() Using these new macros allows removal of unused pm_ops structure and functions if !CONFIG_PM without the need to mark the function __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Brian Masney Reviewed-by: Brian Masney Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-31-jic23@kernel.org --- drivers/iio/light/tsl2583.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c index efb3c13cfc87..82662dab87c0 100644 --- a/drivers/iio/light/tsl2583.c +++ b/drivers/iio/light/tsl2583.c @@ -888,7 +888,7 @@ static int tsl2583_remove(struct i2c_client *client) return 0; } -static int __maybe_unused tsl2583_suspend(struct device *dev) +static int tsl2583_suspend(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -903,7 +903,7 @@ static int __maybe_unused tsl2583_suspend(struct device *dev) return ret; } -static int __maybe_unused tsl2583_resume(struct device *dev) +static int tsl2583_resume(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct tsl2583_chip *chip = iio_priv(indio_dev); @@ -918,11 +918,8 @@ static int __maybe_unused tsl2583_resume(struct device *dev) return ret; } -static const struct dev_pm_ops tsl2583_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(tsl2583_suspend, tsl2583_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(tsl2583_pm_ops, tsl2583_suspend, + tsl2583_resume, NULL); static const struct i2c_device_id tsl2583_idtable[] = { { "tsl2580", 0 }, @@ -944,7 +941,7 @@ MODULE_DEVICE_TABLE(of, tsl2583_of_match); static struct i2c_driver tsl2583_driver = { .driver = { .name = "tsl2583", - .pm = &tsl2583_pm_ops, + .pm = pm_ptr(&tsl2583_pm_ops), .of_match_table = tsl2583_of_match, }, .id_table = tsl2583_idtable, From 5672f3982ac98c8a8b8f1c5d4e2b3cd03342ea9d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:14 +0100 Subject: [PATCH 53/65] iio: light: tsl2591: Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() Using these new macros allows removal of unused pm_ops structure and functions if !CONFIG_PM without the need to mark the functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Joe Sandom Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-32-jic23@kernel.org --- drivers/iio/light/tsl2591.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/iio/light/tsl2591.c b/drivers/iio/light/tsl2591.c index 39e68d0c9d6a..e485a556e6da 100644 --- a/drivers/iio/light/tsl2591.c +++ b/drivers/iio/light/tsl2591.c @@ -1019,7 +1019,7 @@ static const struct iio_info tsl2591_info_no_irq = { .read_avail = tsl2591_read_available, }; -static int __maybe_unused tsl2591_suspend(struct device *dev) +static int tsl2591_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct tsl2591_chip *chip = iio_priv(indio_dev); @@ -1032,7 +1032,7 @@ static int __maybe_unused tsl2591_suspend(struct device *dev) return ret; } -static int __maybe_unused tsl2591_resume(struct device *dev) +static int tsl2591_resume(struct device *dev) { int power_state = TSL2591_PWR_ON | TSL2591_ENABLE_ALS; struct iio_dev *indio_dev = dev_get_drvdata(dev); @@ -1049,10 +1049,8 @@ static int __maybe_unused tsl2591_resume(struct device *dev) return ret; } -static const struct dev_pm_ops tsl2591_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(tsl2591_suspend, tsl2591_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(tsl2591_pm_ops, tsl2591_suspend, + tsl2591_resume, NULL); static irqreturn_t tsl2591_event_handler(int irq, void *private) { @@ -1213,7 +1211,7 @@ MODULE_DEVICE_TABLE(of, tsl2591_of_match); static struct i2c_driver tsl2591_driver = { .driver = { .name = "tsl2591", - .pm = &tsl2591_pm_ops, + .pm = pm_ptr(&tsl2591_pm_ops), .of_match_table = tsl2591_of_match, }, .probe_new = tsl2591_probe From cd4d10b134c2194c50dc7f58c1f9c502f7f76656 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:15 +0100 Subject: [PATCH 54/65] iio: light: vcnl4000: Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() macros Using these new macros allows the compiler to remove the unused dev_pm_ops structure and related functions if !CONFIG_PM without the need to mark the functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Mathieu Othacehe Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-33-jic23@kernel.org --- drivers/iio/light/vcnl4000.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 947a41b86173..3db4e26731bb 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -1130,7 +1130,7 @@ static int vcnl4000_remove(struct i2c_client *client) return 0; } -static int __maybe_unused vcnl4000_runtime_suspend(struct device *dev) +static int vcnl4000_runtime_suspend(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct vcnl4000_data *data = iio_priv(indio_dev); @@ -1138,7 +1138,7 @@ static int __maybe_unused vcnl4000_runtime_suspend(struct device *dev) return data->chip_spec->set_power_state(data, false); } -static int __maybe_unused vcnl4000_runtime_resume(struct device *dev) +static int vcnl4000_runtime_resume(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct vcnl4000_data *data = iio_priv(indio_dev); @@ -1146,17 +1146,13 @@ static int __maybe_unused vcnl4000_runtime_resume(struct device *dev) return data->chip_spec->set_power_state(data, true); } -static const struct dev_pm_ops vcnl4000_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(vcnl4000_runtime_suspend, - vcnl4000_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(vcnl4000_pm_ops, vcnl4000_runtime_suspend, + vcnl4000_runtime_resume, NULL); static struct i2c_driver vcnl4000_driver = { .driver = { .name = VCNL4000_DRV_NAME, - .pm = &vcnl4000_pm_ops, + .pm = pm_ptr(&vcnl4000_pm_ops), .of_match_table = vcnl_4000_of_match, }, .probe = vcnl4000_probe, From b904854e14bb1301190370fbc5ca032212330003 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:16 +0100 Subject: [PATCH 55/65] iio: light: vcnl4035: Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() macros Using these new macros allows the compiler to remove the unused dev_pm_ops structure and related functions if !CONFIG_PM without the need to mark the functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Parthiban Nallathambi Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-34-jic23@kernel.org --- drivers/iio/light/vcnl4035.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c index 2aaec6bef64c..6a196cf2270b 100644 --- a/drivers/iio/light/vcnl4035.c +++ b/drivers/iio/light/vcnl4035.c @@ -620,7 +620,7 @@ static int vcnl4035_remove(struct i2c_client *client) return 0; } -static int __maybe_unused vcnl4035_runtime_suspend(struct device *dev) +static int vcnl4035_runtime_suspend(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct vcnl4035_data *data = iio_priv(indio_dev); @@ -632,7 +632,7 @@ static int __maybe_unused vcnl4035_runtime_suspend(struct device *dev) return ret; } -static int __maybe_unused vcnl4035_runtime_resume(struct device *dev) +static int vcnl4035_runtime_resume(struct device *dev) { struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct vcnl4035_data *data = iio_priv(indio_dev); @@ -649,12 +649,8 @@ static int __maybe_unused vcnl4035_runtime_resume(struct device *dev) return 0; } -static const struct dev_pm_ops vcnl4035_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(vcnl4035_runtime_suspend, - vcnl4035_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(vcnl4035_pm_ops, vcnl4035_runtime_suspend, + vcnl4035_runtime_resume, NULL); static const struct i2c_device_id vcnl4035_id[] = { { "vcnl4035", 0 }, @@ -671,7 +667,7 @@ MODULE_DEVICE_TABLE(of, vcnl4035_of_match); static struct i2c_driver vcnl4035_driver = { .driver = { .name = VCNL4035_DRV_NAME, - .pm = &vcnl4035_pm_ops, + .pm = pm_ptr(&vcnl4035_pm_ops), .of_match_table = vcnl4035_of_match, }, .probe = vcnl4035_probe, From 1539e05b0ba59cb491ecb4c7237d77741d3b44c0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:17 +0100 Subject: [PATCH 56/65] iio: light: veml6030: Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() macros Using these new macros allows the compiler to remove the unused dev_pm_ops structure and related functions if !CONFIG_PM without the need to mark the functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Rishi Gupta Reviewed-by: Rishi Gupta Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-35-jic23@kernel.org --- drivers/iio/light/veml6030.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index 3c937c55a10d..9a7800cdfee2 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -846,7 +846,7 @@ static int veml6030_probe(struct i2c_client *client, return devm_iio_device_register(&client->dev, indio_dev); } -static int __maybe_unused veml6030_runtime_suspend(struct device *dev) +static int veml6030_runtime_suspend(struct device *dev) { int ret; struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); @@ -859,7 +859,7 @@ static int __maybe_unused veml6030_runtime_suspend(struct device *dev) return ret; } -static int __maybe_unused veml6030_runtime_resume(struct device *dev) +static int veml6030_runtime_resume(struct device *dev) { int ret; struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); @@ -872,12 +872,8 @@ static int __maybe_unused veml6030_runtime_resume(struct device *dev) return ret; } -static const struct dev_pm_ops veml6030_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(veml6030_runtime_suspend, - veml6030_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(veml6030_pm_ops, veml6030_runtime_suspend, + veml6030_runtime_resume, NULL); static const struct of_device_id veml6030_of_match[] = { { .compatible = "vishay,veml6030" }, @@ -895,7 +891,7 @@ static struct i2c_driver veml6030_driver = { .driver = { .name = "veml6030", .of_match_table = veml6030_of_match, - .pm = &veml6030_pm_ops, + .pm = pm_ptr(&veml6030_pm_ops), }, .probe = veml6030_probe, .id_table = veml6030_id, From 74f4595ab7f8ff18919c25290e98108671887095 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:18 +0100 Subject: [PATCH 57/65] iio: magnetometer: ak8974: Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() macros Using these new macros allows the compiler to remove the unused dev_pm_ops structure and related functions if !CONFIG_PM without the need to mark the functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Linus Walleij Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-36-jic23@kernel.org --- drivers/iio/magnetometer/ak8974.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c index e54feacfb980..c89a91db0690 100644 --- a/drivers/iio/magnetometer/ak8974.c +++ b/drivers/iio/magnetometer/ak8974.c @@ -985,7 +985,7 @@ static int ak8974_remove(struct i2c_client *i2c) return 0; } -static int __maybe_unused ak8974_runtime_suspend(struct device *dev) +static int ak8974_runtime_suspend(struct device *dev) { struct ak8974 *ak8974 = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); @@ -996,7 +996,7 @@ static int __maybe_unused ak8974_runtime_suspend(struct device *dev) return 0; } -static int __maybe_unused ak8974_runtime_resume(struct device *dev) +static int ak8974_runtime_resume(struct device *dev) { struct ak8974 *ak8974 = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); @@ -1024,12 +1024,8 @@ out_regulator_disable: return ret; } -static const struct dev_pm_ops ak8974_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(ak8974_runtime_suspend, - ak8974_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(ak8974_dev_pm_ops, ak8974_runtime_suspend, + ak8974_runtime_resume, NULL); static const struct i2c_device_id ak8974_id[] = { {"ami305", 0 }, @@ -1050,7 +1046,7 @@ MODULE_DEVICE_TABLE(of, ak8974_of_match); static struct i2c_driver ak8974_driver = { .driver = { .name = "ak8974", - .pm = &ak8974_dev_pm_ops, + .pm = pm_ptr(&ak8974_dev_pm_ops), .of_match_table = ak8974_of_match, }, .probe = ak8974_probe, From e5933cf48779064c417fa3a2f75bbef51ea4b137 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Tue, 21 Jun 2022 21:27:19 +0100 Subject: [PATCH 58/65] iio: magn: yas530: Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() macros Using these new macros allows the compiler to remove the unused dev_pm_ops structure and related functions if !CONFIG_PM without the need to mark the functions __maybe_unused. Signed-off-by: Jonathan Cameron Cc: Linus Walleij Reviewed-by: Paul Cercueil Link: https://lore.kernel.org/r/20220621202719.13644-37-jic23@kernel.org --- drivers/iio/magnetometer/yamaha-yas530.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c index b2bc637150bf..aeaa4da6923b 100644 --- a/drivers/iio/magnetometer/yamaha-yas530.c +++ b/drivers/iio/magnetometer/yamaha-yas530.c @@ -965,7 +965,7 @@ static int yas5xx_remove(struct i2c_client *i2c) return 0; } -static int __maybe_unused yas5xx_runtime_suspend(struct device *dev) +static int yas5xx_runtime_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas5xx *yas5xx = iio_priv(indio_dev); @@ -976,7 +976,7 @@ static int __maybe_unused yas5xx_runtime_suspend(struct device *dev) return 0; } -static int __maybe_unused yas5xx_runtime_resume(struct device *dev) +static int yas5xx_runtime_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct yas5xx *yas5xx = iio_priv(indio_dev); @@ -1011,12 +1011,8 @@ out_reset: return ret; } -static const struct dev_pm_ops yas5xx_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) - SET_RUNTIME_PM_OPS(yas5xx_runtime_suspend, - yas5xx_runtime_resume, NULL) -}; +static DEFINE_RUNTIME_DEV_PM_OPS(yas5xx_dev_pm_ops, yas5xx_runtime_suspend, + yas5xx_runtime_resume, NULL); static const struct i2c_device_id yas5xx_id[] = { {"yas530", }, @@ -1038,7 +1034,7 @@ static struct i2c_driver yas5xx_driver = { .driver = { .name = "yas5xx", .of_match_table = yas5xx_of_match, - .pm = &yas5xx_dev_pm_ops, + .pm = pm_ptr(&yas5xx_dev_pm_ops), }, .probe = yas5xx_probe, .remove = yas5xx_remove, From a63d28819ffc6f424137170f19d833a80eddbe47 Mon Sep 17 00:00:00 2001 From: Jiang Jian Date: Wed, 22 Jun 2022 11:59:25 +0800 Subject: [PATCH 59/65] iio: magnetometer: hmc5843: Remove duplicate 'the' Fix an obvious typing error, found by spellcheck(1). Signed-off-by: Jiang Jian Link: https://lore.kernel.org/r/20220622035925.5008-1-jiangjian@cdjrlc.com Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/hmc5843_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c index 92eb2d156ddb..4a63b2da9df0 100644 --- a/drivers/iio/magnetometer/hmc5843_core.c +++ b/drivers/iio/magnetometer/hmc5843_core.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Device driver for the the HMC5843 multi-chip module designed + * Device driver for the HMC5843 multi-chip module designed * for low field magnetic sensing. * * Copyright (C) 2010 Texas Instruments From 7aa68dcce0ab8f1211953799eaee282b301ee719 Mon Sep 17 00:00:00 2001 From: Akira Yokosawa Date: Sun, 3 Jul 2022 13:27:47 +0900 Subject: [PATCH 60/65] iio: proximity: sx9324: add empty line in front of bullet list "make htmldocs" emits a warning of: Documentation/ABI/testing/sysfs-bus-iio-sx9324:2: WARNING: Unexpected indentation. This is due to a missing empty line in front of the bullet list. Fix it. Note: The line count of 2 in the warning is not exact in this case. Signed-off-by: Akira Yokosawa Fixes: 4c18a890dff8 ("iio:proximity:sx9324: Add SX9324 support") Link: https://lore.kernel.org/r/202207021703.lEW6FLT1-lkp@intel.com/ Reported-by: kernel test robot Cc: Gwendal Grignou Cc: Stephen Boyd Cc: Jonathan Cameron Reviewed-by: Bagas Sanjaya Link: https://lore.kernel.org/r/abcaa4f5-7a9b-56b5-c11a-a88fef9d1e0a@gmail.com Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio-sx9324 | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio-sx9324 b/Documentation/ABI/testing/sysfs-bus-iio-sx9324 index 632e3321f5a3..a8342770e7cb 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-sx9324 +++ b/Documentation/ABI/testing/sysfs-bus-iio-sx9324 @@ -5,6 +5,7 @@ Contact: Gwendal Grignou Description: SX9324 has 3 inputs, CS0, CS1 and CS2. Hardware layout defines if the input is + + not connected (HZ), + grounded (GD), + connected to an antenna where it can act as a base From 06ee60eb507f00fb3643876ec05318c63332dc88 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 7 Jul 2022 17:54:45 +0300 Subject: [PATCH 61/65] iio: adc: max1027: unlock on error path in max1027_read_single_value() If max1027_wait_eoc() fails then call iio_device_release_direct_mode() before returning. Fixes: a0e831653ef9 ("iio: adc: max1027: Introduce an end of conversion helper") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/YsbztVuAXnau2cIZ@kili Signed-off-by: Jonathan Cameron --- drivers/iio/adc/max1027.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index b725d012625c..136fcf753837 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c @@ -349,8 +349,7 @@ static int max1027_read_single_value(struct iio_dev *indio_dev, if (ret < 0) { dev_err(&indio_dev->dev, "Failed to configure conversion register\n"); - iio_device_release_direct_mode(indio_dev); - return ret; + goto release; } /* @@ -360,11 +359,12 @@ static int max1027_read_single_value(struct iio_dev *indio_dev, */ ret = max1027_wait_eoc(indio_dev); if (ret) - return ret; + goto release; /* Read result */ ret = spi_read(st->spi, st->buffer, (chan->type == IIO_TEMP) ? 4 : 2); +release: iio_device_release_direct_mode(indio_dev); if (ret < 0) From 5e1f91850365de55ca74945866c002fda8f00331 Mon Sep 17 00:00:00 2001 From: Fawzi Khaber Date: Mon, 18 Jul 2022 15:07:06 +0200 Subject: [PATCH 62/65] iio: fix iio_format_avail_range() printing for none IIO_VAL_INT iio_format_avail_range() should print range as follow [min, step, max], so the function was previously calling iio_format_list() with length = 3, length variable refers to the array size of values not the number of elements. In case of non IIO_VAL_INT values each element has integer part and decimal part. With length = 3 this would cause premature end of loop and result in printing only one element. Signed-off-by: Fawzi Khaber Signed-off-by: Jean-Baptiste Maneyrol Fixes: eda20ba1e25e ("iio: core: Consolidate iio_format_avail_{list,range}()") Link: https://lore.kernel.org/r/20220718130706.32571-1-jmaneyrol@invensense.com Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 358b909298c0..0f4dbda3b9d3 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -812,7 +812,23 @@ static ssize_t iio_format_avail_list(char *buf, const int *vals, static ssize_t iio_format_avail_range(char *buf, const int *vals, int type) { - return iio_format_list(buf, vals, type, 3, "[", "]"); + int length; + + /* + * length refers to the array size , not the number of elements. + * The purpose is to print the range [min , step ,max] so length should + * be 3 in case of int, and 6 for other types. + */ + switch (type) { + case IIO_VAL_INT: + length = 3; + break; + default: + length = 6; + break; + } + + return iio_format_list(buf, vals, type, length, "[", "]"); } static ssize_t iio_read_channel_info_avail(struct device *dev, From 3cfb0e1d395a4323f325baaff58b8fe4a8ff9ecd Mon Sep 17 00:00:00 2001 From: LI Qingwu Date: Fri, 1 Jul 2022 02:30:30 +0000 Subject: [PATCH 63/65] iio: accel: sca3300: Extend the trigger buffer from 16 to 32 bytes After added inclination angle channels, the trigger buffer size is insufficient. Extend the buffer size from 16 to 32 bytes, and change the trigger buffer from the struct to a u8 array to adapt the sensor with/without inclination angles output. New trigger buffer data: - SCA3300: 3 accel channels, temp, and timestamp. - SCL3300: 3 accel channels, temp, 3 incli channels, and timestamp. Readjustment the scan index to make it consistent with the buffer data. Signed-off-by: LI Qingwu Link: https://lore.kernel.org/r/20220701023030.2527019-2-Qing-wu.Li@leica-geosystems.com.cn Signed-off-by: Jonathan Cameron --- drivers/iio/accel/sca3300.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/iio/accel/sca3300.c b/drivers/iio/accel/sca3300.c index 3c4827bfef53..eaa0c9cfda44 100644 --- a/drivers/iio/accel/sca3300.c +++ b/drivers/iio/accel/sca3300.c @@ -52,12 +52,21 @@ enum sca3300_scan_indexes { SCA3300_ACC_Y, SCA3300_ACC_Z, SCA3300_TEMP, - SCA3300_TIMESTAMP, SCA3300_INCLI_X, SCA3300_INCLI_Y, SCA3300_INCLI_Z, + SCA3300_SCAN_MAX }; +/* + * Buffer size max case: + * Three accel channels, two bytes per channel. + * Temperature channel, two bytes. + * Three incli channels, two bytes per channel. + * Timestamp channel, eight bytes. + */ +#define SCA3300_MAX_BUFFER_SIZE (ALIGN(sizeof(s16) * SCA3300_SCAN_MAX, sizeof(s64)) + sizeof(s64)) + #define SCA3300_ACCEL_CHANNEL(index, reg, axis) { \ .type = IIO_ACCEL, \ .address = reg, \ @@ -140,10 +149,10 @@ static const struct iio_chan_spec scl3300_channels[] = { SCA3300_ACCEL_CHANNEL(SCA3300_ACC_Y, 0x2, Y), SCA3300_ACCEL_CHANNEL(SCA3300_ACC_Z, 0x3, Z), SCA3300_TEMP_CHANNEL(SCA3300_TEMP, 0x05), - IIO_CHAN_SOFT_TIMESTAMP(4), SCA3300_INCLI_CHANNEL(SCA3300_INCLI_X, 0x09, X), SCA3300_INCLI_CHANNEL(SCA3300_INCLI_Y, 0x0A, Y), SCA3300_INCLI_CHANNEL(SCA3300_INCLI_Z, 0x0B, Z), + IIO_CHAN_SOFT_TIMESTAMP(7), }; static const unsigned long sca3300_scan_masks[] = { @@ -184,7 +193,9 @@ struct sca3300_chip_info { * @spi: SPI device structure * @lock: Data buffer lock * @chip: Sensor chip specific information - * @scan: Triggered buffer. Four channel 16-bit data + 64-bit timestamp + * @buffer: Triggered buffer: + * -SCA3300: 4 channel 16-bit data + 64-bit timestamp + * -SCL3300: 7 channel 16-bit data + 64-bit timestamp * @txbuf: Transmit buffer * @rxbuf: Receive buffer */ @@ -192,10 +203,7 @@ struct sca3300_data { struct spi_device *spi; struct mutex lock; const struct sca3300_chip_info *chip; - struct { - s16 channels[4]; - s64 ts __aligned(sizeof(s64)); - } scan; + u8 buffer[SCA3300_MAX_BUFFER_SIZE] __aligned(sizeof(s64)); u8 txbuf[4] __aligned(IIO_DMA_MINALIGN); u8 rxbuf[4]; }; @@ -484,21 +492,21 @@ static irqreturn_t sca3300_trigger_handler(int irq, void *p) struct iio_dev *indio_dev = pf->indio_dev; struct sca3300_data *data = iio_priv(indio_dev); int bit, ret, val, i = 0; + s16 *channels = (s16 *)data->buffer; for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) { - ret = sca3300_read_reg(data, sca3300_channels[bit].address, - &val); + ret = sca3300_read_reg(data, indio_dev->channels[bit].address, &val); if (ret) { dev_err_ratelimited(&data->spi->dev, "failed to read register, error: %d\n", ret); /* handled, but bailing out due to errors */ goto out; } - data->scan.channels[i++] = val; + channels[i++] = val; } - iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, + iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); From 06674fc7c003b9d0aa1d37fef7ab2c24802cc6ad Mon Sep 17 00:00:00 2001 From: Zheyu Ma Date: Sun, 17 Jul 2022 08:42:41 +0800 Subject: [PATCH 64/65] iio: light: isl29028: Fix the warning in isl29028_remove() The driver use the non-managed form of the register function in isl29028_remove(). To keep the release order as mirroring the ordering in probe, the driver should use non-managed form in probe, too. The following log reveals it: [ 32.374955] isl29028 0-0010: remove [ 32.376861] general protection fault, probably for non-canonical address 0xdffffc0000000006: 0000 [#1] PREEMPT SMP KASAN PTI [ 32.377676] KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037] [ 32.379432] RIP: 0010:kernfs_find_and_get_ns+0x28/0xe0 [ 32.385461] Call Trace: [ 32.385807] sysfs_unmerge_group+0x59/0x110 [ 32.386110] dpm_sysfs_remove+0x58/0xc0 [ 32.386391] device_del+0x296/0xe50 [ 32.386959] cdev_device_del+0x1d/0xd0 [ 32.387231] devm_iio_device_unreg+0x27/0xb0 [ 32.387542] devres_release_group+0x319/0x3d0 [ 32.388162] i2c_device_remove+0x93/0x1f0 Fixes: 2db5054ac28d ("staging: iio: isl29028: add runtime power management support") Signed-off-by: Zheyu Ma Link: https://lore.kernel.org/r/20220717004241.2281028-1-zheyuma97@gmail.com Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/light/isl29028.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/isl29028.c b/drivers/iio/light/isl29028.c index 4dde9707a52d..ff5996d77818 100644 --- a/drivers/iio/light/isl29028.c +++ b/drivers/iio/light/isl29028.c @@ -625,7 +625,7 @@ static int isl29028_probe(struct i2c_client *client, ISL29028_POWER_OFF_DELAY_MS); pm_runtime_use_autosuspend(&client->dev); - ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); + ret = iio_device_register(indio_dev); if (ret < 0) { dev_err(&client->dev, "%s(): iio registration failed with error %d\n", From 180c6cb6b9b79c55b79e8414f4c0208f2463af7d Mon Sep 17 00:00:00 2001 From: "Hui.Liu" Date: Tue, 19 Jul 2022 09:46:57 +0800 Subject: [PATCH 65/65] dt-bindings: iio: adc: Add compatible for MT8188 Add dt-binding documentation of auxadc for MediaTek MT8188 SoC platform. Signed-off-by: Hui.Liu Reviewed-by: AngeloGioacchino Del Regno Acked-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20220719014657.28714-2-hui.liu@mediatek.com Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml b/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml index 65581ad4b816..7f79a06e76f5 100644 --- a/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml @@ -35,6 +35,7 @@ properties: - enum: - mediatek,mt8183-auxadc - mediatek,mt8186-auxadc + - mediatek,mt8188-auxadc - mediatek,mt8195-auxadc - mediatek,mt8516-auxadc - const: mediatek,mt8173-auxadc