From: Sascha Hauer <s.hauer@pengutronix.de>
To: Alexander Aring <alex.aring@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] nandtest: use new pread and pwrite functions
Date: Thu, 21 Feb 2013 14:31:02 +0100 [thread overview]
Message-ID: <20130221133102.GQ1906@pengutronix.de> (raw)
In-Reply-To: <1361307394-24649-1-git-send-email-alex.aring@gmail.com>
On Tue, Feb 19, 2013 at 09:56:33PM +0100, Alexander Aring wrote:
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
> commands/nandtest.c | 36 ++++++------------------------------
> 1 file changed, 6 insertions(+), 30 deletions(-)
Applied, thanks
I squashed this into the commit adding pread/pwrite to make this commit
compilable.
Sascha
>
> diff --git a/commands/nandtest.c b/commands/nandtest.c
> index f08f8eb..4e6024b 100644
> --- a/commands/nandtest.c
> +++ b/commands/nandtest.c
> @@ -43,41 +43,17 @@ static unsigned int ecc_stats_over;
> static unsigned int ecc_failed_cnt;
>
> /*
> - * Implementation of pread with lseek and read.
> - */
> -static ssize_t pread(int fd, void *buf, size_t count, loff_t offset)
> -{
> - int ret;
> -
> - /* Seek to offset */
> - ret = lseek(fd, offset, SEEK_SET);
> - if (ret < 0)
> - perror("lseek");
> -
> - /* Read from flash and put it into buf */
> - ret = read(fd, buf, count);
> - if (ret < 0)
> - perror("read");
> -
> - return 0;
> -}
> -
> -/*
> * Implementation of pwrite with lseek and write.
> */
> -static ssize_t pwrite(int fd, const void *buf,
> +static ssize_t __pwrite(int fd, const void *buf,
> size_t count, loff_t offset, loff_t length)
> {
> - int ret;
> -
> - ret = lseek(fd, offset, SEEK_SET);
> - if (ret < 0)
> - perror("lseek");
> + ssize_t ret;
>
> /* Write buf to flash */
> - ret = write(fd, buf, count);
> + ret = pwrite(fd, buf, count, offset);
> if (ret < 0) {
> - perror("write");
> + perror("pwrite");
> if (markbad) {
> printf("\nMark block bad at 0x%08llx\n",
> offset + memregion.offset);
> @@ -88,7 +64,7 @@ static ssize_t pwrite(int fd, const void *buf,
> }
>
> flush(fd);
> - return 0;
> + return ret;
> }
>
> /*
> @@ -119,7 +95,7 @@ static int erase_and_write(loff_t ofs, unsigned char *data,
> for (i = 0; i < meminfo.erasesize;
> i += meminfo.writesize) {
> /* Write data to given offset */
> - pwrite(fd, data + i, meminfo.writesize,
> + __pwrite(fd, data + i, meminfo.writesize,
> ofs + i, length);
>
> /* Read data from offset */
> --
> 1.8.1.3
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-02-21 13:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-19 20:56 Alexander Aring
2013-02-19 20:56 ` [PATCH 2/2] nandtest: fix length calculation Alexander Aring
2013-02-21 13:31 ` Sascha Hauer [this message]
2013-02-21 19:50 ` [PATCH 1/2] nandtest: use new pread and pwrite functions Alexander Aring
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=20130221133102.GQ1906@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=alex.aring@gmail.com \
--cc=barebox@lists.infradead.org \
/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