aboutsummaryrefslogtreecommitdiff
path: root/common/bouncebuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/bouncebuf.c')
-rw-r--r--common/bouncebuf.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/common/bouncebuf.c b/common/bouncebuf.c
index 614eb36c785..0ace152b98e 100644
--- a/common/bouncebuf.c
+++ b/common/bouncebuf.c
@@ -31,17 +31,19 @@ static int addr_aligned(struct bounce_buffer *state)
return 1;
}
-int bounce_buffer_start(struct bounce_buffer *state, void *data,
- size_t len, unsigned int flags)
+int bounce_buffer_start_extalign(struct bounce_buffer *state, void *data,
+ size_t len, unsigned int flags,
+ size_t alignment,
+ int (*addr_is_aligned)(struct bounce_buffer *state))
{
state->user_buffer = data;
state->bounce_buffer = data;
state->len = len;
- state->len_aligned = roundup(len, ARCH_DMA_MINALIGN);
+ state->len_aligned = roundup(len, alignment);
state->flags = flags;
- if (!addr_aligned(state)) {
- state->bounce_buffer = memalign(ARCH_DMA_MINALIGN,
+ if (!addr_is_aligned(state)) {
+ state->bounce_buffer = memalign(alignment,
state->len_aligned);
if (!state->bounce_buffer)
return -ENOMEM;
@@ -62,6 +64,14 @@ int bounce_buffer_start(struct bounce_buffer *state, void *data,
return 0;
}
+int bounce_buffer_start(struct bounce_buffer *state, void *data,
+ size_t len, unsigned int flags)
+{
+ return bounce_buffer_start_extalign(state, data, len, flags,
+ ARCH_DMA_MINALIGN,
+ addr_aligned);
+}
+
int bounce_buffer_stop(struct bounce_buffer *state)
{
if (state->flags & GEN_BB_WRITE) {