summaryrefslogtreecommitdiff
path: root/drivers/crypto/nx/nx-842-powernv.c
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@ieee.org>2015-05-28 16:21:31 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-06-03 10:51:23 +0800
commit3e648cbeb31be5cb84b9ec19822e2b85417f07c4 (patch)
tree4832384e797c3164b3d4321e49f13dd5a8c74c9d /drivers/crypto/nx/nx-842-powernv.c
parentf614e546f5060813ddf69a090cdf200a9ac28cd3 (diff)
crypto: nx - prevent nx 842 load if no hw driver
Change the nx-842 common driver to wait for loading of both platform drivers, and fail loading if the platform driver pointer is not set. Add an independent platform driver pointer, that the platform drivers set if they find they are able to load (i.e. if they find their platform devicetree node(s)). The problem is currently, the main nx-842 driver will stay loaded even if there is no platform driver and thus no possible way it can do any compression or decompression. This allows the crypto 842-nx driver to load even if it won't actually work. For crypto compression users (e.g. zswap) that expect an available crypto compression driver to actually work, this is bad. This patch fixes that, so the 842-nx crypto compression driver won't load if it doesn't have the driver and hardware available to perform the compression. 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-powernv.c')
-rw-r--r--drivers/crypto/nx/nx-842-powernv.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/crypto/nx/nx-842-powernv.c b/drivers/crypto/nx/nx-842-powernv.c
index 6a9fb8b2d05b..c388dba7da64 100644
--- a/drivers/crypto/nx/nx-842-powernv.c
+++ b/drivers/crypto/nx/nx-842-powernv.c
@@ -23,7 +23,6 @@
#include <asm/prom.h>
#include <asm/icswx.h>
-#define MODULE_NAME NX842_POWERNV_MODULE_NAME
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>");
MODULE_DESCRIPTION("842 H/W Compression driver for IBM PowerNV processors");
@@ -571,6 +570,7 @@ static struct nx842_constraints nx842_powernv_constraints = {
};
static struct nx842_driver nx842_powernv_driver = {
+ .name = KBUILD_MODNAME,
.owner = THIS_MODULE,
.constraints = &nx842_powernv_constraints,
.compress = nx842_powernv_compress,
@@ -593,7 +593,7 @@ static __init int nx842_powernv_init(void)
pr_info("loading\n");
- for_each_compatible_node(dn, NULL, NX842_POWERNV_COMPAT_NAME)
+ for_each_compatible_node(dn, NULL, "ibm,power-nx")
nx842_powernv_probe(dn);
if (!nx842_ct) {
@@ -601,7 +601,16 @@ static __init int nx842_powernv_init(void)
return -ENODEV;
}
- nx842_register_driver(&nx842_powernv_driver);
+ if (!nx842_platform_driver_set(&nx842_powernv_driver)) {
+ struct nx842_coproc *coproc, *n;
+
+ list_for_each_entry_safe(coproc, n, &nx842_coprocs, list) {
+ list_del(&coproc->list);
+ kfree(coproc);
+ }
+
+ return -EEXIST;
+ }
pr_info("loaded\n");
@@ -613,7 +622,7 @@ static void __exit nx842_powernv_exit(void)
{
struct nx842_coproc *coproc, *n;
- nx842_unregister_driver(&nx842_powernv_driver);
+ nx842_platform_driver_unset(&nx842_powernv_driver);
list_for_each_entry_safe(coproc, n, &nx842_coprocs, list) {
list_del(&coproc->list);