[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7f0c4c6a-a6fd-5c4f-9c40-f23f694cee6f@cogentembedded.com>
Date: Sun, 14 May 2017 12:13:37 +0300
From: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To: Andrew Lunn <andrew@...n.ch>, Woojung.Huh@...rochip.com
Cc: f.fainelli@...il.com, vivien.didelot@...oirfairelinux.com,
netdev@...r.kernel.org, davem@...emloft.net,
UNGLinuxDriver@...rochip.com
Subject: Re: [PATCH v2 net-next 3/5] dsa: add DSA switch driver for Microchip
KSZ9477
Hello!
On 5/13/2017 5:56 PM, Andrew Lunn wrote:
[...]
>> +static int ksz_reset_switch(struct dsa_switch *ds)
>> +{
>> + struct ksz_device *dev = ds->priv;
>> + u8 data8;
>> + u16 data16;
>> + u32 data32;
>> +
>
> ...
>
>> +
>> + memset(dev->vlan_cache, 0, sizeof(*dev->vlan_cache) * dev->num_vlans);
>> +
>> + return 0;
>> +}
>
>> +static int ksz_setup(struct dsa_switch *ds)
>> +{
>> + struct ksz_device *dev = ds->priv;
>> + int ret = 0;
>> +
>> + dev->vlan_cache = devm_kmalloc_array(dev->dev,
>> + sizeof(struct vlan_table),
>> + dev->num_vlans, GFP_KERNEL);
>
> You should check, but i think devm_kmalloc_array sets the allocated
> memory to 0.
No. Else there would be no need for it, since kcalloc() is a function that
allocates the arrays and zeroes them.
> So i don't think you need the memset. If it is needed, i
> would move it here, after the check the allocation is successful.
If it could be done here, kcalloc() should be used.
[...]
MBR, Sergei
Powered by blists - more mailing lists