* [PATCH v5 01/12] err.h: move IOMEM_ERR_PTR() to err.h
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 6:32 ` Arnd Bergmann
2025-02-12 6:25 ` [PATCH v5 02/12] driver core: Split devres APIs to device/devres.h Raag Jadav
` (11 subsequent siblings)
12 siblings, 1 reply; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-iio, Raag Jadav
Since IOMEM_ERR_PTR() macro deals with an error pointer, a better place
for it is err.h. This helps avoid dependency on io.h for the users that
don't need it.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
include/linux/err.h | 3 +++
include/linux/io.h | 2 --
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/err.h b/include/linux/err.h
index a4dacd745fcf..1d60aa86db53 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -44,6 +44,9 @@ static inline void * __must_check ERR_PTR(long error)
/* Return the pointer in the percpu address space. */
#define ERR_PTR_PCPU(error) ((void __percpu *)(unsigned long)ERR_PTR(error))
+/* Cast an error pointer to __iomem. */
+#define IOMEM_ERR_PTR(error) (__force void __iomem *)ERR_PTR(error)
+
/**
* PTR_ERR - Extract the error code from an error pointer.
* @ptr: An error pointer.
diff --git a/include/linux/io.h b/include/linux/io.h
index 59ec5eea696c..40cb2de73f5e 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -65,8 +65,6 @@ static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr)
}
#endif
-#define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
-
void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
resource_size_t size);
void __iomem *devm_ioremap_uc(struct device *dev, resource_size_t offset,
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH v5 01/12] err.h: move IOMEM_ERR_PTR() to err.h
2025-02-12 6:25 ` [PATCH v5 01/12] err.h: move IOMEM_ERR_PTR() to err.h Raag Jadav
@ 2025-02-12 6:32 ` Arnd Bergmann
0 siblings, 0 replies; 23+ messages in thread
From: Arnd Bergmann @ 2025-02-12 6:32 UTC (permalink / raw)
To: Raag Jadav, Greg Kroah-Hartman, Rafael J . Wysocki, Linus Walleij,
Mika Westerberg, Andy Shevchenko, Dmitry Torokhov,
Jonathan Cameron, Przemek Kitszel
Cc: open list:GPIO SUBSYSTEM, linux-kernel, linux-input, linux-iio
On Wed, Feb 12, 2025, at 07:25, Raag Jadav wrote:
> Since IOMEM_ERR_PTR() macro deals with an error pointer, a better place
> for it is err.h. This helps avoid dependency on io.h for the users that
> don't need it.
>
> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v5 02/12] driver core: Split devres APIs to device/devres.h
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
2025-02-12 6:25 ` [PATCH v5 01/12] err.h: move IOMEM_ERR_PTR() to err.h Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 6:41 ` Arnd Bergmann
2025-02-20 11:59 ` Greg KH
2025-02-12 6:25 ` [PATCH v5 03/12] iio: imu: st_lsm9ds0: Replace device.h with what is needed Raag Jadav
` (10 subsequent siblings)
12 siblings, 2 replies; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, 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.
While at it, cast the error pointers to __iomem using IOMEM_ERR_PTR()
and fix sparse warnings.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Raag Jadav <raag.jadav@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..6b0b265058bc
--- /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 IOMEM_ERR_PTR(-EINVAL);
+}
+
+static inline
+void __iomem *devm_ioremap_resource_wc(struct device *dev, const struct resource *res)
+{
+ return IOMEM_ERR_PTR(-EINVAL);
+}
+
+static inline
+void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int index,
+ resource_size_t *size)
+{
+ return IOMEM_ERR_PTR(-EINVAL);
+}
+
+#endif
+
+#endif /* _DEVICE_DEVRES_H_ */
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH v5 02/12] driver core: Split devres APIs to device/devres.h
2025-02-12 6:25 ` [PATCH v5 02/12] driver core: Split devres APIs to device/devres.h Raag Jadav
@ 2025-02-12 6:41 ` Arnd Bergmann
2025-02-12 11:00 ` Andy Shevchenko
2025-02-20 11:59 ` Greg KH
1 sibling, 1 reply; 23+ messages in thread
From: Arnd Bergmann @ 2025-02-12 6:41 UTC (permalink / raw)
To: Raag Jadav, Greg Kroah-Hartman, Rafael J . Wysocki, Linus Walleij,
Mika Westerberg, Andy Shevchenko, Dmitry Torokhov,
Jonathan Cameron, Przemek Kitszel
Cc: open list:GPIO SUBSYSTEM, linux-kernel, linux-input, linux-iio
On Wed, Feb 12, 2025, at 07:25, Raag Jadav wrote:
> 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.
>
> While at it, cast the error pointers to __iomem using IOMEM_ERR_PTR()
> and fix sparse warnings.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> ---
> include/linux/device.h | 119 +-------------------------------
> include/linux/device/devres.h | 124 ++++++++++++++++++++++++++++++++++
Acked-by: Arnd Bergmann <arnd@arndb.de>
Splitting this out makes a lot of sense conceptually, though
I don't think it will actually help with build speed: In order
to see real benefits, we'd need to remove the linux/device.h
inclusion from other headers that are frequently included,
but those don't really rely on the devres interfaces.
Arnd
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 02/12] driver core: Split devres APIs to device/devres.h
2025-02-12 6:41 ` Arnd Bergmann
@ 2025-02-12 11:00 ` Andy Shevchenko
0 siblings, 0 replies; 23+ messages in thread
From: Andy Shevchenko @ 2025-02-12 11:00 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Raag Jadav, Greg Kroah-Hartman, Rafael J . Wysocki, Linus Walleij,
Mika Westerberg, Dmitry Torokhov, Jonathan Cameron,
Przemek Kitszel, open list:GPIO SUBSYSTEM, linux-kernel,
linux-input, linux-iio
On Wed, Feb 12, 2025 at 07:41:47AM +0100, Arnd Bergmann wrote:
> On Wed, Feb 12, 2025, at 07:25, Raag Jadav wrote:
> > 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.
> >
> > While at it, cast the error pointers to __iomem using IOMEM_ERR_PTR()
> > and fix sparse warnings.
...
> Acked-by: Arnd Bergmann <arnd@arndb.de>
Thank you!
> Splitting this out makes a lot of sense conceptually, though
> I don't think it will actually help with build speed: In order
> to see real benefits, we'd need to remove the linux/device.h
> inclusion from other headers that are frequently included,
> but those don't really rely on the devres interfaces.
Yeah, that's just yet another baby step to the right direction, but it won't
change picture if being alone. I already did a number of patches to split
kernel.h and removing it from other headers, but a lot of work is still ahead
and it's not my hight priority task...
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v5 02/12] driver core: Split devres APIs to device/devres.h
2025-02-12 6:25 ` [PATCH v5 02/12] driver core: Split devres APIs to device/devres.h Raag Jadav
2025-02-12 6:41 ` Arnd Bergmann
@ 2025-02-20 11:59 ` Greg KH
2025-02-20 12:18 ` Andy Shevchenko
1 sibling, 1 reply; 23+ messages in thread
From: Greg KH @ 2025-02-20 11:59 UTC (permalink / raw)
To: Raag Jadav
Cc: arnd, rafael, linus.walleij, mika.westerberg, andriy.shevchenko,
dmitry.torokhov, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-iio
On Wed, Feb 12, 2025 at 11:55:03AM +0530, Raag Jadav wrote:
> 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.
>
> While at it, cast the error pointers to __iomem using IOMEM_ERR_PTR()
> and fix sparse warnings.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v5 02/12] driver core: Split devres APIs to device/devres.h
2025-02-20 11:59 ` Greg KH
@ 2025-02-20 12:18 ` Andy Shevchenko
0 siblings, 0 replies; 23+ messages in thread
From: Andy Shevchenko @ 2025-02-20 12:18 UTC (permalink / raw)
To: Greg KH
Cc: Raag Jadav, arnd, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-iio
On Thu, Feb 20, 2025 at 12:59:02PM +0100, Greg KH wrote:
> On Wed, Feb 12, 2025 at 11:55:03AM +0530, Raag Jadav wrote:
> > 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.
> >
> > While at it, cast the error pointers to __iomem using IOMEM_ERR_PTR()
> > and fix sparse warnings.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Signed-off-by: Raag Jadav <raag.jadav@intel.com>
>
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Thank you!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v5 03/12] iio: imu: st_lsm9ds0: Replace device.h with what is needed
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
2025-02-12 6:25 ` [PATCH v5 01/12] err.h: move IOMEM_ERR_PTR() to err.h Raag Jadav
2025-02-12 6:25 ` [PATCH v5 02/12] driver core: Split devres APIs to device/devres.h Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 6:25 ` [PATCH v5 04/12] devres: Introduce devm_kmemdup_array() Raag Jadav
` (9 subsequent siblings)
12 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-iio, Raag Jadav,
Jonathan Cameron
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>
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>
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH v5 04/12] devres: Introduce devm_kmemdup_array()
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (2 preceding siblings ...)
2025-02-12 6:25 ` [PATCH v5 03/12] iio: imu: st_lsm9ds0: Replace device.h with what is needed Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 6:25 ` [PATCH v5 05/12] pinctrl: intel: copy communities using devm_kmemdup_array() Raag Jadav
` (8 subsequent siblings)
12 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, 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 6b0b265058bc..9b49f9915850 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] 23+ messages in thread* [PATCH v5 05/12] pinctrl: intel: copy communities using devm_kmemdup_array()
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (3 preceding siblings ...)
2025-02-12 6:25 ` [PATCH v5 04/12] devres: Introduce devm_kmemdup_array() Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 6:25 ` [PATCH v5 06/12] pinctrl: baytrail: " Raag Jadav
` (7 subsequent siblings)
12 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, 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 e4de88e10d68..d889c7c878e2 100644
--- a/drivers/pinctrl/intel/pinctrl-intel.c
+++ b/drivers/pinctrl/intel/pinctrl-intel.c
@@ -1576,8 +1576,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->soc->communities), GFP_KERNEL);
if (!pctrl->communities)
return -ENOMEM;
@@ -1587,8 +1587,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] 23+ messages in thread* [PATCH v5 06/12] pinctrl: baytrail: copy communities using devm_kmemdup_array()
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (4 preceding siblings ...)
2025-02-12 6:25 ` [PATCH v5 05/12] pinctrl: intel: copy communities using devm_kmemdup_array() Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 6:25 ` [PATCH v5 07/12] pinctrl: cherryview: use devm_kmemdup_array() Raag Jadav
` (6 subsequent siblings)
12 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, 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: Linus Walleij <linus.walleij@linaro.org>
---
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 c4458ac539ff..969137c4cb06 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -1560,16 +1560,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->soc->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] 23+ messages in thread* [PATCH v5 07/12] pinctrl: cherryview: use devm_kmemdup_array()
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (5 preceding siblings ...)
2025-02-12 6:25 ` [PATCH v5 06/12] pinctrl: baytrail: " Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 6:25 ` [PATCH v5 08/12] pinctrl: tangier: " Raag Jadav
` (5 subsequent siblings)
12 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() and while at it, use source size
instead of destination.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
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..69b18ce0f685 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->soc->communities), GFP_KERNEL);
if (!pctrl->communities)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH v5 08/12] pinctrl: tangier: use devm_kmemdup_array()
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (6 preceding siblings ...)
2025-02-12 6:25 ` [PATCH v5 07/12] pinctrl: cherryview: use devm_kmemdup_array() Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 6:25 ` [PATCH v5 09/12] pinctrl: pxa2xx: " Raag Jadav
` (4 subsequent siblings)
12 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() and while at it, use source size
instead of destination.
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..ac61e632b487 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(*tp->families), GFP_KERNEL);
if (!families)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH v5 09/12] pinctrl: pxa2xx: use devm_kmemdup_array()
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (7 preceding siblings ...)
2025-02-12 6:25 ` [PATCH v5 08/12] pinctrl: tangier: " Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 6:25 ` [PATCH v5 10/12] iio: adc: xilinx-xadc-core: " Raag Jadav
` (3 subsequent siblings)
12 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, 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] 23+ messages in thread* [PATCH v5 10/12] iio: adc: xilinx-xadc-core: use devm_kmemdup_array()
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (8 preceding siblings ...)
2025-02-12 6:25 ` [PATCH v5 09/12] pinctrl: pxa2xx: " Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-16 16:59 ` Jonathan Cameron
2025-02-12 6:25 ` [PATCH v5 11/12] input: sparse-keymap: " Raag Jadav
` (2 subsequent siblings)
12 siblings, 1 reply; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() and while at it, use source size
instead of destination.
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..e1f8740ae688 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(*channel_templates), GFP_KERNEL);
if (!channels)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* Re: [PATCH v5 10/12] iio: adc: xilinx-xadc-core: use devm_kmemdup_array()
2025-02-12 6:25 ` [PATCH v5 10/12] iio: adc: xilinx-xadc-core: " Raag Jadav
@ 2025-02-16 16:59 ` Jonathan Cameron
0 siblings, 0 replies; 23+ messages in thread
From: Jonathan Cameron @ 2025-02-16 16:59 UTC (permalink / raw)
To: Raag Jadav
Cc: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, przemyslaw.kitszel,
linux-gpio, linux-kernel, linux-input, linux-iio
On Wed, 12 Feb 2025 11:55:11 +0530
Raag Jadav <raag.jadav@intel.com> wrote:
> Convert to use devm_kmemdup_array() and while at it, use source size
> instead of destination.
>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Seems fine to me.
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.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..e1f8740ae688 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(*channel_templates), GFP_KERNEL);
> if (!channels)
> return -ENOMEM;
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v5 11/12] input: sparse-keymap: use devm_kmemdup_array()
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (9 preceding siblings ...)
2025-02-12 6:25 ` [PATCH v5 10/12] iio: adc: xilinx-xadc-core: " Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 6:25 ` [PATCH v5 12/12] input: ipaq-micro-keys: " Raag Jadav
2025-02-12 11:05 ` [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Andy Shevchenko
12 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, linux-iio, Raag Jadav
Convert to use devm_kmemdup_array() and while at it, use source size
instead of destination.
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..96f23ae57d5a 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(*keymap), GFP_KERNEL);
if (!map)
return -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH v5 12/12] input: ipaq-micro-keys: use devm_kmemdup_array()
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (10 preceding siblings ...)
2025-02-12 6:25 ` [PATCH v5 11/12] input: sparse-keymap: " Raag Jadav
@ 2025-02-12 6:25 ` Raag Jadav
2025-02-12 11:05 ` [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Andy Shevchenko
12 siblings, 0 replies; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 6:25 UTC (permalink / raw)
To: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
andriy.shevchenko, dmitry.torokhov, jic23, przemyslaw.kitszel
Cc: linux-gpio, linux-kernel, linux-input, 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/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] 23+ messages in thread* Re: [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array()
2025-02-12 6:25 [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Raag Jadav
` (11 preceding siblings ...)
2025-02-12 6:25 ` [PATCH v5 12/12] input: ipaq-micro-keys: " Raag Jadav
@ 2025-02-12 11:05 ` Andy Shevchenko
2025-02-12 16:22 ` Raag Jadav
12 siblings, 1 reply; 23+ messages in thread
From: Andy Shevchenko @ 2025-02-12 11:05 UTC (permalink / raw)
To: Raag Jadav
Cc: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-iio
On Wed, Feb 12, 2025 at 11:55:01AM +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 make the review
> process easier and reduce conflicts while merging.
>
> Current proposal is to merge initial patches with an immutable tag (volunteered
> by Andy) for other subsystems to use. Feel free to share a better alternative.
> v5: Move IOMEM_ERR_PTR() to err.h (Andy)
> Reduce distribution to pinctrl/iio/input patches
Weren't there two more patches that were actually Acked by Jonathan?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array()
2025-02-12 11:05 ` [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array() Andy Shevchenko
@ 2025-02-12 16:22 ` Raag Jadav
2025-02-12 17:21 ` Andy Shevchenko
0 siblings, 1 reply; 23+ messages in thread
From: Raag Jadav @ 2025-02-12 16:22 UTC (permalink / raw)
To: Andy Shevchenko
Cc: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-iio
On Wed, Feb 12, 2025 at 01:05:17PM +0200, Andy Shevchenko wrote:
> On Wed, Feb 12, 2025 at 11:55:01AM +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 make the review
> > process easier and reduce conflicts while merging.
> >
> > Current proposal is to merge initial patches with an immutable tag (volunteered
> > by Andy) for other subsystems to use. Feel free to share a better alternative.
>
> > v5: Move IOMEM_ERR_PTR() to err.h (Andy)
> > Reduce distribution to pinctrl/iio/input patches
>
> Weren't there two more patches that were actually Acked by Jonathan?
Nope, iio only has one user each.
Raag
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array()
2025-02-12 16:22 ` Raag Jadav
@ 2025-02-12 17:21 ` Andy Shevchenko
2025-02-20 12:19 ` Andy Shevchenko
0 siblings, 1 reply; 23+ messages in thread
From: Andy Shevchenko @ 2025-02-12 17:21 UTC (permalink / raw)
To: Raag Jadav
Cc: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-iio
On Wed, Feb 12, 2025 at 06:22:06PM +0200, Raag Jadav wrote:
> On Wed, Feb 12, 2025 at 01:05:17PM +0200, Andy Shevchenko wrote:
> > On Wed, Feb 12, 2025 at 11:55:01AM +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 make the review
> > > process easier and reduce conflicts while merging.
> > >
> > > Current proposal is to merge initial patches with an immutable tag (volunteered
> > > by Andy) for other subsystems to use. Feel free to share a better alternative.
> >
> > > v5: Move IOMEM_ERR_PTR() to err.h (Andy)
> > > Reduce distribution to pinctrl/iio/input patches
> >
> > Weren't there two more patches that were actually Acked by Jonathan?
>
> Nope, iio only has one user each.
Okay, so we basically waiting then for Greg KH to review / ack the couple of
patches (2 and 4) and Dmitry and Jonathan one patch for each.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v5 00/12] Split devres APIs to device/devres.h and introduce devm_kmemdup_array()
2025-02-12 17:21 ` Andy Shevchenko
@ 2025-02-20 12:19 ` Andy Shevchenko
0 siblings, 0 replies; 23+ messages in thread
From: Andy Shevchenko @ 2025-02-20 12:19 UTC (permalink / raw)
To: Raag Jadav
Cc: arnd, gregkh, rafael, linus.walleij, mika.westerberg,
dmitry.torokhov, jic23, przemyslaw.kitszel, linux-gpio,
linux-kernel, linux-input, linux-iio
On Wed, Feb 12, 2025 at 07:21:34PM +0200, Andy Shevchenko wrote:
> On Wed, Feb 12, 2025 at 06:22:06PM +0200, Raag Jadav wrote:
> > On Wed, Feb 12, 2025 at 01:05:17PM +0200, Andy Shevchenko wrote:
> > > On Wed, Feb 12, 2025 at 11:55:01AM +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 make the review
> > > > process easier and reduce conflicts while merging.
> > > >
> > > > Current proposal is to merge initial patches with an immutable tag (volunteered
> > > > by Andy) for other subsystems to use. Feel free to share a better alternative.
> > >
> > > > v5: Move IOMEM_ERR_PTR() to err.h (Andy)
> > > > Reduce distribution to pinctrl/iio/input patches
> > >
> > > Weren't there two more patches that were actually Acked by Jonathan?
> >
> > Nope, iio only has one user each.
>
> Okay, so we basically waiting then for Greg KH to review / ack the couple of
> patches (2 and 4) and Dmitry and Jonathan one patch for each.
I'm going to apply this series to Intel pin control tree soon and share
an immutable tag TWIMC, please tell me if it shouldn't be the case.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 23+ messages in thread