Skip to contentSkip to conversation

crypto: picoxcell: adjust the position of tasklet_init and fix missed tasklet_kill

PATCH Superseded Chuhong Yuan 2 participants 2 messages Nov 23, 2019 Crypto API

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 crypto: picoxcell: adjust the position of tasklet_init and fix missed tasklet_kill

Since tasklet is needed to be initialized before registering IRQ handler, adjust the position of tasklet_init to fix the wrong order.

Besides, to fix the missed tasklet_kill, this patch adds a helper function and uses devm_add_action_or_reset to kill the tasklet automatically.

Fixes ce92136843cb ("crypto: picoxcell - add support for the picoxcell crypto engines")

---
Changes in v3:
- Use devm_add_action_or_reset to simplify the patch.

 drivers/crypto/picoxcell_crypto.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/crypto/picoxcell_crypto.c +13 -2
index 3cbefb41b099..497dbf1d6cf6 100644
@@ -1613,6 +1613,11 @@ static const struct of_device_id spacc_of_id_table[] = {
 MODULE_DEVICE_TABLE(of, spacc_of_id_table);
 #endif /* CONFIG_OF */
 
+static void spacc_tasklet_kill(void *data)
+{
+	tasklet_kill(data);
+}
+
 static int spacc_probe(struct platform_device *pdev)
 {
 	int i, err, ret;
@@ -1655,6 +1660,14 @@ static int spacc_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
+	tasklet_init(&engine->complete, spacc_spacc_complete,
+		     (unsigned long)engine);
+
+	ret = devm_add_action_or_reset(&pdev->dev, spacc_tasklet_kill,
+				       &engine->complete);
+	if (ret)
+		return ret;
+
 	if (devm_request_irq(&pdev->dev, irq->start, spacc_spacc_irq, 0,
 			     engine->name, engine)) {
 		dev_err(engine->dev, "failed to request IRQ\n");
@@ -1712,8 +1725,6 @@ static int spacc_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&engine->completed);
 	INIT_LIST_HEAD(&engine->in_progress);
 	engine->in_flight = 0;
-	tasklet_init(&engine->complete, spacc_spacc_complete,
-		     (unsigned long)engine);
 
 	platform_set_drvdata(pdev, engine);
 
Signature · 1 line
2.24.0
maintainer
#1 lore raw
Quoted 7 lines · Chuhong Yuan

Since tasklet is needed to be initialized before registering IRQ handler, adjust the position of tasklet_init to fix the wrong order.

Besides, to fix the missed tasklet_kill, this patch adds a helper function and uses devm_add_action_or_reset to kill the tasklet automatically.

Quoted 8 lines
Fixes ce92136843cb ("crypto: picoxcell - add support for the picoxcell crypto engines")

---
Changes in v3:
- Use devm_add_action_or_reset to simplify the patch.

 drivers/crypto/picoxcell_crypto.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Thanks for the patch. It looks much nicer.

drivers/crypto/picoxcell_crypto.c static int spacc_probe(struct platform_device *pdev) · line 1667

Quoted 9 lines
drivers/crypto/picoxcell_crypto.c +5 -0
@@ -1655,6 +1660,14 @@ static int spacc_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
+	tasklet_init(&engine->complete, spacc_spacc_complete,
+		     (unsigned long)engine);
+
+	ret = devm_add_action_or_reset(&pdev->dev, spacc_tasklet_kill,
+				       &engine->complete);

Minor nit. You only need devm_add_action as calling tasklet_kill at this point should be a no-op.

Cheers,

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