From patchwork Wed Jul 31 17:42:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11068961 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4931814DB for ; Wed, 31 Jul 2019 17:43:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32D0B205A4 for ; Wed, 31 Jul 2019 17:43:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 272D926E73; Wed, 31 Jul 2019 17:43:19 +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,FREEMAIL_FROM,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 AA7BF26E54 for ; Wed, 31 Jul 2019 17:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729103AbfGaRnC (ORCPT ); Wed, 31 Jul 2019 13:43:02 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40935 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727571AbfGaRnC (ORCPT ); Wed, 31 Jul 2019 13:43:02 -0400 Received: by mail-pf1-f196.google.com with SMTP id p184so32270651pfp.7; Wed, 31 Jul 2019 10:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WuzVLvZdKStMf7KPRVxvRBDEhESLbhQ1mKTbOhc19xs=; b=YNdq+5f2foG8iGzCcwYGOkQgzLJhYFy5/EH17Jm0D3Iao1h2DsOdQwURe8wuLmFNQq K1NcSMdX+KCl18pE+7f28lS6DP9qZgk/sg4Y3WgaZs11Y4KhvMsMJO7DSDLl9nwM2oFF ibSuy1DMhziAPcWzhJxsXGsA/yEKq4y1xG0qFocNtg8aEfzaDDtV58+lkJy9Zu2DTj8e bRXNzh0bDEpLNcuwdBPIcZTkxvM8W0vQbZBHzWapFLzgVhy6GugK3MZCBPfvhQGwRTJk BQZVMzWvN3K/CHVcil+ay3VWV2W5NIhwKRT/YHkLYDSOcrHFoGWIFAVmhGNf7M/GnaA+ TD2w== 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:mime-version:content-transfer-encoding; bh=WuzVLvZdKStMf7KPRVxvRBDEhESLbhQ1mKTbOhc19xs=; b=iLFT/T+nnZmTlpx61LuKMmrHoOUef7HrOHNTLMIpiaQTeWa9+2FSvDe9UP4v/QzSYG e+f2gdW+ez0DDfYWggPT341XsigxvyjmFGcNSC+wjnjdl41fORDR4vciy9xIt8l/yFfK 2Bm06jgEJsMayM/7huItmuNLQ8Jb1vuw6TrR77s3pNsXssGgxoQAMpiAdf0C7/rCNVkl P+ObBLxEAAvUOiaFEjAYM1C72eMrmXJj/GTUOI5gLOCxdGb0b4uUszjtZzjCDVmwSXDN +3TH+wPfRdUICil54rUhF6KN2hSgwCvDfuUAanyC1xj4QF499xVHFY8JN8XC1gEAQUar KLoA== X-Gm-Message-State: APjAAAWUsKBe8diRucWlHYr0mOearwju9iYGXgreQlV1QKMR/8M0wY2t ho1uQz215BUUQvXzaykZtmp2bp4r X-Google-Smtp-Source: APXvYqwu46sKbaOdeNSZNvtt1hphkMcI3J7DmnmMCr1gghK9AjGOsJPSNewALN1xeFEYw5Lo3sO1qg== X-Received: by 2002:a17:90a:dac3:: with SMTP id g3mr4091069pjx.45.1564594980634; Wed, 31 Jul 2019 10:43:00 -0700 (PDT) Received: from localhost.localdomain ([2607:fb90:4ad:5a0b:2aff:6e0f:8973:5a26]) by smtp.gmail.com with ESMTPSA id k8sm65941259pgm.14.2019.07.31.10.42.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 10:42:59 -0700 (PDT) From: Andrey Smirnov To: linux-watchdog@vger.kernel.org Cc: Andrey Smirnov , Chris Healy , Guenter Roeck , Rick Ramstetter , linux-kernel@vger.kernel.org Subject: [PATCH 1/5] watchdog: ziirave_wdt: Add missing newline Date: Wed, 31 Jul 2019 10:42:48 -0700 Message-Id: <20190731174252.18041-2-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190731174252.18041-1-andrew.smirnov@gmail.com> References: <20190731174252.18041-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add missing newline. Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Guenter Roeck Cc: Rick Ramstetter Cc: linux-watchdog@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Guenter Roeck --- drivers/watchdog/ziirave_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/ziirave_wdt.c b/drivers/watchdog/ziirave_wdt.c index dec660c509b3..6ec028fb2635 100644 --- a/drivers/watchdog/ziirave_wdt.c +++ b/drivers/watchdog/ziirave_wdt.c @@ -671,7 +671,7 @@ static int ziirave_wdt_probe(struct i2c_client *client, if (ret) return ret; - dev_info(&client->dev, "Timeout set to %ds.", + dev_info(&client->dev, "Timeout set to %ds\n", w_priv->wdd.timeout); } From patchwork Wed Jul 31 17:42:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11068959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2264A1395 for ; Wed, 31 Jul 2019 17:43:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0952F200E7 for ; Wed, 31 Jul 2019 17:43:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1CC126E7B; Wed, 31 Jul 2019 17:43:18 +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,FREEMAIL_FROM,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 8A354205A4 for ; Wed, 31 Jul 2019 17:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727230AbfGaRnF (ORCPT ); Wed, 31 Jul 2019 13:43:05 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34814 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729162AbfGaRnD (ORCPT ); Wed, 31 Jul 2019 13:43:03 -0400 Received: by mail-pg1-f196.google.com with SMTP id n9so26179323pgc.1; Wed, 31 Jul 2019 10:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RnccxTMv5+LcoppvjojR/fSKkox/Hhf3XMW3FYv8fqE=; b=tXa44HXR5xfJHnRGG15h9FQetBMUhenRl3sm87oP8YRVsqYY0cy054Z1Z/p5gMzNKc UpD1N5lvG7eYieD5vypBah15wgmZcKOJYgV5caqovynwdvDCAf6PYU35xMEAF2JKUXdE NksYgv4fQLuMxhtdHVCYz3KPymT3LO9LKUCxXKrguSeRZX+CmB2BgTzbWe9Yq5+Ay6l+ mYJ1MZ0lepNzgtV4qFcie+IMSda3IpnVjfI76KHjItpxq4t/RJBir1eMn8a3vs9o4VCy GvSscBUDYG+s9i4aOkJUo54oZqUflQMbfC0ZDaerCh6nIINCy6SouQQFCnkM8BeiMLXm gSSA== 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:mime-version:content-transfer-encoding; bh=RnccxTMv5+LcoppvjojR/fSKkox/Hhf3XMW3FYv8fqE=; b=WyUt4rCwxakQ60SB1BsRXx1i5WyQeBcc3e9NUhZLZbnYcHjHol2rZ/aG7Xy0GlrdJw DSbGqoLVUzDEMf5MuTnDQdDMYzOR/43pYpwgVqFz1bcuMe3RvdrupXHP9bF0WU7bkCe/ IkhBhJVfueJ/BUYpohLPgJrWK0FyhSIhcEetAA9ewF+anwgjjpcgBIkAHuCrbStbxfAd bub1KQMYhFIbxSgnSbO6im0IKq7t3qJ1DQvn6tyMrrmAMGoygMIETcvN+2xPmO2xXsb7 0DGoK7ZB/VChM1HrR0HP72YByNyei06V6RXLesUrKYIAz+YsYBKZk/8t58tAWS0h4lJA NCfA== X-Gm-Message-State: APjAAAXfnKsh2hHY41lPNVDao9YZGX4i1xc5icSsmxNLFZKStDdxBYFV h8JdPBCRnoAgkPTqr/cJl1hz5a/L X-Google-Smtp-Source: APXvYqztJRy80ROLAN9XD0XKanZ5OUWLyXWDy3qubqx2akOfIqdJsSZ+7ei1laY0oem2q7ji4ueCYQ== X-Received: by 2002:a17:90a:7787:: with SMTP id v7mr4099480pjk.143.1564594982503; Wed, 31 Jul 2019 10:43:02 -0700 (PDT) Received: from localhost.localdomain ([2607:fb90:4ad:5a0b:2aff:6e0f:8973:5a26]) by smtp.gmail.com with ESMTPSA id k8sm65941259pgm.14.2019.07.31.10.43.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 10:43:01 -0700 (PDT) From: Andrey Smirnov To: linux-watchdog@vger.kernel.org Cc: Andrey Smirnov , Chris Healy , Guenter Roeck , Rick Ramstetter , linux-kernel@vger.kernel.org Subject: [PATCH 2/5] watchdog: ziirave_wdt: Be verbose about errors in probe() Date: Wed, 31 Jul 2019 10:42:49 -0700 Message-Id: <20190731174252.18041-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190731174252.18041-1-andrew.smirnov@gmail.com> References: <20190731174252.18041-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver is quite silent in case of probe failure, which makes it more difficult to diagnose problem from the kernel log. Add logging to all of the silent error paths ziirave_wdt_probe() to improve that. Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Guenter Roeck Cc: Rick Ramstetter Cc: linux-watchdog@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Guenter Roeck --- drivers/watchdog/ziirave_wdt.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/watchdog/ziirave_wdt.c b/drivers/watchdog/ziirave_wdt.c index 6ec028fb2635..8c71341a9c1c 100644 --- a/drivers/watchdog/ziirave_wdt.c +++ b/drivers/watchdog/ziirave_wdt.c @@ -658,8 +658,10 @@ static int ziirave_wdt_probe(struct i2c_client *client, */ if (w_priv->wdd.timeout == 0) { val = i2c_smbus_read_byte_data(client, ZIIRAVE_WDT_TIMEOUT); - if (val < 0) + if (val < 0) { + dev_err(&client->dev, "Failed to read timeout\n"); return val; + } if (val < ZIIRAVE_TIMEOUT_MIN) return -ENODEV; @@ -668,8 +670,10 @@ static int ziirave_wdt_probe(struct i2c_client *client, } else { ret = ziirave_wdt_set_timeout(&w_priv->wdd, w_priv->wdd.timeout); - if (ret) + if (ret) { + dev_err(&client->dev, "Failed to set timeout\n"); return ret; + } dev_info(&client->dev, "Timeout set to %ds\n", w_priv->wdd.timeout); @@ -681,34 +685,46 @@ static int ziirave_wdt_probe(struct i2c_client *client, /* If in unconfigured state, set to stopped */ val = i2c_smbus_read_byte_data(client, ZIIRAVE_WDT_STATE); - if (val < 0) + if (val < 0) { + dev_err(&client->dev, "Failed to read state\n"); return val; + } if (val == ZIIRAVE_STATE_INITIAL) ziirave_wdt_stop(&w_priv->wdd); ret = ziirave_wdt_init_duration(client); - if (ret) + if (ret) { + dev_err(&client->dev, "Failed to init duration\n"); return ret; + } ret = ziirave_wdt_revision(client, &w_priv->firmware_rev, ZIIRAVE_WDT_FIRM_VER_MAJOR); - if (ret) + if (ret) { + dev_err(&client->dev, "Failed to read firmware version\n"); return ret; + } ret = ziirave_wdt_revision(client, &w_priv->bootloader_rev, ZIIRAVE_WDT_BOOT_VER_MAJOR); - if (ret) + if (ret) { + dev_err(&client->dev, "Failed to read bootloader version\n"); return ret; + } w_priv->reset_reason = i2c_smbus_read_byte_data(client, ZIIRAVE_WDT_RESET_REASON); - if (w_priv->reset_reason < 0) + if (w_priv->reset_reason < 0) { + dev_err(&client->dev, "Failed to read reset reason\n"); return w_priv->reset_reason; + } if (w_priv->reset_reason >= ARRAY_SIZE(ziirave_reasons) || - !ziirave_reasons[w_priv->reset_reason]) + !ziirave_reasons[w_priv->reset_reason]) { + dev_err(&client->dev, "Invalid reset reason\n"); return -ENODEV; + } ret = watchdog_register_device(&w_priv->wdd); From patchwork Wed Jul 31 17:42:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11068963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49959912 for ; Wed, 31 Jul 2019 17:43:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3394126E79 for ; Wed, 31 Jul 2019 17:43:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2825826E90; Wed, 31 Jul 2019 17:43:23 +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,FREEMAIL_FROM,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 CA93526E7B for ; Wed, 31 Jul 2019 17:43:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729196AbfGaRnS (ORCPT ); Wed, 31 Jul 2019 13:43:18 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40342 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727571AbfGaRnF (ORCPT ); Wed, 31 Jul 2019 13:43:05 -0400 Received: by mail-pg1-f195.google.com with SMTP id w10so32408382pgj.7; Wed, 31 Jul 2019 10:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Cpujuh1ZR9rlNCezYBnwej7X6RImv6OA33MLjjo+nmw=; b=UOkNfQv1O2Gs2RI9Br/pIeBvWpb5MbI7oGm8try41ElbbiEQuiZh14isJekmD5A4sc rx7UVhhAfsqmlL3Kx49PGwrhEF2ok6ydS99DW03jDQFb1v5L3pd9qqRMJJaG6xQMHput VRULMPVa62qw5P8GcgPwCWEAIIetoeRNEYRqlkq6TRF5E1CMjT6Czj8OWScUNLfadJFl RhBLqsPgbM7NRBOJ+XIV3R47N+tPlF+LHN1yb+EEWx2t1KQZ75kOGrNvhQ0lHe18q69x VhxyEDgdg0Qz8r9nnbKPFAIaFbs+j6ftLyQwyPOAnTF839+v1+/qgsYyIo9OgHGYWkDx RiqA== 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:mime-version:content-transfer-encoding; bh=Cpujuh1ZR9rlNCezYBnwej7X6RImv6OA33MLjjo+nmw=; b=Q8Bsw2Hv4cIsndbn2Xod0twVGwPekRsIPNx/ACNjz3mf2tpUx1T2kwB3eOPZ3UxZEO kc5oej2JEKwsYrg13pQ9fUiwo/HXtiKXi5b02I4GC8caX9pD7cURGR22bJtLHwZqkwbY a9PBibXIbtvprVXCNYRXbyRUaKIh6dM5+Mmdis9x+oXaIxChAJCEX2ckEaGIByagn2am 3jVIUVFNC+KlIx8MODt5tPYsXme/du/Twncq5hDZsb8WlortFC4MHwdKM3TUujOaozvd 9r2YWharPVAxhkdACwjLg6i3z3dUSk/sHcLwb3E7txfsC+uF90nt5i19SWG2jnVwCVwt cJwQ== X-Gm-Message-State: APjAAAUptp/8c9t5yJpU09QYBfmAQPejPKZ8eyiBngz5GNlcvryv+tHL PEcZ7FDubhTZeY9/3T5EB6Eq3UHV X-Google-Smtp-Source: APXvYqyk2h4seKn5/mzLa7JMMKFrbJjUhAi4IWsEUgC/qHW6HwO1rvdGWF4IPNcrvfGJ4suzYmK5pg== X-Received: by 2002:a65:5144:: with SMTP id g4mr62535446pgq.202.1564594984189; Wed, 31 Jul 2019 10:43:04 -0700 (PDT) Received: from localhost.localdomain ([2607:fb90:4ad:5a0b:2aff:6e0f:8973:5a26]) by smtp.gmail.com with ESMTPSA id k8sm65941259pgm.14.2019.07.31.10.43.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 10:43:03 -0700 (PDT) From: Andrey Smirnov To: linux-watchdog@vger.kernel.org Cc: Andrey Smirnov , Chris Healy , Guenter Roeck , Rick Ramstetter , linux-kernel@vger.kernel.org Subject: [PATCH 3/5] watchdog: ziirave_wdt: Be more verbose during firmware update Date: Wed, 31 Jul 2019 10:42:50 -0700 Message-Id: <20190731174252.18041-4-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190731174252.18041-1-andrew.smirnov@gmail.com> References: <20190731174252.18041-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add more error logging to ziirave_firm_upload() for diagnostics. Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Guenter Roeck Cc: Rick Ramstetter Cc: linux-watchdog@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Guenter Roeck --- drivers/watchdog/ziirave_wdt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/ziirave_wdt.c b/drivers/watchdog/ziirave_wdt.c index 8c71341a9c1c..89ce6982ba53 100644 --- a/drivers/watchdog/ziirave_wdt.c +++ b/drivers/watchdog/ziirave_wdt.c @@ -335,14 +335,18 @@ static int ziirave_firm_upload(struct watchdog_device *wdd, ret = ziirave_firm_write_byte(wdd, ZIIRAVE_CMD_JUMP_TO_BOOTLOADER, 1, false); - if (ret) + if (ret) { + dev_err(&client->dev, "Failed to jump to bootloader\n"); return ret; + } msleep(500); ret = ziirave_firm_write_byte(wdd, ZIIRAVE_CMD_DOWNLOAD_START, 1, true); - if (ret) + if (ret) { + dev_err(&client->dev, "Failed to start download\n"); return ret; + } msleep(500); From patchwork Wed Jul 31 17:42:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11068957 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6EEF2912 for ; Wed, 31 Jul 2019 17:43:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 560DB271CB for ; Wed, 31 Jul 2019 17:43:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49A5526E79; Wed, 31 Jul 2019 17:43:16 +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,FREEMAIL_FROM,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 DEF8326E90 for ; Wed, 31 Jul 2019 17:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729369AbfGaRnH (ORCPT ); Wed, 31 Jul 2019 13:43:07 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36658 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728836AbfGaRnH (ORCPT ); Wed, 31 Jul 2019 13:43:07 -0400 Received: by mail-pl1-f193.google.com with SMTP id k8so30821632plt.3; Wed, 31 Jul 2019 10:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1kLt0NkSrpfjb5sCHuXjSffvs/aOPPaGzJ2Iaa+HT+0=; b=VZTc2lW93SQrSVzQNk5dBXVq52RHm/mLu+2BEstuOuS96w4Zs/BSY7jHBEH6+4aSXo kYoQoDGFKqWLqzEqub5aQkV/5t21TX9pyqyhz2HoHAzjvk8XOe6RzZL7wxifQOjv8lMl SrOdO86F7p7c2vM60xJQ421EH9er+GiijTOAo4QAnjh+2oO7VORFtO6lMrTwoCP+Z4T/ M26zoEIFpPtj2Rbg+tONcM0bIKh5F87caXoVCEeuk95qGbysWqm+xBAW6qdEw7YAkKSt F5RJsIJmQOKaemUGY6nHMw0/3LqxoGq5zz7VkvteHOD2jMMw1XJBcT227EHVNeQh7Mu8 YIaA== 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:mime-version:content-transfer-encoding; bh=1kLt0NkSrpfjb5sCHuXjSffvs/aOPPaGzJ2Iaa+HT+0=; b=bBTbhfdZCWkFRyOe+kMB4I7Bab/j2XDYteXODC37PZtmbgyDKTnq6MAh4/CV7Y0xht yISnPkBXYbiGJfTgkglBJcMeWUJ9ZsbKSuAQ0F0XN5PGoRVl6k9ft/DqjDG5bU5DI9/U e7hCgMAP6aN+goHut5qj++cuv5xWCLJ17PHEOx3WMmreM4bHx4nNFgEtnBI5EekJ9IVO hTi+HhGmqYcww67jGOJMsRNpJbwp1PidOBPU3mbFLYZzBHiQWV5WD0VUm7hFNnBhrLxl 0VzcZcNzbwO+nYLnJeCHBM3WXXLcLHA9Rvvob7g01FUAbxugayb6Dmg6oApS1zs+3NBt YL8A== X-Gm-Message-State: APjAAAVygo+Q9C2M5WaFH4h387jOuB31KHadJ2temjnnYCpgC5UjvDlh UpChmysFwWrTUvDo3hImq9sAmJID X-Google-Smtp-Source: APXvYqyqr6rE02ERXrhyXVMx8kPIqVNteisuUAch0gdlXI+1lp4hg5SJgDi39bQK0phDZmxijafcGA== X-Received: by 2002:a17:902:9f93:: with SMTP id g19mr120328966plq.223.1564594985912; Wed, 31 Jul 2019 10:43:05 -0700 (PDT) Received: from localhost.localdomain ([2607:fb90:4ad:5a0b:2aff:6e0f:8973:5a26]) by smtp.gmail.com with ESMTPSA id k8sm65941259pgm.14.2019.07.31.10.43.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 10:43:05 -0700 (PDT) From: Andrey Smirnov To: linux-watchdog@vger.kernel.org Cc: Andrey Smirnov , Chris Healy , Guenter Roeck , Rick Ramstetter , linux-kernel@vger.kernel.org Subject: [PATCH 4/5] watchdog: ziirave_wdt: Don't bail out on unexpected timeout value Date: Wed, 31 Jul 2019 10:42:51 -0700 Message-Id: <20190731174252.18041-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190731174252.18041-1-andrew.smirnov@gmail.com> References: <20190731174252.18041-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Reprogramming bootloader on watchdog MCU will result in reported default timeout value of "0". That in turn will be unnecesarily rejected by the driver as invalid device (-ENODEV). Simplify probe to just read stored timeout value, clamp it to an acceptable range and program the value unconditionally to fix the above. Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Guenter Roeck Cc: Rick Ramstetter Cc: linux-watchdog@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Guenter Roeck --- drivers/watchdog/ziirave_wdt.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/watchdog/ziirave_wdt.c b/drivers/watchdog/ziirave_wdt.c index 89ce6982ba53..33c8d2eadada 100644 --- a/drivers/watchdog/ziirave_wdt.c +++ b/drivers/watchdog/ziirave_wdt.c @@ -667,22 +667,18 @@ static int ziirave_wdt_probe(struct i2c_client *client, return val; } - if (val < ZIIRAVE_TIMEOUT_MIN) - return -ENODEV; - - w_priv->wdd.timeout = val; - } else { - ret = ziirave_wdt_set_timeout(&w_priv->wdd, - w_priv->wdd.timeout); - if (ret) { - dev_err(&client->dev, "Failed to set timeout\n"); - return ret; - } + w_priv->wdd.timeout = clamp(val, ZIIRAVE_TIMEOUT_MIN, + ZIIRAVE_TIMEOUT_MAX); + } - dev_info(&client->dev, "Timeout set to %ds\n", - w_priv->wdd.timeout); + ret = ziirave_wdt_set_timeout(&w_priv->wdd, w_priv->wdd.timeout); + if (ret) { + dev_err(&client->dev, "Failed to set timeout\n"); + return ret; } + dev_info(&client->dev, "Timeout set to %ds\n", w_priv->wdd.timeout); + watchdog_set_nowayout(&w_priv->wdd, nowayout); i2c_set_clientdata(client, w_priv); From patchwork Wed Jul 31 17:42:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11068955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 655BD1395 for ; Wed, 31 Jul 2019 17:43:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E49126E73 for ; Wed, 31 Jul 2019 17:43:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4287F271FD; Wed, 31 Jul 2019 17:43:14 +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,FREEMAIL_FROM,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 D532F26E79 for ; Wed, 31 Jul 2019 17:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728836AbfGaRnJ (ORCPT ); Wed, 31 Jul 2019 13:43:09 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38879 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729495AbfGaRnJ (ORCPT ); Wed, 31 Jul 2019 13:43:09 -0400 Received: by mail-pf1-f196.google.com with SMTP id y15so32285014pfn.5; Wed, 31 Jul 2019 10:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qdP7zcW+fsPauZxZz+eQFRnAEj1f5IU9NKoZzh/om+g=; b=eVcB1DArHZXjOZuYdvsD76Fy22cr4pxD2N0Ar6T4p/tAZMZDaUr431SUCDf16cN2g0 YAxqE4/ytqjfsqmgQSPTBz2RZ6yrntUJSLYahSBDS4ze4+iuRO5A+Ze+d1ZYilOcBNCA 6JOezh5ndagN9dKbXS4hTEmusmoNt+9tGt5UBG6bwUbqlmMckZ/ToPEy2J1SNXPRac9N H8/s+2bBEbPTv9sQ/G+kW9vKrzSqtrBDc/6Rq7+ogQvVsRI7kI7DTG33X9/Q3VGkwmvP ASZGqscxPJe83BKuBJgZFjYzEIKUuk6WbehoDGWTufXvEENw5qcvvyPyCRBkruA4nP0r YcWA== 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:mime-version:content-transfer-encoding; bh=qdP7zcW+fsPauZxZz+eQFRnAEj1f5IU9NKoZzh/om+g=; b=rSnme//CmrkzNC9DuvqPH10GFd4fhsXr90cUlTRwxqPDswAxCVrrga/1GqPP3RVyyU EOgWxhR5z+565yICzOGnpUMYbsSavfABLkDS4fePFl+I38162G3M2CxYn0nZKO7mLBSv VfOzu+eHbYg/PaEZtdcyX7qw5EM6FwuJboTW8VtgO3nmI7weOTMxwhQEaTrtwA/ntaPu IncMjYhCHbW4FvkzEAACKKQEff/xo4IyPXh30qHjHmg95Cb7AKIkuG8qN1RMApFM0BNl BIMOXE8LveVB/gBJ5GqXlf2Kf6iKVDN+eoPUCmQ3ml6VtPfqJkyDVaxj0pNeB+RqUKfO Yf0w== X-Gm-Message-State: APjAAAVrClJUWXd3LzQa3XfdA20onu/TuHudk5uJ6GSRqE1ckG1btGJc EVKf3MEp17eRDGvce0zHBrtCTsqZ X-Google-Smtp-Source: APXvYqxC1zj4+nftzjZqEJJIxCEGbwiSzWdB5H+pOucxoZmOZPbLbAPK0BTvJ/p2il1olsoJE/yHhA== X-Received: by 2002:a17:90a:8d09:: with SMTP id c9mr4117269pjo.131.1564594988181; Wed, 31 Jul 2019 10:43:08 -0700 (PDT) Received: from localhost.localdomain ([2607:fb90:4ad:5a0b:2aff:6e0f:8973:5a26]) by smtp.gmail.com with ESMTPSA id k8sm65941259pgm.14.2019.07.31.10.43.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 10:43:07 -0700 (PDT) From: Andrey Smirnov To: linux-watchdog@vger.kernel.org Cc: Andrey Smirnov , Chris Healy , Guenter Roeck , Rick Ramstetter , linux-kernel@vger.kernel.org Subject: [PATCH 5/5] watchdog: ziirave_wdt: Log bootloader/firmware info during probe Date: Wed, 31 Jul 2019 10:42:52 -0700 Message-Id: <20190731174252.18041-6-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190731174252.18041-1-andrew.smirnov@gmail.com> References: <20190731174252.18041-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Log bootloader/firmware info during probe. This information is available via sysfs already, but it's really helpful to have this in kernel log during startup as well. Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Guenter Roeck Cc: Rick Ramstetter Cc: linux-watchdog@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Guenter Roeck --- drivers/watchdog/ziirave_wdt.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/ziirave_wdt.c b/drivers/watchdog/ziirave_wdt.c index 33c8d2eadada..84ba8820ac86 100644 --- a/drivers/watchdog/ziirave_wdt.c +++ b/drivers/watchdog/ziirave_wdt.c @@ -68,6 +68,9 @@ static char *ziirave_reasons[] = {"power cycle", "hw watchdog", NULL, NULL, #define ZIIRAVE_CMD_JUMP_TO_BOOTLOADER 0x0c #define ZIIRAVE_CMD_DOWNLOAD_PACKET 0x0e +#define ZIIRAVE_FW_VERSION_FMT "02.%02u.%02u" +#define ZIIRAVE_BL_VERSION_FMT "01.%02u.%02u" + struct ziirave_wdt_rev { unsigned char major; unsigned char minor; @@ -482,7 +485,7 @@ static ssize_t ziirave_wdt_sysfs_show_firm(struct device *dev, if (ret) return ret; - ret = sprintf(buf, "02.%02u.%02u", w_priv->firmware_rev.major, + ret = sprintf(buf, ZIIRAVE_FW_VERSION_FMT, w_priv->firmware_rev.major, w_priv->firmware_rev.minor); mutex_unlock(&w_priv->sysfs_mutex); @@ -505,7 +508,7 @@ static ssize_t ziirave_wdt_sysfs_show_boot(struct device *dev, if (ret) return ret; - ret = sprintf(buf, "01.%02u.%02u", w_priv->bootloader_rev.major, + ret = sprintf(buf, ZIIRAVE_BL_VERSION_FMT, w_priv->bootloader_rev.major, w_priv->bootloader_rev.minor); mutex_unlock(&w_priv->sysfs_mutex); @@ -572,7 +575,8 @@ static ssize_t ziirave_wdt_sysfs_store_firm(struct device *dev, goto unlock_mutex; } - dev_info(&client->dev, "Firmware updated to version 02.%02u.%02u\n", + dev_info(&client->dev, + "Firmware updated to version " ZIIRAVE_FW_VERSION_FMT "\n", w_priv->firmware_rev.major, w_priv->firmware_rev.minor); /* Restore the watchdog timeout */ @@ -706,6 +710,10 @@ static int ziirave_wdt_probe(struct i2c_client *client, return ret; } + dev_info(&client->dev, + "Firmware version: " ZIIRAVE_FW_VERSION_FMT "\n", + w_priv->firmware_rev.major, w_priv->firmware_rev.minor); + ret = ziirave_wdt_revision(client, &w_priv->bootloader_rev, ZIIRAVE_WDT_BOOT_VER_MAJOR); if (ret) { @@ -713,6 +721,10 @@ static int ziirave_wdt_probe(struct i2c_client *client, return ret; } + dev_info(&client->dev, + "Bootloader version: " ZIIRAVE_BL_VERSION_FMT "\n", + w_priv->bootloader_rev.major, w_priv->bootloader_rev.minor); + w_priv->reset_reason = i2c_smbus_read_byte_data(client, ZIIRAVE_WDT_RESET_REASON); if (w_priv->reset_reason < 0) {