From patchwork Wed Feb 15 18:15:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9574727 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 EAA9B60209 for ; Wed, 15 Feb 2017 18:16:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0A5428494 for ; Wed, 15 Feb 2017 18:16:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3CD828503; Wed, 15 Feb 2017 18:16:38 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 42FA228494 for ; Wed, 15 Feb 2017 18:16:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=oGmB10NaBpXxMJmvfquwIdFVFgwqHb6hLn0HHjZlSGA=; b=ptZ 81V7wOcC4Mi4BSpNRND9a9iAJAL7MTinD6pQ1Rw+8cp4RXu67Gt6HwWriP0VnkSRN+Z7P6MSMF1sv 0vnDiwBvgY3bUDnXy6OPubvyqAcwyuuxGvXHbUu5P0POYy3Zb4vxbOWzwKREFipdqmXFSH9F48Gax welqKgXdR4T/VhbESgsN/VuOfN4iynZm65c8kHyFVh2lR+N3cSKW/uWiWQj1dnLt76xXH/znD9KLO R9XYFj3osxi5Q4pKt9o3K2QPoi7Y7dAS7eYjo++k1/srnWZ7LtA0DgsTuVi3dCCCJAEMTcEkhLDwg iI7wuH2EEX+PyFot/oILOBW6djoDK8A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ce47u-0002ch-S2; Wed, 15 Feb 2017 18:16:26 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ce47p-0002Z3-1B for linux-amlogic@lists.infradead.org; Wed, 15 Feb 2017 18:16:24 +0000 Received: by mail-wm0-x235.google.com with SMTP id v77so47030751wmv.0 for ; Wed, 15 Feb 2017 10:16:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=dO873KX8xdbLPKCdI7wTsdh0O8f0xRf5RuLH9sigQzw=; b=KMN5sS/+xVFLUNNErsu6sf1VXSDDmKeP3Y4bnp228wRQbD96aZnQuWqdzz3IolhyAa 3dqZ97Im2WMwB4T0wFkcMYlUWYkStSOQNeKb8WZZEtVdce5VuM2QlSxBmGqbQVFK3veM VMuwJO79D6bqvOUNIYoRbqFAvEAp4olMtYSeqYEkGEmS2/b4Cg3C92jQAQRrF0rWxInk NA8CBr69JcfY1lHpwG9sAwhRbrP8uwcbJnaO/goj9EXnUlWBQot8LB90D9CvGIfBNYHj rAkEPdCfA9k2DnJt3Zz/707PjCUodsulmSSGwqS6poBgz6A11i3ZS5Y2Qy3AWebdPl8E lxsg== 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; bh=dO873KX8xdbLPKCdI7wTsdh0O8f0xRf5RuLH9sigQzw=; b=iqxclf63Bz+ePivxDtE57y6GpO8+GH6b76rSAMYbJDmMFOsNin8NQZxAm3yQgW+JRa wKvphvPmyzxLii+0nstza3a0eFKg7DmvwP4znxYq1MK2oTwhb0wsrIAoi0MsKle4/FKJ cpLzQfi70/Z2tVUjEvlUESCrheXXLK2frLl6GP62iw8mn5vDLD2RnBry76W2GIQ4LSrN 3CHz4XCNz7+XbzSoQtqvio95lzTOM8sxz7gvIBNOvUAE5ofKS+wg4iN4nMQiKPK1FUOS 3mOoHpykJNQ5TNUNPthrfynMNv2nIEO4eQXbtb/HOKvCdYT6e94pXfbDcBEhAs9uZbVk INxg== X-Gm-Message-State: AMke39lubYg+7xcKkTA2i2rGO0b/F2WDEWSJhogQx9ENx+H0RhzbckOUX8EwgioAvQk0e9HH X-Received: by 10.28.129.147 with SMTP id c141mr9604236wmd.12.1487182559448; Wed, 15 Feb 2017 10:15:59 -0800 (PST) Received: from boomer.localdomain (uluru.liltaz.com. [163.172.81.188]) by smtp.googlemail.com with ESMTPSA id w126sm495682wmw.0.2017.02.15.10.15.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Feb 2017 10:15:58 -0800 (PST) From: Jerome Brunet To: Philipp Zabel , Martin Blumenstingl Subject: [PATCH] reset: fix shared reset triggered_count decrement on error Date: Wed, 15 Feb 2017 19:15:51 +0100 Message-Id: <1487182551-31517-1-git-send-email-jbrunet@baylibre.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170215_101621_238229_C5704D4D X-CRM114-Status: GOOD ( 10.72 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP For a shared reset, when the reset is successful, the triggered_count is incremented when trying to call the reset callback, so that another device sharing the same reset line won't trigger it again. If the reset has not been triggered successfully, the trigger_count should be decremented. The code does the opposite, and decrements the trigger_count on success. As a consequence, another device sharing the reset will be able to trigger it again. Fixed be removing negation in from of the error code of the reset function. Fixes: 7da33a37b48f ("reset: allow using reset_control_reset with shared reset") Signed-off-by: Jerome Brunet Acked-by: Martin Blumenstingl --- Hi Philipp, I found this issue while testing your patch [0] It fixes a regression we have been having with usb. On meson-gxbb platforms, usb0 and usb1 share the same reset line. Martin had reports that usb0 recently got broken. In fact usb1 was able to trigger the reset again because the issue mentioned above. [0]: http://lkml.kernel.org/r/20170130114116.22089-10-p.zabel@pengutronix.de drivers/reset/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index 71ccf281dce3..f1e5e65388bb 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -169,7 +169,7 @@ int reset_control_reset(struct reset_control *rstc) } ret = rstc->rcdev->ops->reset(rstc->rcdev, rstc->id); - if (rstc->shared && !ret) + if (rstc->shared && ret) atomic_dec(&rstc->triggered_count); return ret;