From patchwork Sat Sep 30 09:40:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Zhang X-Patchwork-Id: 820200 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EIoLtkzV"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y43Mb3FsBz9sRq for ; Sat, 30 Sep 2017 19:40:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752414AbdI3Jkz (ORCPT ); Sat, 30 Sep 2017 05:40:55 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35026 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751160AbdI3Jky (ORCPT ); Sat, 30 Sep 2017 05:40:54 -0400 Received: by mail-pg0-f65.google.com with SMTP id j16so1349194pga.2 for ; Sat, 30 Sep 2017 02:40:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=4rtRXaopM943z5baA3qWT+ZWFvq+1IfvlKajtJpjdJo=; b=EIoLtkzVrQft5Op4aNGr9EjH84UZW9kAvcT1UWlG7Wf4cc/vA4iZoBPDuHeXRosiRY grZxcJrwP9wwSY79q8/VOJHdt59/MJ9d8JqTpapUJ/LfEQRMzPQ4wagBpgWyTirniyS8 W5zRhc5lBk5KI8FxywmoGVPrS5cuKzFoM5NrQEdjrKuMaVM62jyIAKlNwgQlx/KHrpJF lBg/8nNKl1wCu1YhTIVw2GdwElEjs4Kqv3cl/sd+MNgPKlNXpoMjbzavvHuMurY0xKnR 0/vQubyMaDe7FFsEcFO3IWKS8+jqynTDtftJ5ViJmXPj38D7XxVbxIJTytf5jw37/zhH E3XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4rtRXaopM943z5baA3qWT+ZWFvq+1IfvlKajtJpjdJo=; b=Amw/3kSVHej+eD8oHPiixMNiwuj/QimFbaRopdvijWVbIgAGg2QXUOrnNJRuMBpAc3 7JtE/iOb8nEL6NiHAaILP3rKAz7TZisaqY4IPDAdVbCIEZBSWgV9M9GBin3EbRflmUvL y76cUzpiGyeyPoUIzB87OAdBMRf21LTCw+FL8JwBCFzhyO69Z2UGS/Oorr6jIha8532h XIEesLOYYOyhxDw1TE5BGkShx6aCWJTAUbqCGbur7ai4F2AiAe/zWxeQ6F1mSqADpdwk r5t49IZpKL6blhQAkRBzbSZTDftZKwf85Fe6G8BPYXNDrjEXLDydYIuIPnobpy+Y17L0 d/tQ== X-Gm-Message-State: AHPjjUgWTkcloAhs1zmxAW9y3K9nd6gGqryGMGLLWKgme6Q9mON9MvW9 n69oti60+yil3G02MILyHA== X-Google-Smtp-Source: AOwi7QBciik/4zj43E1Z0Tfr37xBdYt30cepNviUEtXqgTxEonQ01kCJMG50uN0o72nHvW5rTpBllg== X-Received: by 10.84.214.151 with SMTP id j23mr9616351pli.21.1506764454393; Sat, 30 Sep 2017 02:40:54 -0700 (PDT) Received: from localhost.localdomain.localdomain ([171.88.42.60]) by smtp.gmail.com with ESMTPSA id c7sm12522615pfg.85.2017.09.30.02.40.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Sep 2017 02:40:53 -0700 (PDT) From: Lin Zhang To: davem@davemloft.net Cc: netdev@vger.kernel.org, courmisch@gmail.com, Lin Zhang Subject: [PATCH v2 2/2] net: phonet: mark phonet_protocol as const Date: Sat, 30 Sep 2017 17:40:48 +0800 Message-Id: <1506764448-6915-1-git-send-email-xiaolou4617@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The phonet_protocol structs don't need to be written by anyone and so can be marked as const. Signed-off-by: Lin Zhang --- changelog: v1 -> v2: * remove __read_mostly tag --- include/net/phonet/phonet.h | 6 ++++-- net/phonet/af_phonet.c | 15 ++++++++------- net/phonet/datagram.c | 2 +- net/phonet/pep.c | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h index 039cc29..51e1a2a 100644 --- a/include/net/phonet/phonet.h +++ b/include/net/phonet/phonet.h @@ -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); diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index b12142e..63b9870 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c @@ -35,11 +35,11 @@ #include /* Transport protocol registration */ -static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly; +static const struct phonet_protocol *proto_tab[PHONET_NPROTO]; -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 int phonet_rcv(struct sk_buff *skb, struct net_device *dev, 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); diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c index 5e71043..b44fb90 100644 --- a/net/phonet/datagram.c +++ b/net/phonet/datagram.c @@ -195,7 +195,7 @@ static int pn_backlog_rcv(struct sock *sk, struct sk_buff *skb) .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, diff --git a/net/phonet/pep.c b/net/phonet/pep.c index e815379..9fc76b1 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c @@ -1351,7 +1351,7 @@ static void pep_sock_unhash(struct sock *sk) .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,