From patchwork Thu Jun 28 13:07:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10493837 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 7E8CA6022E for ; Thu, 28 Jun 2018 13:07:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B36529FDC for ; Thu, 28 Jun 2018 13:07:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FE4129FE0; Thu, 28 Jun 2018 13:07:44 +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 08A0829FDC for ; Thu, 28 Jun 2018 13:07:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964849AbeF1NHm (ORCPT ); Thu, 28 Jun 2018 09:07:42 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:43889 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965245AbeF1NHl (ORCPT ); Thu, 28 Jun 2018 09:07:41 -0400 Received: by mail-lj1-f194.google.com with SMTP id h2-v6so1216423ljb.10 for ; Thu, 28 Jun 2018 06:07:40 -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=se/vxmp7nkVG7uhxmaj52atkM34NStXapZjQpW93EF0=; b=W3JTLi87U82S5euM/Bv2KNdqrHnrkej7clgWZUAq8fLf7/a+U48jOLqxM6wDWZEaGV fpg8vQGcwVa5XG74yzW8yl44MZP9Zio35hzB6UHX7x3+etdmcypnjp9HcDhVgPE0svjW vRDACK5L5SB2Hzv3dJczzdcfwsEf4YU7b8xp8= 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=se/vxmp7nkVG7uhxmaj52atkM34NStXapZjQpW93EF0=; b=GVqVa+QnY0AhyYAGGZmB8gCXjBhmf69gI/20x4Xb8gBUTUoNv3tqKEgr5bH3aE6BjJ bFZecusBe6UY7OXvpHUkGBW7B+7jb4Kt8c8fPJI4yqBGpKbiULqRFfRTYUrS2huWVaY6 N3qFbp35uicXE4nQ/DyIBgXuFWHh3RzpRcBmrS45KoE6a14l7BJy8haohSmuAR7BnjNz UMvlNX9wvQg9qJSzkS2hXo6+oXdaMnaK1fgHpuFYQ1e9424iNsI8iZG43brwVjxPT5kd IOpeFJsMgqDvBbkpYxUGcYD3JH6Rn+IYaq0tOHTlNN10DhNNsVlWZzfzbAtX2GDbCR9w C3pA== X-Gm-Message-State: APt69E1bk8EnokQnee+Sx+tLUVZ46B4hR1T/YBfXuTueOGaDEmrTQ/rb kVbmhFcO6jZLGXT3uG8PyL5iNHt2AlI= X-Google-Smtp-Source: AAOMgpe7vBSxVo19RKXY36u0HMe8KbVfuYfmyDXCKsWbI6GcoDGX6qtb9G9on9knK98HVQUtNzxZnw== X-Received: by 2002:a2e:4811:: with SMTP id v17-v6mr6938418lja.39.1530191259185; Thu, 28 Jun 2018 06:07:39 -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.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jun 2018 06:07:37 -0700 (PDT) From: Linus Walleij To: linux-crypto@vger.kernel.org, Herbert Xu , Tudor Ambarus Cc: Linus Walleij Subject: [PATCH 3/9 v2] crypto: atmel-ecc: More helpful error messages Date: Thu, 28 Jun 2018 15:07:23 +0200 Message-Id: <20180628130729.17589-3-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 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 --- ChangeLog v1->v2: - Strip some comments that are now obvious from the context with the error messages. - Do not print the excess ECC error message, atmel_ecc_status() already prints error messages. --- drivers/crypto/atmel-ecc.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c index 33773920e4bf..baef0d07164d 100644 --- a/drivers/crypto/atmel-ecc.c +++ b/drivers/crypto/atmel-ecc.c @@ -310,26 +310,31 @@ 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); @@ -624,8 +629,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