Subject: Re: [PATCH RFC 06/28] net: dsa: Have the switch driver allocate there own private memory

From: Florian Fainelli <[email-masked]>
Date: Wed, 23 Dec 2015 12:39:19 -0800

Le 23/12/2015 04:56, Andrew Lunn a écrit :
> Now the switch devices have a dev pointer, make use if it for allocating
> the drivers private data structures using a devm_kzalloc().
> 
> Signed-off-by: Andrew Lunn <[email-masked]>
> ---
>  drivers/net/dsa/bcm_sf2.c   |  7 +++++--
>  drivers/net/dsa/mv88e6123.c |  6 +++---
>  drivers/net/dsa/mv88e6131.c |  6 +++---
>  drivers/net/dsa/mv88e6171.c |  6 +++---
>  drivers/net/dsa/mv88e6352.c |  6 +++---
>  drivers/net/dsa/mv88e6xxx.c | 13 ++++++++++---
>  drivers/net/dsa/mv88e6xxx.h |  5 ++++-
>  include/net/dsa.h           |  8 +++++++-
>  8 files changed, 38 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index 6925b3c13895..23326c2a01b8 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -929,7 +929,7 @@ static void bcm_sf2_identify_ports(struct bcm_sf2_priv *priv,
>  static int bcm_sf2_sw_setup(struct dsa_switch *ds, struct device *dev)
>  {
>  	const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME;
> -	struct bcm_sf2_priv *priv = ds_to_priv(ds);
> +	struct bcm_sf2_priv *priv;
>  	struct device_node *dn;
>  	void __iomem **base;
>  	unsigned int port;
> @@ -937,6 +937,10 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds, struct device *dev)
>  	u32 reg, rev;
>  	int ret;
>  
> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;

This looks fine overall, except that part, there is an earlier priv =
ds_to_priv() in the function so we might be missing a ds->priv = priv
here once the allocation is successful.

With that fixed: Acked-by: Florian Fainelli <[email-masked]>
-- 
Florian