public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Convert media drivers to use devm_kmemdup_array()
@ 2025-02-28  7:36 Raag Jadav
  2025-02-28  7:36 ` [PATCH v2 1/2] media: atmel-isi: " Raag Jadav
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Raag Jadav @ 2025-02-28  7:36 UTC (permalink / raw)
  To: eugen.hristev, mchehab, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, hugues.fruchet, alain.volmat, mcoquelin.stm32,
	alexandre.torgue, andriy.shevchenko, sakari.ailus
  Cc: linux-media, linux-kernel, Raag Jadav

This series converts media drivers to use the newly introduced[1]
devm_kmemdup_array() helper. This depends on changes available on
immutable tag[2].

[1] https://lore.kernel.org/r/20250212062513.2254767-1-raag.jadav@intel.com
[2] https://lore.kernel.org/r/Z7xGpz3Q4Zj6YHx7@black.fi.intel.com

v2: Split patch series per subsystem

Raag Jadav (2):
  media: atmel-isi: use devm_kmemdup_array()
  media: stm32-dcmi: use devm_kmemdup_array()

 drivers/media/platform/atmel/atmel-isi.c     | 8 ++------
 drivers/media/platform/st/stm32/stm32-dcmi.c | 8 ++------
 2 files changed, 4 insertions(+), 12 deletions(-)


base-commit: b8c38ccb2ca52b9a38cfeb9f89abab5d6e713221
-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] media: atmel-isi: use devm_kmemdup_array()
  2025-02-28  7:36 [PATCH v2 0/2] Convert media drivers to use devm_kmemdup_array() Raag Jadav
@ 2025-02-28  7:36 ` Raag Jadav
  2025-02-28  7:36 ` [PATCH v2 2/2] media: stm32-dcmi: " Raag Jadav
  2025-03-10  6:45 ` [PATCH v2 0/2] Convert media drivers to " Raag Jadav
  2 siblings, 0 replies; 7+ messages in thread
From: Raag Jadav @ 2025-02-28  7:36 UTC (permalink / raw)
  To: eugen.hristev, mchehab, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, hugues.fruchet, alain.volmat, mcoquelin.stm32,
	alexandre.torgue, andriy.shevchenko, sakari.ailus
  Cc: linux-media, linux-kernel, Raag Jadav

Convert to use devm_kmemdup_array() and while at it, make the size robust
against type changes.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/media/platform/atmel/atmel-isi.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index 0d1c39347529..7d8bec46af89 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -1072,16 +1072,12 @@ static int isi_formats_init(struct atmel_isi *isi)
 		return -ENXIO;
 
 	isi->num_user_formats = num_fmts;
-	isi->user_formats = devm_kcalloc(isi->dev,
-					 num_fmts, sizeof(struct isi_format *),
-					 GFP_KERNEL);
+	isi->user_formats = devm_kmemdup_array(isi->dev, isi_fmts, num_fmts,
+					       sizeof(isi_fmts[0]), GFP_KERNEL);
 	if (!isi->user_formats)
 		return -ENOMEM;
 
-	memcpy(isi->user_formats, isi_fmts,
-	       num_fmts * sizeof(struct isi_format *));
 	isi->current_fmt = isi->user_formats[0];
