From patchwork Fri May 13 20:34:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 95508 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A9636B6F07 for ; Sat, 14 May 2011 06:36:16 +1000 (EST) Received: from canuck.infradead.org ([134.117.69.58]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1QKz4B-0002R7-N5; Fri, 13 May 2011 20:34:31 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1QKz4A-0004ur-Vp; Fri, 13 May 2011 20:34:31 +0000 Received: from mail-ew0-f49.google.com ([209.85.215.49]) by canuck.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1QKz46-0004uY-Dl for linux-mtd@lists.infradead.org; Fri, 13 May 2011 20:34:27 +0000 Received: by ewy3 with SMTP id 3so959091ewy.36 for ; Fri, 13 May 2011 13:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=UaDekYU+yx8QjxWL2ehGOybrsGgr4Jkjt9XH5yR+Iqk=; b=PJXp11/gRKstwojFDC31dO/RvClTG5yPrQhhpABT8M4lWnjfMHu79E4tW58eZPo1Xh Aruw1OMcaF8tjSv4E+XER2yetipNFRdPRUKu4Uy/A0bN/d4B9pEychTZmaxdzBIP85q5 wCWAo6wmDAx82hK1gZr0dXQaIKBgLTp0dgan0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=O6sTCpyeNd73iwYFLCjCBE/js2aYYNve8gbDVhz7eU/vFlz9vMB+Tb4RFfOS8L2YhU hi/61tqv7hpgh2X+oamyY2iFMYS2a+rmtj8uqH63mhdZhV6fKK45NB9ZhIi3szt9XTPI HZoypKTbwGMD4Es6i7AU6IaDF9Y8lIPyEtaGs= Received: by 10.14.49.197 with SMTP id x45mr759158eeb.120.1305318863913; Fri, 13 May 2011 13:34:23 -0700 (PDT) Received: from p183 (vulture-nat-37.telecom.by [213.184.224.37]) by mx.google.com with ESMTPS id z1sm1663418eeb.21.2011.05.13.13.34.22 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 May 2011 13:34:22 -0700 (PDT) Date: Fri, 13 May 2011 23:34:19 +0300 From: Alexey Dobriyan To: dwmw2@infradead.org Subject: [PATCH] mtd: convert to seq_file interface Message-ID: <20110513203419.GA29261@p183> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110513_163426_774419_E0086D9D X-CRM114-Status: GOOD ( 13.72 ) X-Spam-Score: 1.1 (+) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] 0.0 FREEMAIL_FROM Sender email is freemail (adobriyan[at]gmail.com) 0.6 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [213.184.224.37 listed in dnsbl.sorbs.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.49 listed in list.dnswl.org] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL Cc: akpm@linux-foundation.org, linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org ->read_proc interface is going away, switch to seq_file. Signed-off-by: Alexey Dobriyan Acked-by: Mike Frysinger --- drivers/mtd/mtdcore.c | 50 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -656,44 +657,32 @@ EXPORT_SYMBOL_GPL(default_mtd_writev); static struct proc_dir_entry *proc_mtd; -static inline int mtd_proc_info(char *buf, struct mtd_info *this) -{ - return sprintf(buf, "mtd%d: %8.8llx %8.8x \"%s\"\n", this->index, - (unsigned long long)this->size, - this->erasesize, this->name); -} - -static int mtd_read_proc (char *page, char **start, off_t off, int count, - int *eof, void *data_unused) +static int mtd_proc_show(struct seq_file *m, void *v) { struct mtd_info *mtd; - int len, l; - off_t begin = 0; + seq_puts(m, "dev: size erasesize name\n"); mutex_lock(&mtd_table_mutex); - - len = sprintf(page, "dev: size erasesize name\n"); mtd_for_each_device(mtd) { - l = mtd_proc_info(page + len, mtd); - len += l; - if (len+begin > off+count) - goto done; - if (len+begin < off) { - begin += len; - len = 0; - } + seq_printf(m, "mtd%d: %8.8llx %8.8x \"%s\"\n", + mtd->index, (unsigned long long)mtd->size, + mtd->erasesize, mtd->name); } - - *eof = 1; - -done: mutex_unlock(&mtd_table_mutex); - if (off >= len+begin) - return 0; - *start = page + (off-begin); - return ((count < begin+len-off) ? count : begin+len-off); + return 0; } +static int mtd_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, mtd_proc_show, NULL); +} + +static const struct file_operations mtd_proc_ops = { + .open = mtd_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; #endif /* CONFIG_PROC_FS */ /*====================================================================*/ @@ -734,8 +723,7 @@ static int __init init_mtd(void) goto err_bdi3; #ifdef CONFIG_PROC_FS - if ((proc_mtd = create_proc_entry( "mtd", 0, NULL ))) - proc_mtd->read_proc = mtd_read_proc; + proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops); #endif /* CONFIG_PROC_FS */ return 0;