Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1782609imm; Wed, 16 May 2018 03:02:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq1vwR+vDESi8xDVUuBvublBF9LYlhmTMDV1YNUu94BTRGOXIbGgaHZ3RSuF3ipYjsDCFiZ X-Received: by 2002:a62:b909:: with SMTP id z9-v6mr235053pfe.254.1526464975443; Wed, 16 May 2018 03:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526464975; cv=none; d=google.com; s=arc-20160816; b=IQPMzOwIrpH0W2+8uAEPKwydpFUu/Muv5qvJ2zMpnNF6yH1iI2E/9rrA9y4WA11IAn DTMDeSGistVIppJqn0zOSWtdlar++OjNcoxnZmnaHRU6f4Q4hRR8KajjNrXHhlmfrJ2P IsjI90lJYrZS8yDDcG+yE8+ISRsaMOjkUJge2Yb9tukMez5dNS352X2+7q/R8cJYeSRJ HGTQkPC7ukqmgUvuDJ5WoS1dXNfxA8kqTz8Hal/Xp5v3jOc7ZI+N+/l1xZyuhKmIdN7m xufRjNeWgLpqRdtVxysx+lttXBKj/StlW38owFln9z3+URecPyIZS79RJmQRQIw4zIn9 xv2Q== 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=/7M9BV2gSqZxArf2tpJ6MueHLbUBS7SR4pWC8vWn63Q=; b=NEfiaJejUJOF0yKiAKKJpUgFyVFfmGNKi0mEgF3MamQh/vsuMecvtKqL6LFv0Rsz1n NXNppUQjEi6x0k70LCjDgBonEry254fKsfcgTbR91lWkytbG1LeXSSD660iu2l4mtJHh 8pwByRtSA5OkjFhhmcRlZngUZD8L0hocvZq9iO3fMqc7WVWs8ZRynLDzVCo7W3Rcg93Q 5aCAPzW2kTjndXdeczwGC7IUNFn57W+sceVN+wvZsECHdAahjykMCnQE/uvPhvY9j0sh 26OewfnAFS1qetvEE3H8MZovPTWoHgMX+Bu0RnqpOm+ZJyQOH9fx5PSc8/s0++2ktHly 1yZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=BbvCJU9g; 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 f64-v6si1986393plf.496.2018.05.16.03.02.33; Wed, 16 May 2018 03:02:55 -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=BbvCJU9g; 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 S1753325AbeEPKCM (ORCPT + 99 others); Wed, 16 May 2018 06:02:12 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:47698 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752962AbeEPJpg (ORCPT ); Wed, 16 May 2018 05:45:36 -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=/7M9BV2gSqZxArf2tpJ6MueHLbUBS7SR4pWC8vWn63Q=; b=BbvCJU9gmZ8oyF84Dg3QTDQPP zhm1JQQEOoDYnIqUA2EzM4lJcuncMg/KMs9RxRwh6VPq/CKFy3CpWbREi61GSa0azm8Sn5kQEQuAS TTisw3JtUv38OHCE+0Xd6oSwYUSwaC/rEzaq3JL2glGts/jTAhgpcjxNVpO/KTQ1dO+x2lYkmBsLo uOeo6JPaEf0Rl7p+SfQAYhsugVI37P9aK7329afGFlKU+sfKNJnv/hR583ZnjL8PqZmsnCE6rBNWl 9K5B/7SQxvslAb1Ycr4asroWVSs4OwJ/qmgaOHCu06iwcRSRJe22Sn0L32mcazu9CvtABhqg77tmu UctOFwOhw==; 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 1fIszn-00071Y-2U; Wed, 16 May 2018 09:45:19 +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 20/42] sgi-gru: simplify procfs code Date: Wed, 16 May 2018 11:43:24 +0200 Message-Id: <20180516094346.20506-21-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 Use remove_proc_subtree to remove the whole subtree on cleanup, and unwind the registration loop into individual calls. Switch to use proc_create_seq where applicable. Signed-off-by: Christoph Hellwig --- drivers/misc/sgi-gru/gruprocfs.c | 81 ++++++-------------------------- 1 file changed, 14 insertions(+), 67 deletions(-) diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c index 4f7635922394..42ea2eccaee9 100644 --- a/drivers/misc/sgi-gru/gruprocfs.c +++ b/drivers/misc/sgi-gru/gruprocfs.c @@ -270,16 +270,6 @@ static int options_open(struct inode *inode, struct file *file) return single_open(file, options_show, NULL); } -static int cch_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &cch_seq_ops); -} - -static int gru_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &gru_seq_ops); -} - /* *INDENT-OFF* */ static const struct file_operations statistics_fops = { .open = statistics_open, @@ -305,73 +295,30 @@ static const struct file_operations options_fops = { .release = single_release, }; -static const struct file_operations cch_fops = { - .open = cch_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; -static const struct file_operations gru_fops = { - .open = gru_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - -static struct proc_entry { - char *name; - umode_t mode; - const struct file_operations *fops; - struct proc_dir_entry *entry; -} proc_files[] = { - {"statistics", 0644, &statistics_fops}, - {"mcs_statistics", 0644, &mcs_statistics_fops}, - {"debug_options", 0644, &options_fops}, - {"cch_status", 0444, &cch_fops}, - {"gru_status", 0444, &gru_fops}, - {NULL} -}; -/* *INDENT-ON* */ - static struct proc_dir_entry *proc_gru __read_mostly; -static int create_proc_file(struct proc_entry *p) -{ - p->entry = proc_create(p->name, p->mode, proc_gru, p->fops); - if (!p->entry) - return -1; - return 0; -} - -static void delete_proc_files(void) -{ - struct proc_entry *p; - - if (proc_gru) { - for (p = proc_files; p->name; p++) - if (p->entry) - remove_proc_entry(p->name, proc_gru); - proc_remove(proc_gru); - } -} - int gru_proc_init(void) { - struct proc_entry *p; - proc_gru = proc_mkdir("sgi_uv/gru", NULL); - - for (p = proc_files; p->name; p++) - if (create_proc_file(p)) - goto err; + if (!proc_gru) + return -1; + if (!proc_create("statistics", 0644, proc_gru, &statistics_fops)) + goto err; + if (!proc_create("mcs_statistics", 0644, proc_gru, &mcs_statistics_fops)) + goto err; + if (!proc_create("debug_options", 0644, proc_gru, &options_fops)) + goto err; + if (!proc_create_seq("cch_status", 0444, proc_gru, &cch_seq_ops)) + goto err; + if (!proc_create_seq("gru_status", 0444, proc_gru, &gru_seq_ops)) + goto err; return 0; - err: - delete_proc_files(); + remove_proc_subtree("sgi_uv/gru", NULL); return -1; } void gru_proc_exit(void) { - delete_proc_files(); + remove_proc_subtree("sgi_uv/gru", NULL); } -- 2.17.0