From: Roland Dreier <rdreier@cisco.com>
To: akepner@sgi.com
Cc: Tony Luck <tony.luck@intel.com>,
Grant Grundler <grundler@parisc-linux.org>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
Jes Sorensen <jes@sgi.com>,
Randy Dunlap <randy.dunlap@oracle.com>,
James Bottomley <James.Bottomley@HansenPartnership.com>,
David Miller <davem@davemloft.net>,
Muli Ben-Yehuda <muli@il.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC/PATCH] dma: dma_{un}map_{single|sg}_attrs() interface
Date: Tue, 22 Jan 2008 20:59:50 -0800 [thread overview]
Message-ID: <adawsq1qgqh.fsf@cisco.com> (raw)
In-Reply-To: <20080122024251.GJ30022@sgi.com> (akepner@sgi.com's message of "Mon, 21 Jan 2008 18:42:51 -0800")
> --- a/include/linux/dma-attrs.h
> +++ b/include/linux/dma-attrs.h
> @@ -0,0 +1,33 @@
> +#ifndef _DMA_ATTR_H
> +#define _DMA_ATTR_H
> +
> +#include <linux/bug.h>
> +
> +enum {
> + DMA_ATTR_INVALID,
> + DMA_ATTR_BARRIER,
> + DMA_ATTR_FOO,
> + DMA_ATTR_GOO,
> + DMA_ATTR_MAX,
> +};
> +
> +struct dma_attrs {
> + unsigned flags;
> +};
> +
> +static inline int dma_set_attr(struct dma_attrs *attrs, unsigned attr) {
maybe this would be cleaner if you named the DMA_ATTR enum and used
that instead of unsigned here (and below)?
> + BUG_ON(attrs == NULL);
does this BUG_ON() buy us much? It seems the only thing we would fail
to oops on is if someone did dma_set_attr(NULL, INVALID) and I'm not
sure it's worth it to BUG here.
> + if (attr > DMA_ATTR_INVALID && attr < DMA_ATTR_MAX) {
> + attrs->flags = (1 << attr);
> + return 0;
> + }
> + return 1;
returning -EINVAL here instead of 1 would probably be more "kernelish".
> +}
> +
> +static inline int dma_get_attr(struct dma_attrs *attrs, unsigned attr) {
> + if (attrs)
> + return attrs->flags & (1 << attr);
so it's OK to pass attrs == NULL into dma_get_attr() but not into
dma_set_attr()? seems kind of odd.
> + return 0;
> +}
It seems you're missing a way to initialize a struct dma_attrs. How
do I clear the flags field to start with?
A macro like DEFINE_DMA_ATTRS() that initializes things for you (like
LIST_HEAD or DEFINE_SPIN_LOCK) would probably be a good thing to have
as well.
Also I guess you could test ARCH_USES_DMA_ATTRS in this file and stub
everything out and define an empty structure if it's not defined.
save a few bytes of stack etc.
> +
> +#endif /* _DMA_ATTR_H */
next prev parent reply other threads:[~2008-01-23 5:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-22 2:42 [RFC/PATCH] dma: dma_{un}map_{single|sg}_attrs() interface akepner
2008-01-23 4:59 ` Roland Dreier [this message]
2008-01-24 23:36 ` akepner
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=adawsq1qgqh.fsf@cisco.com \
--to=rdreier@cisco.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=akepner@sgi.com \
--cc=davem@davemloft.net \
--cc=grundler@parisc-linux.org \
--cc=jbarnes@virtuousgeek.org \
--cc=jes@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=muli@il.ibm.com \
--cc=randy.dunlap@oracle.com \
--cc=tony.luck@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.