From patchwork Fri Nov 27 06:51:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 63285 X-Patchwork-Delegate: kyle@mcmartin.ca Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAR6pHuI018533 for ; Fri, 27 Nov 2009 06:51:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751519AbZK0GvK (ORCPT ); Fri, 27 Nov 2009 01:51:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751620AbZK0GvK (ORCPT ); Fri, 27 Nov 2009 01:51:10 -0500 Received: from mail-ew0-f219.google.com ([209.85.219.219]:59320 "EHLO mail-ew0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751539AbZK0GvJ (ORCPT ); Fri, 27 Nov 2009 01:51:09 -0500 Received: by ewy19 with SMTP id 19so1128997ewy.21 for ; Thu, 26 Nov 2009 22:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=l5ifZU60UH5/lLx/fXM6A44Fjox+BxhIgTjUSM9EXpo=; b=G/8qvk1jCM7w9G2NwYY6vdgHyZ8IPU/igK0Jq0e6KLX6YrL7s5ud+oLGlQHnznX8l7 gMG7n6sx9Vn6PJslI/8zbhZsGAhouH3eDlqxc8L2aIcPOS4r6Ga+6ib1z08xs1LCuCF4 Ytc+6KiEuRzrhxW+tXmfN+Ma9kaaEeIbPTySQ= 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=iPRKh59pQ4lySnE8DqxQ92IINN1zRRIfx5yv0RlEv+6RlKEP7f/+JMilgleWVSr81Z CkqGQMvL69D4iagV86bYJAiy1SYPW8ontuGUM9+iIIo9bhUkFagiAFIBrL1AJNU/FdG4 bVe36tXu2UdAYHLczXHkshhOLBASXiezYrv9c= Received: by 10.213.2.73 with SMTP id 9mr765639ebi.21.1259304674768; Thu, 26 Nov 2009 22:51:14 -0800 (PST) Received: from x200.malnet.ru ([213.171.34.231]) by mx.google.com with ESMTPS id 7sm2321944eyg.33.2009.11.26.22.51.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 26 Nov 2009 22:51:14 -0800 (PST) Date: Fri, 27 Nov 2009 09:51:12 +0300 From: Alexey Dobriyan To: kyle@mcmartin.ca Cc: akpm@linux-foundation.org, linux-parisc@vger.kernel.org Subject: [PATCH] parisc: convert /proc/pdc/{lcd,led} to seq_file Message-ID: <20091127065112.GC26327@x200.malnet.ru> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -147,41 +148,34 @@ device_initcall(start_task); static void (*led_func_ptr) (unsigned char) __read_mostly; #ifdef CONFIG_PROC_FS -static int led_proc_read(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int led_proc_show(struct seq_file *m, void *v) { - char *out = page; - int len; - - switch ((long)data) + switch ((long)m->private) { case LED_NOLCD: - out += sprintf(out, "Heartbeat: %d\n", led_heartbeat); - out += sprintf(out, "Disk IO: %d\n", led_diskio); - out += sprintf(out, "LAN Rx/Tx: %d\n", led_lanrxtx); + seq_printf(m, "Heartbeat: %d\n", led_heartbeat); + seq_printf(m, "Disk IO: %d\n", led_diskio); + seq_printf(m, "LAN Rx/Tx: %d\n", led_lanrxtx); break; case LED_HASLCD: - out += sprintf(out, "%s\n", lcd_text); + seq_printf(m, "%s\n", lcd_text); break; default: - *eof = 1; return 0; } + return 0; +} - len = out - page - off; - if (len < count) { - *eof = 1; - if (len <= 0) return 0; - } else { - len = count; - } - *start = page + off; - return len; +static int led_proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, led_proc_show, PDE(inode)->data); } -static int led_proc_write(struct file *file, const char *buf, - unsigned long count, void *data) + +static ssize_t led_proc_write(struct file *file, const char *buf, + size_t count, loff_t *pos) { + void *data = PDE(file->f_path.dentry->d_inode)->data; char *cur, lbuf[count + 1]; int d; @@ -234,6 +228,15 @@ parse_error: return -EINVAL; } +static const struct file_operations led_proc_fops = { + .owner = THIS_MODULE, + .open = led_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = led_proc_write, +}; + static int __init led_create_procfs(void) { struct proc_dir_entry *proc_pdc_root = NULL; @@ -243,19 +246,15 @@ static int __init led_create_procfs(void) proc_pdc_root = proc_mkdir("pdc", 0); if (!proc_pdc_root) return -1; - ent = create_proc_entry("led", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root); + ent = proc_create_data("led", S_IRUGO|S_IWUSR, proc_pdc_root, + &led_proc_fops, (void *)LED_NOLCD); /* LED */ if (!ent) return -1; - ent->data = (void *)LED_NOLCD; /* LED */ - ent->read_proc = led_proc_read; - ent->write_proc = led_proc_write; if (led_type == LED_HASLCD) { - ent = create_proc_entry("lcd", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root); + ent = proc_create_data("lcd", S_IRUGO|S_IWUSR, proc_pdc_root, + &led_proc_fops, (void *)LED_HASLCD); /* LCD */ if (!ent) return -1; - ent->data = (void *)LED_HASLCD; /* LCD */ - ent->read_proc = led_proc_read; - ent->write_proc = led_proc_write; } return 0;