From: Tony Lindgren <tony@atomide.com>
To: David Howells <dhowells@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Russell King <linux@arm.linux.org.uk>,
Kevin Hilman <khilman@deeprootsystems.com>,
viro@ZenIV.linux.org.uk, linux-omap@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 25/26] arm: Don't use create_proc_read_entry() [RFC]
Date: Thu, 11 Apr 2013 08:48:07 -0700 [thread overview]
Message-ID: <20130411154806.GU10155@atomide.com> (raw)
In-Reply-To: <20130411133058.32763.5466.stgit@warthog.procyon.org.uk>
* David Howells <dhowells@redhat.com> [130411 06:35]:
> Don't use create_proc_read_entry() as that is deprecated, but rather use
> proc_create_data() and seq_file instead.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Russell King <linux@arm.linux.org.uk>
> cc: Kevin Hilman <khilman@deeprootsystems.com>
Looks like the mach-omap1/pm.c part we can make into
a debugfs entry as it only contains PM debug data. But
that we can do after this patch.
Acked-by: Tony Lindgren <tony@atomide.com>
> cc: linux-arm-kernel@lists.infradead.org
> cc: linux-omap@vger.kernel.org
> ---
>
> arch/arm/kernel/swp_emulate.c | 42 +++++++++++++-----------------
> arch/arm/mach-omap1/pm.c | 58 +++++++++++++++++------------------------
> 2 files changed, 43 insertions(+), 57 deletions(-)
>
> diff --git a/arch/arm/kernel/swp_emulate.c b/arch/arm/kernel/swp_emulate.c
> index 0bba47a..087fc32 100644
> --- a/arch/arm/kernel/swp_emulate.c
> +++ b/arch/arm/kernel/swp_emulate.c
> @@ -21,6 +21,7 @@
> #include <linux/init.h>
> #include <linux/kernel.h>
> #include <linux/proc_fs.h>
> +#include <linux/seq_file.h>
> #include <linux/sched.h>
> #include <linux/syscalls.h>
> #include <linux/perf_event.h>
> @@ -79,27 +80,27 @@ static unsigned long abtcounter;
> static pid_t previous_pid;
>
> #ifdef CONFIG_PROC_FS
> -static int proc_read_status(char *page, char **start, off_t off, int count,
> - int *eof, void *data)
> +static int proc_status_show(struct seq_file *m, void *v)
> {
> - char *p = page;
> - int len;
> -
> - p += sprintf(p, "Emulated SWP:\t\t%lu\n", swpcounter);
> - p += sprintf(p, "Emulated SWPB:\t\t%lu\n", swpbcounter);
> - p += sprintf(p, "Aborted SWP{B}:\t\t%lu\n", abtcounter);
> + seq_printf(m, "Emulated SWP:\t\t%lu\n", swpcounter);
> + seq_printf(m, "Emulated SWPB:\t\t%lu\n", swpbcounter);
> + seq_printf(m, "Aborted SWP{B}:\t\t%lu\n", abtcounter);
> if (previous_pid != 0)
> - p += sprintf(p, "Last process:\t\t%d\n", previous_pid);
> -
> - len = (p - page) - off;
> - if (len < 0)
> - len = 0;
> -
> - *eof = (len <= count) ? 1 : 0;
> - *start = page + off;
> + seq_printf(m, "Last process:\t\t%d\n", previous_pid);
> + return 0;
> +}
>
> - return len;
> +static int proc_status_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, proc_status_show, PDE_DATA(inode));
> }
> +
> +static const struct file_operations proc_status_fops = {
> + .open = proc_status_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = seq_release,
> +};
> #endif
>
> /*
> @@ -266,12 +267,7 @@ static struct undef_hook swp_hook = {
> static int __init swp_emulation_init(void)
> {
> #ifdef CONFIG_PROC_FS
> - struct proc_dir_entry *res;
> -
> - res = create_proc_read_entry("cpu/swp_emulation", S_IRUGO, NULL,
> - proc_read_status, NULL);
> -
> - if (!res)
> + if (!proc_create("cpu/swp_emulation", S_IRUGO, NULL, &proc_status_fops))
> return -ENOMEM;
> #endif /* CONFIG_PROC_FS */
>
> diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
> index 7a7690a..2645e37 100644
> --- a/arch/arm/mach-omap1/pm.c
> +++ b/arch/arm/mach-omap1/pm.c
> @@ -38,6 +38,7 @@
> #include <linux/suspend.h>
> #include <linux/sched.h>
> #include <linux/proc_fs.h>
> +#include <linux/seq_file.h>
> #include <linux/interrupt.h>
> #include <linux/sysfs.h>
> #include <linux/module.h>
> @@ -423,22 +424,11 @@ void omap1_pm_suspend(void)
> }
>
> #if defined(DEBUG) && defined(CONFIG_PROC_FS)
> -static int g_read_completed;
> -
> /*
> * Read system PM registers for debugging
> */
> -static int omap_pm_read_proc(
> - char *page_buffer,
> - char **my_first_byte,
> - off_t virtual_start,
> - int length,
> - int *eof,
> - void *data)
> +static int omap_pm_proc_show(struct seq_file *m, void *v)
> {
> - int my_buffer_offset = 0;
> - char * const my_base = page_buffer;
> -
> ARM_SAVE(ARM_CKCTL);
> ARM_SAVE(ARM_IDLECT1);
> ARM_SAVE(ARM_IDLECT2);
> @@ -479,10 +469,7 @@ static int omap_pm_read_proc(
> MPUI1610_SAVE(EMIFS_CONFIG);
> }
>
> - if (virtual_start == 0) {
> - g_read_completed = 0;
> -
> - my_buffer_offset += sprintf(my_base + my_buffer_offset,
> + seq_printf(m,
> "ARM_CKCTL_REG: 0x%-8x \n"
> "ARM_IDLECT1_REG: 0x%-8x \n"
> "ARM_IDLECT2_REG: 0x%-8x \n"
> @@ -512,8 +499,8 @@ static int omap_pm_read_proc(
> ULPD_SHOW(ULPD_STATUS_REQ),
> ULPD_SHOW(ULPD_POWER_CTRL));
>
> - if (cpu_is_omap7xx()) {
> - my_buffer_offset += sprintf(my_base + my_buffer_offset,
> + if (cpu_is_omap7xx()) {
> + seq_printf(m,
> "MPUI7XX_CTRL_REG 0x%-8x \n"
> "MPUI7XX_DSP_STATUS_REG: 0x%-8x \n"
> "MPUI7XX_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
> @@ -526,8 +513,8 @@ static int omap_pm_read_proc(
> MPUI7XX_SHOW(MPUI_DSP_API_CONFIG),
> MPUI7XX_SHOW(EMIFF_SDRAM_CONFIG),
> MPUI7XX_SHOW(EMIFS_CONFIG));
> - } else if (cpu_is_omap15xx()) {
> - my_buffer_offset += sprintf(my_base + my_buffer_offset,
> + } else if (cpu_is_omap15xx()) {
> + seq_printf(m,
> "MPUI1510_CTRL_REG 0x%-8x \n"
> "MPUI1510_DSP_STATUS_REG: 0x%-8x \n"
> "MPUI1510_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
> @@ -540,8 +527,8 @@ static int omap_pm_read_proc(
> MPUI1510_SHOW(MPUI_DSP_API_CONFIG),
> MPUI1510_SHOW(EMIFF_SDRAM_CONFIG),
> MPUI1510_SHOW(EMIFS_CONFIG));
> - } else if (cpu_is_omap16xx()) {
> - my_buffer_offset += sprintf(my_base + my_buffer_offset,
> + } else if (cpu_is_omap16xx()) {
> + seq_printf(m,
> "MPUI1610_CTRL_REG 0x%-8x \n"
> "MPUI1610_DSP_STATUS_REG: 0x%-8x \n"
> "MPUI1610_DSP_BOOT_CONFIG_REG: 0x%-8x \n"
> @@ -554,25 +541,28 @@ static int omap_pm_read_proc(
> MPUI1610_SHOW(MPUI_DSP_API_CONFIG),
> MPUI1610_SHOW(EMIFF_SDRAM_CONFIG),
> MPUI1610_SHOW(EMIFS_CONFIG));
> - }
> -
> - g_read_completed++;
> - } else if (g_read_completed >= 1) {
> - *eof = 1;
> - return 0;
> }
> - g_read_completed++;
>
> - *my_first_byte = page_buffer;
> - return my_buffer_offset;
> + return 0;
> +}
> +
> +static int omap_pm_proc_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, omap_pm_proc_show, PDE_DATA(inode));
> }
>
> +static const struct file_operations omap_pm_proc_fops = {
> + .open = omap_pm_proc_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = seq_release,
> +};
> +
> static void omap_pm_init_proc(void)
> {
> /* XXX Appears to leak memory */
> - create_proc_read_entry("driver/omap_pm",
> - S_IWUSR | S_IRUGO, NULL,
> - omap_pm_read_proc, NULL);
> + create_proc("driver/omap_pm", S_IWUSR | S_IRUGO, NULL,
> + &omap_pm_proc_fops);
> }
>
> #endif /* DEBUG && CONFIG_PROC_FS */
>
next prev parent reply other threads:[~2013-04-11 15:48 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-11 13:27 [PATCH 00/26] Eliminate create_proc_read_entry() [RFC] David Howells
2013-04-11 13:27 ` [PATCH 01/26] procfs: Mark create_proc_read_entry deprecated [RFC] David Howells
2013-04-11 13:27 ` [PATCH 02/26] rtl8192u: Don't use create_proc_read_entry() [RFC] David Howells
2013-04-11 13:28 ` [PATCH 03/26] rtl8187se: " David Howells
2013-04-11 13:28 ` [PATCH 04/26] ft1000: " David Howells
2013-04-11 13:28 ` [PATCH 05/26] comedi: " David Howells
2013-04-11 15:07 ` Ian Abbott
2013-04-11 15:15 ` David Howells
2013-04-11 19:05 ` Greg Kroah-Hartman
2013-04-12 10:56 ` Ian Abbott
2013-04-11 13:28 ` [PATCH 06/26] csr: " David Howells
2013-04-11 13:28 ` [PATCH 07/26] cxt1e1: " David Howells
2013-04-11 13:28 ` [PATCH 08/26] wlags49_h2: " David Howells
2013-04-11 13:28 ` [PATCH 09/26] goku_udc: " David Howells
2013-04-11 13:29 ` [PATCH 10/26] fsl_udc: " David Howells
2013-04-11 13:29 ` [PATCH 11/26] nubus: " David Howells
2013-04-11 13:29 ` [PATCH 12/26] hp_sdc_rtc: " David Howells
2013-04-11 13:29 ` [PATCH 13/26] genrtc: " David Howells
2013-04-11 13:29 ` [PATCH 14/26] efirtc: " David Howells
2013-04-11 13:29 ` [PATCH 15/26] ds1620: " David Howells
2013-04-11 13:29 ` [PATCH 16/26] atmel: " David Howells
2013-04-11 13:30 ` [PATCH 18/26] megaraid: " David Howells
2013-04-12 8:56 ` Hannes Reinecke
2013-04-11 13:30 ` [PATCH 19/26] sh: " David Howells
2013-04-16 6:11 ` Simon Horman
2013-04-16 6:28 ` Al Viro
2013-04-16 18:42 ` Paul Mundt
2013-04-17 0:41 ` Simon Horman
2013-04-11 13:30 ` [PATCH 20/26] parisc: " David Howells
2013-04-11 13:30 ` [PATCH 21/26] mips: " David Howells
2013-04-11 13:30 ` [PATCH 22/26] ia64: " David Howells
2013-04-11 13:30 ` [PATCH 23/26] h8300: " David Howells
2013-04-11 13:30 ` [PATCH 24/26] cris: " David Howells
2013-04-12 10:58 ` Jesper Nilsson
2013-04-11 13:30 ` [PATCH 25/26] arm: " David Howells
2013-04-11 15:48 ` Tony Lindgren [this message]
2013-04-11 16:45 ` David Howells
2013-04-11 16:57 ` Tony Lindgren
2013-04-11 18:03 ` Tony Lindgren
2013-04-11 13:31 ` [PATCH 26/26] proc: Delete " David Howells
2013-04-11 14:11 ` [PATCH 00/26] Eliminate " Arnd Bergmann
[not found] ` <20130411132952.32763.3184.stgit@warthog.procyon.org.uk>
2013-04-11 19:06 ` [PATCH 17/26] hostap: Don't use " Greg Kroah-Hartman
2013-04-11 19:07 ` [PATCH 00/26] Eliminate " Greg KH
2013-04-11 22:34 ` David Howells
2013-04-12 20:12 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130411154806.GU10155@atomide.com \
--to=tony@atomide.com \
--cc=dhowells@redhat.com \
--cc=khilman@deeprootsystems.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).