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

net: dsa: Simplify 'dsa_tag_protocol_to_str()'

There is no point in preparing the module name in a buffer. The format
string can be passed diectly to 'request_module()'.

This axes a few lines of code and cleans a few things:
- max len for a driver name is MODULE_NAME_LEN wich is ~ 60 chars,
not 128. It would be down-sized in 'request_module()'
- we should pass the total size of the buffer to 'snprintf()', not the
size minus 1

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Christophe JAILLET and committed by
David S. Miller
ee91a83e 32109c70

+1 -5
+1 -5
net/dsa/dsa.c
··· 88 88 { 89 89 struct dsa_tag_driver *dsa_tag_driver; 90 90 const struct dsa_device_ops *ops; 91 - char module_name[128]; 92 91 bool found = false; 93 92 94 - snprintf(module_name, 127, "%s%d", DSA_TAG_DRIVER_ALIAS, 95 - tag_protocol); 96 - 97 - request_module(module_name); 93 + request_module("%s%d", DSA_TAG_DRIVER_ALIAS, tag_protocol); 98 94 99 95 mutex_lock(&dsa_tag_drivers_lock); 100 96 list_for_each_entry(dsa_tag_driver, &dsa_tag_drivers_list, list) {