Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3304493rwb; Mon, 5 Sep 2022 09:21:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR7AP/wrDYozG+ccn+ZtDuSZ9W83ZgePIkTBRLEuSwIsoPHUiArah6qYrKdP7Em4Ed4z0Ax2 X-Received: by 2002:a05:6402:27d1:b0:448:7587:15db with SMTP id c17-20020a05640227d100b00448758715dbmr31047013ede.217.1662394897849; Mon, 05 Sep 2022 09:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662394897; cv=none; d=google.com; s=arc-20160816; b=rGH0syLStL6Ts6cWaVBDepcSrwD2X7EsAh3lcJ21F/FY7/npj5FfyitRAbm92T5SeX f5n+uoUzsgVZfROQtCrFwQe6vmTM72l3dfL1+opIgFJqRoba67OnTzK5cEfFxROP3nzH ufb4ywojAO89OFdPNbneZolsOivLrV5wky9DwFWdmX9hIsYmJF9a8vxSSOMdohijpoe5 4jtP+wT113YxNrqnfDiHYuebd+qguacJlxJ5OwYF6Mv+mTP0SmEGinzn80V5tmqYj8el e/fXLavHdonG+DGBJMcASu3FhV3q7/92aSLMe/qbEUh39RT7m8wQsl8Mefnlv1rhoN/5 L27w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+ZiqcY4iwW4z7/E7mCAKrjs2qkOwesFoeuU+408Ac8o=; b=uTBao8KLW+g4FHpZehOSRx122Jy6eNPB0L84ci/aMRxkbWYpaYI6I/HOAHfvgo9Lgm nR+4KJ3K1PqA1+iH9IaD+VVxcs0PrxjNBgxg7sBFaTWsu6CMVst3tTUxto59iH+UpqIi GZXCODNPnSHzM4bKIgzt1CiBtyzeQKGKz/Ta3LiTxqzKcAb8I9GOHhR779ZWuh8FXB9k V47aC2IcDO0cXjMgqdiFTnbHaFvXjFi6ynuHlXzjKovHQAZCATP2ita+dO+vf9HeKuWN 8zGAn7W2AwAbY7PqR/GEuD01MupUS04HfZoE6q0EXxhTvNapsgAVawzFoCBBfQJ1pkv1 aWXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VFmGFDTE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x69-20020a50bacb000000b0044816827be2si6733431ede.314.2022.09.05.09.21.12; Mon, 05 Sep 2022 09:21:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VFmGFDTE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238811AbiIEPW7 (ORCPT + 99 others); Mon, 5 Sep 2022 11:22:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238810AbiIEPW0 (ORCPT ); Mon, 5 Sep 2022 11:22:26 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32E5F5E65A; Mon, 5 Sep 2022 08:22:19 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id s22so6492937qkj.3; Mon, 05 Sep 2022 08:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=+ZiqcY4iwW4z7/E7mCAKrjs2qkOwesFoeuU+408Ac8o=; b=VFmGFDTElC9gVBP4IH125hq51A7FGr51vQ9KGLGqsDH5FAEMbMbUXIVHi85ww+a0fI GziSfVv/AV96vVMyihm0a9WLMAOVaqURD6Z6C0QYsgp+rD6u9b5XKuySpRwB9/4ukD5r ntRcngBKUZIdj1p7dnKxVpS61IIJC70YsoWsdaYgU3yQ1OeaPC6Dp8pG57kfBWmOL/93 L/IFFf00dHT3zgOp5UKnif6AxMU2wmHM+SIXzgJwfA+idsrUzSPhTV0Cy8bk19HNDekI +ldaJp7J0Y+v4fVjKkwUglDoR826zDL6l5uW2KrYqW3xGquKc2bpuTp1y4lh/YVJ6mAK GUTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=+ZiqcY4iwW4z7/E7mCAKrjs2qkOwesFoeuU+408Ac8o=; b=X6vXErVPMJY7d1KHJ77+zIPQCFI0nwzh7fnLnnmSbuQktl5hH9FtjLRDtYuOI0WmG6 Kz7kh8TDh2HB3DV5mlOrGD2uV8vB4EWEZrp4W0faBhfTjKk3giHYFE1KfO4Xvd24RhM6 aGp5qEDIxfTWy6MfSwEpxi4bDypI5y4zEcgpC3G94j1LW3ESHj1f0BbMKhwwxMN4sv4E vFgzPkpOJsMXgVTHijBSspw7sYMW878mYTkjqwPrSXHqe1MQBOTAGhMogWGD3hUipc0a kVNiJsvM6x1bBO4kvgBNpqQZsEMHHMN20n3o/yiYOtxdZ5IGI3dOsp6NSzUj5IjgEv5J 8YYQ== X-Gm-Message-State: ACgBeo35E66bskPTI7omOBhSkr9TDFyyrrO6OkACMhX9OBlca8TALC2y un8UsY7S4/gZYKkpzPLRtYb2NQaXKfBvEVr6xv4= X-Received: by 2002:a05:620a:410e:b0:6bc:5cdc:88ec with SMTP id j14-20020a05620a410e00b006bc5cdc88ecmr33187504qko.734.1662391338268; Mon, 05 Sep 2022 08:22:18 -0700 (PDT) MIME-Version: 1.0 References: <20220903-gpiod_get_from_of_node-remove-v1-0-b29adfb27a6c@gmail.com> <20220903-gpiod_get_from_of_node-remove-v1-10-b29adfb27a6c@gmail.com> <75e60144-9fa2-d6ba-bc92-edd23f7e7189@roeck-us.net> In-Reply-To: <75e60144-9fa2-d6ba-bc92-edd23f7e7189@roeck-us.net> From: Andy Shevchenko Date: Mon, 5 Sep 2022 18:21:42 +0300 Message-ID: Subject: Re: [PATCH v1 10/11] watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get() To: Guenter Roeck Cc: Dmitry Torokhov , Thierry Reding , Mark Brown , Matti Vaittinen , Lorenzo Pieralisi , Claudiu Beznea , Liam Girdwood , Wim Van Sebroeck , Greg Kroah-Hartman , Miquel Raynal , Linus Walleij , Felipe Balbi , Alexandre Belloni , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Vignesh Raghavendra , Daniel Vetter , Thomas Petazzoni , Alexandre Torgue , Marc Zyngier , Richard Weinberger , David Airlie , Nicolas Ferre , Alyssa Rosenzweig , Bartosz Golaszewski , Jonathan Hunter , Rob Herring , Maxime Coquelin , Bjorn Helgaas , =?UTF-8?Q?Pali_Roh=C3=A1r?= , LINUXWATCHDOG , USB , "open list:GPIO SUBSYSTEM" , linux-pci , linux-tegra , "open list:MEMORY TECHNOLOGY..." , Linux Kernel Mailing List , dri-devel , linux-stm32@st-md-mailman.stormreply.com, linux-arm Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 5, 2022 at 6:13 PM Guenter Roeck wrote: > On 9/5/22 04:09, Andy Shevchenko wrote: > > On Mon, Sep 5, 2022 at 9:33 AM Dmitry Torokhov > > wrote: ... > >> + count = device_property_count_u32(dev->parent, "rohm,hw-timeout-ms"); > >> + if (count < 0 && count != -EINVAL) > >> + return count; > >> + > >> + if (count > 0) { > > > >> + if (count > ARRAY_SIZE(hw_margin)) > >> + return -EINVAL; > > > > Why double check? You may move it out of the (count > 0). > > Two checks will always be needed, so I don't entirely see > how that would be better. But not nested. That's my point: if (count > ARRAY_SIZE()) return ... if (count > 0) ... > >> - if (ret == 1) > >> - hw_margin_max = hw_margin[0]; > > > >> + ret = device_property_read_u32_array(dev->parent, > >> + "rohm,hw-timeout-ms", > >> + hw_margin, count); > >> + if (ret < 0) > >> + return ret; > > > > So, only this needs the count > 0 check since below already has it implicitly. > > > Sorry, I don't understand this comment. if (count > 0) { ret = device_property_read_u32_array(...); ... } if (count == 1) ... if (count == 2) ... But here it might be better to have the nested conditionals. > >> - if (ret == 2) { > >> - hw_margin_max = hw_margin[1]; > >> - hw_margin_min = hw_margin[0]; > >> + if (count == 1) > >> + hw_margin_max = hw_margin[0]; > >> + > >> + if (count == 2) { > >> + hw_margin_max = hw_margin[1]; > >> + hw_margin_min = hw_margin[0]; > >> + } > >> } -- With Best Regards, Andy Shevchenko