From bc24681ca896900e9b61a2aa6d26b467f038815b Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 24 Oct 2016 18:58:58 -0400 Subject: driver: internals: added the static inlined pe_get_driver_ictx() helper. --- src/internal/perk_driver_impl.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/internal') diff --git a/src/internal/perk_driver_impl.h b/src/internal/perk_driver_impl.h index 5063fa1..bbd5f44 100644 --- a/src/internal/perk_driver_impl.h +++ b/src/internal/perk_driver_impl.h @@ -44,4 +44,18 @@ struct pe_unit_ctx_impl { struct pe_unit_ctx uctx; }; + +static inline struct pe_driver_ctx_impl * pe_get_driver_ictx( + const struct pe_driver_ctx * dctx) +{ + uintptr_t addr; + + if (dctx) { + addr = (uintptr_t)dctx - offsetof(struct pe_driver_ctx_impl,ctx); + return (struct pe_driver_ctx_impl *)addr; + } + + return 0; +} + #endif -- cgit v1.2.3