From: hartkopp Date: Thu, 5 May 2011 14:55:40 +0000 (+0000) Subject: can: rename can_try_module_get to can_get_proto X-Git-Url: http://rtime.felk.cvut.cz/gitweb/socketcan-devel.git/commitdiff_plain/b6c64c58563bdb6d720f5c369bd426472144c955 can: rename can_try_module_get to can_get_proto 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 Acked-by: Oliver Hartkopp git-svn-id: svn://svn.berlios.de//socketcan/trunk@1253 030b6a49-0b11-0410-94ab-b0dab22257f2 --- diff --git a/kernel/2.6/net/can/af_can.c b/kernel/2.6/net/can/af_can.c index 91f8727..be0b066 100644 --- a/kernel/2.6/net/can/af_can.c +++ b/kernel/2.6/net/can/af_can.c @@ -140,7 +140,7 @@ static void can_sock_destruct(struct sock *sk) #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; @@ -158,6 +158,15 @@ static const struct can_proto *can_try_module_get(int protocol) 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) @@ -180,7 +189,7 @@ static int can_create(struct socket *sock, int protocol) return -EAFNOSUPPORT; #endif - cp = can_try_module_get(protocol); + cp = can_get_proto(protocol); #ifdef CONFIG_MODULES if (!cp) { @@ -197,7 +206,7 @@ static int can_create(struct socket *sock, int protocol) printk(KERN_ERR "can: request_module " "(can-proto-%d) failed.\n", protocol); - cp = can_try_module_get(protocol); + cp = can_get_proto(protocol); } #endif @@ -261,11 +270,7 @@ static int can_create(struct socket *sock, int protocol) } 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; }