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: 10493851 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8177160230 for ; Thu, 28 Jun 2018 13:09:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E36B29FD4 for ; Thu, 28 Jun 2018 13:09:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6231F2A01F; Thu, 28 Jun 2018 13:09:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 002432A029 for ; Thu, 28 Jun 2018 13:09:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965895AbeF1NIp (ORCPT ); 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-Google-Smtp-Source: AAOMgpdNbtiIqSgIVXHG1LQ8kla64JFnnANmPKm/bR6ZIWbZwEA9VDwzmkNMtZEANxW5yLJNJ60o5Q== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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) {