Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1793868imm; Wed, 16 May 2018 03:13:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqQFGv+Lc+IZAvItPBuRhW6jzQ83FMoUzBSH0FTW3ano9la3ZvFes+IVHgITQHPQv0hJfzi X-Received: by 2002:a17:902:3381:: with SMTP id b1-v6mr283254plc.248.1526465605453; Wed, 16 May 2018 03:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526465605; cv=none; d=google.com; s=arc-20160816; b=wYKSG35U6YxK8QOxdna7r+4OGS1a2curKSdYBz7OkB/JApSGimvA5A0Gj+eZ2dJJK9 9gAKp/DnL2fQfhoQx24glquGSqJIbKoY1TVfR1+Zs8tx657rXyvfEodGDPr2kJ7rUbF4 fycZXi0tiZJG5teo1dcgjNd3r3rTFtZj6A2BsIUKpaNCAqzhKIRe8EYf331QCrsyFsSK q3tL7j5j/NiWH6M1V8gSJsZBEaZxuEpY+ZrzFIS0Vb5WpeOFGcYZjKbCk819/g7jvnif JuPTDK+lRsAB9d29QB4VaoYRYmZzpKMyCrNyH7Mw/5hXSXTnrXUKtP/kqaJ/Ti46lESo VQ5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=IBw29W98o9JhaE0Ol1cLFdA5CBPn6ll6ey0TFerNt7I=; b=vfXYlhdxbvNiDBFXz+sr15K7Z0hFbHDpzx1HdGM4C4h6gDZL5PG47yFvEBThPFR5nt qGRJ0SmxgcTSk9l9sqb1sRFaLwfkgmay1oFxrU1/1yT15LUEy9gIEtvUht377mb2wdVY 1pJdtDVKY60a9quNV/ksH13Fwrg3okdIyddlaUVzNUWBUjI2weSihXXuIC2LaYwMK6/Z p6BQvPBPB1vQ77xP6w7QwkcQCHVdh8CTfuDyxfC7Du6xiVjzUmPHs67MFEt0yXuJ7G5E wP9tux6AFkyvhjIagnGsUpHNBgpirYmfDHCyHMuBrODmXlFjmzoZGk2KdQxLgE9V+BjH S9Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oCTiSmwD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8-v6si2387610pls.261.2018.05.16.03.13.10; Wed, 16 May 2018 03:13:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oCTiSmwD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753375AbeEPKLG (ORCPT + 99 others); Wed, 16 May 2018 06:11:06 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } -- 2.17.0