-
 	return 0;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] media: stm32-dcmi: use devm_kmemdup_array()
  2025-02-28  7:36 [PATCH v2 0/2] Convert media drivers to use devm_kmemdup_array() Raag Jadav
  2025-02-28  7:36 ` [PATCH v2 1/2] media: atmel-isi: " Raag Jadav
@ 2025-02-28  7:36 ` Raag Jadav
  2025-03-10  6:45 ` [PATCH v2 0/2] Convert media drivers to " Raag Jadav
  2 siblings, 0 replies; 7+ messages in thread
From: Raag Jadav @ 2025-02-28  7:36 UTC (permalink / raw)
  To: eugen.hristev, mchehab, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, hugues.fruchet, alain.volmat, mcoquelin.stm32,
	alexandre.torgue, andriy.shevchenko, sakari.ailus
  Cc: linux-media, linux-kernel, Raag Jadav

Convert to use devm_kmemdup_array() and while at it, make the size robust
against type changes.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/media/platform/st/stm32/stm32-dcmi.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/st/stm32/stm32-dcmi.c b/drivers/media/platform/st/stm32/stm32-dcmi.c
index 9b699ee2b1e0..eedc15b30edc 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmi.c
@@ -1682,18 +1682,14 @@ static int dcmi_formats_init(struct stm32_dcmi *dcmi)
 		return -ENXIO;
 
 	dcmi->num_of_sd_formats = num_fmts;
-	dcmi->sd_formats = devm_kcalloc(dcmi->dev,
-					num_fmts, sizeof(struct dcmi_format *),
-					GFP_KERNEL);
+	dcmi->sd_formats = devm_kmemdup_array(dcmi->dev, sd_fmts, num_fmts,
+					      sizeof(sd_fmts[0]), GFP_KERNEL);
 	if (!dcmi->sd_formats) {
 		dev_err(dcmi->dev, "Could not allocate memory\n");
 		return -ENOMEM;
 	}
 
-	memcpy(dcmi->sd_formats, sd_fmts,
-	       num_fmts * sizeof(struct dcmi_format *));
 	dcmi->sd_format = dcmi->sd_formats[0];
-
 	return 0;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] Convert media drivers to use devm_kmemdup_array()
  2025-02-28  7:36 [PATCH v2 0/2] Convert media drivers to use devm_kmemdup_array() Raag Jadav
  2025-02-28  7:36 ` [PATCH v2 1/2] media: atmel-isi: " Raag Jadav
  2025-02-28  7:36 ` [PATCH v2 2/2] media: stm32-dcmi: " Raag Jadav
@ 2025-03-10  6:45 ` Raag Jadav
  2025-03-10 10:53   ` Sakari Ailus
  2 siblings, 1 reply; 7+ messages in thread
From: Raag Jadav @ 2025-03-10  6:45 UTC (permalink / raw)
  To: eugen.hristev, mchehab, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, hugues.fruchet, alain.volmat, mcoquelin.stm32,
	alexandre.torgue, andriy.shevchenko, sakari.ailus, hverkuil-cisco
  Cc: linux-media, linux-kernel

On Fri, Feb 28, 2025 at 01:06:47PM +0530, Raag Jadav wrote:
> This series converts media drivers to use the newly introduced[1]
> devm_kmemdup_array() helper. This depends on changes available on
> immutable tag[2].
> 
> [1] https://lore.kernel.org/r/20250212062513.2254767-1-raag.jadav@intel.com
> [2] https://lore.kernel.org/r/Z7xGpz3Q4Zj6YHx7@black.fi.intel.com

Bump, anything I can do to move this forward?

Raag

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] Convert media drivers to use devm_kmemdup_array()
  2025-03-10  6:45 ` [PATCH v2 0/2] Convert media drivers to " Raag Jadav
@ 2025-03-10 10:53   ` Sakari Ailus
  2025-03-11  6:31     ` Raag Jadav
  0 siblings, 1 reply; 7+ messages in thread
From: Sakari Ailus @ 2025-03-10 10:53 UTC (permalink / raw)
  To: Raag Jadav
  Cc: eugen.hristev, mchehab, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, hugues.fruchet, alain.volmat, mcoquelin.stm32,
	alexandre.torgue, andriy.shevchenko, hverkuil-cisco, linux-media,
	linux-kernel

Hi Raag,

On Mon, Mar 10, 2025 at 08:45:12AM +0200, Raag Jadav wrote:
> On Fri, Feb 28, 2025 at 01:06:47PM +0530, Raag Jadav wrote:
> > This series converts media drivers to use the newly introduced[1]
> > devm_kmemdup_array() helper. This depends on changes available on
> > immutable tag[2].
> > 
> > [1] https://lore.kernel.org/r/20250212062513.2254767-1-raag.jadav@intel.com
> > [2] https://lore.kernel.org/r/Z7xGpz3Q4Zj6YHx7@black.fi.intel.com
> 
> Bump, anything I can do to move this forward?

The patches these depend on (those adding devm_kmemdup_array()) aren't in
the Media tree yet. They don't seem urgent though so I'd just wait.

Speaking of the patches themselves: I'd use *array instead of array[0] for
sizeof argument.

