Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1769026imm; Wed, 16 May 2018 02:48:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZppjuH0PFf+XqevzKeaj8A692lK7NqAAHqr4ApCvYr501DjHB4SBJQC18fBoFdx4vDbk4db X-Received: by 2002:a63:3c08:: with SMTP id j8-v6mr126348pga.203.1526464096088; Wed, 16 May 2018 02:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526464096; cv=none; d=google.com; s=arc-20160816; b=Eh/wUC/WkDyNsdjiEVDts2I4LxzJ3KgcEK/QCvxsvexzvvn8b/naO89HXktgATfP1h 2OhBT6RTbvriRwCxPETbj1e+RDQU4qDW0qyYCDJvZwzQe1Hu0zZNwsYm3XMGTLVHirmm SfyAGPNGAtPa8M7Z2iwHRs+UVKzUarhjfz5sxAHaecrL0FQA/AA2m03EPeTT1X22+VQd GmqmoVBQMgxFkA8t8zN+dZ3qfAbzR+Ygjny+PQyCvR4yhYCWLDVAe4tOZHIUbbjr2XJ4 X0Ft15UuvQ0VlVGhgmUHccTXMJKaz68cUZYktjBKAhsnz33DTseUKA/vTncFvhWemA5c KQaQ== 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=GTrUthCMCvz/WgK420kGDqMxfC+70xqzgZlDMTrA2Vg=; b=IGVjsn3Od7nVPv8VYYYhyuQ5Y1VvUhxse3JD7Dce+GUETfkvfGIIGRZxUsbyP4ruMs mJ9ZommIXMkfY4EVUJY4ejXFg6fBxdAQnAuKFd4rh/MQ1YHn66dCojXaeinnOhV8GzEo io3IxnHSbN/tWjXyMBFHq8dA/a9Zd/FUWeWfsC40ONIP/FZ/u0nQA3rhL7r9iyKnSA4N DiN+aCJc/si6XpSTZMYJblJlgJ6L2G/7+St5BXs6NqO36PkQKRUomBtjjE+dMs0gA1D5 WBdIA+MiWJzJgH5DN0aGLdBtMCKm2rB+PQc2ccM7ynVofdudEU9N+weOPd5Qri7VoZeg wuqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=hQlkFaIu; 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 43-v6si2302615plb.511.2018.05.16.02.48.01; Wed, 16 May 2018 02:48:16 -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=hQlkFaIu; 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 S1753339AbeEPJrY (ORCPT + 99 others); Wed, 16 May 2018 05:47:24 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:48650 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753226AbeEPJrU (ORCPT ); Wed, 16 May 2018 05:47:20 -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=GTrUthCMCvz/WgK420kGDqMxfC+70xqzgZlDMTrA2Vg=; b=hQlkFaIumdultzYwNkDSw6X67 adJj7XlizkfuUN4qcU4fqDkcSP6QX9GBsDRFOqizdHdTdrQeL3ZyZluYBDNeXOHru0sG0VDHIPvlt SDp/ILkInlackwjRBSpJ2ZV0XL4EBuWz/hoCz138jLpcm/1YnQKenr9K0FUevX/k2h8msdnWiMzc1 pyNS2/NKh4W3D1sBdlbGWYespCfamWJ4NcqJMl168t0mv74ZQKWwfFPzWYZ+1jH2vwkZPvY91fpOZ K/Ws5z97CSp4MaU7NDAGSvSN7hGNGBGur94jvEOi0J+PyRNCKnzW3sELpFe7HqE8sUwUpy3eKXgFb umWaHI8KA==; 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 1fIt0v-00080P-Vm; Wed, 16 May 2018 09:46:30 +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 37/42] atm: switch to proc_create_seq_private Date: Wed, 16 May 2018 11:43:41 +0200 Message-Id: <20180516094346.20506-38-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 And remove proc boilerplate code. Signed-off-by: Christoph Hellwig --- net/atm/proc.c | 72 +++++++++----------------------------------------- 1 file changed, 13 insertions(+), 59 deletions(-) diff --git a/net/atm/proc.c b/net/atm/proc.c index f272b0f59d82..0b0495a41bbe 100644 --- a/net/atm/proc.c +++ b/net/atm/proc.c @@ -68,7 +68,6 @@ static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev) struct vcc_state { int bucket; struct sock *sk; - int family; }; static inline int compare_family(struct sock *sk, int family) @@ -106,23 +105,13 @@ static int __vcc_walk(struct sock **sock, int family, int *bucket, loff_t l) return (l < 0); } -static inline void *vcc_walk(struct vcc_state *state, loff_t l) +static inline void *vcc_walk(struct seq_file *seq, loff_t l) { - return __vcc_walk(&state->sk, state->family, &state->bucket, l) ? - state : NULL; -} - -static int __vcc_seq_open(struct inode *inode, struct file *file, - int family, const struct seq_operations *ops) -{ - struct vcc_state *state; - - state = __seq_open_private(file, ops, sizeof(*state)); - if (state == NULL) - return -ENOMEM; + struct vcc_state *state = seq->private; + int family = (uintptr_t)(PDE_DATA(file_inode(seq->file))); - state->family = family; - return 0; + return __vcc_walk(&state->sk, family, &state->bucket, l) ? + state : NULL; } static void *vcc_seq_start(struct seq_file *seq, loff_t *pos) @@ -133,7 +122,7 @@ static void *vcc_seq_start(struct seq_file *seq, loff_t *pos) read_lock(&vcc_sklist_lock); state->sk = SEQ_START_TOKEN; - return left ? vcc_walk(state, left) : SEQ_START_TOKEN; + return left ? vcc_walk(seq, left) : SEQ_START_TOKEN; } static void vcc_seq_stop(struct seq_file *seq, void *v) @@ -144,9 +133,7 @@ static void vcc_seq_stop(struct seq_file *seq, void *v) static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos) { - struct vcc_state *state = seq->private; - - v = vcc_walk(state, 1); + v = vcc_walk(seq, 1); *pos += !!PTR_ERR(v); return v; } @@ -280,18 +267,6 @@ static const struct seq_operations pvc_seq_ops = { .show = pvc_seq_show, }; -static int pvc_seq_open(struct inode *inode, struct file *file) -{ - return __vcc_seq_open(inode, file, PF_ATMPVC, &pvc_seq_ops); -} - -static const struct file_operations pvc_seq_fops = { - .open = pvc_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release_private, -}; - static int vcc_seq_show(struct seq_file *seq, void *v) { if (v == SEQ_START_TOKEN) { @@ -314,18 +289,6 @@ static const struct seq_operations vcc_seq_ops = { .show = vcc_seq_show, }; -static int vcc_seq_open(struct inode *inode, struct file *file) -{ - return __vcc_seq_open(inode, file, 0, &vcc_seq_ops); -} - -static const struct file_operations vcc_seq_fops = { - .open = vcc_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release_private, -}; - static int svc_seq_show(struct seq_file *seq, void *v) { static const char atm_svc_banner[] = @@ -349,18 +312,6 @@ static const struct seq_operations svc_seq_ops = { .show = svc_seq_show, }; -static int svc_seq_open(struct inode *inode, struct file *file) -{ - return __vcc_seq_open(inode, file, PF_ATMSVC, &svc_seq_ops); -} - -static const struct file_operations svc_seq_fops = { - .open = svc_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release_private, -}; - static ssize_t proc_dev_atm_read(struct file *file, char __user *buf, size_t count, loff_t *pos) { @@ -434,9 +385,12 @@ int __init atm_proc_init(void) if (!atm_proc_root) 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); + proc_create_seq_private("pvc", 0444, atm_proc_root, &pvc_seq_ops, + sizeof(struct vcc_state), (void *)(uintptr_t)PF_ATMPVC); + proc_create_seq_private("svc", 0444, atm_proc_root, &svc_seq_ops, + sizeof(struct vcc_state), (void *)(uintptr_t)PF_ATMSVC); + proc_create_seq_private("vc", 0444, atm_proc_root, &vcc_seq_ops, + sizeof(struct vcc_state), NULL); return 0; } -- 2.17.0