[CAN]: Move proto_{,un}register() out of spin-locked region
The implementation of proto_register() has changed so that it can now sleep. The call to proto_register() must be moved out of the spin-locked region. 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
5423dd67bd
commit
a2fea5f19f
1 changed files with 15 additions and 14 deletions
|
@ -656,27 +656,27 @@ int can_proto_register(struct can_proto *cp)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = proto_register(cp->prot, 0);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
spin_lock(&proto_tab_lock);
|
spin_lock(&proto_tab_lock);
|
||||||
if (proto_tab[proto]) {
|
if (proto_tab[proto]) {
|
||||||
printk(KERN_ERR "can: protocol %d already registered\n",
|
printk(KERN_ERR "can: protocol %d already registered\n",
|
||||||
proto);
|
proto);
|
||||||
err = -EBUSY;
|
err = -EBUSY;
|
||||||
goto errout;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
err = proto_register(cp->prot, 0);
|
|
||||||
if (err < 0)
|
|
||||||
goto errout;
|
|
||||||
|
|
||||||
proto_tab[proto] = cp;
|
proto_tab[proto] = cp;
|
||||||
|
|
||||||
/* use generic ioctl function if the module doesn't bring its own */
|
/* use generic ioctl function if not defined by module */
|
||||||
if (!cp->ops->ioctl)
|
if (!cp->ops->ioctl)
|
||||||
cp->ops->ioctl = can_ioctl;
|
cp->ops->ioctl = can_ioctl;
|
||||||
|
}
|
||||||
errout:
|
|
||||||
spin_unlock(&proto_tab_lock);
|
spin_unlock(&proto_tab_lock);
|
||||||
|
|
||||||
|
if (err < 0)
|
||||||
|
proto_unregister(cp->prot);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(can_proto_register);
|
EXPORT_SYMBOL(can_proto_register);
|
||||||
|
@ -694,9 +694,10 @@ void can_proto_unregister(struct can_proto *cp)
|
||||||
printk(KERN_ERR "BUG: can: protocol %d is not registered\n",
|
printk(KERN_ERR "BUG: can: protocol %d is not registered\n",
|
||||||
proto);
|
proto);
|
||||||
}
|
}
|
||||||
proto_unregister(cp->prot);
|
|
||||||
proto_tab[proto] = NULL;
|
proto_tab[proto] = NULL;
|
||||||
spin_unlock(&proto_tab_lock);
|
spin_unlock(&proto_tab_lock);
|
||||||
|
|
||||||
|
proto_unregister(cp->prot);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(can_proto_unregister);
|
EXPORT_SYMBOL(can_proto_unregister);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue