[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20090912145712.GC6511@localhost>
Date: Sat, 12 Sep 2009 22:57:12 +0800
From: Wu Fengguang <fengguang.wu@...el.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: "mtosatti@...hat.com" <mtosatti@...hat.com>,
"gregkh@...e.de" <gregkh@...e.de>,
"broonie@...nsource.wolfsonmicro.com"
<broonie@...nsource.wolfsonmicro.com>,
"johannes@...solutions.net" <johannes@...solutions.net>,
"avi@...ranet.com" <avi@...ranet.com>,
"andi@...stfloor.org" <andi@...stfloor.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] devmem: cleanup unxlate_dev_mem_ptr() calls
On Sat, Sep 12, 2009 at 08:05:00AM +0800, Andrew Morton wrote:
> On Fri, 11 Sep 2009 10:23:36 +0800
> Wu Fengguang <fengguang.wu@...el.com> wrote:
>
> > No behavior change.
> >
> > CC: Marcelo Tosatti <mtosatti@...hat.com>
> > CC: Greg Kroah-Hartman <gregkh@...e.de>
> > CC: Mark Brown <broonie@...nsource.wolfsonmicro.com>
> > CC: Johannes Berg <johannes@...solutions.net>
> > CC: Avi Kivity <avi@...ranet.com>
> > Signed-off-by: Wu Fengguang <fengguang.wu@...el.com>
> > ---
> > drivers/char/mem.c | 13 +++++--------
> > 1 file changed, 5 insertions(+), 8 deletions(-)
> >
> > --- linux-mm.orig/drivers/char/mem.c 2009-09-10 21:59:39.000000000 +0800
> > +++ linux-mm/drivers/char/mem.c 2009-09-10 22:00:12.000000000 +0800
> > @@ -131,6 +131,7 @@ static ssize_t read_mem(struct file * fi
> > size_t count, loff_t *ppos)
> > {
> > unsigned long p = *ppos;
> > + unsigned long ret;
> > ssize_t read, sz;
> > char *ptr;
> >
> > @@ -169,12 +170,10 @@ static ssize_t read_mem(struct file * fi
> > if (!ptr)
> > return -EFAULT;
> >
> > - if (copy_to_user(buf, ptr, sz)) {
> > - unxlate_dev_mem_ptr(p, ptr);
> > - return -EFAULT;
> > - }
> > -
> > + ret = copy_to_user(buf, ptr, sz);
> > unxlate_dev_mem_ptr(p, ptr);
> > + if (ret)
> > + return -EFAULT;
> >
> > buf += sz;
> > p += sz;
>
> - local var `ret' didn't need function-wide scope. I think it's
> better to reduce its scope if poss.
OK.
> - conventionally the identifier `ret' refers to "the value which this
> function will return". Ditto `retval' and `rc'.
Good to know that, thanks!
> But that's not what `ret' does here so let's call it something
> else? `remaining' is rather verbose and formal, but accurate.
>
>
> --- a/drivers/char/mem.c~dev-mem-cleanup-unxlate_dev_mem_ptr-calls-fix
> +++ a/drivers/char/mem.c
> @@ -131,7 +131,6 @@ static ssize_t read_mem(struct file * fi
> size_t count, loff_t *ppos)
> {
> unsigned long p = *ppos;
> - unsigned long ret;
I got compile error because another place in read_mem() used ret.
I'll send you an updated fix.
Thanks,
Fengguang
> ssize_t read, sz;
> char *ptr;
>
> @@ -156,6 +155,8 @@ static ssize_t read_mem(struct file * fi
> #endif
>
> while (count > 0) {
> + unsigned long remaining;
> +
> sz = size_inside_page(p, count);
>
> if (!range_is_allowed(p >> PAGE_SHIFT, count))
> @@ -170,9 +171,9 @@ static ssize_t read_mem(struct file * fi
> if (!ptr)
> return -EFAULT;
>
> - ret = copy_to_user(buf, ptr, sz);
> + remaining = copy_to_user(buf, ptr, sz);
> unxlate_dev_mem_ptr(p, ptr);
> - if (ret)
> + if (remaining)
> return -EFAULT;
>
> buf += sz;
> _
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists