can_try_module_get does return a struct can_proto.
The name explains what is done in so much detail that a caller
may not notice that a struct can_proto is locked/unlocked.
Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1253
030b6a49-0b11-0410-94ab-
b0dab22257f2
-static const struct can_proto *can_try_module_get(int protocol)
+static const struct can_proto *can_get_proto(int protocol)
{
const struct can_proto *cp;
{
const struct can_proto *cp;
+static inline void can_put_proto(const struct can_proto *cp)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
+ module_put(cp->prot->owner);
+#else
+ module_put(cp->owner);
+#endif
+}
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
static int can_create(struct net *net, struct socket *sock, int protocol, int kern)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
static int can_create(struct net *net, struct socket *sock, int protocol, int kern)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
return -EAFNOSUPPORT;
#endif
return -EAFNOSUPPORT;
#endif
- cp = can_try_module_get(protocol);
+ cp = can_get_proto(protocol);
#ifdef CONFIG_MODULES
if (!cp) {
#ifdef CONFIG_MODULES
if (!cp) {
printk(KERN_ERR "can: request_module "
"(can-proto-%d) failed.\n", protocol);
printk(KERN_ERR "can: request_module "
"(can-proto-%d) failed.\n", protocol);
- cp = can_try_module_get(protocol);
+ cp = can_get_proto(protocol);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
- module_put(cp->prot->owner);
-#else
- module_put(cp->owner);
-#endif