From 39a81cdd7d7b44330451eefaf6daaac80fa8afa9 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 25 Oct 2016 22:28:27 -0400 Subject: driver: internals: added the static inlined sfrt_get_driver_ictx() helper. --- src/internal/sofort_driver_impl.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/internal') diff --git a/src/internal/sofort_driver_impl.h b/src/internal/sofort_driver_impl.h index 0808b55..4fdcf96 100644 --- a/src/internal/sofort_driver_impl.h +++ b/src/internal/sofort_driver_impl.h @@ -35,4 +35,17 @@ struct sfrt_unit_ctx_impl { struct sfrt_unit_ctx uctx; }; +static inline struct sfrt_driver_ctx_impl * sfrt_get_driver_ictx( + const struct sfrt_driver_ctx * dctx) +{ + uintptr_t addr; + + if (dctx) { + addr = (uintptr_t)dctx - offsetof(struct sfrt_driver_ctx_impl,ctx); + return (struct sfrt_driver_ctx_impl *)addr; + } + + return 0; +} + #endif -- cgit v1.2.3