aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/nx/nx-842-pseries.c
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@ieee.org>2015-05-07 13:49:17 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-05-11 15:06:46 +0800
commit7011a122383e36dab594406720fa1d089e0be8f9 (patch)
treecd69055e54a29a9628331d8594545e50878352f3 /drivers/crypto/nx/nx-842-pseries.c
parentcrypto: nx - rename nx-842.c to nx-842-pseries.c (diff)
downloadlinux-dev-7011a122383e36dab594406720fa1d089e0be8f9.tar.xz
linux-dev-7011a122383e36dab594406720fa1d089e0be8f9.zip
crypto: nx - add NX-842 platform frontend driver
Add NX-842 frontend that allows using either the pSeries platform or PowerNV platform driver (to be added by later patch) for the NX-842 hardware. Update the MAINTAINERS file to include the new filenames. Update Kconfig files to clarify titles and descriptions, and correct dependencies. 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.c57
1 files changed, 27 insertions, 30 deletions
diff --git a/drivers/crypto/nx/nx-842-pseries.c b/drivers/crypto/nx/nx-842-pseries.c
index 887196e9b50c..9b83c9e7fd73 100644
--- a/drivers/crypto/nx/nx-842-pseries.c
+++ b/drivers/crypto/nx/nx-842-pseries.c
@@ -21,18 +21,13 @@
* Seth Jennings <sjenning@linux.vnet.ibm.com>
*/
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/nx842.h>
-#include <linux/of.h>
-#include <linux/slab.h>
-
#include <asm/page.h>
#include <asm/vio.h>
+#include "nx-842.h"
#include "nx_csbcpb.h" /* struct nx_csbcpb */
-#define MODULE_NAME "nx-compress"
+#define MODULE_NAME NX842_PSERIES_MODULE_NAME
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Robert Jennings <rcj@linux.vnet.ibm.com>");
MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors");
@@ -236,18 +231,6 @@ struct nx842_workmem {
};
};
-int nx842_get_workmem_size(void)
-{
- return sizeof(struct nx842_workmem) + NX842_HW_PAGE_SIZE;
-}
-EXPORT_SYMBOL_GPL(nx842_get_workmem_size);
-
-int nx842_get_workmem_size_aligned(void)
-{
- return sizeof(struct nx842_workmem);
-}
-EXPORT_SYMBOL_GPL(nx842_get_workmem_size_aligned);
-
static int nx842_validate_result(struct device *dev,
struct cop_status_block *csb)
{
@@ -300,7 +283,7 @@ static int nx842_validate_result(struct device *dev,
}
/**
- * nx842_compress - Compress data using the 842 algorithm
+ * nx842_pseries_compress - Compress data using the 842 algorithm
*
* Compression provide by the NX842 coprocessor on IBM Power systems.
* The input buffer is compressed and the result is stored in the
@@ -315,7 +298,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_get_workmem_size()
+ * NX842_MEM_COMPRESS
*
* Returns:
* 0 Success, output of length @outlen stored in the buffer at @out
@@ -325,8 +308,9 @@ static int nx842_validate_result(struct device *dev,
* -EIO Internal error
* -ENODEV Hardware unavailable
*/
-int nx842_compress(const unsigned char *in, unsigned int inlen,
- unsigned char *out, unsigned int *outlen, void *wmem)
+static int nx842_pseries_compress(const unsigned char *in, unsigned int inlen,
+ unsigned char *out, unsigned int *outlen,
+ void *wmem)
{
struct nx842_header *hdr;
struct nx842_devdata *local_devdata;
@@ -493,13 +477,12 @@ unlock:
rcu_read_unlock();
return ret;
}
-EXPORT_SYMBOL_GPL(nx842_compress);
static int sw842_decompress(const unsigned char *, int, unsigned char *, int *,
const void *);
/**
- * nx842_decompress - Decompress data using the 842 algorithm
+ * nx842_pseries_decompress - Decompress data using the 842 algorithm
*
* Decompression provide by the NX842 coprocessor on IBM Power systems.
* The input buffer is decompressed and the result is stored in the
@@ -515,7 +498,7 @@ static int sw842_decompress(const unsigned char *, int, unsigned char *, int *,
* @out: Pointer to output buffer, must be page aligned
* @outlen: Length of output buffer, must be PAGE_SIZE
* @wrkmem: ptr to buffer for working memory, size determined by
- * nx842_get_workmem_size()
+ * NX842_MEM_COMPRESS
*
* Returns:
* 0 Success, output of length @outlen stored in the buffer at @out
@@ -525,8 +508,9 @@ static int sw842_decompress(const unsigned char *, int, unsigned char *, int *,
* -EINVAL Bad input data encountered when attempting decompress
* -EIO Internal error
*/
-int nx842_decompress(const unsigned char *in, unsigned int inlen,
- unsigned char *out, unsigned int *outlen, void *wmem)
+static int nx842_pseries_decompress(const unsigned char *in, unsigned int inlen,
+ unsigned char *out, unsigned int *outlen,
+ void *wmem)
{
struct nx842_header *hdr;
struct nx842_devdata *local_devdata;
@@ -694,7 +678,6 @@ unlock:
rcu_read_unlock();
return ret;
}
-EXPORT_SYMBOL_GPL(nx842_decompress);
/**
* nx842_OF_set_defaults -- Set default (disabled) values for devdata
@@ -1130,6 +1113,12 @@ static struct attribute_group nx842_attribute_group = {
.attrs = nx842_sysfs_entries,
};
+static struct nx842_driver nx842_pseries_driver = {
+ .owner = THIS_MODULE,
+ .compress = nx842_pseries_compress,
+ .decompress = nx842_pseries_decompress,
+};
+
static int __init nx842_probe(struct vio_dev *viodev,
const struct vio_device_id *id)
{
@@ -1192,6 +1181,8 @@ static int __init nx842_probe(struct vio_dev *viodev,
goto error;
}
+ nx842_register_driver(&nx842_pseries_driver);
+
return 0;
error_unlock:
@@ -1222,11 +1213,14 @@ static int __exit nx842_remove(struct vio_dev *viodev)
if (old_devdata)
kfree(old_devdata->counters);
kfree(old_devdata);
+
+ nx842_unregister_driver(&nx842_pseries_driver);
+
return 0;
}
static struct vio_device_id nx842_driver_ids[] = {
- {"ibm,compression-v1", "ibm,compression"},
+ {NX842_PSERIES_COMPAT_NAME "-v1", NX842_PSERIES_COMPAT_NAME},
{"", ""},
};
@@ -1243,6 +1237,8 @@ static int __init nx842_init(void)
struct nx842_devdata *new_devdata;
pr_info("Registering IBM Power 842 compression driver\n");
+ BUILD_BUG_ON(sizeof(struct nx842_workmem) > NX842_MEM_COMPRESS);
+
RCU_INIT_POINTER(devdata, NULL);
new_devdata = kzalloc(sizeof(*new_devdata), GFP_KERNEL);
if (!new_devdata) {
@@ -1272,6 +1268,7 @@ static void __exit nx842_exit(void)
if (old_devdata)
dev_set_drvdata(old_devdata->dev, NULL);
kfree(old_devdata);
+ nx842_unregister_driver(&nx842_pseries_driver);
vio_unregister_driver(&nx842_driver);
}