From patchwork Mon Aug 12 20:09:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11090803 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 6ABC913B1 for ; Mon, 12 Aug 2019 20:10:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BD872856B for ; Mon, 12 Aug 2019 20:10:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FE9C2857B; Mon, 12 Aug 2019 20:10:02 +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 F0A3E2856F for ; Mon, 12 Aug 2019 20:10:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727816AbfHLUJo (ORCPT ); Mon, 12 Aug 2019 16:09:44 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44661 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727781AbfHLUJn (ORCPT ); Mon, 12 Aug 2019 16:09:43 -0400 Received: by mail-pl1-f195.google.com with SMTP id t14so48269338plr.11; Mon, 12 Aug 2019 13:09:42 -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=GoHqMWoeBEMrIjbLSbTR7or87F8V770ooMxvzxudxeo=; b=pDEMCJ+gUgFE6FzktAdhoi91phyuBXIkv1Op7UAi8GjHzDwM18bQeFm1NnaojggXP8 5cl5Alp2+X1Yiob1XMqYsHJeNm1e8j2rWhvGZ4k4mTJuesue9Xozkm/21rY3EwOfBk9r rhLohCGdss9wFB0oy5sxYFDLuC9GxICOCViBm1RylbuhL/8tQPLKVfdWKgLcDGdyBAI2 9+emwTAtK/QUr1AWhPTXMWug00/kuktSAM2ZWl0Te++LZi9K/UBvd00OfbOSBTSbuia9 kys5YM8ku7PCqC91Ka+liQu8QI6sMM3XZFZqEJYvE3QsOeNoP1H4PwMt/3TcRGAq03A2 K6pA== 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=GoHqMWoeBEMrIjbLSbTR7or87F8V770ooMxvzxudxeo=; b=dn8WL9qeoXJFTJtFrMxZi20B0mB0qIBgPgICLlLqDOEnVQl5QKisGwSun99nltrHh6 SVJW2zKhStFxRgICoZmCAZk+xylzrkBVkGXio6X8PGI9yN6QD4LJ4UjxQvWYlN3dc7D/ 7uzsHC7XLIdm49/uByqB3NRrJU/4SrvkuvKNANyEazPsEl3RNmLmErmvriqK9PRrsc+A 2qL1dY478uEiOG8y/A773cs/5J2i8WKqqknra9ta1daRlM/IaI7RYf4McsOUQ+KrjPVm zwn+z2h9ZdWgZYUAElbn4mlCEcOOOfM5LwHkxneZqoWEO73cMr6XNFViHZZGCPRgoxwi Z+sw== X-Gm-Message-State: APjAAAX+4W0eF9kJGbQOApVMMyiXcR+Ag8G/Rag2K3nytAJb6crynKsd R59dIL5P0F2yM8TPH88vBljBYvvT X-Google-Smtp-Source: APXvYqyaZ3b7dnxh52ixz5DMKHMYp0ySfvRh5bgox/pqOQR0u/zyebMTpeAe//iijAfGSxVWrJ3d7w== X-Received: by 2002:a17:902:9a84:: with SMTP id w4mr33492746plp.160.1565640581949; Mon, 12 Aug 2019 13:09:41 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id n26sm110286451pfa.83.2019.08.12.13.09.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 12 Aug 2019 13:09:41 -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 v2 18/22] watchdog: ziirave_wdt: Fix RESET_PROCESSOR payload Date: Mon, 12 Aug 2019 13:09:02 -0700 Message-Id: <20190812200906.31344-19-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190812200906.31344-1-andrew.smirnov@gmail.com> References: <20190812200906.31344-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 Bootloader firmware expects the following traffic for RESET_PROCESSOR: S Addr Wr [A] 0x0b [A] 0x01 [A] P using ziirave_firm_write_byte() will result in S Addr Wr [A] 0x0b [A] 0x01 [A] 0x01 [A] P which happens to work because firmware will ignore any extra bytes and expected magic value matches byte count sent by i2c_smbus_write_block_data(). Fix this by converting the code to use i2c_smbus_write_byte_data() instead. 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/ziirave_wdt.c b/drivers/watchdog/ziirave_wdt.c index a598780d73d3..92df27350e41 100644 --- a/drivers/watchdog/ziirave_wdt.c +++ b/drivers/watchdog/ziirave_wdt.c @@ -73,6 +73,7 @@ static char *ziirave_reasons[] = {"power cycle", "hw watchdog", NULL, NULL, #define ZIIRAVE_CMD_DOWNLOAD_PACKET 0x0e #define ZIIRAVE_CMD_JUMP_TO_BOOTLOADER_MAGIC 1 +#define ZIIRAVE_CMD_RESET_PROCESSOR_MAGIC 1 #define ZIIRAVE_FW_VERSION_FMT "02.%02u.%02u" #define ZIIRAVE_BL_VERSION_FMT "01.%02u.%02u" @@ -433,8 +434,9 @@ static int ziirave_firm_upload(struct watchdog_device *wdd, } /* Reset the processor */ - ret = ziirave_firm_write_byte(wdd, ZIIRAVE_CMD_RESET_PROCESSOR, 1, - false); + ret = i2c_smbus_write_byte_data(client, + ZIIRAVE_CMD_RESET_PROCESSOR, + ZIIRAVE_CMD_RESET_PROCESSOR_MAGIC); if (ret) { dev_err(&client->dev, "Failed to reset the watchdog: %d\n", ret);