From patchwork Fri Nov 27 06:42:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 63282 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 nAR6gLpL017563 for ; Fri, 27 Nov 2009 06:42:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750971AbZK0GmO (ORCPT ); Fri, 27 Nov 2009 01:42:14 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751002AbZK0GmN (ORCPT ); Fri, 27 Nov 2009 01:42:13 -0500 Received: from mail-ew0-f219.google.com ([209.85.219.219]:53774 "EHLO mail-ew0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750964AbZK0GmN (ORCPT ); Fri, 27 Nov 2009 01:42:13 -0500 Received: by ewy19 with SMTP id 19so1125670ewy.21 for ; Thu, 26 Nov 2009 22:42:18 -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=0L1j83Y1zF51GcLdjFT7hP43ClUbFFJ8i2+tChQTR/k=; b=Sstr4+vqoZmWVdalO7xDQldYF8PufJ2xwGOvF7LtVhzYi0UJ6ukHE3mfUqvEmDGF8W GAJ2JiwHVVFHn+P5QkLXmXnWcLCx5XR5x9fuiwBFg66nxUXEDpqgDg4uJUqqFBxycWkD Z8x0nQ6CioZq0ycYQmec4mJB8rZQDZ+VeQAJI= 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=jonZ1z2QxVda5U66lBT9BgCyeRoOq5qZEAwgAnakAoQtFR0kD7h7cF+VYf61JW/USF ceqKKE7dSOUDFG7LyM0jB3Rz/aNT5fKg/ez/RwdnayPsY9vJxOFN1oe3teX8kjPGSAdh T+ys72cClmKFkglIsjHKe1i2ONwocr1J/2ESY= Received: by 10.213.107.16 with SMTP id z16mr714943ebo.47.1259304138066; Thu, 26 Nov 2009 22:42:18 -0800 (PST) Received: from x200.malnet.ru ([213.171.34.231]) by mx.google.com with ESMTPS id 10sm2318173eyd.45.2009.11.26.22.42.17 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 26 Nov 2009 22:42:17 -0800 (PST) Date: Fri, 27 Nov 2009 09:42:16 +0300 From: Alexey Dobriyan To: lethal@linux-sh.org Cc: akpm@linux-foundation.org, linux-sh@vger.kernel.org Subject: [PATCH] sh: convert /proc/cpu/aligmnent, /proc/cpu/kernel_alignment to seq_file Message-ID: <20091127064216.GD25983@x200.malnet.ru> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org --- a/arch/sh/kernel/traps_32.c +++ b/arch/sh/kernel/traps_32.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -68,61 +69,49 @@ static const char *se_usermode_action[] = { "signal+warn" }; -static int -proc_alignment_read(char *page, char **start, off_t off, int count, int *eof, - void *data) +static int alignment_proc_show(struct seq_file *m, void *v) { - char *p = page; - int len; - - p += sprintf(p, "User:\t\t%lu\n", se_user); - p += sprintf(p, "System:\t\t%lu\n", se_sys); - p += sprintf(p, "Half:\t\t%lu\n", se_half); - p += sprintf(p, "Word:\t\t%lu\n", se_word); - p += sprintf(p, "DWord:\t\t%lu\n", se_dword); - p += sprintf(p, "Multi:\t\t%lu\n", se_multi); - p += sprintf(p, "User faults:\t%i (%s)\n", se_usermode, + seq_printf(m, "User:\t\t%lu\n", se_user); + seq_printf(m, "System:\t\t%lu\n", se_sys); + seq_printf(m, "Half:\t\t%lu\n", se_half); + seq_printf(m, "Word:\t\t%lu\n", se_word); + seq_printf(m, "DWord:\t\t%lu\n", se_dword); + seq_printf(m, "Multi:\t\t%lu\n", se_multi); + seq_printf(m, "User faults:\t%i (%s)\n", se_usermode, se_usermode_action[se_usermode]); - p += sprintf(p, "Kernel faults:\t%i (fixup%s)\n", se_kernmode_warn, + seq_printf(m, "Kernel faults:\t%i (fixup%s)\n", se_kernmode_warn, se_kernmode_warn ? "+warn" : ""); - - len = (p - page) - off; - if (len < 0) - len = 0; - - *eof = (len <= count) ? 1 : 0; - *start = page + off; - - return len; + return 0; } -static int proc_alignment_write(struct file *file, const char __user *buffer, - unsigned long count, void *data) +static int alignment_proc_open(struct inode *inode, struct file *file) { - char mode; - - if (count > 0) { - if (get_user(mode, buffer)) - return -EFAULT; - if (mode >= '0' && mode <= '5') - se_usermode = mode - '0'; - } - return count; + return single_open(file, alignment_proc_show, NULL); } -static int proc_alignment_kern_write(struct file *file, const char __user *buffer, - unsigned long count, void *data) +static ssize_t alignment_proc_write(struct file *file, + const char __user *buffer, size_t count, loff_t *pos) { + int *data = PDE(file->f_path.dentry->d_inode)->data; char mode; if (count > 0) { if (get_user(mode, buffer)) return -EFAULT; - if (mode >= '0' && mode <= '1') - se_kernmode_warn = mode - '0'; + if (mode >= '0' && mode <= '5') + *data = mode - '0'; } return count; } + +static const struct file_operations alignment_proc_fops = { + .owner = THIS_MODULE, + .open = alignment_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, + .write = alignment_proc_write, +}; #endif static void dump_mem(const char *str, unsigned long bottom, unsigned long top) @@ -1011,20 +1000,16 @@ static int __init alignment_init(void) if (!dir) return -ENOMEM; - res = create_proc_entry("alignment", S_IWUSR | S_IRUGO, dir); + res = proc_create_data("alignment", S_IWUSR | S_IRUGO, dir, + &alignment_proc_fops, &se_usermode); if (!res) return -ENOMEM; - res->read_proc = proc_alignment_read; - res->write_proc = proc_alignment_write; - - res = create_proc_entry("kernel_alignment", S_IWUSR | S_IRUGO, dir); + res = proc_create_data("kernel_alignment", S_IWUSR | S_IRUGO, dir, + &alignment_proc_fops, &se_kernmode_warn); if (!res) return -ENOMEM; - res->read_proc = proc_alignment_read; - res->write_proc = proc_alignment_kern_write; - return 0; }