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: 10448331 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 0A4A3600CA for ; Tue, 5 Jun 2018 13:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEA9C294A4 for ; Tue, 5 Jun 2018 13:50:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2D86294AD; Tue, 5 Jun 2018 13:50:29 +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 8F08E294A4 for ; Tue, 5 Jun 2018 13:50:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751941AbeFENu2 (ORCPT ); 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-Google-Smtp-Source: ADUXVKLrks0wJ+hxUWKEKIb9iVCfne3WB5nqQErZRVai4PfTQ/NZX9d43VWjztAd3zACMB8QLQuC7Q== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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