public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: dsa: felix: use kmalloc_flex helper
@ 2026-02-25  4:03 Rosen Penev
  2026-02-25  9:13 ` Jijie Shao
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rosen Penev @ 2026-02-25  4:03 UTC (permalink / raw)
  To: netdev
  Cc: Vladimir Oltean, Claudiu Manoil, Alexandre Belloni,
	maintainer:OCELOT ETHERNET SWITCH DRIVER, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list

A little simpler than using a separate size variable.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/dsa/ocelot/felix_vsc9959.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index 8387dd208adb..cb132679fd99 100644
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -2254,7 +2254,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
 	struct felix_stream_gate *sgi;
 	struct ocelot_psfp_list *psfp;
 	struct ocelot_policer pol;
-	int ret, i, size;
+	int ret, i;
 	u64 rate, burst;
 	u32 index;
 
@@ -2271,8 +2271,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
 	flow_action_for_each(i, a, &f->rule->action) {
 		switch (a->id) {
 		case FLOW_ACTION_GATE:
-			size = struct_size(sgi, entries, a->gate.num_entries);
-			sgi = kzalloc(size, GFP_KERNEL);
+			sgi = kzalloc_flex(*sgi, entries, a->gate.num_entries, GFP_KERNEL);
 			if (!sgi) {
 				ret = -ENOMEM;
 				goto err;
-- 
2.53.0


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

* Re: [PATCH] net: dsa: felix: use kmalloc_flex helper
  2026-02-25  4:03 [PATCH] net: dsa: felix: use kmalloc_flex helper Rosen Penev
@ 2026-02-25  9:13 ` Jijie Shao
  2026-02-26 12:23 ` Simon Horman
  2026-02-26 13:03 ` Vladimir Oltean
  2 siblings, 0 replies; 4+ messages in thread
From: Jijie Shao @ 2026-02-25  9:13 UTC (permalink / raw)
  To: Rosen Penev, netdev
  Cc: shaojijie, Vladimir Oltean, Claudiu Manoil, Alexandre Belloni,
	maintainer:OCELOT ETHERNET SWITCH DRIVER, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list


