Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2858458pxk; Mon, 28 Sep 2020 01:45:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL7DuaphlyCj9KWY3KOX+HVLIglF4k23uTTlESaspjYhcZOaVF/kDYLTcCYR2pjfzMJDLK X-Received: by 2002:a17:906:915:: with SMTP id i21mr589590ejd.113.1601282741212; Mon, 28 Sep 2020 01:45:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601282741; cv=none; d=google.com; s=arc-20160816; b=lhzJL4g2zkAnyW/dhB7CziH3FIpE7bbsWWi5bJul+1zlIlPymTXTQ7tbJFChVoePkW PiZwg+oQpX3kiYGZR1kGSEk9dG7C/i3sHLvKvsM87c8lfWUVHHrheKwPGGc2I+VQEAUt Jxf8K+4UXFr76c/HuXVTXwj9ehKYU5BjWgvrAF0wzwFBw9qmn1AxWr8fzq8Ii04IBBQ0 z0FDu52xHGMolrxTCAHy012ZaP1W3zpBGtdEv5GYFRiEaS1t6P8Cn5EdnHDmEpPZt5rg y3Uad+l9nw5ZRO0EJLQnKBPFE2FW25e9Gwd20dq8XDOCs7MdAR5VKt7cmMShv2/LNBOQ 5GOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=BN5GYsKajobIQ4LtxyHCluKrtoAcEBSBFiHfcIFTXd4=; b=I+Rp4q4KjJgTKr+wb8IWl6fsDDFtQZnwNBwR6BE2fEDKa3/Pfg2rjHbYTWTwJcuLIa 0x+MySYxWZoRw4OLDfJl3iBE2pJ2/9AxtNBCVfdyu1YrPNjhUS08jNbrjx6kcBXdwW1R C82qPyIS5Mt9bUh7LFktyJ4LFrENGQ+1gCGVYhla2ID5gVgPGgkNl95yoIl56hKSeKtZ /bHyrj04FTcJJDK68WRa/wSNL2Se/AtjCC0anaZSdoyWDXdjEJdJf00yxSTBcza6qGz1 duyPvQQ2tmJyDcGMv97kOvItvSafZV4jeBAIzeaHn/HMPE43njFTz+uTB0Bwvhni2+DJ mmgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x15si180454ejs.713.2020.09.28.01.45.18; Mon, 28 Sep 2020 01:45:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726634AbgI1IoA (ORCPT + 99 others); Mon, 28 Sep 2020 04:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbgI1In7 (ORCPT ); Mon, 28 Sep 2020 04:43:59 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2784C0613CE for ; Mon, 28 Sep 2020 01:43:59 -0700 (PDT) Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMol7-0001Mn-GS; Mon, 28 Sep 2020 10:43:45 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1kMol5-0006Ul-T2; Mon, 28 Sep 2020 10:43:43 +0200 Date: Mon, 28 Sep 2020 10:43:43 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Guenter Roeck Cc: Bruno Thomsen , linux-rtc@vger.kernel.org, Alessandro Zummo , Alexandre Belloni , linux-watchdog@vger.kernel.org, "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , open list , Rob Herring , Sascha Hauer , Wim Van Sebroeck , Qiang Zhao Subject: Re: [PATCH 2/2] [RFC] rtc: pcf2127: only use watchdog when explicitly available Message-ID: <20200928084343.cl42lxsiionvq7tg@pengutronix.de> References: <20200924074715.GT9675@piout.net> <20200924105256.18162-1-u.kleine-koenig@pengutronix.de> <20200924105256.18162-3-u.kleine-koenig@pengutronix.de> <8f88f2a2-4a6d-021f-4404-f05518b0477d@roeck-us.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="374kthn377ofw35y" Content-Disposition: inline In-Reply-To: <8f88f2a2-4a6d-021f-4404-f05518b0477d@roeck-us.net> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --374kthn377ofw35y Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Sep 27, 2020 at 08:54:47AM -0700, Guenter Roeck wrote: > On 9/27/20 1:09 AM, Bruno Thomsen wrote: > > Den tor. 24. sep. 2020 kl. 12.53 skrev Uwe Kleine-K=F6nig > > : > >> > >> Most boards using the pcf2127 chip (in my bubble) don't make use of the > >> watchdog functionality and the respective output is not connected. The > >> effect on such a board is that there is a watchdog device provided that > >> doesn't work. > >> > >> So only register the watchdog if the device tree has a "has-watchdog" > >> property. > >> > >> Signed-off-by: Uwe Kleine-K=F6nig > >> --- > >> drivers/rtc/rtc-pcf2127.c | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c > >> index 5b1f1949b5e5..8bd89d641578 100644 > >> --- a/drivers/rtc/rtc-pcf2127.c > >> +++ b/drivers/rtc/rtc-pcf2127.c > >> @@ -340,7 +340,8 @@ static int pcf2127_watchdog_init(struct device *de= v, struct pcf2127 *pcf2127) > >> u32 wdd_timeout; > >> int ret; > >> > >> - if (!IS_ENABLED(CONFIG_WATCHDOG)) > >> + if (!IS_ENABLED(CONFIG_WATCHDOG) || > >> + !device_property_read_bool(dev, "has-watchdog")) > >> return 0; > >=20 > > I don't think the compiler can remove the function if > > CONFIG_WATCHDOG is disabled due to the device tree > > value check. Maybe it can if split into 2 conditions. > >=20 >=20 > If the first part of the expression is always false, the second > part should not even be evaluated. This is wrong. For || the second expression isn't evaluated if the first evaluates to true (and the whole expression becomes true). This is the intended behaviour: If CONFIG_WATCHDOG is off, we don't need to check for the dt property and just skip the watchdog part. > Either case, the code now hard depends on the compiler optimizing the > code away. >=20 > It calls devm_watchdog_register_device() which doesn't exist > if CONFIG_WATCHDOG is not enabled. I didn't know that this is safe, > and I would personally not want to rely on it, but we live and > learn. AFAICT this is save and used in other places in the kernel, too. This is one of the reasons why you cannot compile the kernel with -O0. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --374kthn377ofw35y Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAl9xoj0ACgkQwfwUeK3K 7AloGQgAmT9jAsBE55nkCiQIvfTONeRIQHfU/NnP8IE+OO7uaKe+rs00xj0rIerX vLQyiWvIbRKkYDNvb/sbsp6OdhBh0o8C7d9wXPe7gzIgdU0VUI6aUfPv+SrpuArL 75ye2ADjrI7fOAtdEI3FLgQPUvqlEmGBtqNqP2D6ub4KFSvKJr29X2+8QMO4aHpJ KZI/3e/3CSmg0C7a3mnPu0ghHUZUBFd7eOuiZbNrlVuaOc2cBMEdwQrtLm/dTZto IhWtwplF4GWZaDo84GsEA7MU8v38tN2g3KnEdzlOwqdU+/pqGYv4uNm1vrRq2NMG 68zaImE+9OUEnlS364NiBvRoV8zeLQ== =x1uh -----END PGP SIGNATURE----- --374kthn377ofw35y--