From patchwork Sat Sep 30 09:08:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Zhang X-Patchwork-Id: 820187 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="gt4aN6Oi"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y42fW3MySz9t2h for ; Sat, 30 Sep 2017 19:08:51 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752648AbdI3JIr (ORCPT ); Sat, 30 Sep 2017 05:08:47 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34999 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752427AbdI3JIo (ORCPT ); Sat, 30 Sep 2017 05:08:44 -0400 Received: by mail-pg0-f65.google.com with SMTP id j16so1313133pga.2 for ; Sat, 30 Sep 2017 02:08:44 -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=i+Frp5lfvzd/BIjmdI5hlZBZkIHoGxAGx2+kDAis/Cs=; b=gt4aN6OijMKNKXZrJyNBOQzRdpKGAKAgVr3WkHj9DYhQJFdwN0WYCp5gvgeEQ+FSW+ wDQJjsM9OSxjj3Mzx+tw64iBcVyiL0UIzO+e3OAAz5uRgUx+Ytbdf3OXmaUEfzY+CxNR hJpq0zCONAugbC6MAitD09Te/obsHQdD08GjIcGSh6o0mJZ0mMATgtFTcxhRSPW6abJD HFDgG8mXt2YBGdfOhvhisoL0d6P1YG6zf4r22StzBRiMXPPEAYdbR+k1EpSY0THYBgKr pipvIDl1qqJT+vmMTLIlL2B+/Xmz2rhKvA/6wMpz5UAUyv4cjlMwjIRw9je4VA1jEf0W 0AjA== 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=i+Frp5lfvzd/BIjmdI5hlZBZkIHoGxAGx2+kDAis/Cs=; b=iQQNNUJSMuIEYP10cIJA+igrOPHGZM9l7R0L6aLnYwLbGI5F55VHa9tK//3Ew5Vuv8 bz1rU/5og5WTAzYfIxAqDCda9bFOHefaywUqIUg+XA+sx9ZBN+7ZxeHlaFk3YGgbSW48 0q3JDlkN966cQymmzqmpTKJtWaKE4aaS429IcON4YiqiMN10/B1wyTKgpEgR5G8KsJGH wwoufqONhaSuQzYZKbIW3u265ESllss+8ZkUN/WdbTLprPNm+VmDD3ICEoB6cQHifUzC 6xHBZ1XRn04/eacR2Yz5Q8s16THHKqAoy7AN0nAIuE1wU61n6aSTL6U2xvjm0w1iqLd1 a/lg== X-Gm-Message-State: AMCzsaUJr1poYGr+nXqfGa3qJ4HDnTGK8nWhoJ1dJpumG5LPKcxOARD6 SdgEG105cmL9PtJa+6BYndVM X-Google-Smtp-Source: AOwi7QDJztPDSDP1anYWa9lGy7VoDZKqgaS9vjEdOrofPKWmdJPLyAcPEv2TUW4gxIPmc5+YI08xSA== X-Received: by 10.99.138.76 with SMTP id y73mr975760pgd.124.1506762524409; Sat, 30 Sep 2017 02:08:44 -0700 (PDT) Received: from localhost.localdomain.localdomain ([119.4.240.19]) by smtp.gmail.com with ESMTPSA id m13sm9058814pgc.58.2017.09.30.02.08.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Sep 2017 02:08:43 -0700 (PDT) From: Lin Zhang To: davem@davemloft.net Cc: netdev@vger.kernel.org, courmisch@gmail.com, Lin Zhang Subject: [PATCH 1/2] net: phonet: mark header_ops as const Date: Sat, 30 Sep 2017 17:08:39 +0800 Message-Id: <1506762519-4709-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 Signed-off-by: Lin Zhang --- net/phonet/af_phonet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index f925753..b12142e 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c @@ -149,7 +149,7 @@ static int pn_header_parse(const struct sk_buff *skb, unsigned char *haddr) return 1; } -struct header_ops phonet_header_ops = { +const struct header_ops phonet_header_ops = { .create = pn_header_create, .parse = pn_header_parse, }; From patchwork Sat Sep 30 09:11:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Zhang X-Patchwork-Id: 820195 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="jGytF1/F"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y42kV35F6z9t2h for ; Sat, 30 Sep 2017 19:12:18 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751395AbdI3JMN (ORCPT ); Sat, 30 Sep 2017 05:12:13 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37902 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750968AbdI3JMM (ORCPT ); Sat, 30 Sep 2017 05:12:12 -0400 Received: by mail-pg0-f67.google.com with SMTP id y192so1305892pgd.5 for ; Sat, 30 Sep 2017 02:12:12 -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=Dbfej1MCmCSM0r9L74o/HSBHent+gGZnTMTz6ie246w=; b=jGytF1/F3cdvj1DwBxNjMgoq6woeDqbDAScbEK8RixBJabbkMOCITujBdyxa3xSFB2 CslXzcCEM/i6HM7XfXiNZsxjBsLTwj19mpLtKGv0TIVnrIO18s8iNc4br8ZeIX8n+fyu 1WSu6Yh9wwR6Lbf+5IMGq+/llefZNaA1HxsZgePaS8Y7uJusPuO0SgBn7TtucGlOLfdF UZcFQD0KjucXUAkSYtZAarTit8p1OPOhmekQVjUnDcQjXtL+zvV2sjoysb8YJR7N5JAP vpgyBbDCzeLgNOBva0RC/PJSW7aWaP2ZZOt3QDyKHRLzKvp2l9zORCAixNtebJVWDZOW SAJg== 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=Dbfej1MCmCSM0r9L74o/HSBHent+gGZnTMTz6ie246w=; b=RfUpWm2WVDA335bb4Iw5AJvgMkNRbotFJuA55jXJ6E+n7VzA1yxn0ZPRSfa03INvyn tgr36VThWSf1162z94MEGLnd94u9H+U+t8WNnm52EfppWIABI9OpT5fO9SwqgmtbKSJX Zw1WeDb7WzfrwA7S64zS3qyM+xmiLfmhg9qxpgXYtLyw452ZPyJpKiG9LvH3Ac/NY7ti Oq6Stsofuq87Oqv1HRl+Eukd1CgcpmLk3vbkISRzFL+pC5IMIU5OH6rAijYwshejcLA7 NWfNBav7l6MZJ4ivF+30kDTO69Y4pRXQi9dXuTfJuRW3HWxlfm2m0hltIvrjZlv3WIC7 wuxA== X-Gm-Message-State: AHPjjUjmp1gd2lBVZplbhrSBCHqR7Jzreumvx0TJYo5RaySmKMmULpch PXCl+8tKFqtdbpFWGoW72A== X-Google-Smtp-Source: AOwi7QBAQc4MAg3h1siqTe8NKeOeu1e/h5NLGKa+HQ8csOqhmnys9QcIgtZVd/5Mf5IveHlUyuIZ/w== X-Received: by 10.98.73.2 with SMTP id w2mr10045698pfa.133.1506762731776; Sat, 30 Sep 2017 02:12:11 -0700 (PDT) Received: from localhost.localdomain.localdomain ([171.88.42.60]) by smtp.gmail.com with ESMTPSA id c82sm9653903pfe.172.2017.09.30.02.12.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Sep 2017 02:12:11 -0700 (PDT) From: Lin Zhang To: davem@davemloft.net Cc: netdev@vger.kernel.org, courmisch@gmail.com, Lin Zhang Subject: [PATCH 2/2] net: phonet: mark phonet_protocol as const Date: Sat, 30 Sep 2017 17:11:03 +0800 Message-Id: <1506762663-4907-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 --- 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..3b0ef69 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] __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 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,