From 2c6f6eabc0bfcea0a62370038da713e3873cff31 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Fri, 12 Jun 2015 10:58:47 -0400 Subject: 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 Signed-off-by: Herbert Xu --- drivers/crypto/nx/nx-842-pseries.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/crypto/nx/nx-842-pseries.c') 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; -- cgit v1.2.3