Skip to contentSkip to conversation

crypto: qat - fix crypto_get_instance_node function

PATCH In review Tadeusz Struk 2 participants 2 messages Oct 16, 2015 – Oct 20, 2015 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: qat - fix crypto_get_instance_node function

qat_crypto_get_instance_node function needs to handle situation when the first dev in the list is not started.

---
 drivers/crypto/qat/qat_common/qat_crypto.c |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/crypto/qat/qat_common/qat_crypto.c +16 -4
index 25db27c..9cab154 100644
@@ -118,11 +118,23 @@ struct qat_crypto_instance *qat_crypto_get_instance_node(int node)
 			}
 		}
 	}
-	if (!accel_dev) {
-		pr_err("QAT: Could not find a device on node %d\n", node);
-		accel_dev = adf_devmgr_get_first();
+	if (!accel_dev)
+		pr_info("QAT: Could not find a device on node %d\n", node);
+
+	/* Get any started device */
+	list_for_each(itr, adf_devmgr_get_head()) {
+		struct adf_accel_dev *tmp_dev;
+
+		tmp_dev = list_entry(itr, struct adf_accel_dev, list);
+
+		if (adf_dev_started(tmp_dev) &&
+		    !list_empty(&tmp_dev->crypto_list)) {
+			accel_dev = tmp_dev;
+			break;
+		}
 	}
-	if (!accel_dev || !adf_dev_started(accel_dev))
+
+	if (!accel_dev)
 		return NULL;
 
 	best = ~0;
maintainer
#1 lore raw
Quoted 4 lines · Tadeusz Struk

qat_crypto_get_instance_node function needs to handle situation when the first dev in the list is not started.

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt