]> rtime.felk.cvut.cz Git - socketcan-devel.git/commitdiff
can: make struct proto const
authorhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Tue, 19 Apr 2011 13:03:41 +0000 (13:03 +0000)
committerhartkopp <hartkopp@030b6a49-0b11-0410-94ab-b0dab22257f2>
Tue, 19 Apr 2011 13:03:41 +0000 (13:03 +0000)
can_ioctl is the only reason for struct proto to be non-const.
script/check-patch.pl suggests struct proto be const.

Setting the reference to the common can_ioctl() in all CAN protocols directly
removes the need to make the struct proto writable in af_can.c

Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
git-svn-id: svn://svn.berlios.de//socketcan/trunk@1237 030b6a49-0b11-0410-94ab-b0dab22257f2

kernel/2.6/include/socketcan/can/core.h
kernel/2.6/net/can/af_can.c
kernel/2.6/net/can/bcm-prior-2-6-22.c
kernel/2.6/net/can/bcm.c
kernel/2.6/net/can/isotp.c
kernel/2.6/net/can/raw.c

index b8a17b126c5761a85ea2cdf8a744e0304985b9e4..af7fd6506149a08c274a452460c628a177c02490 100644 (file)
  * @prot:       pointer to struct proto structure.
  */
 struct can_proto {
-       int              type;
-       int              protocol;
+       int type;
+       int protocol;
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
-       int              capability;
+       int capability;
 #endif
-       struct proto_ops *ops;
+       const struct proto_ops *ops;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
-       struct proto     *prot;
+       struct proto *prot;
 #else
-       struct module    *owner;
-       int              (*init)(struct sock *sk);
-       size_t           obj_size;
+       struct module *owner;
+       int (*init)(struct sock *sk);
+       size_t obj_size;
 #endif
 };
 
@@ -70,5 +70,6 @@ extern void can_rx_unregister(struct net_device *dev, canid_t can_id,
                              void *data);
 
 extern int can_send(struct sk_buff *skb, int loop);
+extern int can_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
 
 #endif /* CAN_CORE_H */
index e3f7b3ccc94f3e57a9e970ff27662d2c12f9d1f5..98b9f36c92c33079a2b3531229d497036b8843e9 100644 (file)
@@ -112,7 +112,7 @@ struct s_pstats   can_pstats;      /* receive list statistics */
  * af_can socket functions
  */
 
-static int can_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
+int can_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 {
        struct sock *sk = sock->sk;
 
@@ -129,6 +129,7 @@ static int can_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 #endif
        }
 }
+EXPORT_SYMBOL(can_ioctl);
 
 static void can_sock_destruct(struct sock *sk)
 {
@@ -867,13 +868,9 @@ int can_proto_register(struct can_proto *cp)
                printk(KERN_ERR "can: protocol %d already registered\n",
                       proto);
                err = -EBUSY;
-       } else {
+       } 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);
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
index 4e47e9c268f0bdc4d2cd37e5524e48268aa1e395..bc58c79e433a02a9fba219069a853e91f21b83ee 100644 (file)
@@ -1545,7 +1545,7 @@ static int bcm_recvmsg(struct kiocb *iocb, struct socket *sock,
        return size;
 }
 
-static struct proto_ops bcm_ops __read_mostly = {
+static const struct proto_ops bcm_ops = {
        .family        = PF_CAN,
        .release       = bcm_release,
        .bind          = sock_no_bind,
@@ -1554,7 +1554,7 @@ static struct proto_ops bcm_ops __read_mostly = {
        .accept        = sock_no_accept,
        .getname       = sock_no_getname,
        .poll          = datagram_poll,
-       .ioctl         = NULL,          /* use can_ioctl() from af_can.c */
+       .ioctl         = can_ioctl,     /* use can_ioctl() from af_can.c */
        .listen        = sock_no_listen,
        .shutdown      = sock_no_shutdown,
        .setsockopt    = sock_no_setsockopt,
index a33218b9ed1155f5b7c1667617bb728c650e3390..c1b0ed8bfcffe6a708623d2b8c57536afc11beea 100644 (file)
@@ -1702,7 +1702,7 @@ static int bcm_recvmsg(struct kiocb *iocb, struct socket *sock,
        return size;
 }
 
-static struct proto_ops bcm_ops __read_mostly = {
+static const struct proto_ops bcm_ops = {
        .family        = PF_CAN,
        .release       = bcm_release,
        .bind          = sock_no_bind,
@@ -1711,7 +1711,7 @@ static struct proto_ops bcm_ops __read_mostly = {
        .accept        = sock_no_accept,
        .getname       = sock_no_getname,
        .poll          = datagram_poll,
-       .ioctl         = NULL,          /* use can_ioctl() from af_can.c */
+       .ioctl         = can_ioctl,     /* use can_ioctl() from af_can.c */
        .listen        = sock_no_listen,
        .shutdown      = sock_no_shutdown,
        .setsockopt    = sock_no_setsockopt,
index b8249845002d4fa819afa1372678998299205df3..21477e2a4c72bf3e59b17a02f2b2b353c1704829 100644 (file)
@@ -1126,7 +1126,7 @@ static int isotp_init(struct sock *sk)
 }
 
 
-static struct proto_ops isotp_ops __read_mostly = {
+static const struct proto_ops isotp_ops = {
        .family        = PF_CAN,
        .release       = isotp_release,
        .bind          = isotp_bind,
@@ -1135,7 +1135,7 @@ static struct proto_ops isotp_ops __read_mostly = {
        .accept        = sock_no_accept,
        .getname       = isotp_getname,
        .poll          = datagram_poll,
-       .ioctl         = NULL,          /* use can_ioctl() from af_can.c */
+       .ioctl         = can_ioctl,     /* use can_ioctl() from af_can.c */
        .listen        = sock_no_listen,
        .shutdown      = sock_no_shutdown,
        .setsockopt    = isotp_setsockopt,
index 68937ce7b3905995fcb44fceaa4b7fa6badffcb8..5ab46cea80890f3c440ba616055fff3330a5526c 100644 (file)
@@ -774,7 +774,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct socket *sock,
        return size;
 }
 
-static struct proto_ops raw_ops __read_mostly = {
+static const struct proto_ops raw_ops = {
        .family        = PF_CAN,
        .release       = raw_release,
        .bind          = raw_bind,
@@ -783,7 +783,7 @@ static struct proto_ops raw_ops __read_mostly = {
        .accept        = sock_no_accept,
        .getname       = raw_getname,
        .poll          = datagram_poll,
-       .ioctl         = NULL,          /* use can_ioctl() from af_can.c */
+       .ioctl         = can_ioctl,     /* use can_ioctl() from af_can.c */
        .listen        = sock_no_listen,
        .shutdown      = sock_no_shutdown,
        .setsockopt    = raw_setsockopt,