]> rtime.felk.cvut.cz Git - socketcan-devel.git/commitdiff
can: rename can_try_module_get to can_get_proto
authorhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Thu, 5 May 2011 14:55:40 +0000 (14:55 +0000)
committerhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Thu, 5 May 2011 14:55:40 +0000 (14:55 +0000)
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

kernel/2.6/net/can/af_can.c

index 91f872764c093749320f5fcf775a8f12cf49fbf6..be0b06617639e62080ea85b7ce2663a3ca931918 100644 (file)
@@ -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;
 }