* [PATCH] crypto: atmel-ecc - use guards to release i2c_list_lock
@ 2026-12-01 11:21 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-12-01 11:21 UTC (permalink / raw)
To: Thorsten Blum, Herbert Xu, David S. Miller, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea
Cc: linux-crypto, linux-arm-kernel
Use guard(spinlock) and scoped guards to release i2c_list_lock
automatically.
No functional change.
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/crypto/atmel-ecc.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index b538e818a26f..c6d14854128a 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -17,6 +17,7 @@
#include <linux/of.h>
#include <linux/scatterlist.h>
#include <linux/slab.h>
+#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <crypto/internal/kpp.h>
#include <crypto/ecdh.h>
@@ -194,12 +195,10 @@ static struct i2c_client *atmel_ecc_i2c_client_alloc(void)
int min_tfm_cnt = INT_MAX;
int tfm_cnt;
- spin_lock(&driver_data.i2c_list_lock);
+ guard(spinlock)(&driver_data.i2c_list_lock);
- if (list_empty(&driver_data.i2c_client_list)) {
- spin_unlock(&driver_data.i2c_list_lock);
+ if (list_empty(&driver_data.i2c_client_list))
return ERR_PTR(-ENODEV);
- }
list_for_each_entry(i2c_priv, &driver_data.i2c_client_list,
i2c_client_list_node) {
@@ -217,8 +216,6 @@ static struct i2c_client *atmel_ecc_i2c_client_alloc(void)
client = min_i2c_priv->client;
}
- spin_unlock(&driver_data.i2c_list_lock);
-
return client;
}
@@ -299,16 +296,13 @@ static int atmel_ecc_probe(struct i2c_client *client)
i2c_priv = i2c_get_clientdata(client);
- spin_lock(&driver_data.i2c_list_lock);
- list_add_tail(&i2c_priv->i2c_client_list_node,
- &driver_data.i2c_client_list);
- spin_unlock(&driver_data.i2c_list_lock);
+ scoped_guard(spinlock, &driver_data.i2c_list_lock)
+ list_add_tail(&i2c_priv->i2c_client_list_node, &driver_data.i2c_client_list);
ret = crypto_register_kpp(&atmel_ecdh_nist_p256);
if (ret) {
- spin_lock(&driver_data.i2c_list_lock);
- list_del(&i2c_priv->i2c_client_list_node);
- spin_unlock(&driver_data.i2c_list_lock);
+ scoped_guard(spinlock, &driver_data.i2c_list_lock)
+ list_del(&i2c_priv->i2c_client_list_node);
dev_err(&client->dev, "%s alg registration failed\n",
atmel_ecdh_nist_p256.base.cra_driver_name);
@@ -339,9 +333,8 @@ static void atmel_ecc_remove(struct i2c_client *client)
crypto_unregister_kpp(&atmel_ecdh_nist_p256);
- spin_lock(&driver_data.i2c_list_lock);
- list_del(&i2c_priv->i2c_client_list_node);
- spin_unlock(&driver_data.i2c_list_lock);
+ scoped_guard(spinlock, &driver_data.i2c_list_lock)
+ list_del(&i2c_priv->i2c_client_list_node);
}
static const struct of_device_id atmel_ecc_dt_ids[] = {
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-01 11:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 11:21 [PATCH] crypto: atmel-ecc - use guards to release i2c_list_lock Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox