net: phonet: mark phonet_protocol as const
authorLin Zhang <xiaolou4617@gmail.com>
Thu, 5 Oct 2017 17:40:35 +0000 (01:40 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 7 Oct 2017 22:15:08 +0000 (23:15 +0100)
The phonet_protocol structs don't need to be written by anyone and
so can be marked as const.

Signed-off-by: Lin Zhang <xiaolou4617@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/phonet/phonet.h
net/phonet/af_phonet.c
net/phonet/datagram.c
net/phonet/pep.c

index 039cc29cb4a81284d29935c23451a84f04fe1ded..51e1a2a45d027bf68a15813da132b02a4f5ad6fe 100644 (file)
@@ -108,8 +108,10 @@ struct phonet_protocol {
        int                     sock_type;
 };
 
-int phonet_proto_register(unsigned int protocol, struct phonet_protocol *pp);
-void phonet_proto_unregister(unsigned int protocol, struct phonet_protocol *pp);
+int phonet_proto_register(unsigned int protocol,
+               const struct phonet_protocol *pp);
+void phonet_proto_unregister(unsigned int protocol,
+               const struct phonet_protocol *pp);
 
 int phonet_sysctl_init(void);
 void phonet_sysctl_exit(void);
index b12142e55d199b0fd74c3c81ebbd1095fcc24839..3b0ef691f5b1ba532a19e74c910356ada9ac3b6c 100644 (file)
 #include <net/phonet/pn_dev.h>
 
 /* Transport protocol registration */
-static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly;
+static const struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly;
 
-static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
+static const struct phonet_protocol *phonet_proto_get(unsigned int protocol)
 {
-       struct phonet_protocol *pp;
+       const struct phonet_protocol *pp;
 
        if (protocol >= PHONET_NPROTO)
                return NULL;
@@ -53,7 +53,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
        return pp;
 }
 
-static inline void phonet_proto_put(struct phonet_protocol *pp)
+static inline void phonet_proto_put(const struct phonet_protocol *pp)
 {
        module_put(pp->prot->owner);
 }
@@ -65,7 +65,7 @@ static int pn_socket_create(struct net *net, struct socket *sock, int protocol,
 {
        struct sock *sk;
        struct pn_sock *pn;
-       struct phonet_protocol *pnp;
+       const struct phonet_protocol *pnp;
        int err;
 
        if (!capable(CAP_SYS_ADMIN))
@@ -470,7 +470,7 @@ static struct packet_type phonet_packet_type __read_mostly = {
 static DEFINE_MUTEX(proto_tab_lock);
 
 int __init_or_module phonet_proto_register(unsigned int protocol,
-                                               struct phonet_protocol *pp)
+                               const struct phonet_protocol *pp)
 {
        int err = 0;
 
@@ -492,7 +492,8 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
 }
 EXPORT_SYMBOL(phonet_proto_register);
 
-void phonet_proto_unregister(unsigned int protocol, struct phonet_protocol *pp)
+void phonet_proto_unregister(unsigned int protocol,
+                       const struct phonet_protocol *pp)
 {
        mutex_lock(&proto_tab_lock);
        BUG_ON(proto_tab[protocol] != pp);
index 5e710435ffa96943a59184de054553739e70d953..b44fb9018fb83f243e95df257f55e17257ec0392 100644 (file)
@@ -195,7 +195,7 @@ static struct proto pn_proto = {
        .name           = "PHONET",
 };
 
-static struct phonet_protocol pn_dgram_proto = {
+static const struct phonet_protocol pn_dgram_proto = {
        .ops            = &phonet_dgram_ops,
        .prot           = &pn_proto,
        .sock_type      = SOCK_DGRAM,
index e81537991ddf0d67e6eca19fc9eb6f442d3c06a4..9fc76b19cd3c17289604976f61accfb8013eabd6 100644 (file)
@@ -1351,7 +1351,7 @@ static struct proto pep_proto = {
        .name           = "PNPIPE",
 };
 
-static struct phonet_protocol pep_pn_proto = {
+static const struct phonet_protocol pep_pn_proto = {
        .ops            = &phonet_stream_ops,
        .prot           = &pep_proto,
        .sock_type      = SOCK_SEQPACKET,