#endif
}
-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;
return 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)
return -EAFNOSUPPORT;
#endif
- cp = can_try_module_get(protocol);
+ cp = can_get_proto(protocol);
#ifdef CONFIG_MODULES
if (!cp) {
printk(KERN_ERR "can: request_module "
"(can-proto-%d) failed.\n", protocol);
- cp = can_try_module_get(protocol);
+ cp = can_get_proto(protocol);
}
#endif
}
errout:
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
- module_put(cp->prot->owner);
-#else
- module_put(cp->owner);
-#endif
+ can_put_proto(cp);
return err;
}