]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/can/af_can.c
block: send disk "change" event for rescan_partitions()
[linux-2.6-omap-h63xx.git] / net / can / af_can.c
index 5158e886630f3c2ba732a4c7df8f5d34abd8607c..2759b76f731c30461d6205db15e1c2bad4efb8c4 100644 (file)
@@ -118,7 +118,6 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
 {
        struct sock *sk;
        struct can_proto *cp;
-       char module_name[sizeof("can-proto-000")];
        int err = 0;
 
        sock->state = SS_UNCONNECTED;
@@ -129,26 +128,21 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
        if (net != &init_net)
                return -EAFNOSUPPORT;
 
+#ifdef CONFIG_KMOD
        /* try to load protocol module, when CONFIG_KMOD is defined */
        if (!proto_tab[protocol]) {
-               sprintf(module_name, "can-proto-%d", protocol);
-               err = request_module(module_name);
+               err = request_module("can-proto-%d", protocol);
 
                /*
                 * In case of error we only print a message but don't
                 * return the error code immediately.  Below we will
                 * return -EPROTONOSUPPORT
                 */
-               if (err == -ENOSYS) {
-                       if (printk_ratelimit())
-                               printk(KERN_INFO "can: request_module(%s)"
-                                      " not implemented.\n", module_name);
-               } else if (err) {
-                       if (printk_ratelimit())
-                               printk(KERN_ERR "can: request_module(%s)"
-                                      " failed.\n", module_name);
-               }
+               if (err && printk_ratelimit())
+                       printk(KERN_ERR "can: request_module "
+                              "(can-proto-%d) failed.\n", protocol);
        }
+#endif
 
        spin_lock(&proto_tab_lock);
        cp = proto_tab[protocol];
@@ -605,7 +599,7 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev,
        struct dev_rcv_lists *d;
        int matches;
 
-       if (dev->type != ARPHRD_CAN || dev->nd_net != &init_net) {
+       if (dev->type != ARPHRD_CAN || dev_net(dev) != &init_net) {
                kfree_skb(skb);
                return 0;
        }
@@ -662,26 +656,26 @@ int can_proto_register(struct can_proto *cp)
                return -EINVAL;
        }
 
+       err = proto_register(cp->prot, 0);
+       if (err < 0)
+               return err;
+
        spin_lock(&proto_tab_lock);
        if (proto_tab[proto]) {
                printk(KERN_ERR "can: protocol %d already registered\n",
                       proto);
                err = -EBUSY;
-               goto errout;
+       } else {
+               proto_tab[proto] = cp;
+
+               /* use generic ioctl function if not defined by module */
+               if (!cp->ops->ioctl)
+                       cp->ops->ioctl = can_ioctl;
        }
+       spin_unlock(&proto_tab_lock);
 
-       err = proto_register(cp->prot, 0);
        if (err < 0)
-               goto errout;
-
-       proto_tab[proto] = cp;
-
-       /* use generic ioctl function if the module doesn't bring its own */
-       if (!cp->ops->ioctl)
-               cp->ops->ioctl = can_ioctl;
-
- errout:
-       spin_unlock(&proto_tab_lock);
+               proto_unregister(cp->prot);
 
        return err;
 }
@@ -700,9 +694,10 @@ void can_proto_unregister(struct can_proto *cp)
                printk(KERN_ERR "BUG: can: protocol %d is not registered\n",
                       proto);
        }
-       proto_unregister(cp->prot);
        proto_tab[proto] = NULL;
        spin_unlock(&proto_tab_lock);
+
+       proto_unregister(cp->prot);
 }
 EXPORT_SYMBOL(can_proto_unregister);
 
@@ -715,7 +710,7 @@ static int can_notifier(struct notifier_block *nb, unsigned long msg,
        struct net_device *dev = (struct net_device *)data;
        struct dev_rcv_lists *d;
 
-       if (dev->nd_net != &init_net)
+       if (dev_net(dev) != &init_net)
                return NOTIFY_DONE;
 
        if (dev->type != ARPHRD_CAN)