diff mbox series

[5/9] crypto: atmel-ecc: Create a config word reader

Message ID 20180605134950.6605-5-linus.walleij@linaro.org
State Superseded
Headers show
Series [1/9] crypto: atmel-ecc: Make available for other platforms | expand

Commit Message

Linus Walleij June 5, 2018, 1:49 p.m. UTC
Rewrite the function atmel_ecc_init_read_cmd() into a more
general atmel_ecc_init_read_config_word() function to read
any word from the configuration zone, and use this
parameterized with what we want to read out.

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

---
 drivers/crypto/atmel-ecc.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

-- 
2.17.0
diff mbox series

Patch

diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index f1f422385a91..d89b69d228ac 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -136,16 +136,13 @@  static void atmel_ecc_checksum(struct atmel_ecc_cmd *cmd)
 	*crc16 = atmel_ecc_crc16(0, data, len);
 }
 
-static void atmel_ecc_init_read_cmd(struct atmel_ecc_cmd *cmd)
+static void atmel_ecc_init_read_config_word(struct atmel_ecc_cmd *cmd,
+					    u16 config_word)
 {
 	cmd->word_addr = COMMAND;
 	cmd->opcode = OPCODE_READ;
-	/*
-	 * Read the word from Configuration zone that contains the lock bytes
-	 * (UserExtra, Selector, LockValue, LockConfig).
-	 */
 	cmd->param1 = CONFIG_ZONE;
-	cmd->param2 = CONFIG_ZONE_FOOTER;
+	cmd->param2 = config_word;
 	cmd->count = READ_COUNT;
 
 	atmel_ecc_checksum(cmd);
@@ -633,7 +630,7 @@  static int device_sanity_check(struct i2c_client *client)
 	if (!cmd)
 		return -ENOMEM;
 
-	atmel_ecc_init_read_cmd(cmd);
+	atmel_ecc_init_read_config_word(cmd, CONFIG_ZONE_FOOTER);
 
 	ret = atmel_ecc_send_receive(client, cmd);
 	if (ret) {