From patchwork Thu Jun 28 13:07:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 140446 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2167326ljj; Thu, 28 Jun 2018 06:09:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIH0xX9midTmeoQTv43VgI5CdoxO5lNWcSYJ+qD1g7BUWKLLU0tBLwQN3KOzj0JW8mTn8DF X-Received: by 2002:a17:902:8a95:: with SMTP id p21-v6mr10418961plo.91.1530191341922; Thu, 28 Jun 2018 06:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530191341; cv=none; d=google.com; s=arc-20160816; b=UG9IvdnW8t3eY+VCMJ4ypnY5bQeqBg9jwLZwgO+VpJW21LTLRf1C7neD07NgyUoy3o Txnj/EUku+p9rk7mX7lssie1M/YhEnwA75w8+MAAQaggFHFjrjkb3iOZl70fxDHEfYTD FlD7jJKYe+4GB8MZYCpPLuEgdMbNR3CRF4zgpS3tic3GjGX18gy0cMvhZNCTAmkiPx3B BFuDJW7lO1caQsccMQSqoC3/dbATT3ow2e9KkOo9UOqIp1k+IlpMQBf0rYPmgrpotFJ6 fOkJiZd5O9sTVj4honLM19uPSkCXYwZtZvf3V8xUemnqI85f7LYzdMkQT+SCxqEPEz7y 8sPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=RCUZOTlkGLi6p/CY8nAqZie/MEHQ0+WtYX7Cnp+kF/w=; b=zS0LBC+9grkQk6aI/77tu0xAX99P5y60c7h59dyuRRkpi7c9E65PQGRs3Q+MMDSZve T/I3oKeEqRc4e+bRjvTc5NsXeO32WK3e0sRgidFlH/QvBgkYLYBlpMvVHryr2xEndk3a eYXkzpJyZKZlahKrFqPr2ddE5pM92jwjDPogt3+DomWZCyqO724nF6fX//5kUZicuP1Z TeY/HHhv8M7yMjYG9PpfieUXU6icFr3rXvCmuEag2rfrxgiLsziuot5+aBYvGzWT/bVK m75PSlBb8eR3xXESL5vgASe92PVFKFPwDlZxMPobAiJLJlOWxhMnuYlf/zkqCr/UJteE kSCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=McoSqrqB; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i130-v6si5408126pgd.691.2018.06.28.06.09.01; Thu, 28 Jun 2018 06:09:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=McoSqrqB; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965895AbeF1NIp (ORCPT + 1 other); Thu, 28 Jun 2018 09:08:45 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:37334 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965485AbeF1NHp (ORCPT ); Thu, 28 Jun 2018 09:07:45 -0400 Received: by mail-lj1-f193.google.com with SMTP id c11-v6so4454266lja.4 for ; Thu, 28 Jun 2018 06:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RCUZOTlkGLi6p/CY8nAqZie/MEHQ0+WtYX7Cnp+kF/w=; b=McoSqrqBwgplQxgSboqPCE5oZNmkZoA8fAwgGBfjXbtcC22bgqcdtRWo0CpnL87aSu NQdTnA/hJNr4iUX8extgtkBJf4FRv2G0tpV9kDnfuLwGsNH4Hh3RAxgQc+gOCyIdQ3V8 9jD5df0WjheZO1frvaQV17IK/xbgtinHs+aAU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RCUZOTlkGLi6p/CY8nAqZie/MEHQ0+WtYX7Cnp+kF/w=; b=JyseguEfD0Mq+qXUo6IT5wqqRtPA2EDIkfMzSGhdSzoHJmHaGR/oTUOmYcn+OaHZ6A W+UKXg1T1Zn91QyO+qHFGKex3vyu2BIgRunmm1gqnr+PMPlQiQQB2AXYGpyUXFFvD++y Zt08UkNEb+EmFxEIOcXpJ+jh85pXJa+AgqMlkHTDGr7zMUvcdDFdiwShj7PxK1dm+a9+ SHZ5oEd2CUYy8XDdT2FKm3dh/FlmJdxem1leunOPtRxW8tVnnbVNaKXhzUsPbWDebTiT 5Xv+Ztu4MkWPdS24dXR1BeGR9aE5psNA1ngClN7qzTVa7Su4h5V40bAGmnl4VGJ549CU 4L9A== X-Gm-Message-State: APt69E1DHwrU4hfIVFTIv2X88KWx+2zkJYwI+eZWn/Ra04w9IGv6RyaX F27bVWXl2Nm4vuwks08KSFYrPSe7/NQ= X-Received: by 2002:a2e:7603:: with SMTP id r3-v6mr6926166ljc.81.1530191263584; Thu, 28 Jun 2018 06:07:43 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id d24-v6sm1314649lfl.53.2018.06.28.06.07.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jun 2018 06:07:42 -0700 (PDT) From: Linus Walleij To: linux-crypto@vger.kernel.org, Herbert Xu , Tudor Ambarus Cc: Linus Walleij Subject: [PATCH 5/9 v2] crypto: atmel-ecc: Create a config word reader Date: Thu, 28 Jun 2018 15:07:25 +0200 Message-Id: <20180628130729.17589-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180628130729.17589-1-linus.walleij@linaro.org> References: <20180628130729.17589-1-linus.walleij@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 --- ChangeLog v1->v2: - Rebased --- drivers/crypto/atmel-ecc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 2.17.0 diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c index 98f9322ca303..2ec570d06a27 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); @@ -626,7 +623,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) {