[CAN]: Clean up module auto loading
Remove local char array to construct module name. Don't call request_module() when CONFIG_KMOD is not set. Signed-off-by: Urs Thuermann <urs.thuermann@volkswagen.de> Signed-off-by: Oliver Hartkopp <oliver.hartkopp@volkswagen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
5f58a5c872
commit
5423dd67bd
|
@ -118,7 +118,6 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
|
||||||
{
|
{
|
||||||
struct sock *sk;
|
struct sock *sk;
|
||||||
struct can_proto *cp;
|
struct can_proto *cp;
|
||||||
char module_name[sizeof("can-proto-000")];
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
sock->state = SS_UNCONNECTED;
|
sock->state = SS_UNCONNECTED;
|
||||||
|
@ -129,26 +128,21 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
|
||||||
if (net != &init_net)
|
if (net != &init_net)
|
||||||
return -EAFNOSUPPORT;
|
return -EAFNOSUPPORT;
|
||||||
|
|
||||||
|
#ifdef CONFIG_KMOD
|
||||||
/* try to load protocol module, when CONFIG_KMOD is defined */
|
/* try to load protocol module, when CONFIG_KMOD is defined */
|
||||||
if (!proto_tab[protocol]) {
|
if (!proto_tab[protocol]) {
|
||||||
sprintf(module_name, "can-proto-%d", protocol);
|
err = request_module("can-proto-%d", protocol);
|
||||||
err = request_module(module_name);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In case of error we only print a message but don't
|
* In case of error we only print a message but don't
|
||||||
* return the error code immediately. Below we will
|
* return the error code immediately. Below we will
|
||||||
* return -EPROTONOSUPPORT
|
* return -EPROTONOSUPPORT
|
||||||
*/
|
*/
|
||||||
if (err == -ENOSYS) {
|
if (err && printk_ratelimit())
|
||||||
if (printk_ratelimit())
|
printk(KERN_ERR "can: request_module "
|
||||||
printk(KERN_INFO "can: request_module(%s)"
|
"(can-proto-%d) failed.\n", protocol);
|
||||||
" not implemented.\n", module_name);
|
|
||||||
} else if (err) {
|
|
||||||
if (printk_ratelimit())
|
|
||||||
printk(KERN_ERR "can: request_module(%s)"
|
|
||||||
" failed.\n", module_name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
spin_lock(&proto_tab_lock);
|
spin_lock(&proto_tab_lock);
|
||||||
cp = proto_tab[protocol];
|
cp = proto_tab[protocol];
|
||||||
|
|
Loading…
Reference in New Issue