From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mtd: nand: new base driver for memory mapped nand devices
Date: Mon, 13 Apr 2009 18:09:16 -0400 [thread overview]
Message-ID: <200904131809.17185.vapier@gentoo.org> (raw)
In-Reply-To: <49E3B1A8.3060104@freescale.com>
On Monday 13 April 2009 17:42:00 Scott Wood wrote:
> Mike Frysinger wrote:
> > On Monday 13 April 2009 11:59:30 Scott Wood wrote:
> >> On Sat, Apr 11, 2009 at 09:26:42PM -0400, Mike Frysinger wrote:
> >>> +#ifdef NAND_PLAT_WRITE_CMD
> >>
> >> Why would a user select this driver without providing the necessary
> >> definitions -- and if they do, why do you want anything other than
> >> a compilation error to result?
> >
> > *shrug* ... i'm not completely familiar with the nand layers and what
> > people have done to know exactly what is optional.
>
> You're defining the interface -- there are no existing users.
just because *my* device needs it doesnt mean every device needs it. i was
trying to be nice from the get go.
> > easy enough to turn it into:
> > #ifndef NAND_PLAT_WRITE_CMD
> > # error "You must define NAND_PLAT_WRITE_CMD"
> > #endif
>
> Or just let the compiler give an undefined symbol error.
true, but i think that route leads to people grepping files and scratching
their heads. an #error would save them some time.
> >> + /* Drain the writebuffer */
> >> + sync();
> >>
> >> This doesn't look generic to me.
> >
> > yes it does. every arch should define "sync()" in asm/io.h. if it
> > doesnt, your arch is broken.
>
> I realize that there is a "sync" defined in every architecture
> (otherwise, my comment would have been "this breaks on XXX arch").
>
> However, the need to do a sync in this specific situation is specific to
> how NAND_PLAT_WRITE_* are implemented (in many cases, they will have
> already included a sync or something similar -- they're often included
> in the basic I/O accessors). And the specific comment about a
> "writebuffer" seems even more out of place in generic code.
if they're included in the I/O accessors, then the arch most likely defines
sync() to nothing, so it doesnt matter. "write buffer" may not be entirely
arch independent, but it conveys the exact same thing as "make sure write
makes it to external device". this is how sync() is used -- just grep the
drivers tree and see the smsc driver for example.
> >> If we do do it in the header file, though, at least use static inline
> >> functions rather than macros -- besides being less visually obnoxious,
> >> they provide type checking of arguments and avoid problems with name
> >> collisions.
> >
> > actually, it kind of does the opposite. it increases name space
> > pollution. if someone does a #define with the same variable name or
> > similar as is used in the function, then you can easily get a build
> > failure.
>
> The root cause of that is the namespace-polluting #define, not the
> function. It would just as easily cause problems with code in .c files
> (including when your macros get expanded) as with inline functions in
> headers.
or accidental shadowing of global state, but i guess you dont care much about
that usage either
> > see all the random times this has caused a problem with
> > linux/glibc/uClibc and just function prototypes let alone function
> > definitions.
>
> This is an internal header file, not a public library header that is
> standards-constrained to accept #define interference from the application.
really ? you call internal kernel headers "standards constrained" ? my point
is that it's seen in both scenarios.
> > plus, not so critically, using
> > static inlines would slow down the compiler as it would need to compile &
> > optimize & consider it in every single file rather than letting the CPP
> > cull it early on.
>
> On the other hand, that means that errors get caught immediately rather
> than when usage changes.
indeed
> >> The latter will break if you put it in the body of a single-line if
> >> statement.
> >
> > i'm fully aware of this, but didnt care since i knew how it was used
>
> And maybe it gets used differently in the future? Or someone copies the
> bad example to somewhere else where it matters?
people should check their work before they hand in their paper ;)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090413/7d02c21b/attachment.pgp
next prev parent reply other threads:[~2009-04-13 22:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-12 1:26 [U-Boot] [PATCH] mtd: nand: new base driver for memory mapped nand devices Mike Frysinger
2009-04-13 15:59 ` Scott Wood
2009-04-13 21:18 ` Mike Frysinger
2009-04-13 21:42 ` Scott Wood
2009-04-13 22:09 ` Mike Frysinger [this message]
2009-04-13 23:02 ` Scott Wood
2009-04-13 23:47 ` Mike Frysinger
2009-05-06 13:05 ` [U-Boot] [PATCH v2] " Mike Frysinger
2009-05-06 17:35 ` Scott Wood
2009-05-06 18:04 ` Mike Frysinger
2009-05-06 18:19 ` Scott Wood
2009-05-06 19:14 ` Mike Frysinger
2009-05-06 19:38 ` [U-Boot] [PATCH v3] " Mike Frysinger
2009-05-06 19:49 ` Scott Wood
2009-05-06 20:10 ` Mike Frysinger
2009-05-06 20:53 ` Wolfgang Denk
2009-05-06 20:51 ` [U-Boot] [PATCH v2] " Wolfgang Denk
2009-05-06 23:28 ` Mike Frysinger
2009-05-07 0:28 ` [U-Boot] [PATCH v4] " Mike Frysinger
2009-05-11 19:14 ` Scott Wood
2009-05-13 23:45 ` [U-Boot] [PATCH v5] " Mike Frysinger
2009-05-19 21:55 ` Scott Wood
2009-05-26 2:42 ` [U-Boot] [PATCH v6] " Mike Frysinger
2009-05-29 19:52 ` Scott Wood
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=200904131809.17185.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=u-boot@lists.denx.de \
/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