on 2026/2/25 12:03, Rosen Penev wrote:
> A little simpler than using a separate size variable.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>   drivers/net/dsa/ocelot/felix_vsc9959.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
> index 8387dd208adb..cb132679fd99 100644
> --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
> +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
> @@ -2254,7 +2254,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
>   	struct felix_stream_gate *sgi;
>   	struct ocelot_psfp_list *psfp;
>   	struct ocelot_policer pol;
> -	int ret, i, size;
> +	int ret, i;
>   	u64 rate, burst;
>   	u32 index;
>   
> @@ -2271,8 +2271,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
>   	flow_action_for_each(i, a, &f->rule->action) {
>   		switch (a->id) {
>   		case FLOW_ACTION_GATE:
> -			size = struct_size(sgi, entries, a->gate.num_entries);
> -			sgi = kzalloc(size, GFP_KERNEL);
> +			sgi = kzalloc_flex(*sgi, entries, a->gate.num_entries, GFP_KERNEL);

Sorry, the subject is kmalloc_flex but code is kzalloc_flex

>   			if (!sgi) {
>   				ret = -ENOMEM;
>   				goto err;

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

* Re: [PATCH] net: dsa: felix: use kmalloc_flex helper
  2026-02-25  4:03 [PATCH] net: dsa: felix: use kmalloc_flex helper Rosen Penev
  2026-02-25  9:13 ` Jijie Shao
@ 2026-02-26 12:23 ` Simon Horman
  2026-02-26 13:03 ` Vladimir Oltean
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2026-02-26 12:23 UTC (permalink / raw)
  To: Rosen Penev
  Cc: netdev, Vladimir Oltean, Claudiu Manoil, Alexandre Belloni,
	maintainer:OCELOT ETHERNET SWITCH DRIVER, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list

On Tue, Feb 24, 2026 at 08:03:23PM -0800, Rosen Penev wrote:
> A little simpler than using a separate size variable.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/net/dsa/ocelot/felix_vsc9959.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
> index 8387dd208adb..cb132679fd99 100644
> --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
> +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
> @@ -2254,7 +2254,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
>  	struct felix_stream_gate *sgi;
>  	struct ocelot_psfp_list *psfp;
>  	struct ocelot_policer pol;
> -	int ret, i, size;
> +	int ret, i;
>  	u64 rate, burst;
>  	u32 index;
>  
> @@ -2271,8 +2271,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
>  	flow_action_for_each(i, a, &f->rule->action) {
>  		switch (a->id) {
>  		case FLOW_ACTION_GATE:
> -			size = struct_size(sgi, entries, a->gate.num_entries);
> -			sgi = kzalloc(size, GFP_KERNEL);
> +			sgi = kzalloc_flex(*sgi, entries, a->gate.num_entries, GFP_KERNEL);

Hi Rosen,

This line is now too long; Kernel code still prefers code to be 80
columns wide or less.

To be honest, I think the improvement here is marginal.
And I lean towards the rule about cleanups applying here.

Quoting documentation:

  Clean-up patches
  ~~~~~~~~~~~~~~~~

  Netdev discourages patches which perform simple clean-ups, which are not in
  the context of other work. For example:

  * Addressing checkpatch.pl warnings
  * Addressing Local variable ordering issues
  * Conversions to device-managed APIs (devm_ helpers)

  This is because it is felt that the churn that such changes produce comes
  at a greater cost than the value of such clean-ups.

  Conversely, spelling and grammar fixes are not discouraged.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#clean-up-patches
--
pw-bot: cr

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

* Re: [PATCH] net: dsa: felix: use kmalloc_flex helper
  2026-02-25  4:03 [PATCH] net: dsa: felix: use kmalloc_flex helper Rosen Penev
  2026-02-25  9:13 ` Jijie Shao
  2026-02-26 12:23 ` Simon Horman
@ 2026-02-26 13:03 ` Vladimir Oltean
  2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Oltean @ 2026-02-26 13:03 UTC (permalink / raw)
  To: Rosen Penev
  Cc: netdev, Claudiu Manoil, Alexandre Belloni,
	maintainer:OCELOT ETHERNET SWITCH DRIVER, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list

On Tue, Feb 24, 2026 at 08:03:23PM -0800, Rosen Penev wrote:
> A little simpler than using a separate size variable.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/net/dsa/ocelot/felix_vsc9959.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
> index 8387dd208adb..cb132679fd99 100644
> --- a/drivers/net/dsa/ocelot/felix_vsc9959.c
> +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
> @@ -2254,7 +2254,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
>  	struct felix_stream_gate *sgi;
>  	struct ocelot_psfp_list *psfp;
>  	struct ocelot_policer pol;
> -	int ret, i, size;
> +	int ret, i;

Please don't break reverse Christmas tree variable ordering.
And put "PATCH v2 net-next" in the git subject prefix.

>  	u64 rate, burst;
>  	u32 index;
>  
> @@ -2271,8 +2271,7 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
>  	flow_action_for_each(i, a, &f->rule->action) {
>  		switch (a->id) {
>  		case FLOW_ACTION_GATE:
> -			size = struct_size(sgi, entries, a->gate.num_entries);
> -			sgi = kzalloc(size, GFP_KERNEL);
> +			sgi = kzalloc_flex(*sgi, entries, a->gate.num_entries, GFP_KERNEL);
>  			if (!sgi) {
>  				ret = -ENOMEM;
>  				goto err;
> -- 
> 2.53.0
>

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

end of thread, other threads:[~2026-02-26 13:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-25  4:03 [PATCH] net: dsa: felix: use kmalloc_flex helper Rosen Penev
2026-02-25  9:13 ` Jijie Shao
2026-02-26 12:23 ` Simon Horman
2026-02-26 13:03 ` Vladimir Oltean

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