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