Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: mv88e6xxx: Use kcalloc()

Use kcalloc() instead of hand writing it. This is less verbose.

Also move the initialization of 'count' to save some LoC.

On a x86_64, with allmodconfig, as an example:
Before:
======
text data bss dec hex filename
18652 5920 64 24636 603c drivers/net/dsa/mv88e6xxx/devlink.o

After:
=====
text data bss dec hex filename
18498 5920 64 24482 5fa2 drivers/net/dsa/mv88e6xxx/devlink.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/2f4fca4ff84950da71e007c9169f18a0272476f3.1751200453.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Christophe JAILLET and committed by
Jakub Kicinski
a63b5a0b ff2d4cfd

+4 -9
+4 -9
drivers/net/dsa/mv88e6xxx/devlink.c
··· 376 376 struct dsa_switch *ds = dsa_devlink_to_ds(dl); 377 377 struct mv88e6xxx_devlink_atu_entry *table; 378 378 struct mv88e6xxx_chip *chip = ds->priv; 379 - int fid = -1, err = 0, count; 379 + int fid = -1, err = 0, count = 0; 380 380 381 - table = kmalloc_array(mv88e6xxx_num_databases(chip), 382 - sizeof(struct mv88e6xxx_devlink_atu_entry), 383 - GFP_KERNEL); 381 + table = kcalloc(mv88e6xxx_num_databases(chip), 382 + sizeof(struct mv88e6xxx_devlink_atu_entry), 383 + GFP_KERNEL); 384 384 if (!table) 385 385 return -ENOMEM; 386 - 387 - memset(table, 0, mv88e6xxx_num_databases(chip) * 388 - sizeof(struct mv88e6xxx_devlink_atu_entry)); 389 - 390 - count = 0; 391 386 392 387 mv88e6xxx_reg_lock(chip); 393 388