-- 
Regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] Convert media drivers to use devm_kmemdup_array()
  2025-03-10 10:53   ` Sakari Ailus
@ 2025-03-11  6:31     ` Raag Jadav
  2025-03-11 10:24       ` Sakari Ailus
  0 siblings, 1 reply; 7+ messages in thread
From: Raag Jadav @ 2025-03-11  6:31 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: eugen.hristev, mchehab, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, hugues.fruchet, alain.volmat, mcoquelin.stm32,
	alexandre.torgue, andriy.shevchenko, hverkuil-cisco, linux-media,
	linux-kernel

On Mon, Mar 10, 2025 at 10:53:57AM +0000, Sakari Ailus wrote:
> Hi Raag,
> 
> On Mon, Mar 10, 2025 at 08:45:12AM +0200, Raag Jadav wrote:
> > On Fri, Feb 28, 2025 at 01:06:47PM +0530, Raag Jadav wrote:
> > > This series converts media drivers to use the newly introduced[1]
> > > devm_kmemdup_array() helper. This depends on changes available on
> > > immutable tag[2].
> > > 
> > > [1] https://lore.kernel.org/r/20250212062513.2254767-1-raag.jadav@intel.com
> > > [2] https://lore.kernel.org/r/Z7xGpz3Q4Zj6YHx7@black.fi.intel.com
> > 
> > Bump, anything I can do to move this forward?
> 
> The patches these depend on (those adding devm_kmemdup_array()) aren't in
> the Media tree yet. They don't seem urgent though so I'd just wait.

I was hoping the immutable tag would be useful here. But sure, no problem.

> Speaking of the patches themselves: I'd use *array instead of array[0] for
> sizeof argument.

I know it doesn't matter much to the compiler but since the source itself
is an array here, doesn't [0] make more sense?

Raag

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/2] Convert media drivers to use devm_kmemdup_array()
  2025-03-11  6:31     ` Raag Jadav
@ 2025-03-11 10:24       ` Sakari Ailus
  0 siblings, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2025-03-11 10:24 UTC (permalink / raw)
  To: Raag Jadav
  Cc: eugen.hristev, mchehab, nicolas.ferre, alexandre.belloni,
	claudiu.beznea, hugues.fruchet, alain.volmat, mcoquelin.stm32,
	alexandre.torgue, andriy.shevchenko, hverkuil-cisco, linux-media,
	linux-kernel

Hi Raag,

On Tue, Mar 11, 2025 at 08:31:12AM +0200, Raag Jadav wrote:
> On Mon, Mar 10, 2025 at 10:53:57AM +0000, Sakari Ailus wrote:
> > Hi Raag,
> > 
> > On Mon, Mar 10, 2025 at 08:45:12AM +0200, Raag Jadav wrote:
> > > On Fri, Feb 28, 2025 at 01:06:47PM +0530, Raag Jadav wrote:
> > > > This series converts media drivers to use the newly introduced[1]
> > > > devm_kmemdup_array() helper. This depends on changes available on
> > > > immutable tag[2].
> > > > 
> > > > [1] https://lore.kernel.org/r/20250212062513.2254767-1-raag.jadav@intel.com
> > > > [2] https://lore.kernel.org/r/Z7xGpz3Q4Zj6YHx7@black.fi.intel.com
> > > 
> > > Bump, anything I can do to move this forward?
> > 
> > The patches these depend on (those adding devm_kmemdup_array()) aren't in
> > the Media tree yet. They don't seem urgent though so I'd just wait.
> 
> I was hoping the immutable tag would be useful here. But sure, no problem.
> 
> > Speaking of the patches themselves: I'd use *array instead of array[0] for
> > sizeof argument.
> 
> I know it doesn't matter much to the compiler but since the source itself
> is an array here, doesn't [0] make more sense?

The element at index 0 isn't anyhow special in this respect so I do prefer
*array instead. In practice it works either way of course.

-- 
Regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-11 10:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28  7:36 [PATCH v2 0/2] Convert media drivers to use devm_kmemdup_array() Raag Jadav
2025-02-28  7:36 ` [PATCH v2 1/2] media: atmel-isi: " Raag Jadav
2025-02-28  7:36 ` [PATCH v2 2/2] media: stm32-dcmi: " Raag Jadav
2025-03-10  6:45 ` [PATCH v2 0/2] Convert media drivers to " Raag Jadav
2025-03-10 10:53   ` Sakari Ailus
2025-03-11  6:31     ` Raag Jadav
2025-03-11 10:24       ` Sakari Ailus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox