From patchwork Wed Jul 21 15:55:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1508313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=NSh36avJ; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=UFKXZ76C; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GVKtY3cchz9s5R for ; Thu, 22 Jul 2021 01:55:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=XOSu/z2grcu9S8fxVo2wdHhcY/cvpqK8wNbQgIUAswA=; b=NSh36avJiHhUR9 1OYShZhMVyQxgJgyA/2yPWeuZs1We6YV7/t+FsMNyGtIM+RbWTMZ6S2UIgWjJ+7Rw4M/iV+7gY//4 Uv3SGWZRdrlJUOB8e8JmboCR7sATFS8WuPZfvbj0L1xVHbRteG1LZDhGOF++DKWIXNsgUFg9aPul8 gyB7zj1n9dzRKS5B6MM6oBqNBPb66wzQXyo/Y0E3yHMSug59KQ+hqcbOs24NWnAc2M0FHil/XczXz eZc1YS0+nTlJbVitmIcciSe99//sG3lEZlWfT37/NI+VNIKJOmnGlL3shwfX4T+5SEoVWppg/66GG STAn2rggaUf9ajRoa+4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EZV-00GSAB-H7; Wed, 21 Jul 2021 15:55:45 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EZS-00GS96-5u for opensbi@lists.infradead.org; Wed, 21 Jul 2021 15:55:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1626882933; bh=gT5V6OIazWGNf6JBwKGOeTw2z82m/MuZ3Z1aVEitV+U=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=UFKXZ76CdodmUfKluZAC1NiS7mppzOwvT05U49ULh5djUwAkEbqcrUh6TZYyvylmi /MoNqc09VrvhJN81Yh/3gzEEvOqvpYJw3oadpaRneLzrqsjG0rHyaA+bgKbsm0tFOg hhTKCTj0DgQWKswA+tlByKXssItw2X8v1cLITPFY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation.fritz.box ([88.152.144.157]) by mail.gmx.net (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1Mlf4S-1lOxOB2Mks-00ikSE; Wed, 21 Jul 2021 17:55:33 +0200 From: Heinrich Schuchardt To: OpenSBI Cc: Green Wan , Anup Patel , Atish Patra , Heinrich Schuchardt , Heinrich Schuchardt Subject: [PATCH 1/1] lib: utils: support multiple reset drivers of same type Date: Wed, 21 Jul 2021 17:55:27 +0200 Message-Id: <20210721155527.72568-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Provags-ID: V03:K1:PZpQuWwzH96mDc2GihK80yR0WOMng9WopXRYJBz4O8Wbkyf6gp0 2HXf1QOUSG7LDuYdg3lm+HaZTUYkax2PwzAOsL3xrgzcWSgkR72lau6X7mBBIORZNZnPjhm zC7ItPo8EKqmN5LwaCt1O1tTo5cP2s0Pc//BLX4KC3+intVpPlGJUrTG9gzuoPQfPMKD1Kh K3gz0XWcEnzmWv5nKfx4w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:meWAwrS4cqQ=:oE1kQjvTP0tOHaGt126cGC CdN0l/Wm4BoOnGD/Q6l6W7/AU0vaKlR/QxWOfQDOB0l0gBa6V1GS/zdegr34clgdba1kQifU0 2t0mK+wURCbW05/4ROVjiZukfPCm4ScNWU9GvPgLL8CJd9B+/81hIyS6Hak9mGNhJltNteh9q 96ec7ZnrCvxiOcfYCueQhye1Nj2UWrybTwDJNP+EYGqbbCnHW+u9aDGQXWMEUt0kuLdRQ4pAz 1Eco+cPMHrOMA7dkebAoM6R7eJtoe7ssO2X341KqM+pM1PvwFX1hD0und3W0WoYBFfmhKdySp TdV38Hl7z9hOD5WjnURC9nCD//3CMPgEOaiJ+9lPPEP08dasvZa6UfOxm3vq1/b9x3eGhojsR d5CGX4643+ZTeCMUGqQKr9Jzhq/wnUJKaE+KXEwuT1Bwj87n5hlnrwWt9Lj3a7XVn1UfxoYmp Ys5NSCgee0VnkXmgq403PLR7CyNHEBPCNTNM0r+/fQu0mZLYzwWl/C1fGTnbtq79jmkJq8oup 7TukPSiyOgoqyEGOlDoihNoL+bTM88OkG/fku5NSZWiK2YHXrL8x1bfiwU+dEYSADyDwro8RH C47ggk+uGdA2ETkcCbcUaEsMNeb2W0QY9ku99tG3txpOzhA1eMiYxamOvZnH8RC7Ov+e8Iyli PpGBbRqeDB+oyY3UfU51AE8nnqNJ0aYKnDqU4DWE+wQYQdWiAvNRzihieS6/J+sPsuhCs9G8Y ZLM/C2sw8yWMrd1Xs9fMz4XOu3SsQumqavcqbzYOEEFDvcuoaocK0uFveqytzJC037+CYMSfz SsDASzh2Cjch8Ids6gRKM/6u1eAHya3QeBxxAcEbLRbhrI8AtGzJCW2RjTPksBmE1JVtPQVrh ikUE+0b37ea/ZRJ4duc9t011s190rYnmJe/N2sac0NmaZproOt1DsZQxZ3A7Ci35IZASWA/VW d2cPpRhm91zXQNKid/d5F7w4sTZtl/G75iF//z3jwbD5D8l3owOtO11W851e7BhIZS8KLw8MT +J6cntOUpiJL7EXLZGcVe5Ol8N8g6gYAt8cxbFggsbYC1v5yeZzBNLrNVaYWpQie50YtXB9Js H8qCmDIhHRQ5xxQocbx9zv3EK0jNP8fepa0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210721_085542_594871_2BB141CE X-CRM114-Status: GOOD ( 12.96 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The generic GPIO reset driver has two entries in the match table: "gpio-poweroff", "gpio-reset". Only the first entry is considered by fdt_reset_init(). Let fdt_reset_init() loop over all entries. Fixes: e3d6919d10d7 ("lib: utils/reset: Add generic GPIO reset driver") Fixes: 7cc6fa4d8a65 ("lib: utils: Add simple FDT reset framework") Signed-off-by: Heinrich Schuchardt --- lib/utils/reset/fdt_ [...] Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [212.227.15.18 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [212.227.15.18 listed in wl.mailspike.net] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [xypron.glpk[at]gmx.de] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The generic GPIO reset driver has two entries in the match table: "gpio-poweroff", "gpio-reset". Only the first entry is considered by fdt_reset_init(). Let fdt_reset_init() loop over all entries. Fixes: e3d6919d10d7 ("lib: utils/reset: Add generic GPIO reset driver") Fixes: 7cc6fa4d8a65 ("lib: utils: Add simple FDT reset framework") Signed-off-by: Heinrich Schuchardt --- lib/utils/reset/fdt_reset.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) -- 2.30.2 diff --git a/lib/utils/reset/fdt_reset.c b/lib/utils/reset/fdt_reset.c index aa5f59f..a77a680 100644 --- a/lib/utils/reset/fdt_reset.c +++ b/lib/utils/reset/fdt_reset.c @@ -7,6 +7,7 @@ * Anup Patel */ +#include #include #include #include @@ -24,8 +25,14 @@ static struct fdt_reset *reset_drivers[] = { &fdt_reset_thead, }; -static struct fdt_reset *current_driver = NULL; - +/** + * fdt_reset_init() - initialize reset drivers + * + * For each reset driver we iterate over the match table. For each matching + * entry we call the driver initialization code once. This is necessary as + * drivers may use different compatible string for different reset functions, + * e.g. both "gpio-poweroff" and "gpio-reset". + */ int fdt_reset_init(void) { int pos, noff, rc; @@ -35,20 +42,19 @@ int fdt_reset_init(void) for (pos = 0; pos < array_size(reset_drivers); pos++) { drv = reset_drivers[pos]; - - noff = fdt_find_match(fdt, -1, drv->match_table, &match); - if (noff < 0) - continue; - - if (drv->init) { - rc = drv->init(fdt, noff, match); - if (rc == SBI_ENODEV) + for(match = drv->match_table; match->compatible; ++match) { + noff = fdt_node_offset_by_compatible(fdt, -1, + match->compatible); + if (noff < 0) continue; - if (rc) - return rc; + if (drv->init) { + rc = drv->init(fdt, noff, match); + if (rc == SBI_ENODEV) + continue; + if (rc) + return rc; + } } - current_driver = drv; - break; } return 0;