Skip to content

Commit 548ec11

Browse files
Lin Zhangdavem330
authored andcommitted
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>
1 parent 6423747 commit 548ec11

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

‎include/net/phonet/phonet.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ struct phonet_protocol {
108108
int sock_type;
109109
};
110110

111-
int phonet_proto_register(unsigned int protocol, struct phonet_protocol *pp);
112-
void phonet_proto_unregister(unsigned int protocol, struct phonet_protocol *pp);
111+
int phonet_proto_register(unsigned int protocol,
112+
const struct phonet_protocol *pp);
113+
void phonet_proto_unregister(unsigned int protocol,
114+
const struct phonet_protocol *pp);
113115

114116
int phonet_sysctl_init(void);
115117
void phonet_sysctl_exit(void);

‎net/phonet/af_phonet.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
#include <net/phonet/pn_dev.h>
3636

3737
/* 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;
3939

40-
static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
40+
static const struct phonet_protocol *phonet_proto_get(unsigned int protocol)
4141
{
42-
struct phonet_protocol *pp;
42+
const struct phonet_protocol *pp;
4343

4444
if (protocol >= PHONET_NPROTO)
4545
return NULL;
@@ -53,7 +53,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
5353
return pp;
5454
}
5555

56-
static inline void phonet_proto_put(struct phonet_protocol *pp)
56+
static inline void phonet_proto_put(const struct phonet_protocol *pp)
5757
{
5858
module_put(pp->prot->owner);
5959
}
@@ -65,7 +65,7 @@ static int pn_socket_create(struct net *net, struct socket *sock, int protocol,
6565
{
6666
struct sock *sk;
6767
struct pn_sock *pn;
68-
struct phonet_protocol *pnp;
68+
const struct phonet_protocol *pnp;
6969
int err;
7070

7171
if (!capable(CAP_SYS_ADMIN))
@@ -470,7 +470,7 @@ static struct packet_type phonet_packet_type __read_mostly = {
470470
static DEFINE_MUTEX(proto_tab_lock);
471471

472472
int __init_or_module phonet_proto_register(unsigned int protocol,
473-
struct phonet_protocol *pp)
473+
const struct phonet_protocol *pp)
474474
{
475475
int err = 0;
476476

@@ -492,7 +492,8 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
492492
}
493493
EXPORT_SYMBOL(phonet_proto_register);
494494

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)
496497
{
497498
mutex_lock(&proto_tab_lock);
498499
BUG_ON(proto_tab[protocol] != pp);

‎net/phonet/datagram.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static struct proto pn_proto = {
195195
.name = "PHONET",
196196
};
197197

198-
static struct phonet_protocol pn_dgram_proto = {
198+
static const struct phonet_protocol pn_dgram_proto = {
199199
.ops = &phonet_dgram_ops,
200200
.prot = &pn_proto,
201201
.sock_type = SOCK_DGRAM,

‎net/phonet/pep.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ static struct proto pep_proto = {
13511351
.name = "PNPIPE",
13521352
};
13531353

1354-
static struct phonet_protocol pep_pn_proto = {
1354+
static const struct phonet_protocol pep_pn_proto = {
13551355
.ops = &phonet_stream_ops,
13561356
.prot = &pep_proto,
13571357
.sock_type = SOCK_SEQPACKET,

0 commit comments

Comments
 (0)