From patchwork Tue Jun 5 13:49:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 137738 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp986011lji; Tue, 5 Jun 2018 06:50:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIk4apgyYyHBfV2IZOzd8vNVHNs5aXHUELXrF68ilx8Xc3yD83kx69sxxWaseYqOwBIxnZ5 X-Received: by 2002:a63:6dc5:: with SMTP id i188-v6mr16037112pgc.391.1528206635280; Tue, 05 Jun 2018 06:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528206635; cv=none; d=google.com; s=arc-20160816; b=qsfQjqmxhpZEmRvw1YpKheuCO/E5JRNyXu40WEfw29jmrhO3HMyq+5VfCBi928lUHp QrCmrKfuSMcGpWz0vCpYvSEhvtjsSMVpVUe7eAk5E9t6p3s6728zcnN/iSE6IMJ3F8vi tAWdG/KacbFQ+v2Rfrr7lF1eLCb1TshIIEFe2f/1mpyPD9H/qWoYDTe4N2JlIthZlhzo +c/99WRc20xTv9ceDWJ8yk+gA5tlQ2D0y4bYpWh5r6D0uz0ss94ZPWzHVTjlPtLZj3C8 fI9rahf/Sgyn3P9dKWdXmP9taBbqwcUvRjGmZ8ke7628J1CdFYMQDaXilPvmyn3bSMkv KJRA== 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=Rh3sCnI3vLegjKnR3N/27pCwp0NKmzxY+Xf21CxeW5I=; b=Fp/UuQmergk7munvQ6WL2zC9VjEtv76TbIzQecmtLxxKiaShkPm5rY5jEHgADCK8PS Del+eWu93kT6Cg9/0MNayZ52PIY/et0nQRU2in/vTcHS6ZI7r90Ephiii2QuHkfOGOEL ETi18kUwi0DjJ6aT0k6eKaOg6JwIkERXcuP6UwpUBTsw4FYHXYFh1bvEcZKVYSmAkFLP e2pczqb7GPPzRDIQeFZn6vVBr5OSxE0jLWLowEvHAdH+z/zX2u18HSZNKGzWkLVvVVgY 775rAvjRdPN3lIturbkfkz9JZT9NospwjXs0GmHmnxVzsr3jLBjEU92O5SHDqo7VLH9c zYsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HyTFZSlk; 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 j78-v6si24186154pfe.187.2018.06.05.06.50.35; Tue, 05 Jun 2018 06:50:35 -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=HyTFZSlk; 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 S1751942AbeFENue (ORCPT + 1 other); Tue, 5 Jun 2018 09:50:34 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:44944 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751750AbeFENuc (ORCPT ); Tue, 5 Jun 2018 09:50:32 -0400 Received: by mail-lf0-f66.google.com with SMTP id 36-v6so3678248lfr.11 for ; Tue, 05 Jun 2018 06:50:32 -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=Rh3sCnI3vLegjKnR3N/27pCwp0NKmzxY+Xf21CxeW5I=; b=HyTFZSlk+sFDyh2U5pdQcTW4qs+oJrD1DBsTpbQZ9zc5BnFUHZuD8WgDuxN+o80++2 tMmVoNnLC8UC9WURRfptlhGuwdKiLYCqT+QbgukLSEYSG68sZirHyS3FmpTARxPC87I+ Y1zvnG52PRaGGTjCW7V1lKsRvh/Edhf5B5YBg= 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=Rh3sCnI3vLegjKnR3N/27pCwp0NKmzxY+Xf21CxeW5I=; b=q6xoqUEnp4cfVKXO6nkQtn+zVdDhmG+PHI2lE5GPiS9T/rf1Raupf8sEIIyDRekVe/ Hwje8HmPeB8Ecs/5UfoWHtMrt8tdpNzmwuTI30LymVgkasTovUbDC4zc4v/v9h6tvHkH ZP0GK3llFlYXYwcUERKkgpJO6negP3k5RiBg1MuNrMd9x2Pr9FooQJ0z848vw/9+uRgs KrNdG+l6J0/3ohaX1eQq7TEgUeSylkPN7DV3oYJi1Mhh1V3fsoGuBM9EHoQtPOGjMFCl dxUYyE4UV0B2UiNtkgqOiVeXD4JkwBdsHOVic1tNxSIuiDwGz5mDGoXPXvqlgt+3nCYl 7Vlw== X-Gm-Message-State: APt69E3R9a6BLjA2wGGv4ARkSxtg/AeLQbUJ6WC2RaouvcVPrOm7IZQ3 ayIz0kGfV0b4I97a0BJwN1qNgrT8460= X-Received: by 2002:a19:5d54:: with SMTP id p20-v6mr1789606lfj.21.1528206631352; Tue, 05 Jun 2018 06:50:31 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id x72-v6sm5201092lfi.52.2018.06.05.06.50.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 06:50:30 -0700 (PDT) From: Linus Walleij To: linux-crypto@vger.kernel.org, Herbert Xu , Tudor Ambarus Cc: Linus Walleij Subject: [PATCH 5/9] crypto: atmel-ecc: Create a config word reader Date: Tue, 5 Jun 2018 15:49:46 +0200 Message-Id: <20180605134950.6605-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180605134950.6605-1-linus.walleij@linaro.org> References: <20180605134950.6605-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 --- 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 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) {