2007-08-16 20:05:52

by Sebastian Siewior

[permalink] [raw]
Subject: [patch 01/10] t add cast to regain ablkcipher_request from private ctx

This cast allows to regain the struct ablkcipher_request for a request
from private data.

Signed-off-by: Sebastian Siewior <[email protected]>
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -580,6 +580,12 @@ static inline struct ablkcipher_request
return container_of(req, struct ablkcipher_request, base);
}

+static inline struct ablkcipher_request *ablkcipher_ctx_cast(
+ void *ctx)
+{
+ return container_of(ctx, struct ablkcipher_request, __ctx);
+}
+
static inline struct ablkcipher_request *ablkcipher_request_alloc(
struct crypto_ablkcipher *tfm, gfp_t gfp)
{

--


2007-08-17 08:55:19

by Herbert Xu

[permalink] [raw]
Subject: Re: [patch 01/10] t add cast to regain ablkcipher_request from private ctx

On Thu, Aug 16, 2007 at 10:01:06PM +0200, Sebastian Siewior wrote:
> This cast allows to regain the struct ablkcipher_request for a request
> from private data.

Hi Sebastian:

I think this function would make more sense as a private
function in your driver. That way you can give it an
explicit type rather than having it take a void *.

We want to avoid unnecessary casting like this where
possible as it's error-prone.

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt