From patchwork Wed May 16 09:43:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10403401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF982601D2 for ; Wed, 16 May 2018 10:11:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEFFD28857 for ; Wed, 16 May 2018 10:11:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D347928863; Wed, 16 May 2018 10:11:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A6A528857 for ; Wed, 16 May 2018 10:11:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753009AbeEPKLE (ORCPT ); Wed, 16 May 2018 06:11:04 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:47350 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752119AbeEPJpH (ORCPT ); Wed, 16 May 2018 05:45:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=IBw29W98o9JhaE0Ol1cLFdA5CBPn6ll6ey0TFerNt7I=; b=oCTiSmwDvdNn4JPjs6rte/eup 2FVQBE+/8kAuHnoAF/9x1kZluCUoMLPjYT2BBNcMUZDAp6PjQ6mhS9cRizwtMsbFIgR5fYs22pwHY MrBNOHrspZPcX+Tm5w/TS3OTXKFPv0MpLNRgBc0QCoPAPyD54C0Y9cenYG2vfrxRH6HkpqIhAhYh0 HB+ZrtzKTWc0HAviA24avWHemZeKbRumt4ZmJ+vdPhH3UvPb42X98aQ7mNSXDsuxna44mTNbbAgq3 GURAE6s9S3stCUGcZ57q5QFjpkHoFb+anVgeen0y9nn9l3kxEtEyT9h9t31tpACcrRe23aVQVkVmF K3wzgcFCA==; Received: from 089144199016.atnat0008.highway.a1.net ([89.144.199.16] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fIszM-0005NO-4c; Wed, 16 May 2018 09:44:53 +0000 From: Christoph Hellwig To: Andrew Morton , Alexander Viro Cc: Alexey Dobriyan , Greg Kroah-Hartman , Jiri Slaby , Alessandro Zummo , Alexandre Belloni , linux-acpi@vger.kernel.org, drbd-dev@lists.linbit.com, linux-ide@vger.kernel.org, netdev@vger.kernel.org, linux-rtc@vger.kernel.org, megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, devel@driverdev.osuosl.org, linux-afs@lists.infradead.org, linux-ext4@vger.kernel.org, jfs-discussion@lists.sourceforge.net, netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/42] net/kcm: simplify proc registration Date: Wed, 16 May 2018 11:43:18 +0200 Message-Id: <20180516094346.20506-15-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180516094346.20506-1-hch@lst.de> References: <20180516094346.20506-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove a couple indirections to make the code look like most other protocols. Signed-off-by: Christoph Hellwig --- net/kcm/kcmproc.c | 71 ++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 54 deletions(-) diff --git a/net/kcm/kcmproc.c b/net/kcm/kcmproc.c index 1fac92543094..6d0667e62baf 100644 --- a/net/kcm/kcmproc.c +++ b/net/kcm/kcmproc.c @@ -15,12 +15,6 @@ #include #ifdef CONFIG_PROC_FS -struct kcm_seq_muxinfo { - char *name; - const struct file_operations *seq_fops; - const struct seq_operations seq_ops; -}; - static struct kcm_mux *kcm_get_first(struct seq_file *seq) { struct net *net = seq_file_net(seq); @@ -86,14 +80,6 @@ struct kcm_proc_mux_state { int idx; }; -static int kcm_seq_open(struct inode *inode, struct file *file) -{ - struct kcm_seq_muxinfo *muxinfo = PDE_DATA(inode); - - return seq_open_net(inode, file, &muxinfo->seq_ops, - sizeof(struct kcm_proc_mux_state)); -} - static void kcm_format_mux_header(struct seq_file *seq) { struct net *net = seq_file_net(seq); @@ -246,6 +232,19 @@ static int kcm_seq_show(struct seq_file *seq, void *v) return 0; } +static const struct seq_operations kcm_seq_ops = { + .show = kcm_seq_show, + .start = kcm_seq_start, + .next = kcm_seq_next, + .stop = kcm_seq_stop, +}; + +static int kcm_seq_open(struct inode *inode, struct file *file) +{ + return seq_open_net(inode, file, &kcm_seq_ops, + sizeof(struct kcm_proc_mux_state)); +} + static const struct file_operations kcm_seq_fops = { .open = kcm_seq_open, .read = seq_read, @@ -253,37 +252,6 @@ static const struct file_operations kcm_seq_fops = { .release = seq_release_net, }; -static struct kcm_seq_muxinfo kcm_seq_muxinfo = { - .name = "kcm", - .seq_fops = &kcm_seq_fops, - .seq_ops = { - .show = kcm_seq_show, - .start = kcm_seq_start, - .next = kcm_seq_next, - .stop = kcm_seq_stop, - } -}; - -static int kcm_proc_register(struct net *net, struct kcm_seq_muxinfo *muxinfo) -{ - struct proc_dir_entry *p; - int rc = 0; - - p = proc_create_data(muxinfo->name, 0444, net->proc_net, - muxinfo->seq_fops, muxinfo); - if (!p) - rc = -ENOMEM; - return rc; -} -EXPORT_SYMBOL(kcm_proc_register); - -static void kcm_proc_unregister(struct net *net, - struct kcm_seq_muxinfo *muxinfo) -{ - remove_proc_entry(muxinfo->name, net->proc_net); -} -EXPORT_SYMBOL(kcm_proc_unregister); - static int kcm_stats_seq_show(struct seq_file *seq, void *v) { struct kcm_psock_stats psock_stats; @@ -404,16 +372,11 @@ static const struct file_operations kcm_stats_seq_fops = { static int kcm_proc_init_net(struct net *net) { - int err; - if (!proc_create("kcm_stats", 0444, net->proc_net, - &kcm_stats_seq_fops)) { - err = -ENOMEM; + &kcm_stats_seq_fops)) goto out_kcm_stats; - } - err = kcm_proc_register(net, &kcm_seq_muxinfo); - if (err) + if (!proc_create("kcm", 0444, net->proc_net, &kcm_seq_fops)) goto out_kcm; return 0; @@ -421,12 +384,12 @@ static int kcm_proc_init_net(struct net *net) out_kcm: remove_proc_entry("kcm_stats", net->proc_net); out_kcm_stats: - return err; + return -ENOMEM; } static void kcm_proc_exit_net(struct net *net) { - kcm_proc_unregister(net, &kcm_seq_muxinfo); + remove_proc_entry("kcm", net->proc_net); remove_proc_entry("kcm_stats", net->proc_net); }