diff options
author | Lin Zhang <xiaolou4617@gmail.com> | 2017-10-05 13:40:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-07 18:15:08 -0400 |
commit | 548ec114705bb8f0879a0da12abec17f17a7cc26 (patch) | |
tree | 2109c7f34d7bea667c3a0540470dbf644016e0bd /net/phonet | |
parent | 64237470ddf97b63155fbd272c9e743e01d5f514 (diff) |
net: phonet: mark phonet_protocol as const
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>
Diffstat (limited to 'net/phonet')
-rw-r--r-- | net/phonet/af_phonet.c | 15 | ||||
-rw-r--r-- | net/phonet/datagram.c | 2 | ||||
-rw-r--r-- | net/phonet/pep.c | 2 |
3 files changed, 10 insertions, 9 deletions
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index b12142e55d19..3b0ef691f5b1 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c | |||
@@ -35,11 +35,11 @@ | |||
35 | #include <net/phonet/pn_dev.h> | 35 | #include <net/phonet/pn_dev.h> |
36 | 36 | ||
37 | /* Transport protocol registration */ | 37 | /* Transport protocol registration */ |
38 | static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly; | 38 | static const struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly; |
39 | 39 | ||
40 | static struct phonet_protocol *phonet_proto_get(unsigned int protocol) | 40 | static const struct phonet_protocol *phonet_proto_get(unsigned int protocol) |
41 | { | 41 | { |
42 | struct phonet_protocol *pp; | 42 | const struct phonet_protocol *pp; |
43 | 43 | ||
44 | if (protocol >= PHONET_NPROTO) | 44 | if (protocol >= PHONET_NPROTO) |
45 | return NULL; | 45 | return NULL; |
@@ -53,7 +53,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol) | |||
53 | return pp; | 53 | return pp; |
54 | } | 54 | } |
55 | 55 | ||
56 | static inline void phonet_proto_put(struct phonet_protocol *pp) | 56 | static inline void phonet_proto_put(const struct phonet_protocol *pp) |
57 | { | 57 | { |
58 | module_put(pp->prot->owner); | 58 | module_put(pp->prot->owner); |
59 | } | 59 | } |
@@ -65,7 +65,7 @@ static int pn_socket_create(struct net *net, struct socket *sock, int protocol, | |||
65 | { | 65 | { |
66 | struct sock *sk; | 66 | struct sock *sk; |
67 | struct pn_sock *pn; | 67 | struct pn_sock *pn; |
68 | struct phonet_protocol *pnp; | 68 | const struct phonet_protocol *pnp; |
69 | int err; | 69 | int err; |
70 | 70 | ||
71 | if (!capable(CAP_SYS_ADMIN)) | 71 | if (!capable(CAP_SYS_ADMIN)) |
@@ -470,7 +470,7 @@ static struct packet_type phonet_packet_type __read_mostly = { | |||
470 | static DEFINE_MUTEX(proto_tab_lock); | 470 | static DEFINE_MUTEX(proto_tab_lock); |
471 | 471 | ||
472 | int __init_or_module phonet_proto_register(unsigned int protocol, | 472 | int __init_or_module phonet_proto_register(unsigned int protocol, |
473 | struct phonet_protocol *pp) | 473 | const struct phonet_protocol *pp) |
474 | { | 474 | { |
475 | int err = 0; | 475 | int err = 0; |
476 | 476 | ||
@@ -492,7 +492,8 @@ int __init_or_module phonet_proto_register(unsigned int protocol, | |||
492 | } | 492 | } |
493 | EXPORT_SYMBOL(phonet_proto_register); | 493 | EXPORT_SYMBOL(phonet_proto_register); |
494 | 494 | ||
495 | void phonet_proto_unregister(unsigned int protocol, struct phonet_protocol *pp) | 495 | void phonet_proto_unregister(unsigned int protocol, |
496 | const struct phonet_protocol *pp) | ||
496 | { | 497 | { |
497 | mutex_lock(&proto_tab_lock); | 498 | mutex_lock(&proto_tab_lock); |
498 | BUG_ON(proto_tab[protocol] != pp); | 499 | BUG_ON(proto_tab[protocol] != pp); |
diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c index 5e710435ffa9..b44fb9018fb8 100644 --- a/net/phonet/datagram.c +++ b/net/phonet/datagram.c | |||
@@ -195,7 +195,7 @@ static struct proto pn_proto = { | |||
195 | .name = "PHONET", | 195 | .name = "PHONET", |
196 | }; | 196 | }; |
197 | 197 | ||
198 | static struct phonet_protocol pn_dgram_proto = { | 198 | static const struct phonet_protocol pn_dgram_proto = { |
199 | .ops = &phonet_dgram_ops, | 199 | .ops = &phonet_dgram_ops, |
200 | .prot = &pn_proto, | 200 | .prot = &pn_proto, |
201 | .sock_type = SOCK_DGRAM, | 201 | .sock_type = SOCK_DGRAM, |
diff --git a/net/phonet/pep.c b/net/phonet/pep.c index e81537991ddf..9fc76b19cd3c 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c | |||
@@ -1351,7 +1351,7 @@ static struct proto pep_proto = { | |||
1351 | .name = "PNPIPE", | 1351 | .name = "PNPIPE", |
1352 | }; | 1352 | }; |
1353 | 1353 | ||
1354 | static struct phonet_protocol pep_pn_proto = { | 1354 | static const struct phonet_protocol pep_pn_proto = { |
1355 | .ops = &phonet_stream_ops, | 1355 | .ops = &phonet_stream_ops, |
1356 | .prot = &pep_proto, | 1356 | .prot = &pep_proto, |
1357 | .sock_type = SOCK_SEQPACKET, | 1357 | .sock_type = SOCK_SEQPACKET, |