aboutsummaryrefslogtreecommitdiff
path: root/drivers/crypto/nx/nx-842-pseries.c
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@ieee.org>2015-06-12 10:58:47 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-06-15 18:15:57 +0800
commit2c6f6eabc0bfcea0a62370038da713e3873cff31 (patch)
tree7c82b26a28581a9502c59a96e8f8a4fc5b94df2f /drivers/crypto/nx/nx-842-pseries.c
parent32be6d3e362b896c81aae7c635d44e5a91406ce2 (diff)
crypto: nx - replace NX842_MEM_COMPRESS with function
Replace the NX842_MEM_COMPRESS define with a function that returns the specific platform driver's required working memory size. The common nx-842.c driver refuses to load if there is no platform driver present, so instead of defining an approximate working memory size that's the maximum approximate size of both platform driver's size requirements, the platform driver can directly provide its specific, i.e. sizeof(struct nx842_workmem), size requirements which the 842-nx crypto compression driver will use. This saves memory by both reducing the required size of each driver to the specific sizeof() amount, as well as using the specific loaded platform driver's required amount, instead of the maximum of both. Signed-off-by: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/nx/nx-842-pseries.c')
-rw-r--r--drivers/crypto/nx/nx-842-pseries.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/crypto/nx/nx-842-pseries.c b/drivers/crypto/nx/nx-842-pseries.c
index 41bc551ccaf3..da52d8edefb3 100644
--- a/drivers/crypto/nx/nx-842-pseries.c
+++ b/drivers/crypto/nx/nx-842-pseries.c
@@ -284,7 +284,7 @@ static int nx842_validate_result(struct device *dev,
* @out: Pointer to output buffer
* @outlen: Length of output buffer
* @wrkmem: ptr to buffer for working memory, size determined by
- * NX842_MEM_COMPRESS
+ * nx842_pseries_driver.workmem_size
*
* Returns:
* 0 Success, output of length @outlen stored in the buffer at @out
@@ -411,7 +411,7 @@ unlock:
* @out: Pointer to output buffer
* @outlen: Length of output buffer
* @wrkmem: ptr to buffer for working memory, size determined by
- * NX842_MEM_COMPRESS
+ * nx842_pseries_driver.workmem_size
*
* Returns:
* 0 Success, output of length @outlen stored in the buffer at @out
@@ -963,6 +963,7 @@ static struct attribute_group nx842_attribute_group = {
static struct nx842_driver nx842_pseries_driver = {
.name = KBUILD_MODNAME,
.owner = THIS_MODULE,
+ .workmem_size = sizeof(struct nx842_workmem),
.constraints = &nx842_pseries_constraints,
.compress = nx842_pseries_compress,
.decompress = nx842_pseries_decompress,
@@ -1084,8 +1085,6 @@ static int __init nx842_init(void)
pr_info("Registering IBM Power 842 compression driver\n");
- BUILD_BUG_ON(sizeof(struct nx842_workmem) > NX842_MEM_COMPRESS);
-
if (!of_find_compatible_node(NULL, NULL, "ibm,compression"))
return -ENODEV;