[8/9,v2] crypto: atmel-ecc: Detail what is unlocked

Message ID 20180628130729.17589-8-linus.walleij@linaro.org
State New
Headers show
Series
  • [1/9,v2] crypto: atmel-ecc: Make available for other platforms
Related show

Commit Message

Linus Walleij June 28, 2018, 1:07 p.m.
Instead of just providing a broad error message about the
chip being unlocked provide details on what is unlocked,
one line per thing that can be locked: data and OTP and
configuration are locked independently. Loose the
overzealous defines.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
ChangeLog v1->v2:
- Rebased
---
 drivers/crypto/atmel-ecc.c | 8 ++++++--
 drivers/crypto/atmel-ecc.h | 2 --
 2 files changed, 6 insertions(+), 4 deletions(-)

-- 
2.17.0

Patch

diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index 659cb3cf37a9..0dfea6eadc56 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -690,8 +690,12 @@  static int device_sanity_check(struct i2c_client *client)
 	 * Failure to lock these zones may permit modification of any secret
 	 * keys and may lead to other security problems.
 	 */
-	if (cmd->data[LOCK_CONFIG_IDX] || cmd->data[LOCK_VALUE_IDX]) {
-		dev_err(&client->dev, "Configuration or Data and OTP zones are unlocked!\n");
+	if (cmd->data[RSP_DATA_IDX+3] == 0x55) {
+		dev_err(&client->dev, "configuration zone is unlocked\n");
+		ret = -ENOTSUPP;
+	}
+	if (cmd->data[RSP_DATA_IDX+2] == 0x55) {
+		dev_err(&client->dev, "data and OTP zones are unlocked\n");
 		ret = -ENOTSUPP;
 	}
 
diff --git a/drivers/crypto/atmel-ecc.h b/drivers/crypto/atmel-ecc.h
index 4458585ab588..42b724256f93 100644
--- a/drivers/crypto/atmel-ecc.h
+++ b/drivers/crypto/atmel-ecc.h
@@ -97,8 +97,6 @@  static const struct {
 #define CONFIG_ZONE_SERIAL_8_I2CEN	0x03
 #define CONFIG_ZONE_I2C_OTP		0x04
 #define CONFIG_ZONE_FOOTER		0x15
-#define LOCK_VALUE_IDX			(RSP_DATA_IDX + 2)
-#define LOCK_CONFIG_IDX			(RSP_DATA_IDX + 3)
 
 /*
  * Wake High delay to data communication (microseconds). SDA should be stable