* [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array()
@ 2025-02-03 8:08 Raag Jadav
2025-02-03 8:08 ` [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h Raag Jadav
` (20 more replies)
0 siblings, 21 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
This series
1. Splits device/devres.h for the users that are only interested in devres APIs.
Original work by Andy Shevchenko:
https://lore.kernel.org/r/20241203195340.855879-1-andriy.shevchenko@linux.intel.com
2. Introduces a more robust and cleaner devm_kmemdup_array() helper and uses it
across drivers.
The idea behind embedding both work into a single series is to reduce conflicts
and dependencies while merging.
v2: Use size_mul() for multiplication (Dmitry)
Update commit message (Dmitry)
v3: Embed devres.h work by Andy
Add more users of devm_kmemdup_array()
Update tags and rebase
Andy Shevchenko (2):
driver core: Split devres APIs to device/devres.h
iio: imu: st_lsm9ds0: Replace device.h with what is needed
Raag Jadav (18):
devres: Introduce devm_kmemdup_array()
pinctrl: intel: copy communities using devm_kmemdup_array()
pinctrl: baytrail: copy communities using devm_kmemdup_array()
pinctrl: cherryview: use devm_kmemdup_array()
pinctrl: tangier: use devm_kmemdup_array()
pinctrl: pxa2xx: use devm_kmemdup_array()
input: sparse-keymap: use devm_kmemdup_array()
input: ipaq-micro-keys: use devm_kmemdup_array()
regulator: devres: use devm_kmemdup_array()
regulator: cros-ec: use devm_kmemdup_array()
power: supply: sc27xx: use devm_kmemdup_array()
iio: adc: xilinx-xadc-core: use devm_kmemdup_array()
ASoC: Intel: avs: use devm_kmemdup_array()
ASoC: hdac_hdmi: use devm_kmemdup_array()
ASoC: tlv320dac33: use devm_kmemdup_array()
ASoC: uda1380: use devm_kmemdup_array()
ASoC: meson: axg-tdm-interface: use devm_kmemdup_array()
ASoC: uniphier: use devm_kmemdup_array()
drivers/iio/adc/xilinx-xadc-core.c | 4 +-
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 2 +-
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 2 +-
drivers/input/keyboard/ipaq-micro-keys.c | 5 +-
drivers/input/sparse-keymap.c | 3 +-
drivers/pinctrl/intel/pinctrl-baytrail.c | 6 +-
drivers/pinctrl/intel/pinctrl-cherryview.c | 5 +-
drivers/pinctrl/intel/pinctrl-intel.c | 6 +-
drivers/pinctrl/intel/pinctrl-tangier.c | 5 +-
drivers/pinctrl/pxa/pinctrl-pxa2xx.c | 8 +-
drivers/power/supply/sc27xx_fuel_gauge.c | 5 +-
drivers/regulator/cros-ec-regulator.c | 4 +-
drivers/regulator/devres.c | 5 +-
include/linux/device.h | 119 +-----------------
include/linux/device/devres.h | 129 ++++++++++++++++++++
sound/soc/codecs/hdac_hdmi.c | 3 +-
sound/soc/codecs/tlv320dac33.c | 6 +-
sound/soc/codecs/uda1380.c | 6 +-
sound/soc/intel/avs/boards/da7219.c | 3 +-
sound/soc/intel/avs/boards/es8336.c | 3 +-
sound/soc/intel/avs/boards/nau8825.c | 3 +-
sound/soc/intel/avs/boards/rt274.c | 3 +-
sound/soc/intel/avs/boards/rt286.c | 3 +-
sound/soc/intel/avs/boards/rt298.c | 3 +-
sound/soc/intel/avs/boards/rt5663.c | 3 +-
sound/soc/intel/avs/boards/rt5682.c | 2 +-
sound/soc/meson/axg-tdm-interface.c | 9 +-
sound/soc/uniphier/aio-cpu.c | 8 +-
28 files changed, 179 insertions(+), 184 deletions(-)
create mode 100644 include/linux/device/devres.h
base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
--
2.34.1
^ permalink raw reply [flat|nested] 46+ messages in thread
* [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-05 16:27 ` kernel test robot
2025-02-03 8:08 ` [PATCH v3 02/20] iio: imu: st_lsm9ds0: Replace device.h with what is needed Raag Jadav
` (19 subsequent siblings)
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
device.h is a huge header which is hard to follow and easy to miss
something. Improve that by splitting devres APIs to device/devres.h.
In particular this helps to speedup the build of the code that includes
device.h solely for a devres APIs.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/device.h | 119 +-------------------------------
include/linux/device/devres.h | 124 ++++++++++++++++++++++++++++++++++
2 files changed, 125 insertions(+), 118 deletions(-)
create mode 100644 include/linux/device/devres.h
diff --git a/include/linux/device.h b/include/linux/device.h
index 80a5b3268986..78ca7fd0e625 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -26,9 +26,9 @@
#include <linux/atomic.h>
#include <linux/uidgid.h>
#include <linux/gfp.h>
-#include <linux/overflow.h>
#include <linux/device/bus.h>
#include <linux/device/class.h>
+#include <linux/device/devres.h>
#include <linux/device/driver.h>
#include <linux/cleanup.h>
#include <asm/device.h>
@@ -281,123 +281,6 @@ int __must_check device_create_bin_file(struct device *dev,
void device_remove_bin_file(struct device *dev,
const struct bin_attribute *attr);
-/* device resource management */
-typedef void (*dr_release_t)(struct device *dev, void *res);
-typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
-
-void *__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
- int nid, const char *name) __malloc;
-#define devres_alloc(release, size, gfp) \
- __devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release)
-#define devres_alloc_node(release, size, gfp, nid) \
- __devres_alloc_node(release, size, gfp, nid, #release)
-
-void devres_for_each_res(struct device *dev, dr_release_t release,
- dr_match_t match, void *match_data,
- void (*fn)(struct device *, void *, void *),
- void *data);
-void devres_free(void *res);
-void devres_add(struct device *dev, void *res);
-void *devres_find(struct device *dev, dr_release_t release,
- dr_match_t match, void *match_data);
-void *devres_get(struct device *dev, void *new_res,
- dr_match_t match, void *match_data);
-void *devres_remove(struct device *dev, dr_release_t release,
- dr_match_t match, void *match_data);
-int devres_destroy(struct device *dev, dr_release_t release,
- dr_match_t match, void *match_data);
-int devres_release(struct device *dev, dr_release_t release,
- dr_match_t match, void *match_data);
-
-/* devres group */
-void * __must_check devres_open_group(struct device *dev, void *id, gfp_t gfp);
-void devres_close_group(struct device *dev, void *id);
-void devres_remove_group(struct device *dev, void *id);
-int devres_release_group(struct device *dev, void *id);
-
-/* managed devm_k.alloc/kfree for device drivers */
-void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __alloc_size(2);
-void *devm_krealloc(struct device *dev, void *ptr, size_t size,
- gfp_t gfp) __must_check __realloc_size(3);
-__printf(3, 0) char *devm_kvasprintf(struct device *dev, gfp_t gfp,
- const char *fmt, va_list ap) __malloc;
-__printf(3, 4) char *devm_kasprintf(struct device *dev, gfp_t gfp,
- const char *fmt, ...) __malloc;
-static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
-{
- return devm_kmalloc(dev, size, gfp | __GFP_ZERO);
-}
-static inline void *devm_kmalloc_array(struct device *dev,
- size_t n, size_t size, gfp_t flags)
-{
- size_t bytes;
-
- if (unlikely(check_mul_overflow(n, size, &bytes)))
- return NULL;
-
- return devm_kmalloc(dev, bytes, flags);
-}
-static inline void *devm_kcalloc(struct device *dev,
- size_t n, size_t size, gfp_t flags)
-{
- return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
-}
-static inline __realloc_size(3, 4) void * __must_check
-devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_size, gfp_t flags)
-{
- size_t bytes;
-
- if (unlikely(check_mul_overflow(new_n, new_size, &bytes)))
- return NULL;
-
- return devm_krealloc(dev, p, bytes, flags);
-}
-
-void devm_kfree(struct device *dev, const void *p);
-char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc;
-const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp);
-void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp)
- __realloc_size(3);
-
-unsigned long devm_get_free_pages(struct device *dev,
- gfp_t gfp_mask, unsigned int order);
-void devm_free_pages(struct device *dev, unsigned long addr);
-
-#ifdef CONFIG_HAS_IOMEM
-void __iomem *devm_ioremap_resource(struct device *dev,
- const struct resource *res);
-void __iomem *devm_ioremap_resource_wc(struct device *dev,
- const struct resource *res);
-
-void __iomem *devm_of_iomap(struct device *dev,
- struct device_node *node, int index,
- resource_size_t *size);
-#else
-
-static inline
-void __iomem *devm_ioremap_resource(struct device *dev,
- const struct resource *res)
-{
- return ERR_PTR(-EINVAL);
-}
-
-static inline
-void __iomem *devm_ioremap_resource_wc(struct device *dev,
- const struct resource *res)
-{
- return ERR_PTR(-EINVAL);
-}
-
-static inline
-void __iomem *devm_of_iomap(struct device *dev,
- struct device_node *node, int index,
- resource_size_t *size)
-{
- return ERR_PTR(-EINVAL);
-}
-
-#endif
-
/* allows to add/remove a custom action to devres stack */
int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
new file mode 100644
index 000000000000..128d65defafc
--- /dev/null
+++ b/include/linux/device/devres.h
@@ -0,0 +1,124 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _DEVICE_DEVRES_H_
+#define _DEVICE_DEVRES_H_
+
+#include <linux/err.h>
+#include <linux/gfp_types.h>
+#include <linux/numa.h>
+#include <linux/overflow.h>
+#include <linux/stdarg.h>
+#include <linux/types.h>
+
+struct device;
+struct device_node;
+struct resource;
+
+/* device resource management */
+typedef void (*dr_release_t)(struct device *dev, void *res);
+typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
+
+void * __malloc
+__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, int nid, const char *name);
+#define devres_alloc(release, size, gfp) \
+ __devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release)
+#define devres_alloc_node(release, size, gfp, nid) \
+ __devres_alloc_node(release, size, gfp, nid, #release)
+
+void devres_for_each_res(struct device *dev, dr_release_t release,
+ dr_match_t match, void *match_data,
+ void (*fn)(struct device *, void *, void *),
+ void *data);
+void devres_free(void *res);
+void devres_add(struct device *dev, void *res);
+void *devres_find(struct device *dev, dr_release_t release, dr_match_t match, void *match_data);
+void *devres_get(struct device *dev, void *new_res, dr_match_t match, void *match_data);
+void *devres_remove(struct device *dev, dr_release_t release, dr_match_t match, void *match_data);
+int devres_destroy(struct device *dev, dr_release_t release, dr_match_t match, void *match_data);
+int devres_release(struct device *dev, dr_release_t release, dr_match_t match, void *match_data);
+
+/* devres group */
+void * __must_check devres_open_group(struct device *dev, void *id, gfp_t gfp);
+void devres_close_group(struct device *dev, void *id);
+void devres_remove_group(struct device *dev, void *id);
+int devres_release_group(struct device *dev, void *id);
+
+/* managed devm_k.alloc/kfree for device drivers */
+void * __alloc_size(2)
+devm_kmalloc(struct device *dev, size_t size, gfp_t gfp);
+void * __must_check __realloc_size(3)
+devm_krealloc(struct device *dev, void *ptr, size_t size, gfp_t gfp);
+static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
+{
+ return devm_kmalloc(dev, size, gfp | __GFP_ZERO);
+}
+static inline void *devm_kmalloc_array(struct device *dev, size_t n, size_t size, gfp_t flags)
+{
+ size_t bytes;
+
+ if (unlikely(check_mul_overflow(n, size, &bytes)))
+ return NULL;
+
+ return devm_kmalloc(dev, bytes, flags);
+}
+static inline void *devm_kcalloc(struct device *dev, size_t n, size_t size, gfp_t flags)
+{
+ return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
+}
+static inline __realloc_size(3, 4) void * __must_check
+devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_size, gfp_t flags)
+{
+ size_t bytes;
+
+ if (unlikely(check_mul_overflow(new_n, new_size, &bytes)))
+ return NULL;
+
+ return devm_krealloc(dev, p, bytes, flags);
+}
+
+void devm_kfree(struct device *dev, const void *p);
+
+void * __realloc_size(3)
+devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp);
+
+char * __malloc
+devm_kstrdup(struct device *dev, const char *s, gfp_t gfp);
+const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp);
+char * __printf(3, 0) __malloc
+devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt, va_list ap);
+char * __printf(3, 4) __malloc
+devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...);
+
+unsigned long devm_get_free_pages(struct device *dev, gfp_t gfp_mask, unsigned int order);
+void devm_free_pages(struct device *dev, unsigned long addr);
+
+#ifdef CONFIG_HAS_IOMEM
+
+void __iomem *devm_ioremap_resource(struct device *dev, const struct resource *res);
+void __iomem *devm_ioremap_resource_wc(struct device *dev, const struct resource *res);
+
+void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int index,
+ resource_size_t *size);
+#else
+
+static inline
+void __iomem *devm_ioremap_resource(struct device *dev, const struct resource *res)
+{
+ return ERR_PTR(-EINVAL);
+}
+
+static inline
+void __iomem *devm_ioremap_resource_wc(struct device *dev, const struct resource *res)
+{
+ return ERR_PTR(-EINVAL);
+}
+
+static inline
+void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int index,
+ resource_size_t *size)
+{
+ return ERR_PTR(-EINVAL);
+}
+
+#endif
+
+#endif /* _DEVICE_DEVRES_H_ */
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 02/20] iio: imu: st_lsm9ds0: Replace device.h with what is needed
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
2025-02-03 8:08 ` [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 11:19 ` Jonathan Cameron
2025-02-03 8:08 ` [PATCH v3 03/20] devres: Introduce devm_kmemdup_array() Raag Jadav
` (18 subsequent siblings)
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Instead of including a huge device.h with tons of dependencies
include only what driver actually uses.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 2 +-
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
index 0732cfa258c4..8cc071463249 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
@@ -7,7 +7,7 @@
* Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
*/
-#include <linux/device.h>
+#include <linux/device/devres.h>
#include <linux/err.h>
#include <linux/gfp_types.h>
#include <linux/i2c.h>
diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
index 43ec57c1e604..806e55f75f65 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
@@ -7,7 +7,7 @@
* Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
*/
-#include <linux/device.h>
+#include <linux/device/devres.h>
#include <linux/err.h>
#include <linux/gfp_types.h>
#include <linux/module.h>
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 03/20] devres: Introduce devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
2025-02-03 8:08 ` [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h Raag Jadav
2025-02-03 8:08 ` [PATCH v3 02/20] iio: imu: st_lsm9ds0: Replace device.h with what is needed Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 8:08 ` [PATCH v3 04/20] pinctrl: intel: copy communities using devm_kmemdup_array() Raag Jadav
` (17 subsequent siblings)
20 siblings, 0 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Introduce '_array' variant of devm_kmemdup() which is more robust and
consistent with alloc family of helpers.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
include/linux/device/devres.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
index 128d65defafc..6ef400abfe21 100644
--- a/include/linux/device/devres.h
+++ b/include/linux/device/devres.h
@@ -79,6 +79,11 @@ void devm_kfree(struct device *dev, const void *p);
void * __realloc_size(3)
devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp);
+static inline void *devm_kmemdup_array(struct device *dev, const void *src,
+ size_t n, size_t size, gfp_t flags)
+{
+ return devm_kmemdup(dev, src, size_mul(size, n), flags);
+}
char * __malloc
devm_kstrdup(struct device *dev, const char *s, gfp_t gfp);
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 04/20] pinctrl: intel: copy communities using devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (2 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 03/20] devres: Introduce devm_kmemdup_array() Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 8:08 ` [PATCH v3 05/20] pinctrl: baytrail: " Raag Jadav
` (16 subsequent siblings)
20 siblings, 0 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Copy communities using devm_kmemdup_array() instead of doing it manually.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/pinctrl/intel/pinctrl-intel.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c
index 527e4b87ae52..0a1905869472 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -1577,8 +1577,8 @@ int intel_pinctrl_probe(struct platform_device *pdev,
* to the registers.
*/
pctrl->ncommunities = pctrl->soc->ncommunities;
- pctrl->communities = devm_kcalloc(dev, pctrl->ncommunities,
- sizeof(*pctrl->communities), GFP_KERNEL);
+ pctrl->communities = devm_kmemdup_array(dev, pctrl->soc->communities, pctrl->ncommunities,
+ sizeof(*pctrl->communities), GFP_KERNEL);
if (!pctrl->communities)
return -ENOMEM;
@@ -1588,8 +1588,6 @@ int intel_pinctrl_probe(struct platform_device *pdev,
u32 offset;
u32 value;
- *community = pctrl->soc->communities[i];
-
regs = devm_platform_ioremap_resource(pdev, community->barno);
if (IS_ERR(regs))
return PTR_ERR(regs);
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 05/20] pinctrl: baytrail: copy communities using devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (3 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 04/20] pinctrl: intel: copy communities using devm_kmemdup_array() Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-06 18:45 ` Linus Walleij
2025-02-03 8:08 ` [PATCH v3 06/20] pinctrl: cherryview: use devm_kmemdup_array() Raag Jadav
` (15 subsequent siblings)
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Copy communities using devm_kmemdup_array() instead of doing it manually.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/pinctrl/intel/pinctrl-baytrail.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 7340dc20349c..797315fee29a 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -1557,16 +1557,14 @@ static int byt_set_soc_data(struct intel_pinctrl *vg,
vg->soc = soc;
vg->ncommunities = vg->soc->ncommunities;
- vg->communities = devm_kcalloc(vg->dev, vg->ncommunities,
- sizeof(*vg->communities), GFP_KERNEL);
+ vg->communities = devm_kmemdup_array(vg->dev, vg->soc->communities, vg->ncommunities,
+ sizeof(*vg->communities), GFP_KERNEL);
if (!vg->communities)
return -ENOMEM;
for (i = 0; i < vg->soc->ncommunities; i++) {
struct intel_community *comm = vg->communities + i;
- *comm = vg->soc->communities[i];
-
comm->pad_regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(comm->pad_regs))
return PTR_ERR(comm->pad_regs);
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 06/20] pinctrl: cherryview: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (4 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 05/20] pinctrl: baytrail: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-06 18:46 ` Linus Walleij
2025-02-03 8:08 ` [PATCH v3 07/20] pinctrl: tangier: " Raag Jadav
` (14 subsequent siblings)
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/pinctrl/intel/pinctrl-cherryview.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index c673e262e1db..df97aa97c278 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -1631,9 +1631,8 @@ static int chv_pinctrl_probe(struct platform_device *pdev)
pctrl->soc = soc_data;
pctrl->ncommunities = pctrl->soc->ncommunities;
- pctrl->communities = devm_kmemdup(dev, pctrl->soc->communities,
- pctrl->ncommunities * sizeof(*pctrl->communities),
- GFP_KERNEL);
+ pctrl->communities = devm_kmemdup_array(dev, pctrl->soc->communities, pctrl->ncommunities,
+ sizeof(*pctrl->communities), GFP_KERNEL);
if (!pctrl->communities)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 07/20] pinctrl: tangier: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (5 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 06/20] pinctrl: cherryview: use devm_kmemdup_array() Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 8:08 ` [PATCH v3 08/20] pinctrl: pxa2xx: " Raag Jadav
` (13 subsequent siblings)
20 siblings, 0 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/pinctrl/intel/pinctrl-tangier.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/intel/pinctrl-tangier.c b/drivers/pinctrl/intel/pinctrl-tangier.c
index d3baf0f4eea0..e9a742ddf1f9 100644
--- a/drivers/pinctrl/intel/pinctrl-tangier.c
+++ b/drivers/pinctrl/intel/pinctrl-tangier.c
@@ -524,7 +524,6 @@ static int tng_pinctrl_probe(struct platform_device *pdev,
struct device *dev = &pdev->dev;
struct tng_family *families;
struct tng_pinctrl *tp;
- size_t families_len;
void __iomem *regs;
unsigned int i;
@@ -543,8 +542,8 @@ static int tng_pinctrl_probe(struct platform_device *pdev,
* Make a copy of the families which we can use to hold pointers
* to the registers.
*/
- families_len = size_mul(sizeof(*families), tp->nfamilies);
- families = devm_kmemdup(dev, tp->families, families_len, GFP_KERNEL);
+ families = devm_kmemdup_array(dev, tp->families, tp->nfamilies,
+ sizeof(*families), GFP_KERNEL);
if (!families)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 08/20] pinctrl: pxa2xx: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (6 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 07/20] pinctrl: tangier: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 8:08 ` [PATCH v3 09/20] input: sparse-keymap: " Raag Jadav
` (12 subsequent siblings)
20 siblings, 0 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/pinctrl/pxa/pinctrl-pxa2xx.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
index 9e34b92ff5f2..9fd7a8fb2bc4 100644
--- a/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
+++ b/drivers/pinctrl/pxa/pinctrl-pxa2xx.c
@@ -281,9 +281,8 @@ static int pxa2xx_build_functions(struct pxa_pinctrl *pctl)
for (df = pctl->ppins[i].functions; df->name; df++)
if (!pxa2xx_find_function(pctl, df->name, functions))
(functions + pctl->nfuncs++)->name = df->name;
- pctl->functions = devm_kmemdup(pctl->dev, functions,
- pctl->nfuncs * sizeof(*functions),
- GFP_KERNEL);
+ pctl->functions = devm_kmemdup_array(pctl->dev, functions, pctl->nfuncs,
+ sizeof(*functions), GFP_KERNEL);
if (!pctl->functions)
return -ENOMEM;
@@ -314,7 +313,8 @@ static int pxa2xx_build_groups(struct pxa_pinctrl *pctl)
pctl->ppins[j].pin.name;
func = pctl->functions + i;
func->ngroups = ngroups;
- func->groups = devm_kmemdup(pctl->dev, gtmp, ngroups * sizeof(*gtmp), GFP_KERNEL);
+ func->groups = devm_kmemdup_array(pctl->dev, gtmp, ngroups,
+ sizeof(*gtmp), GFP_KERNEL);
if (!func->groups)
return -ENOMEM;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 09/20] input: sparse-keymap: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (7 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 08/20] pinctrl: pxa2xx: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 8:08 ` [PATCH v3 10/20] input: ipaq-micro-keys: " Raag Jadav
` (11 subsequent siblings)
20 siblings, 0 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/input/sparse-keymap.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index 25bf8be6e711..5ec3b9ebcac5 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -176,8 +176,7 @@ int sparse_keymap_setup(struct input_dev *dev,
for (e = keymap; e->type != KE_END; e++)
map_size++;
- map = devm_kmemdup(&dev->dev, keymap, map_size * sizeof(*map),
- GFP_KERNEL);
+ map = devm_kmemdup_array(&dev->dev, keymap, map_size, sizeof(*map), GFP_KERNEL);
if (!map)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 10/20] input: ipaq-micro-keys: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (8 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 09/20] input: sparse-keymap: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-06 18:46 ` Linus Walleij
2025-02-03 8:08 ` [PATCH v3 11/20] regulator: devres: " Raag Jadav
` (10 subsequent siblings)
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/input/keyboard/ipaq-micro-keys.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/input/keyboard/ipaq-micro-keys.c b/drivers/input/keyboard/ipaq-micro-keys.c
index 58631bf7ce55..ca7ec054b1ce 100644
--- a/drivers/input/keyboard/ipaq-micro-keys.c
+++ b/drivers/input/keyboard/ipaq-micro-keys.c
@@ -102,9 +102,8 @@ static int micro_key_probe(struct platform_device *pdev)
keys->input->keycodesize = sizeof(micro_keycodes[0]);
keys->input->keycodemax = ARRAY_SIZE(micro_keycodes);
- keys->codes = devm_kmemdup(&pdev->dev, micro_keycodes,
- keys->input->keycodesize * keys->input->keycodemax,
- GFP_KERNEL);
+ keys->codes = devm_kmemdup_array(&pdev->dev, micro_keycodes, keys->input->keycodemax,
+ keys->input->keycodesize, GFP_KERNEL);
if (!keys->codes)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 11/20] regulator: devres: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (9 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 10/20] input: ipaq-micro-keys: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 8:08 ` [PATCH v3 12/20] regulator: cros-ec: " Raag Jadav
` (9 subsequent siblings)
20 siblings, 0 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/regulator/devres.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c
index 36164aec30e8..ab238579879c 100644
--- a/drivers/regulator/devres.c
+++ b/drivers/regulator/devres.c
@@ -332,9 +332,8 @@ int devm_regulator_bulk_get_const(struct device *dev, int num_consumers,
const struct regulator_bulk_data *in_consumers,
struct regulator_bulk_data **out_consumers)
{
- *out_consumers = devm_kmemdup(dev, in_consumers,
- num_consumers * sizeof(*in_consumers),
- GFP_KERNEL);
+ *out_consumers = devm_kmemdup_array(dev, in_consumers, num_consumers,
+ sizeof(*in_consumers), GFP_KERNEL);
if (*out_consumers == NULL)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 12/20] regulator: cros-ec: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (10 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 11/20] regulator: devres: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 9:51 ` Andy Shevchenko
2025-02-03 8:08 ` [PATCH v3 13/20] power: supply: sc27xx: " Raag Jadav
` (8 subsequent siblings)
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/regulator/cros-ec-regulator.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c
index fb9643ed7a49..38afd4b3d2d0 100644
--- a/drivers/regulator/cros-ec-regulator.c
+++ b/drivers/regulator/cros-ec-regulator.c
@@ -138,8 +138,8 @@ static int cros_ec_regulator_init_info(struct device *dev,
data->num_voltages =
min_t(u16, ARRAY_SIZE(resp.voltages_mv), resp.num_voltages);
data->voltages_mV =
- devm_kmemdup(dev, resp.voltages_mv,
- sizeof(u16) * data->num_voltages, GFP_KERNEL);
+ devm_kmemdup_array(dev, resp.voltages_mv, data->num_voltages,
+ sizeof(u16), GFP_KERNEL);
if (!data->voltages_mV)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 13/20] power: supply: sc27xx: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (11 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 12/20] regulator: cros-ec: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 8:08 ` [PATCH v3 14/20] iio: adc: xilinx-xadc-core: " Raag Jadav
` (7 subsequent siblings)
20 siblings, 0 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/power/supply/sc27xx_fuel_gauge.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/power/supply/sc27xx_fuel_gauge.c b/drivers/power/supply/sc27xx_fuel_gauge.c
index f36edc2ba708..573838ca8ed8 100644
--- a/drivers/power/supply/sc27xx_fuel_gauge.c
+++ b/drivers/power/supply/sc27xx_fuel_gauge.c
@@ -1014,9 +1014,8 @@ static int sc27xx_fgu_hw_init(struct sc27xx_fgu_data *data)
if (!table)
return -EINVAL;
- data->cap_table = devm_kmemdup(data->dev, table,
- data->table_len * sizeof(*table),
- GFP_KERNEL);
+ data->cap_table = devm_kmemdup_array(data->dev, table, data->table_len,
+ sizeof(*table), GFP_KERNEL);
if (!data->cap_table) {
power_supply_put_battery_info(data->battery, info);
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 14/20] iio: adc: xilinx-xadc-core: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (12 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 13/20] power: supply: sc27xx: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 9:54 ` Andy Shevchenko
2025-02-03 8:08 ` [PATCH v3 15/20] ASoC: Intel: avs: " Raag Jadav
` (6 subsequent siblings)
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/iio/adc/xilinx-xadc-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index cfbfcaefec0f..4a47d1ded64a 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -1245,8 +1245,8 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, unsigned int *conf, int irq)
channel_templates = xadc_us_channels;
max_channels = ARRAY_SIZE(xadc_us_channels);
}
- channels = devm_kmemdup(dev, channel_templates,
- sizeof(channels[0]) * max_channels, GFP_KERNEL);
+ channels = devm_kmemdup_array(dev, channel_templates, max_channels,
+ sizeof(channels[0]), GFP_KERNEL);
if (!channels)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 15/20] ASoC: Intel: avs: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (13 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 14/20] iio: adc: xilinx-xadc-core: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 8:08 ` [PATCH v3 16/20] ASoC: hdac_hdmi: " Raag Jadav
` (5 subsequent siblings)
20 siblings, 0 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav, Amadeusz Sławiński
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
sound/soc/intel/avs/boards/da7219.c | 3 ++-
sound/soc/intel/avs/boards/es8336.c | 3 ++-
sound/soc/intel/avs/boards/nau8825.c | 3 ++-
sound/soc/intel/avs/boards/rt274.c | 3 ++-
sound/soc/intel/avs/boards/rt286.c | 3 ++-
sound/soc/intel/avs/boards/rt298.c | 3 ++-
sound/soc/intel/avs/boards/rt5663.c | 3 ++-
sound/soc/intel/avs/boards/rt5682.c | 2 +-
8 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/sound/soc/intel/avs/boards/da7219.c b/sound/soc/intel/avs/boards/da7219.c
index 76078a7005b0..6920a3737ddd 100644
--- a/sound/soc/intel/avs/boards/da7219.c
+++ b/sound/soc/intel/avs/boards/da7219.c
@@ -113,7 +113,8 @@ static int avs_da7219_codec_init(struct snd_soc_pcm_runtime *runtime)
}
num_pins = ARRAY_SIZE(card_headset_pins);
- pins = devm_kmemdup(card->dev, card_headset_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
+ pins = devm_kmemdup_array(card->dev, card_headset_pins, num_pins,
+ sizeof(*pins), GFP_KERNEL);
if (!pins)
return -ENOMEM;
diff --git a/sound/soc/intel/avs/boards/es8336.c b/sound/soc/intel/avs/boards/es8336.c
index 426ce37105ae..159d5170dc56 100644
--- a/sound/soc/intel/avs/boards/es8336.c
+++ b/sound/soc/intel/avs/boards/es8336.c
@@ -109,7 +109,8 @@ static int avs_es8336_codec_init(struct snd_soc_pcm_runtime *runtime)
data = snd_soc_card_get_drvdata(card);
num_pins = ARRAY_SIZE(card_headset_pins);
- pins = devm_kmemdup(card->dev, card_headset_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
+ pins = devm_kmemdup_array(card->dev, card_headset_pins, num_pins,
+ sizeof(*pins), GFP_KERNEL);
if (!pins)
return -ENOMEM;
diff --git a/sound/soc/intel/avs/boards/nau8825.c b/sound/soc/intel/avs/boards/nau8825.c
index bf902540744c..cf8604ac222a 100644
--- a/sound/soc/intel/avs/boards/nau8825.c
+++ b/sound/soc/intel/avs/boards/nau8825.c
@@ -88,7 +88,8 @@ static int avs_nau8825_codec_init(struct snd_soc_pcm_runtime *runtime)
jack = snd_soc_card_get_drvdata(card);
num_pins = ARRAY_SIZE(card_headset_pins);
- pins = devm_kmemdup(card->dev, card_headset_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
+ pins = devm_kmemdup_array(card->dev, card_headset_pins, num_pins,
+ sizeof(*pins), GFP_KERNEL);
if (!pins)
return -ENOMEM;
diff --git a/sound/soc/intel/avs/boards/rt274.c b/sound/soc/intel/avs/boards/rt274.c
index 4b6c02a40204..746ae1a4adc5 100644
--- a/sound/soc/intel/avs/boards/rt274.c
+++ b/sound/soc/intel/avs/boards/rt274.c
@@ -98,7 +98,8 @@ static int avs_rt274_codec_init(struct snd_soc_pcm_runtime *runtime)
jack = snd_soc_card_get_drvdata(card);
num_pins = ARRAY_SIZE(card_headset_pins);
- pins = devm_kmemdup(card->dev, card_headset_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
+ pins = devm_kmemdup_array(card->dev, card_headset_pins, num_pins,
+ sizeof(*pins), GFP_KERNEL);
if (!pins)
return -ENOMEM;
diff --git a/sound/soc/intel/avs/boards/rt286.c b/sound/soc/intel/avs/boards/rt286.c
index e40563ca99fd..7f9d8c216b31 100644
--- a/sound/soc/intel/avs/boards/rt286.c
+++ b/sound/soc/intel/avs/boards/rt286.c
@@ -59,7 +59,8 @@ static int avs_rt286_codec_init(struct snd_soc_pcm_runtime *runtime)
jack = snd_soc_card_get_drvdata(card);
num_pins = ARRAY_SIZE(card_headset_pins);
- pins = devm_kmemdup(card->dev, card_headset_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
+ pins = devm_kmemdup_array(card->dev, card_headset_pins, num_pins,
+ sizeof(*pins), GFP_KERNEL);
if (!pins)
return -ENOMEM;
diff --git a/sound/soc/intel/avs/boards/rt298.c b/sound/soc/intel/avs/boards/rt298.c
index 94fce07c83f9..11cd7c85c4a7 100644
--- a/sound/soc/intel/avs/boards/rt298.c
+++ b/sound/soc/intel/avs/boards/rt298.c
@@ -70,7 +70,8 @@ static int avs_rt298_codec_init(struct snd_soc_pcm_runtime *runtime)
jack = snd_soc_card_get_drvdata(card);
num_pins = ARRAY_SIZE(card_headset_pins);
- pins = devm_kmemdup(card->dev, card_headset_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
+ pins = devm_kmemdup_array(card->dev, card_headset_pins, num_pins,
+ sizeof(*pins), GFP_KERNEL);
if (!pins)
return -ENOMEM;
diff --git a/sound/soc/intel/avs/boards/rt5663.c b/sound/soc/intel/avs/boards/rt5663.c
index b456b9d14665..a47beab60c47 100644
--- a/sound/soc/intel/avs/boards/rt5663.c
+++ b/sound/soc/intel/avs/boards/rt5663.c
@@ -65,7 +65,8 @@ static int avs_rt5663_codec_init(struct snd_soc_pcm_runtime *runtime)
jack = &priv->jack;
num_pins = ARRAY_SIZE(card_headset_pins);
- pins = devm_kmemdup(card->dev, card_headset_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
+ pins = devm_kmemdup_array(card->dev, card_headset_pins, num_pins,
+ sizeof(*pins), GFP_KERNEL);
if (!pins)
return -ENOMEM;
diff --git a/sound/soc/intel/avs/boards/rt5682.c b/sound/soc/intel/avs/boards/rt5682.c
index 335960cfd7ba..d503eff827fe 100644
--- a/sound/soc/intel/avs/boards/rt5682.c
+++ b/sound/soc/intel/avs/boards/rt5682.c
@@ -102,7 +102,7 @@ static int avs_rt5682_codec_init(struct snd_soc_pcm_runtime *runtime)
jack = snd_soc_card_get_drvdata(card);
num_pins = ARRAY_SIZE(card_jack_pins);
- pins = devm_kmemdup(card->dev, card_jack_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
+ pins = devm_kmemdup_array(card->dev, card_jack_pins, num_pins, sizeof(*pins), GFP_KERNEL);
if (!pins)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 16/20] ASoC: hdac_hdmi: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (14 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 15/20] ASoC: Intel: avs: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 9:52 ` Andy Shevchenko
2025-02-03 8:08 ` [PATCH v3 17/20] ASoC: tlv320dac33: " Raag Jadav
` (4 subsequent siblings)
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
sound/soc/codecs/hdac_hdmi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index e1a7f0b0c0f3..a0f305a8fbf9 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1017,8 +1017,7 @@ static int hdac_hdmi_create_pin_port_muxs(struct hdac_device *hdev,
return -ENOMEM;
}
- se->texts = devm_kmemdup(&hdev->dev, items,
- (num_items * sizeof(char *)), GFP_KERNEL);
+ se->texts = devm_kmemdup_array(&hdev->dev, items, num_items, sizeof(char *), GFP_KERNEL);
if (!se->texts)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 17/20] ASoC: tlv320dac33: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (15 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 16/20] ASoC: hdac_hdmi: " Raag Jadav
@ 2025-02-03 8:08 ` Raag Jadav
2025-02-03 9:52 ` Andy Shevchenko
2025-02-03 8:09 ` [PATCH v3 18/20] ASoC: uda1380: " Raag Jadav
` (3 subsequent siblings)
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:08 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
sound/soc/codecs/tlv320dac33.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index fa46f51d4341..3919f8b14995 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -1477,10 +1477,8 @@ static int dac33_i2c_probe(struct i2c_client *client)
if (dac33 == NULL)
return -ENOMEM;
- dac33->reg_cache = devm_kmemdup(&client->dev,
- dac33_reg,
- ARRAY_SIZE(dac33_reg) * sizeof(u8),
- GFP_KERNEL);
+ dac33->reg_cache = devm_kmemdup_array(&client->dev, dac33_reg, ARRAY_SIZE(dac33_reg),
+ sizeof(u8), GFP_KERNEL);
if (!dac33->reg_cache)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 18/20] ASoC: uda1380: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (16 preceding siblings ...)
2025-02-03 8:08 ` [PATCH v3 17/20] ASoC: tlv320dac33: " Raag Jadav
@ 2025-02-03 8:09 ` Raag Jadav
2025-02-03 9:57 ` Andy Shevchenko
2025-02-03 8:09 ` [PATCH v3 19/20] ASoC: meson: axg-tdm-interface: " Raag Jadav
` (2 subsequent siblings)
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:09 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
sound/soc/codecs/uda1380.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index 4f8fdd574585..6b474f9ee7c4 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -766,10 +766,8 @@ static int uda1380_i2c_probe(struct i2c_client *i2c)
return ret;
}
- uda1380->reg_cache = devm_kmemdup(&i2c->dev,
- uda1380_reg,
- ARRAY_SIZE(uda1380_reg) * sizeof(u16),
- GFP_KERNEL);
+ uda1380->reg_cache = devm_kmemdup_array(&i2c->dev, uda1380_reg, ARRAY_SIZE(uda1380_reg),
+ sizeof(u16), GFP_KERNEL);
if (!uda1380->reg_cache)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 19/20] ASoC: meson: axg-tdm-interface: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (17 preceding siblings ...)
2025-02-03 8:09 ` [PATCH v3 18/20] ASoC: uda1380: " Raag Jadav
@ 2025-02-03 8:09 ` Raag Jadav
2025-02-03 8:09 ` [PATCH v3 20/20] ASoC: uniphier: " Raag Jadav
2025-02-03 9:48 ` [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Andy Shevchenko
20 siblings, 0 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:09 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
sound/soc/meson/axg-tdm-interface.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c
index 09103eef2a97..20f06b9ccd57 100644
--- a/sound/soc/meson/axg-tdm-interface.c
+++ b/sound/soc/meson/axg-tdm-interface.c
@@ -529,7 +529,6 @@ static int axg_tdm_iface_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct snd_soc_dai_driver *dai_drv;
struct axg_tdm_iface *iface;
- int i;
iface = devm_kzalloc(dev, sizeof(*iface), GFP_KERNEL);
if (!iface)
@@ -541,15 +540,11 @@ static int axg_tdm_iface_probe(struct platform_device *pdev)
* We'll change the number of channel provided by DAI stream, so dpcm
* channel merge can be done properly
*/
- dai_drv = devm_kcalloc(dev, ARRAY_SIZE(axg_tdm_iface_dai_drv),
- sizeof(*dai_drv), GFP_KERNEL);
+ dai_drv = devm_kmemdup_array(dev, axg_tdm_iface_dai_drv, ARRAY_SIZE(axg_tdm_iface_dai_drv),
+ sizeof(*dai_drv), GFP_KERNEL);
if (!dai_drv)
return -ENOMEM;
- for (i = 0; i < ARRAY_SIZE(axg_tdm_iface_dai_drv); i++)
- memcpy(&dai_drv[i], &axg_tdm_iface_dai_drv[i],
- sizeof(*dai_drv));
-
/* Bit clock provided on the pad */
iface->sclk = devm_clk_get(dev, "sclk");
if (IS_ERR(iface->sclk))
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [PATCH v3 20/20] ASoC: uniphier: use devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (18 preceding siblings ...)
2025-02-03 8:09 ` [PATCH v3 19/20] ASoC: meson: axg-tdm-interface: " Raag Jadav
@ 2025-02-03 8:09 ` Raag Jadav
2025-02-03 9:53 ` Andy Shevchenko
2025-02-03 9:48 ` [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Andy Shevchenko
20 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 8:09 UTC (permalink / raw)
To: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() which is more robust.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
sound/soc/uniphier/aio-cpu.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/sound/soc/uniphier/aio-cpu.c b/sound/soc/uniphier/aio-cpu.c
index 470f129166a4..44f4053e5584 100644
--- a/sound/soc/uniphier/aio-cpu.c
+++ b/sound/soc/uniphier/aio-cpu.c
@@ -762,14 +762,10 @@ int uniphier_aio_probe(struct platform_device *pdev)
return -ENOMEM;
chip->num_plls = chip->chip_spec->num_plls;
- chip->plls = devm_kcalloc(dev,
- chip->num_plls,
- sizeof(struct uniphier_aio_pll),
- GFP_KERNEL);
+ chip->plls = devm_kmemdup_array(dev, chip->chip_spec->plls, chip->num_plls,
+ sizeof(struct uniphier_aio_pll), GFP_KERNEL);
if (!chip->plls)
return -ENOMEM;
- memcpy(chip->plls, chip->chip_spec->plls,
- sizeof(struct uniphier_aio_pll) * chip->num_plls);
for (i = 0; i < chip->num_aios; i++) {
struct uniphier_aio *aio = &chip->aios[i];
--
2.34.1
^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array()
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (19 preceding siblings ...)
2025-02-03 8:09 ` [PATCH v3 20/20] ASoC: uniphier: " Raag Jadav
@ 2025-02-03 9:48 ` Andy Shevchenko
2025-02-03 10:34 ` Raag Jadav
20 siblings, 1 reply; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 9:48 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 01:38:42PM +0530, Raag Jadav wrote:
> This series
>
> 1. Splits device/devres.h for the users that are only interested in devres APIs.
> Original work by Andy Shevchenko:
> https://lore.kernel.org/r/20241203195340.855879-1-andriy.shevchenko@linux.intel.com
>
> 2. Introduces a more robust and cleaner devm_kmemdup_array() helper and uses it
> across drivers.
>
> The idea behind embedding both work into a single series is to reduce conflicts
> and dependencies while merging.
>
> v2: Use size_mul() for multiplication (Dmitry)
> Update commit message (Dmitry)
>
> v3: Embed devres.h work by Andy
> Add more users of devm_kmemdup_array()
I understand the desire to cover as much as possible, but it becomes much
harder to coordinate. My proposal stays the same, i.e. I may take the GPIO/pin
control related (and already ACKed!) changes via Intel pin control tree and
the rest may use that immutable tag as needed.
What we need is an Ack for the first patch from Greg and perhaps I can take
IIO, if Jonathan gives an Ack.
> Update tags and rebase
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 12/20] regulator: cros-ec: use devm_kmemdup_array()
2025-02-03 8:08 ` [PATCH v3 12/20] regulator: cros-ec: " Raag Jadav
@ 2025-02-03 9:51 ` Andy Shevchenko
2025-02-03 10:40 ` Raag Jadav
0 siblings, 1 reply; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 9:51 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 01:38:54PM +0530, Raag Jadav wrote:
> Convert to use devm_kmemdup_array() which is more robust.
...
> data->voltages_mV =
> - devm_kmemdup(dev, resp.voltages_mv,
> - sizeof(u16) * data->num_voltages, GFP_KERNEL);
> + devm_kmemdup_array(dev, resp.voltages_mv, data->num_voltages,
> + sizeof(u16), GFP_KERNEL);
Wondering if this can be sizeof(*data->voltages_mV) that makes code robust
against type changes.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 16/20] ASoC: hdac_hdmi: use devm_kmemdup_array()
2025-02-03 8:08 ` [PATCH v3 16/20] ASoC: hdac_hdmi: " Raag Jadav
@ 2025-02-03 9:52 ` Andy Shevchenko
0 siblings, 0 replies; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 9:52 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 01:38:58PM +0530, Raag Jadav wrote:
> Convert to use devm_kmemdup_array() which is more robust.
...
> - se->texts = devm_kmemdup(&hdev->dev, items,
> - (num_items * sizeof(char *)), GFP_KERNEL);
> + se->texts = devm_kmemdup_array(&hdev->dev, items, num_items, sizeof(char *), GFP_KERNEL);
In similar way, sizeof(*se->texts) ?
> if (!se->texts)
> return -ENOMEM;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 17/20] ASoC: tlv320dac33: use devm_kmemdup_array()
2025-02-03 8:08 ` [PATCH v3 17/20] ASoC: tlv320dac33: " Raag Jadav
@ 2025-02-03 9:52 ` Andy Shevchenko
0 siblings, 0 replies; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 9:52 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 01:38:59PM +0530, Raag Jadav wrote:
> Convert to use devm_kmemdup_array() which is more robust.
...
> - dac33->reg_cache = devm_kmemdup(&client->dev,
> - dac33_reg,
> - ARRAY_SIZE(dac33_reg) * sizeof(u8),
> - GFP_KERNEL);
> + dac33->reg_cache = devm_kmemdup_array(&client->dev, dac33_reg, ARRAY_SIZE(dac33_reg),
> + sizeof(u8), GFP_KERNEL);
sizeof(*dac33->reg_cache) ?
> if (!dac33->reg_cache)
> return -ENOMEM;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 20/20] ASoC: uniphier: use devm_kmemdup_array()
2025-02-03 8:09 ` [PATCH v3 20/20] ASoC: uniphier: " Raag Jadav
@ 2025-02-03 9:53 ` Andy Shevchenko
0 siblings, 0 replies; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 9:53 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 01:39:02PM +0530, Raag Jadav wrote:
> Convert to use devm_kmemdup_array() which is more robust.
...
> chip->num_plls = chip->chip_spec->num_plls;
> - chip->plls = devm_kcalloc(dev,
> - chip->num_plls,
> - sizeof(struct uniphier_aio_pll),
> - GFP_KERNEL);
> + chip->plls = devm_kmemdup_array(dev, chip->chip_spec->plls, chip->num_plls,
> + sizeof(struct uniphier_aio_pll), GFP_KERNEL);
sizeof(*chip->plls) ?
> if (!chip->plls)
> return -ENOMEM;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 14/20] iio: adc: xilinx-xadc-core: use devm_kmemdup_array()
2025-02-03 8:08 ` [PATCH v3 14/20] iio: adc: xilinx-xadc-core: " Raag Jadav
@ 2025-02-03 9:54 ` Andy Shevchenko
2025-02-03 10:42 ` Raag Jadav
0 siblings, 1 reply; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 9:54 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 01:38:56PM +0530, Raag Jadav wrote:
> Convert to use devm_kmemdup_array() which is more robust.
...
> - channels = devm_kmemdup(dev, channel_templates,
> - sizeof(channels[0]) * max_channels, GFP_KERNEL);
> + channels = devm_kmemdup_array(dev, channel_templates, max_channels,
> + sizeof(channels[0]), GFP_KERNEL);
I would use more regular sizeof(*channels)
> if (!channels)
> return -ENOMEM;
P.S. For all sizeof() replacements the changes would probably need the updated
commit messages.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 18/20] ASoC: uda1380: use devm_kmemdup_array()
2025-02-03 8:09 ` [PATCH v3 18/20] ASoC: uda1380: " Raag Jadav
@ 2025-02-03 9:57 ` Andy Shevchenko
0 siblings, 0 replies; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 9:57 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 01:39:00PM +0530, Raag Jadav wrote:
> Convert to use devm_kmemdup_array() which is more robust.
...
> - uda1380->reg_cache = devm_kmemdup(&i2c->dev,
> - uda1380_reg,
> - ARRAY_SIZE(uda1380_reg) * sizeof(u16),
> - GFP_KERNEL);
> + uda1380->reg_cache = devm_kmemdup_array(&i2c->dev, uda1380_reg, ARRAY_SIZE(uda1380_reg),
> + sizeof(u16), GFP_KERNEL);
sizeof(*uda1380->reg_cache) ?
> if (!uda1380->reg_cache)
> return -ENOMEM;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array()
2025-02-03 9:48 ` [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Andy Shevchenko
@ 2025-02-03 10:34 ` Raag Jadav
2025-02-03 11:29 ` Andy Shevchenko
0 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 10:34 UTC (permalink / raw)
To: Andy Shevchenko
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 11:48:52AM +0200, Andy Shevchenko wrote:
> On Mon, Feb 03, 2025 at 01:38:42PM +0530, Raag Jadav wrote:
> > This series
> >
> > 1. Splits device/devres.h for the users that are only interested in devres APIs.
> > Original work by Andy Shevchenko:
> > https://lore.kernel.org/r/20241203195340.855879-1-andriy.shevchenko@linux.intel.com
> >
> > 2. Introduces a more robust and cleaner devm_kmemdup_array() helper and uses it
> > across drivers.
> >
> > The idea behind embedding both work into a single series is to reduce conflicts
> > and dependencies while merging.
> >
> > v2: Use size_mul() for multiplication (Dmitry)
> > Update commit message (Dmitry)
> >
> > v3: Embed devres.h work by Andy
>
> > Add more users of devm_kmemdup_array()
>
> I understand the desire to cover as much as possible, but it becomes much
> harder to coordinate.
I have a few more patches which I'm delaying to reduce dependency.
Raag
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 12/20] regulator: cros-ec: use devm_kmemdup_array()
2025-02-03 9:51 ` Andy Shevchenko
@ 2025-02-03 10:40 ` Raag Jadav
2025-02-03 11:23 ` Andy Shevchenko
0 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 10:40 UTC (permalink / raw)
To: Andy Shevchenko
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 11:51:10AM +0200, Andy Shevchenko wrote:
> On Mon, Feb 03, 2025 at 01:38:54PM +0530, Raag Jadav wrote:
> > Convert to use devm_kmemdup_array() which is more robust.
>
> ...
>
> > data->voltages_mV =
> > - devm_kmemdup(dev, resp.voltages_mv,
> > - sizeof(u16) * data->num_voltages, GFP_KERNEL);
> > + devm_kmemdup_array(dev, resp.voltages_mv, data->num_voltages,
> > + sizeof(u16), GFP_KERNEL);
>
> Wondering if this can be sizeof(*data->voltages_mV) that makes code robust
> against type changes.
True, but I opted for a blind treewide conversion that is consistent with
existing driver conventions. Perhaps a better place for it is a separate
filewide series?
Raag
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 14/20] iio: adc: xilinx-xadc-core: use devm_kmemdup_array()
2025-02-03 9:54 ` Andy Shevchenko
@ 2025-02-03 10:42 ` Raag Jadav
2025-02-03 11:14 ` Jonathan Cameron
2025-02-03 11:24 ` Andy Shevchenko
0 siblings, 2 replies; 46+ messages in thread
From: Raag Jadav @ 2025-02-03 10:42 UTC (permalink / raw)
To: Andy Shevchenko
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 11:54:42AM +0200, Andy Shevchenko wrote:
> On Mon, Feb 03, 2025 at 01:38:56PM +0530, Raag Jadav wrote:
> > Convert to use devm_kmemdup_array() which is more robust.
>
> ...
>
> > - channels = devm_kmemdup(dev, channel_templates,
> > - sizeof(channels[0]) * max_channels, GFP_KERNEL);
> > + channels = devm_kmemdup_array(dev, channel_templates, max_channels,
> > + sizeof(channels[0]), GFP_KERNEL);
>
> I would use more regular sizeof(*channels)
This might get confusing since we're assigning it back to channels.
Raag
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 14/20] iio: adc: xilinx-xadc-core: use devm_kmemdup_array()
2025-02-03 10:42 ` Raag Jadav
@ 2025-02-03 11:14 ` Jonathan Cameron
2025-02-03 11:25 ` Andy Shevchenko
2025-02-03 11:24 ` Andy Shevchenko
1 sibling, 1 reply; 46+ messages in thread
From: Jonathan Cameron @ 2025-02-03 11:14 UTC (permalink / raw)
To: Raag Jadav
Cc: Andy Shevchenko, gregkh, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel, linux-gpio, linux-kernel, linux-input,
linux-sound, linux-pm, linux-iio
On Mon, 3 Feb 2025 12:42:36 +0200
Raag Jadav <raag.jadav@intel.com> wrote:
> On Mon, Feb 03, 2025 at 11:54:42AM +0200, Andy Shevchenko wrote:
> > On Mon, Feb 03, 2025 at 01:38:56PM +0530, Raag Jadav wrote:
> > > Convert to use devm_kmemdup_array() which is more robust.
> >
> > ...
> >
> > > - channels = devm_kmemdup(dev, channel_templates,
> > > - sizeof(channels[0]) * max_channels, GFP_KERNEL);
> > > + channels = devm_kmemdup_array(dev, channel_templates, max_channels,
> > > + sizeof(channels[0]), GFP_KERNEL);
> >
> > I would use more regular sizeof(*channels)
>
> This might get confusing since we're assigning it back to channels.
>
It looks like standard pattern. Assign X * the thing to the thing.
So I'd prefer sizeof(*channels) here as well.
> Raag
>
>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 02/20] iio: imu: st_lsm9ds0: Replace device.h with what is needed
2025-02-03 8:08 ` [PATCH v3 02/20] iio: imu: st_lsm9ds0: Replace device.h with what is needed Raag Jadav
@ 2025-02-03 11:19 ` Jonathan Cameron
0 siblings, 0 replies; 46+ messages in thread
From: Jonathan Cameron @ 2025-02-03 11:19 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel, linux-gpio, linux-kernel, linux-input,
linux-sound, linux-pm, linux-iio
On Mon, 3 Feb 2025 13:38:44 +0530
Raag Jadav <raag.jadav@intel.com> wrote:
> From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Instead of including a huge device.h with tons of dependencies
> include only what driver actually uses.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
I'm fine with these going whatever route makes sense.
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 2 +-
> drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
> index 0732cfa258c4..8cc071463249 100644
> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
> @@ -7,7 +7,7 @@
> * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> */
>
> -#include <linux/device.h>
> +#include <linux/device/devres.h>
> #include <linux/err.h>
> #include <linux/gfp_types.h>
> #include <linux/i2c.h>
> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> index 43ec57c1e604..806e55f75f65 100644
> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> @@ -7,7 +7,7 @@
> * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> */
>
> -#include <linux/device.h>
> +#include <linux/device/devres.h>
> #include <linux/err.h>
> #include <linux/gfp_types.h>
> #include <linux/module.h>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 12/20] regulator: cros-ec: use devm_kmemdup_array()
2025-02-03 10:40 ` Raag Jadav
@ 2025-02-03 11:23 ` Andy Shevchenko
0 siblings, 0 replies; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 11:23 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 12:40:23PM +0200, Raag Jadav wrote:
> On Mon, Feb 03, 2025 at 11:51:10AM +0200, Andy Shevchenko wrote:
> > On Mon, Feb 03, 2025 at 01:38:54PM +0530, Raag Jadav wrote:
> > > Convert to use devm_kmemdup_array() which is more robust.
...
> > > data->voltages_mV =
> > > - devm_kmemdup(dev, resp.voltages_mv,
> > > - sizeof(u16) * data->num_voltages, GFP_KERNEL);
> > > + devm_kmemdup_array(dev, resp.voltages_mv, data->num_voltages,
> > > + sizeof(u16), GFP_KERNEL);
> >
> > Wondering if this can be sizeof(*data->voltages_mV) that makes code robust
> > against type changes.
>
> True, but I opted for a blind treewide conversion that is consistent with
> existing driver conventions. Perhaps a better place for it is a separate
> filewide series?
I think an additional series is just an increased churn. In this you are
changing an API in use, it's completely fine to update a parameter in
accordance with new API. I.o.w. I consider these two are coupled enough
to be semantically and logically in a single change along with the fact
that in all such case you are touching the same line(s).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 14/20] iio: adc: xilinx-xadc-core: use devm_kmemdup_array()
2025-02-03 10:42 ` Raag Jadav
2025-02-03 11:14 ` Jonathan Cameron
@ 2025-02-03 11:24 ` Andy Shevchenko
1 sibling, 0 replies; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 11:24 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 12:42:36PM +0200, Raag Jadav wrote:
> On Mon, Feb 03, 2025 at 11:54:42AM +0200, Andy Shevchenko wrote:
> > On Mon, Feb 03, 2025 at 01:38:56PM +0530, Raag Jadav wrote:
> > > Convert to use devm_kmemdup_array() which is more robust.
> >
> > ...
> >
> > > - channels = devm_kmemdup(dev, channel_templates,
> > > - sizeof(channels[0]) * max_channels, GFP_KERNEL);
> > > + channels = devm_kmemdup_array(dev, channel_templates, max_channels,
> > > + sizeof(channels[0]), GFP_KERNEL);
> >
> > I would use more regular sizeof(*channels)
>
> This might get confusing since we're assigning it back to channels.
Then it should be sizeof(*channel_templates) ?
Now since you mention this, in all other suggested cases it may need to be
carefully chosen.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 14/20] iio: adc: xilinx-xadc-core: use devm_kmemdup_array()
2025-02-03 11:14 ` Jonathan Cameron
@ 2025-02-03 11:25 ` Andy Shevchenko
0 siblings, 0 replies; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 11:25 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Raag Jadav, gregkh, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel, linux-gpio, linux-kernel, linux-input,
linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 11:14:58AM +0000, Jonathan Cameron wrote:
> On Mon, 3 Feb 2025 12:42:36 +0200
> Raag Jadav <raag.jadav@intel.com> wrote:
> > On Mon, Feb 03, 2025 at 11:54:42AM +0200, Andy Shevchenko wrote:
> > > On Mon, Feb 03, 2025 at 01:38:56PM +0530, Raag Jadav wrote:
> > > > Convert to use devm_kmemdup_array() which is more robust.
...
> > > > - channels = devm_kmemdup(dev, channel_templates,
> > > > - sizeof(channels[0]) * max_channels, GFP_KERNEL);
> > > > + channels = devm_kmemdup_array(dev, channel_templates, max_channels,
> > > > + sizeof(channels[0]), GFP_KERNEL);
> > >
> > > I would use more regular sizeof(*channels)
> >
> > This might get confusing since we're assigning it back to channels.
> >
> It looks like standard pattern. Assign X * the thing to the thing.
>
> So I'd prefer sizeof(*channels) here as well.
Yeah, but the problem with kmemdup() family of APIs is that we need to pass
the source size if we want to have 1:1 copy. So, sizeof(*channel_templates)
is more accurate in my opinion.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array()
2025-02-03 10:34 ` Raag Jadav
@ 2025-02-03 11:29 ` Andy Shevchenko
0 siblings, 0 replies; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-03 11:29 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-sound, linux-pm, linux-iio
On Mon, Feb 03, 2025 at 12:34:03PM +0200, Raag Jadav wrote:
> On Mon, Feb 03, 2025 at 11:48:52AM +0200, Andy Shevchenko wrote:
> > On Mon, Feb 03, 2025 at 01:38:42PM +0530, Raag Jadav wrote:
> > > This series
> > >
> > > 1. Splits device/devres.h for the users that are only interested in devres APIs.
> > > Original work by Andy Shevchenko:
> > > https://lore.kernel.org/r/20241203195340.855879-1-andriy.shevchenko@linux.intel.com
> > >
> > > 2. Introduces a more robust and cleaner devm_kmemdup_array() helper and uses it
> > > across drivers.
> > >
> > > The idea behind embedding both work into a single series is to reduce conflicts
> > > and dependencies while merging.
> > >
> > > v2: Use size_mul() for multiplication (Dmitry)
> > > Update commit message (Dmitry)
> > >
> > > v3: Embed devres.h work by Andy
> >
> > > Add more users of devm_kmemdup_array()
> >
> > I understand the desire to cover as much as possible, but it becomes much
> > harder to coordinate.
>
> I have a few more patches which I'm delaying to reduce dependency.
So, let's focus on the IIO/pin control ones only for the starter? With the
produced immutable tag you may convince the respective maintainers to pull
that tag along with the patches to their subsystems. It will be much easier
to coordinate and execute.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h
2025-02-03 8:08 ` [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h Raag Jadav
@ 2025-02-05 16:27 ` kernel test robot
2025-02-06 6:13 ` Raag Jadav
0 siblings, 1 reply; 46+ messages in thread
From: kernel test robot @ 2025-02-05 16:27 UTC (permalink / raw)
To: Raag Jadav, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, lgirdwood, broonie, sre,
jic23, przemyslaw.kitszel
Cc: oe-kbuild-all, linux-gpio, linux-kernel, linux-input, linux-sound,
linux-pm, linux-iio, Raag Jadav
Hi Raag,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 2014c95afecee3e76ca4a56956a936e23283f05b]
url: https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/driver-core-Split-devres-APIs-to-device-devres-h/20250203-161554
base: 2014c95afecee3e76ca4a56956a936e23283f05b
patch link: https://lore.kernel.org/r/20250203080902.1864382-2-raag.jadav%40intel.com
patch subject: [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h
config: um-randconfig-r112-20250205 (https://download.01.org/0day-ci/archive/20250206/202502060025.XJwUub6I-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 355d0b186f178668b103068537e517f3d52ad639)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250206/202502060025.XJwUub6I-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502060025.XJwUub6I-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
drivers/net/pcs/pcs-xpcs-plat.c: note: in included file (through include/linux/device.h):
>> include/linux/device/devres.h:106:23: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] __iomem * @@ got void * @@
include/linux/device/devres.h:106:23: sparse: expected void [noderef] __iomem *
include/linux/device/devres.h:106:23: sparse: got void *
vim +106 include/linux/device/devres.h
102
103 static inline
104 void __iomem *devm_ioremap_resource(struct device *dev, const struct resource *res)
105 {
> 106 return ERR_PTR(-EINVAL);
107 }
108
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h
2025-02-05 16:27 ` kernel test robot
@ 2025-02-06 6:13 ` Raag Jadav
2025-02-06 15:12 ` Andy Shevchenko
0 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-06 6:13 UTC (permalink / raw)
To: kernel test robot, andriy.shevchenko
Cc: gregkh, rafael, linus.walleij, mika.westerberg, dmitry.torokhov,
lgirdwood, broonie, sre, jic23, przemyslaw.kitszel, oe-kbuild-all,
linux-gpio, linux-kernel, linux-input, linux-sound, linux-pm,
linux-iio
On Thu, Feb 06, 2025 at 12:27:03AM +0800, kernel test robot wrote:
> Hi Raag,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on 2014c95afecee3e76ca4a56956a936e23283f05b]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/driver-core-Split-devres-APIs-to-device-devres-h/20250203-161554
> base: 2014c95afecee3e76ca4a56956a936e23283f05b
> patch link: https://lore.kernel.org/r/20250203080902.1864382-2-raag.jadav%40intel.com
> patch subject: [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h
> config: um-randconfig-r112-20250205 (https://download.01.org/0day-ci/archive/20250206/202502060025.XJwUub6I-lkp@intel.com/config)
> compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 355d0b186f178668b103068537e517f3d52ad639)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250206/202502060025.XJwUub6I-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202502060025.XJwUub6I-lkp@intel.com/
>
> sparse warnings: (new ones prefixed by >>)
> drivers/net/pcs/pcs-xpcs-plat.c: note: in included file (through include/linux/device.h):
> >> include/linux/device/devres.h:106:23: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] __iomem * @@ got void * @@
> include/linux/device/devres.h:106:23: sparse: expected void [noderef] __iomem *
> include/linux/device/devres.h:106:23: sparse: got void *
>
> vim +106 include/linux/device/devres.h
>
> 102
> 103 static inline
> 104 void __iomem *devm_ioremap_resource(struct device *dev, const struct resource *res)
> 105 {
> > 106 return ERR_PTR(-EINVAL);
> 107 }
> 108
Andy, are we expecting this?
Raag
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h
2025-02-06 6:13 ` Raag Jadav
@ 2025-02-06 15:12 ` Andy Shevchenko
2025-02-06 15:14 ` Andy Shevchenko
0 siblings, 1 reply; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-06 15:12 UTC (permalink / raw)
To: Raag Jadav
Cc: kernel test robot, gregkh, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel, oe-kbuild-all, linux-gpio, linux-kernel,
linux-input, linux-sound, linux-pm, linux-iio
On Thu, Feb 06, 2025 at 08:13:12AM +0200, Raag Jadav wrote:
> On Thu, Feb 06, 2025 at 12:27:03AM +0800, kernel test robot wrote:
> > 102
> > 103 static inline
> > 104 void __iomem *devm_ioremap_resource(struct device *dev, const struct resource *res)
> > 105 {
> > > 106 return ERR_PTR(-EINVAL);
> > 107 }
> > 108
>
> Andy, are we expecting this?
Oh, no, it's sparse error, but easy to fix. Need to have
return IOMEM_ERR_PTR(-EINVAL);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h
2025-02-06 15:12 ` Andy Shevchenko
@ 2025-02-06 15:14 ` Andy Shevchenko
2025-02-06 18:11 ` Raag Jadav
0 siblings, 1 reply; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-06 15:14 UTC (permalink / raw)
To: Raag Jadav
Cc: kernel test robot, gregkh, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel, oe-kbuild-all, linux-gpio, linux-kernel,
linux-input, linux-sound, linux-pm, linux-iio
On Thu, Feb 06, 2025 at 05:12:49PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 06, 2025 at 08:13:12AM +0200, Raag Jadav wrote:
> > On Thu, Feb 06, 2025 at 12:27:03AM +0800, kernel test robot wrote:
...
> > > 102
> > > 103 static inline
> > > 104 void __iomem *devm_ioremap_resource(struct device *dev, const struct resource *res)
> > > 105 {
> > > > 106 return ERR_PTR(-EINVAL);
> > > 107 }
> > > 108
> >
> > Andy, are we expecting this?
>
> Oh, no, it's sparse error, but easy to fix. Need to have
>
> return IOMEM_ERR_PTR(-EINVAL);
But isn't it the original issue? I mean that it was already before this series.
If so, perhaps you can fix all sparse errors like this in the devres* code.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h
2025-02-06 15:14 ` Andy Shevchenko
@ 2025-02-06 18:11 ` Raag Jadav
2025-02-06 18:56 ` Andy Shevchenko
0 siblings, 1 reply; 46+ messages in thread
From: Raag Jadav @ 2025-02-06 18:11 UTC (permalink / raw)
To: Andy Shevchenko
Cc: kernel test robot, gregkh, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel, oe-kbuild-all, linux-gpio, linux-kernel,
linux-input, linux-sound, linux-pm, linux-iio
On Thu, Feb 06, 2025 at 05:14:05PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 06, 2025 at 05:12:49PM +0200, Andy Shevchenko wrote:
> > On Thu, Feb 06, 2025 at 08:13:12AM +0200, Raag Jadav wrote:
> > > On Thu, Feb 06, 2025 at 12:27:03AM +0800, kernel test robot wrote:
>
> ...
>
> > > > 102
> > > > 103 static inline
> > > > 104 void __iomem *devm_ioremap_resource(struct device *dev, const struct resource *res)
> > > > 105 {
> > > > > 106 return ERR_PTR(-EINVAL);
> > > > 107 }
> > > > 108
> > >
> > > Andy, are we expecting this?
> >
> > Oh, no, it's sparse error, but easy to fix. Need to have
> >
> > return IOMEM_ERR_PTR(-EINVAL);
>
> But isn't it the original issue? I mean that it was already before this series.
For all this time?
> If so, perhaps you can fix all sparse errors like this in the devres* code.
With a fixes tag?
Raag
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 05/20] pinctrl: baytrail: copy communities using devm_kmemdup_array()
2025-02-03 8:08 ` [PATCH v3 05/20] pinctrl: baytrail: " Raag Jadav
@ 2025-02-06 18:45 ` Linus Walleij
0 siblings, 0 replies; 46+ messages in thread
From: Linus Walleij @ 2025-02-06 18:45 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel, linux-gpio, linux-kernel, linux-input,
linux-sound, linux-pm, linux-iio
On Mon, Feb 3, 2025 at 9:09 AM Raag Jadav <raag.jadav@intel.com> wrote:
> Copy communities using devm_kmemdup_array() instead of doing it manually.
>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 06/20] pinctrl: cherryview: use devm_kmemdup_array()
2025-02-03 8:08 ` [PATCH v3 06/20] pinctrl: cherryview: use devm_kmemdup_array() Raag Jadav
@ 2025-02-06 18:46 ` Linus Walleij
0 siblings, 0 replies; 46+ messages in thread
From: Linus Walleij @ 2025-02-06 18:46 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel, linux-gpio, linux-kernel, linux-input,
linux-sound, linux-pm, linux-iio
On Mon, Feb 3, 2025 at 9:09 AM Raag Jadav <raag.jadav@intel.com> wrote:
> Convert to use devm_kmemdup_array() which is more robust.
>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 10/20] input: ipaq-micro-keys: use devm_kmemdup_array()
2025-02-03 8:08 ` [PATCH v3 10/20] input: ipaq-micro-keys: " Raag Jadav
@ 2025-02-06 18:46 ` Linus Walleij
0 siblings, 0 replies; 46+ messages in thread
From: Linus Walleij @ 2025-02-06 18:46 UTC (permalink / raw)
To: Raag Jadav
Cc: gregkh, rafael, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel, linux-gpio, linux-kernel, linux-input,
linux-sound, linux-pm, linux-iio
On Mon, Feb 3, 2025 at 9:09 AM Raag Jadav <raag.jadav@intel.com> wrote:
> Convert to use devm_kmemdup_array() which is more robust.
>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h
2025-02-06 18:11 ` Raag Jadav
@ 2025-02-06 18:56 ` Andy Shevchenko
0 siblings, 0 replies; 46+ messages in thread
From: Andy Shevchenko @ 2025-02-06 18:56 UTC (permalink / raw)
To: Raag Jadav
Cc: kernel test robot, gregkh, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, lgirdwood, broonie, sre, jic23,
przemyslaw.kitszel, oe-kbuild-all, linux-gpio, linux-kernel,
linux-input, linux-sound, linux-pm, linux-iio
On Thu, Feb 06, 2025 at 08:11:08PM +0200, Raag Jadav wrote:
> On Thu, Feb 06, 2025 at 05:14:05PM +0200, Andy Shevchenko wrote:
> > On Thu, Feb 06, 2025 at 05:12:49PM +0200, Andy Shevchenko wrote:
> > > On Thu, Feb 06, 2025 at 08:13:12AM +0200, Raag Jadav wrote:
> > > > On Thu, Feb 06, 2025 at 12:27:03AM +0800, kernel test robot wrote:
...
> > > > > 102
> > > > > 103 static inline
> > > > > 104 void __iomem *devm_ioremap_resource(struct device *dev, const struct resource *res)
> > > > > 105 {
> > > > > > 106 return ERR_PTR(-EINVAL);
> > > > > 107 }
> > > > > 108
> > > >
> > > > Andy, are we expecting this?
> > >
> > > Oh, no, it's sparse error, but easy to fix. Need to have
> > >
> > > return IOMEM_ERR_PTR(-EINVAL);
> >
> > But isn't it the original issue? I mean that it was already before this series.
>
> For all this time?
Yep. 0-day bot doesn't complain on pre-existed issues, but in case one touches
the line it becomes a new issue from its point of view.
> > If so, perhaps you can fix all sparse errors like this in the devres* code.
>
> With a fixes tag?
Maybe.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 46+ messages in thread
end of thread, other threads:[~2025-02-06 18:56 UTC | newest]
Thread overview: 46+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03 8:08 [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
2025-02-03 8:08 ` [PATCH v3 01/20] driver core: Split devres APIs to device/devres.h Raag Jadav
2025-02-05 16:27 ` kernel test robot
2025-02-06 6:13 ` Raag Jadav
2025-02-06 15:12 ` Andy Shevchenko
2025-02-06 15:14 ` Andy Shevchenko
2025-02-06 18:11 ` Raag Jadav
2025-02-06 18:56 ` Andy Shevchenko
2025-02-03 8:08 ` [PATCH v3 02/20] iio: imu: st_lsm9ds0: Replace device.h with what is needed Raag Jadav
2025-02-03 11:19 ` Jonathan Cameron
2025-02-03 8:08 ` [PATCH v3 03/20] devres: Introduce devm_kmemdup_array() Raag Jadav
2025-02-03 8:08 ` [PATCH v3 04/20] pinctrl: intel: copy communities using devm_kmemdup_array() Raag Jadav
2025-02-03 8:08 ` [PATCH v3 05/20] pinctrl: baytrail: " Raag Jadav
2025-02-06 18:45 ` Linus Walleij
2025-02-03 8:08 ` [PATCH v3 06/20] pinctrl: cherryview: use devm_kmemdup_array() Raag Jadav
2025-02-06 18:46 ` Linus Walleij
2025-02-03 8:08 ` [PATCH v3 07/20] pinctrl: tangier: " Raag Jadav
2025-02-03 8:08 ` [PATCH v3 08/20] pinctrl: pxa2xx: " Raag Jadav
2025-02-03 8:08 ` [PATCH v3 09/20] input: sparse-keymap: " Raag Jadav
2025-02-03 8:08 ` [PATCH v3 10/20] input: ipaq-micro-keys: " Raag Jadav
2025-02-06 18:46 ` Linus Walleij
2025-02-03 8:08 ` [PATCH v3 11/20] regulator: devres: " Raag Jadav
2025-02-03 8:08 ` [PATCH v3 12/20] regulator: cros-ec: " Raag Jadav
2025-02-03 9:51 ` Andy Shevchenko
2025-02-03 10:40 ` Raag Jadav
2025-02-03 11:23 ` Andy Shevchenko
2025-02-03 8:08 ` [PATCH v3 13/20] power: supply: sc27xx: " Raag Jadav
2025-02-03 8:08 ` [PATCH v3 14/20] iio: adc: xilinx-xadc-core: " Raag Jadav
2025-02-03 9:54 ` Andy Shevchenko
2025-02-03 10:42 ` Raag Jadav
2025-02-03 11:14 ` Jonathan Cameron
2025-02-03 11:25 ` Andy Shevchenko
2025-02-03 11:24 ` Andy Shevchenko
2025-02-03 8:08 ` [PATCH v3 15/20] ASoC: Intel: avs: " Raag Jadav
2025-02-03 8:08 ` [PATCH v3 16/20] ASoC: hdac_hdmi: " Raag Jadav
2025-02-03 9:52 ` Andy Shevchenko
2025-02-03 8:08 ` [PATCH v3 17/20] ASoC: tlv320dac33: " Raag Jadav
2025-02-03 9:52 ` Andy Shevchenko
2025-02-03 8:09 ` [PATCH v3 18/20] ASoC: uda1380: " Raag Jadav
2025-02-03 9:57 ` Andy Shevchenko
2025-02-03 8:09 ` [PATCH v3 19/20] ASoC: meson: axg-tdm-interface: " Raag Jadav
2025-02-03 8:09 ` [PATCH v3 20/20] ASoC: uniphier: " Raag Jadav
2025-02-03 9:53 ` Andy Shevchenko
2025-02-03 9:48 ` [PATCH v3 00/20] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Andy Shevchenko
2025-02-03 10:34 ` Raag Jadav
2025-02-03 11:29 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).