Skip to contentSkip to conversation

crypto: bfin_crc: ignore duplicated registration of the same algorithm

PATCH In review Sonic Zhang 3 participants 4 messages Apr 11, 2014 – Apr 16, 2014 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 crypto: bfin_crc: ignore duplicated registration of the same algorithm

From: Sonic Zhang <[email protected]>

in case of multiple crc devices are probed.
Call platform_set_drvdata() before adding new CRC device into the list.

---
v3-change:
- check list_is_singular() before register the algorithm

 drivers/crypto/bfin_crc.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/crypto/bfin_crc.c +9 -9
index cea3e8c..892b6d2 100644
@@ -665,19 +665,19 @@ static int bfin_crypto_crc_probe(struct platform_device *pdev)
 	if (timeout == 0)
 		dev_info(&pdev->dev, "init crc poly timeout\n");
 
+	platform_set_drvdata(pdev, crc);
+
 	spin_lock(&crc_list.lock);
 	list_add(&crc->list, &crc_list.dev_list);
 	spin_unlock(&crc_list.lock);
 
-	platform_set_drvdata(pdev, crc);
-
-	ret = crypto_register_ahash(&algs);
-	if (ret) {
-		spin_lock(&crc_list.lock);
-		list_del(&crc->list);
-		spin_unlock(&crc_list.lock);
-		dev_err(&pdev->dev, "Cann't register crypto ahash device\n");
-		goto out_error_dma;
+	if (list_is_singular(&crc_list.dev_list)) {
+		ret = crypto_register_ahash(&algs);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"Cann't register crypto ahash device\n");
+			goto out_error_dma;
+		}
 	}
 
 	dev_info(&pdev->dev, "initialized\n");
Signature · 1 line
1.8.2.3
#1 lore raw
Quoted 31 lines · Sonic Zhang

From: Sonic Zhang <[email protected]>

in case of multiple crc devices are probed.
Call platform_set_drvdata() before adding new CRC device into the list.

---
v3-change:
- check list_is_singular() before register the algorithm

 drivers/crypto/bfin_crc.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/crypto/bfin_crc.c +2 -4
index cea3e8c..892b6d2 100644
@@ -665,19 +665,19 @@ static int bfin_crypto_crc_probe(struct
 platform_device *pdev) if (timeout == 0)
 		dev_info(&pdev->dev, "init crc poly timeout\n");
 
+	platform_set_drvdata(pdev, crc);
+
 	spin_lock(&crc_list.lock);
 	list_add(&crc->list, &crc_list.dev_list);
 	spin_unlock(&crc_list.lock);
 
-	platform_set_drvdata(pdev, crc);
-
-	ret = crypto_register_ahash(&algs);
-	if (ret) {

drivers/crypto/bfin_crc.c static int bfin_crypto_crc_probe(struct · line 678

Quoted 10 lines
drivers/crypto/bfin_crc.c +5 -5
-		spin_lock(&crc_list.lock);
-		list_del(&crc->list);
-		spin_unlock(&crc_list.lock);
-		dev_err(&pdev->dev, "Cann't register crypto ahash device\n");
-		goto out_error_dma;
+	if (list_is_singular(&crc_list.dev_list)) {
+		ret = crypto_register_ahash(&algs);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"Cann't register crypto ahash device\n");

"Cann't" with two Ns ;-/

Well, add "Reviewed-by: Marek Vasut <[email protected]>" into the next go please :)

Best regards,
Marek Vasut

#2 lore raw

Hi Herbert,

Could you please review this patch?

Thanks

Sonic Zhang

Quoted 49 lines · Marek Vasut
Quoted 31 lines · Sonic Zhang

From: Sonic Zhang <[email protected]>

in case of multiple crc devices are probed.
Call platform_set_drvdata() before adding new CRC device into the list.

---
v3-change:
- check list_is_singular() before register the algorithm

 drivers/crypto/bfin_crc.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/crypto/bfin_crc.c +2 -4
index cea3e8c..892b6d2 100644
@@ -665,19 +665,19 @@ static int bfin_crypto_crc_probe(struct
 platform_device *pdev) if (timeout == 0)
              dev_info(&pdev->dev, "init crc poly timeout\n");
 
+     platform_set_drvdata(pdev, crc);
+
      spin_lock(&crc_list.lock);
      list_add(&crc->list, &crc_list.dev_list);
      spin_unlock(&crc_list.lock);
 
-     platform_set_drvdata(pdev, crc);
-
-     ret = crypto_register_ahash(&algs);
-     if (ret) {

drivers/crypto/bfin_crc.c static int bfin_crypto_crc_probe(struct · line 678

Quoted 10 lines
drivers/crypto/bfin_crc.c +5 -5
-             spin_lock(&crc_list.lock);
-             list_del(&crc->list);
-             spin_unlock(&crc_list.lock);
-             dev_err(&pdev->dev, "Cann't register crypto ahash device\n");
-             goto out_error_dma;
+     if (list_is_singular(&crc_list.dev_list)) {
+             ret = crypto_register_ahash(&algs);
+             if (ret) {
+                     dev_err(&pdev->dev,
+                             "Cann't register crypto ahash device\n");

"Cann't" with two Ns ;-/

Well, add "Reviewed-by: Marek Vasut <[email protected]>" into the next go please :)

Best regards,
Marek Vasut

maintainer
#3 lore raw
In reply to Marek Vasut
Quoted 45 lines · Marek Vasut
Quoted 31 lines · Sonic Zhang

From: Sonic Zhang <[email protected]>

in case of multiple crc devices are probed.
Call platform_set_drvdata() before adding new CRC device into the list.

---
v3-change:
- check list_is_singular() before register the algorithm

 drivers/crypto/bfin_crc.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/crypto/bfin_crc.c +2 -4
index cea3e8c..892b6d2 100644
@@ -665,19 +665,19 @@ static int bfin_crypto_crc_probe(struct
 platform_device *pdev) if (timeout == 0)
 		dev_info(&pdev->dev, "init crc poly timeout\n");
 
+	platform_set_drvdata(pdev, crc);
+
 	spin_lock(&crc_list.lock);
 	list_add(&crc->list, &crc_list.dev_list);
 	spin_unlock(&crc_list.lock);
 
-	platform_set_drvdata(pdev, crc);
-
-	ret = crypto_register_ahash(&algs);
-	if (ret) {

drivers/crypto/bfin_crc.c static int bfin_crypto_crc_probe(struct · line 678

Quoted 10 lines
drivers/crypto/bfin_crc.c +5 -5
-		spin_lock(&crc_list.lock);
-		list_del(&crc->list);
-		spin_unlock(&crc_list.lock);
-		dev_err(&pdev->dev, "Cann't register crypto ahash device\n");
-		goto out_error_dma;
+	if (list_is_singular(&crc_list.dev_list)) {
+		ret = crypto_register_ahash(&algs);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"Cann't register crypto ahash device\n");

"Cann't" with two Ns ;-/

Quoted 1 line

Well, add "Reviewed-by: Marek Vasut <[email protected]>" into the next go please :)

Both patches applied and I've fixed the typo.

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