]> rtime.felk.cvut.cz Git - socketcan-devel.git/blobdiff - kernel/2.6/net/can/af_can.c
can: rename can_try_module_get to can_get_proto
[socketcan-devel.git] / kernel / 2.6 / net / can / af_can.c
index 81756d15871f6af3397bbb7a036552c2accb5728..be0b06617639e62080ea85b7ce2663a3ca931918 100644 (file)
@@ -101,7 +101,7 @@ static kmem_cache_t *rcv_cache;
 #endif
 
 /* table of registered CAN protocols */
-static struct can_proto *proto_tab[CAN_NPROTO] __read_mostly;
+static const struct can_proto *proto_tab[CAN_NPROTO] __read_mostly;
 static DEFINE_MUTEX(proto_tab_lock);
 
 struct timer_list can_stattimer;   /* timer for statistics update */
@@ -140,9 +140,9 @@ static void can_sock_destruct(struct sock *sk)
 #endif
 }
 
-static struct can_proto *can_try_module_get(int protocol)
+static const struct can_proto *can_get_proto(int protocol)
 {
-       struct can_proto *cp;
+       const struct can_proto *cp;
 
        rcu_read_lock();
        cp = rcu_dereference(proto_tab[protocol]);
@@ -158,6 +158,15 @@ static 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)
@@ -167,7 +176,7 @@ static int can_create(struct socket *sock, int protocol)
 #endif
 {
        struct sock *sk;
-       struct can_proto *cp;
+       const struct can_proto *cp;
        int err = 0;
 
        sock->state = SS_UNCONNECTED;
@@ -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;
 }
 
@@ -858,7 +863,7 @@ drop:
  *  -EBUSY  protocol already in use
  *  -ENOBUF if proto_register() fails
  */
-int can_proto_register(struct can_proto *cp)
+int can_proto_register(const struct can_proto *cp)
 {
        int proto = cp->protocol;
        int err = 0;
@@ -899,7 +904,7 @@ EXPORT_SYMBOL(can_proto_register);
  * can_proto_unregister - unregister CAN transport protocol
  * @cp: pointer to CAN protocol structure
  */
-void can_proto_unregister(struct can_proto *cp)
+void can_proto_unregister(const struct can_proto *cp)
 {
        int proto = cp->protocol;