From patchwork Tue Jun 5 13:49:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 137736 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp985931lji; Tue, 5 Jun 2018 06:50:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJG0WGdb8CTxR6BiBNLckDJ+qSGDOwlpZlZzyJLqUFTcbpBlJl1/KjMn9VJkny1HsTxaXqF X-Received: by 2002:a17:902:8a82:: with SMTP id p2-v6mr26472982plo.244.1528206630495; Tue, 05 Jun 2018 06:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528206630; cv=none; d=google.com; s=arc-20160816; b=E1FoRuvajIK7QJuCvgOCD7z0dcjVGE56VcuHS//TeP7Q7+upiP2UDeuNoTlS6GUk8d /TN5a32ELvW2lx290e4OGbByK40wzIaStp9xhiPTog/nzA4YuMu0lHvIWOWaP0+Kvvea qE6ipoSw8/6U+/AoVpOU2rIyzLxBg9hCeEZYv8BL1kZDoXUR3t5HPIyJIr89Zl4gz/fz mfDEVD9plWHYpc0sCaMUQACY1C3Bg4WolWTCe2Ya9lXSriVezPgoy3X5zZwDj0EqkwG6 tq6D89Uq3HqfJ8yHCGUIrj4bKcpYaGqeMpCrg5U6Sn7EpoM5WOnvHWto7nQew/uPCzre Z7SA== 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=9F6DqNre3XjVSlouDy8KycNnYII/fFaM7FsoPndHocA=; b=esvsd+gZbRoXvYMHYxefwDVVKCCHXphfmFN/ruXcdPiROAk4D18SL6xpKv81wBLgmb AB83hoNYqETK79YNrpMtVGszSuqvvUgMncFqpiisB/1sJoiYItAyARkIm4csmxnBnkhg BGrIlnx833aGOCsafXw3NJTq+eX9X4sM5dHVlWFqJZne+nhTPRIWjZelxYs43J1IQKkc QzpMkvHRH3JzWiHWi7CeutV1iCjr4mrhGRUNW58evg1/cJFcUnpKIeXuxMT+QgxWEo8s bjz7vYordeD5MJTUu4a5PeNik19U+CrSJVCwbBV4EokA5S74xXzX86e1rwiZV73k4Tsc 0EEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FwF3A1d5; 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.30; Tue, 05 Jun 2018 06:50:30 -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=FwF3A1d5; 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 S1751941AbeFENu2 (ORCPT + 1 other); Tue, 5 Jun 2018 09:50:28 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:41545 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751750AbeFENu1 (ORCPT ); Tue, 5 Jun 2018 09:50:27 -0400 Received: by mail-lf0-f65.google.com with SMTP id d24-v6so3694948lfa.8 for ; Tue, 05 Jun 2018 06:50:26 -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=9F6DqNre3XjVSlouDy8KycNnYII/fFaM7FsoPndHocA=; b=FwF3A1d5LF+7Ecn5N4e0H4p7WtQk7XdkIKYIM/f6vYh0HggUCMNVjtNF71ltvRiuXf WanF8u8gv9XMYIUMxEhB7bnCJGJ4b3VUgEFO3zo+JHhVyWgrRPaECSPNw8C8tNywnRzM RWx1rzTgCrqmfiCybxvDbOXR38e3IFajgJgBg= 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=9F6DqNre3XjVSlouDy8KycNnYII/fFaM7FsoPndHocA=; b=bm4Xp2VToRxW6RHYqDkKABstQf4QofWrk1GGAtFeOr658TrjNedt5s83QGcMcO7BDB RyXaNEfEAlf0IaKCOJnI8/xfswlfuxEgh/rMrkQtGVUmD5TE5KuZrNplhCBdeEuOwnWw 0oP+rhzBFQM4qbrXH9VoYSufyB6bVc50gwyqZ+wINDRnRUUNOU8DiISWNc+rtiBDRIML FEsk2EwJ7LZsaYv3hl1SYX/xuYQ8bqy7vnj/AM+zoqv8lw/eBiE5/q2XTLw2pA4cxE0t dlp3yI25bKH0MVO2Jtb18io7hMYYsqvaRktVpnxFnFk++/kRMdHMAai2x8coESCSGplA XB5A== X-Gm-Message-State: APt69E1hpbBqvNRIx7EedR+8VEd/ZOTKoGfucNjEzW/P3ForLYW3c0OC mEM3jdbIm/GJeXFqeJd6r1TztFgdBrI= X-Received: by 2002:a2e:82ce:: with SMTP id n14-v6mr6061711ljh.34.1528206625598; Tue, 05 Jun 2018 06:50:25 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Jun 2018 06:50:24 -0700 (PDT) From: Linus Walleij To: linux-crypto@vger.kernel.org, Herbert Xu , Tudor Ambarus Cc: Linus Walleij Subject: [PATCH 3/9] crypto: atmel-ecc: More helpful error messages Date: Tue, 5 Jun 2018 15:49:44 +0200 Message-Id: <20180605134950.6605-3-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 Report errors once when they happen on the I2C bus so we get good information in cases such as when the wrong I2C address is used. Signed-off-by: Linus Walleij --- drivers/crypto/atmel-ecc.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) -- 2.17.0 diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c index 145ab3a39a56..214b0572bf8b 100644 --- a/drivers/crypto/atmel-ecc.c +++ b/drivers/crypto/atmel-ecc.c @@ -310,29 +310,41 @@ static int atmel_ecc_send_receive(struct i2c_client *client, mutex_lock(&i2c_priv->lock); ret = atmel_ecc_wakeup(client); - if (ret) + if (ret) { + dev_err(&client->dev, "wakeup failed\n"); goto err; + } /* send the command */ ret = i2c_master_send(client, (u8 *)cmd, cmd->count + WORD_ADDR_SIZE); - if (ret < 0) + if (ret < 0) { + dev_err(&client->dev, "command send failed\n"); goto err; + } /* delay the appropriate amount of time for command to execute */ msleep(cmd->msecs); /* receive the response */ ret = i2c_master_recv(client, cmd->data, cmd->rxsize); - if (ret < 0) + if (ret < 0) { + dev_err(&client->dev, "getting response failed\n"); goto err; + } /* put the device into low-power mode */ ret = atmel_ecc_sleep(client); - if (ret < 0) + if (ret < 0) { + dev_err(&client->dev, "putting to sleep failed\n"); goto err; + } mutex_unlock(&i2c_priv->lock); - return atmel_ecc_status(&client->dev, cmd->data); + ret = atmel_ecc_status(&client->dev, cmd->data); + if (ret < 0) + dev_err(&client->dev, "ECC status parse failed\n"); + + return ret; err: mutex_unlock(&i2c_priv->lock); return ret; @@ -624,8 +636,11 @@ static int device_sanity_check(struct i2c_client *client) atmel_ecc_init_read_cmd(cmd); ret = atmel_ecc_send_receive(client, cmd); - if (ret) + if (ret) { + dev_err(&client->dev, + "failed to send ECC init command\n"); goto free_cmd; + } /* * It is vital that the Configuration, Data and OTP zones be locked