Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1778241imm; Wed, 16 May 2018 02:58:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoDgByQjZ7rU69ZpLN+z1JKRh2BxuloctlbDsZI999ArFkBJnCB4BoORcp6x5e2YCErfgSf X-Received: by 2002:a63:2bc4:: with SMTP id r187-v6mr146179pgr.231.1526464727628; Wed, 16 May 2018 02:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526464727; cv=none; d=google.com; s=arc-20160816; b=Sku9TvwLeevKm7g3Xmp46Q6R5fr3neR/+cCfMOV6O7USgvuprMS3JBDSZgGX5isEVY HDF1EG71+V7nn6V5AfAucJJICSTH6gVyAk/S/pj9C8PpGtYh8boDlm/KFdzk6e3yFb6K 9s/3oIUCmLH+CxqnpjkOKqPo+D6sqnyMTPjgj1naVlIc8p/7I9pEqogLhISJLIJhzF9+ 9zYLHw0lmfzTB5m98ZB+PiZg/R73kF6S1IY7jtnzPQrDtD9wjH9pkpe/mvMiapY/6d6F 4XKQ82sp/xQDIQjr7JQ7Y4jZCWhGNIkod5fu9hbBQV/pNNCpIiB6mRL4YRjul/2l5p1s 5Mow== 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=WmbYKgk405YnpxEjrP+1oVWecBlt0Tdru8SBShDVJsI=; b=cU1i4JY1yUj19smN9vodxTRnW3djFnVNOt8zvNIF1cW2IqjNmqeVFE8n0FJPhVXABt Bs21qL+EXgbeQVTyRCx0E+x0UxGj8DvWAcfYY6ntGFv3PCa4saQPKVYoeIPzdH4D4TEr OHHrfh/iq2BgePvplKtdrsRYvrberpcV61sLd3kDMv6B67LUeVoQL1if/slQgh9BTPsq 1xiGyF0xx6wn+mfU8Ow59XuoWJLRHXbA0lYNXzMno6l/hfGhSzQXG43ydtQGqE7cyyEQ EfQt366Rd1oOf4Yq/ObKoBAdPZav1jbx9ZVqb8wS9aiFXSF1XUQO4XAfOpZe36QfvmOG g44Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=RIzlItAp; 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 k9-v6si1817211pgo.340.2018.05.16.02.58.33; Wed, 16 May 2018 02:58:47 -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=RIzlItAp; 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 S1753264AbeEPJ4w (ORCPT + 99 others); Wed, 16 May 2018 05:56:52 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48214 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752179AbeEPJqb (ORCPT ); Wed, 16 May 2018 05:46:31 -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=WmbYKgk405YnpxEjrP+1oVWecBlt0Tdru8SBShDVJsI=; b=RIzlItApmGy/s3BHgupZV+d+l +MxPlKocJWFYXVLfeIQOl7x/WmM5Lszo8HFUlmgRzXo/WPMMyOyO9jAxxX8gJd3BFUNC6m2STp1NL PhE08JIuRyyAD5SMtz3gvXbIaqRV/qtLM/q5Ld3R1O1OKvLzzLmTXuBgUtDr+aeCbmEsDATojKUqJ TTaE++R0yLVzmc9zpSPEsFXx5UWdCOWssCkoEi1lWVh7KzCwNSOGY8dWJWajzPOm+oAmoKpKEZ9H2 CpxR2kCeMtraAiXWlyvbzacAa0GLiDSVvJJwurw2fzCiuR7L96oELEYhAtOwPqoUAhp0PqbcQ3E26 blpH8H2zg==; 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 1fIt0C-0007nM-Jz; Wed, 16 May 2018 09:45:45 +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 26/42] staging/rtl8192u: simplify procfs code Date: Wed, 16 May 2018 11:43:30 +0200 Message-Id: <20180516094346.20506-27-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 Unwind the registration loop into individual calls. Switch to use proc_create_single 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 --- drivers/staging/rtl8192u/r8192U_core.c | 67 ++++++-------------------- 1 file changed, 14 insertions(+), 53 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index d607c59761cf..7a0dbc0fa18e 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -646,64 +646,25 @@ static void rtl8192_proc_module_init(void) rtl8192_proc = proc_mkdir(RTL819xU_MODULE_NAME, init_net.proc_net); } -/* - * seq_file wrappers for procfile show routines. - */ -static int rtl8192_proc_open(struct inode *inode, struct file *file) -{ - struct net_device *dev = proc_get_parent_data(inode); - int (*show)(struct seq_file *, void *) = PDE_DATA(inode); - - return single_open(file, show, dev); -} - -static const struct file_operations rtl8192_proc_fops = { - .open = rtl8192_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -/* - * Table of proc files we need to create. - */ -struct rtl8192_proc_file { - char name[12]; - int (*show)(struct seq_file *, void *); -}; - -static const struct rtl8192_proc_file rtl8192_proc_files[] = { - { "stats-rx", &proc_get_stats_rx }, - { "stats-tx", &proc_get_stats_tx }, - { "stats-ap", &proc_get_stats_ap }, - { "registers", &proc_get_registers }, - { "" } -}; - static void rtl8192_proc_init_one(struct net_device *dev) { - const struct rtl8192_proc_file *f; struct proc_dir_entry *dir; - if (rtl8192_proc) { - dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev); - if (!dir) { - RT_TRACE(COMP_ERR, - "Unable to initialize /proc/net/rtl8192/%s\n", - dev->name); - return; - } + if (!rtl8192_proc) + return; - for (f = rtl8192_proc_files; f->name[0]; f++) { - if (!proc_create_data(f->name, S_IFREG | S_IRUGO, dir, - &rtl8192_proc_fops, f->show)) { - RT_TRACE(COMP_ERR, - "Unable to initialize /proc/net/rtl8192/%s/%s\n", - dev->name, f->name); - return; - } - } - } + dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev); + if (!dir) + return; + + proc_create_single("stats-rx", S_IFREG | S_IRUGO, dir, + proc_get_stats_rx); + proc_create_single("stats-tx", S_IFREG | S_IRUGO, dir, + proc_get_stats_tx); + proc_create_single("stats-ap", S_IFREG | S_IRUGO, dir, + proc_get_stats_ap); + proc_create_single("registers", S_IFREG | S_IRUGO, dir, + proc_get_registers); } static void rtl8192_proc_remove_one(struct net_device *dev) -- 2.17.0