Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1776159imm; Wed, 16 May 2018 02:55:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr+7+Bqd4a+0C77Nx+ECocoZD/c64ainlCYfvGvkw6jt+XdfLKB+3arGs8sqoGsicZBd1h3 X-Received: by 2002:a63:3147:: with SMTP id x68-v6mr175979pgx.108.1526464559927; Wed, 16 May 2018 02:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526464559; cv=none; d=google.com; s=arc-20160816; b=d7XEGklBOS16oFx2+qWYyUPCqTB2le3jYiG9wP4DnnScI+CTM69eTirHO/fS8Qz1ax cTgY72iTYcP2yuKjBdv9cpOca4E+vhBhOxXL9Wd/GfKrxEBpq5JoTwNzj0LN9aV0fqCl w2K7yP6S6lslf9U19nclb5GqclDAcLKn4DmIUfQ8XnLGs3BrPG5zUtdnfNIpWsHc2gOE WijSmOxcf2u4RKUoAMsNZ7K4tyxrqlfQPiAeW4Y+3q2bYFSeZU5YmIqX1w9OLV+Sw4cp vZoxPmlrzBVwopcExhyPj+cWUFPmoEpSjlc2wda2/ufZTAMiYomOMDfjz7x8QxnicqV1 LqOQ== 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=2lAMoZ7tA6GG2Wv+TK8kXAGvWOgo50ltANogicMS5eI=; b=dIz9GnjzyjAQIi1+BXJV9+kE2X6fGRx4wpkfd4Plrn+QXAOU/F0saK2ib+hF22B+GA gJauYTTtfpLuBLJhTTlR7eCQdZ7rkOMptD5CLGPvHrzkM+t4C+1PLpNPmykLqHT3eY9x X46OS+HeuZQ6VozUqA90IYn8c7O8CPsAdSpg79LOSqVpZ8OMSxEHdkPf6THCLZE/0ABn yLVBWI32cd5tMjDV67GJTeDMfj0NOOqa+RBdCuZQDGITttNd5kdPKIE/T0iKIA1raCzt OQ0giiy8wWStPq8O9HNhczEIsTtt7uVEDTbof2bGlcxNIbbTulS1sgO7iB9+h/6KNMXg swHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=dLWLPTqr; 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 b61-v6si2206967plc.500.2018.05.16.02.55.46; Wed, 16 May 2018 02:55:59 -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=dLWLPTqr; 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 S1753179AbeEPJqp (ORCPT + 99 others); Wed, 16 May 2018 05:46:45 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48314 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752458AbeEPJqk (ORCPT ); Wed, 16 May 2018 05:46:40 -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=2lAMoZ7tA6GG2Wv+TK8kXAGvWOgo50ltANogicMS5eI=; b=dLWLPTqrLsQbQ69FUU5ZMyvSi 5Q2aHyEEYpXvRlocs0srRoAmhigjqedj+1t7d1QuBfzd/HMxmn3X6DqWPBc0JmF2HZkUghKmhnIpD kUSbApNDxUbrSQcp6zeV/OdwQ7Pz2s4bAhPyXaD93nTLae3oCN1RpwIyLS4/bqKoDgi+rsAnxu9pv ExXFMIg1p5LUxEybiq0OnX9vKN0kDDEhGijuGzqFTgYb7rQAG3NiEfnAgIyAVCYq7CZohYHfUe9j0 boDvapPU5ghnYLKJfBYLJVD3RLOV6uQ6Xl0iwiIEKT7UL/4h5e2niUpPLUOcR3n0No3swJCuNI5TV 4HDxWC7VA==; 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 1fIt0r-0007zH-O7; Wed, 16 May 2018 09:46:26 +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 36/42] atm: simplify procfs code Date: Wed, 16 May 2018 11:43:40 +0200 Message-Id: <20180516094346.20506-37-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. Also don't bother handling proc_create* failures - the driver works perfectly fine without the proc files, and the cleanup will handle missing files gracefully. Signed-off-by: Christoph Hellwig --- net/atm/proc.c | 65 ++++++-------------------------------------------- 1 file changed, 7 insertions(+), 58 deletions(-) diff --git a/net/atm/proc.c b/net/atm/proc.c index 55410c00c7e2..f272b0f59d82 100644 --- a/net/atm/proc.c +++ b/net/atm/proc.c @@ -257,18 +257,6 @@ static const struct seq_operations atm_dev_seq_ops = { .show = atm_dev_seq_show, }; -static int atm_dev_seq_open(struct inode *inode, struct file *file) -{ - return seq_open(file, &atm_dev_seq_ops); -} - -static const struct file_operations devices_seq_fops = { - .open = atm_dev_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, -}; - static int pvc_seq_show(struct seq_file *seq, void *v) { static char atm_pvc_banner[] = @@ -440,58 +428,19 @@ void atm_proc_dev_deregister(struct atm_dev *dev) kfree(dev->proc_name); } -static struct atm_proc_entry { - char *name; - const struct file_operations *proc_fops; - struct proc_dir_entry *dirent; -} atm_proc_ents[] = { - { .name = "devices", .proc_fops = &devices_seq_fops }, - { .name = "pvc", .proc_fops = &pvc_seq_fops }, - { .name = "svc", .proc_fops = &svc_seq_fops }, - { .name = "vc", .proc_fops = &vcc_seq_fops }, - { .name = NULL, .proc_fops = NULL } -}; - -static void atm_proc_dirs_remove(void) -{ - static struct atm_proc_entry *e; - - for (e = atm_proc_ents; e->name; e++) { - if (e->dirent) - remove_proc_entry(e->name, atm_proc_root); - } - remove_proc_entry("atm", init_net.proc_net); -} - int __init atm_proc_init(void) { - static struct atm_proc_entry *e; - int ret; - atm_proc_root = proc_net_mkdir(&init_net, "atm", init_net.proc_net); if (!atm_proc_root) - goto err_out; - for (e = atm_proc_ents; e->name; e++) { - struct proc_dir_entry *dirent; - - dirent = proc_create(e->name, 0444, - atm_proc_root, e->proc_fops); - if (!dirent) - goto err_out_remove; - e->dirent = dirent; - } - ret = 0; -out: - return ret; - -err_out_remove: - atm_proc_dirs_remove(); -err_out: - ret = -ENOMEM; - goto out; + return -ENOMEM; + proc_create_seq("devices", 0444, atm_proc_root, &atm_dev_seq_ops); + proc_create("pvc", 0444, atm_proc_root, &pvc_seq_fops); + proc_create("svc", 0444, atm_proc_root, &svc_seq_fops); + proc_create("vc", 0444, atm_proc_root, &vcc_seq_fops); + return 0; } void atm_proc_exit(void) { - atm_proc_dirs_remove(); + remove_proc_subtree("atm", init_net.proc_net); } -- 2.17.0