From: fche@redhat.com (Frank Ch. Eigler)
To: Mike Frysinger <vapier@gentoo.org>
Cc: gdb-patches@sourceware.org, toolchain-devel@blackfin.uclinux.org
Subject: Re: =?UTF-8?q?=5BPATCH=20v3=5D=20sim=3A=20cfi=3A=20new=20flash=20device=20simulation?=
Date: Fri, 25 Mar 2011 15:54:00 -0000 [thread overview]
Message-ID: <y0mzkojp6yq.fsf@fche.csb> (raw)
In-Reply-To: <1301012212-2372-1-git-send-email-vapier__17299.0819243298$1301012210$gmane$org@gentoo.org> (Mike Frysinger's message of "Thu, 24 Mar 2011 20:16:52 -0400")
vapier wrote:
> This simulates a CFI flash. [...]
Nice work, good looking code. Only some tiny nits:
> +static unsigned
> +cfi_unshift_addr (struct cfi *cfi, unsigned addr)
> +{
> + switch (cfi->width)
> + {
> + case 4: addr >>= 1;
> + case 2: addr >>= 1;
> + }
A note about the deliberate case fallthrough might be nice.
> +/* Clean up any state when this device is removed (e.g. when shutting down,
> + or when reloading via gdb). */
> +static void
> +cfi_delete_callback (struct hw *me)
> +{
> +#ifdef HAVE_MMAP
> + struct cfi *cfi = hw_data (me);
> +
> + if (cfi->mmap)
> + munmap (cfi->mmap, cfi->dev_size);
> +#endif
> +}
Woudln't you want to write(2) out the contents of the flash backing
store file, if !HAVE_MMAP?
> +static void
> +attach_cfi_regs (struct hw *me, struct cfi *cfi)
> +[...]
> + cfi->data = HW_NALLOC (me, unsigned char, cfi->dev_size);
> + if (fd != -1)
> + read_len = read (fd, cfi->data, cfi->dev_size);
It's more typical to loop in read(2), in case of an EINTR or somesuch
temporary-failure return code. Or use fread(3)?
- FChE
next prev parent reply other threads:[~2011-03-25 15:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-31 6:33 [PATCH] sim: cfi: new flash device simulation Mike Frysinger
2011-02-07 6:11 ` Mike Frysinger
2011-03-15 20:11 ` Mike Frysinger
2011-03-24 11:24 ` [PATCH v2] " Mike Frysinger
2011-03-24 15:50 ` Joel Brobecker
2011-03-25 0:13 ` Mike Frysinger
2011-03-25 9:49 ` [PATCH v3] " Mike Frysinger
2011-03-25 15:55 ` Joel Brobecker
[not found] ` <1301012212-2372-1-git-send-email-vapier__17299.0819243298$1301012210$gmane$org@gentoo.org>
2011-03-25 15:54 ` Frank Ch. Eigler [this message]
2011-03-26 7:00 ` [PATCH v4] " Mike Frysinger
2011-03-29 15:41 ` Joel Brobecker
2011-03-29 20:22 ` Mike Frysinger
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=y0mzkojp6yq.fsf@fche.csb \
--to=fche@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=toolchain-devel@blackfin.uclinux.org \
--cc=vapier@gentoo.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