From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3DD0ECAAD5 for ; Mon, 5 Sep 2022 17:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:To:Subject:MIME-Version: Date:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GWGGTSd0YjxKw3NC5uQJq1jR+Fb8ua55jbUJt1cSDDY=; b=kxKhNtYpUz1k9GQF2x4HaP/QOJ VvJjVt6RKulvuB9ibeFW/X2I2xcW/gnHYq3JWPs2Abz3/28uluM+haHm6CVTMlRAtkddVuT2dL8q7 tqPq7C1FeoTj8cNSJ0eelrGqjHox3aIxoKMM2OMQ8suUNG609cl7JubJXBJG9xpwJG4fXuLbJcElm rWAIp+p1oUsV9xqmrNMINIDD+vGleZE96aRf5Xfefa7LfTwzfNAqYYqc9KrrBB3URCUvA1IbLFjBA p2OjCkK2G+IqAkmvvieQkL5XOz6FDs4nUao5Ot//wY/AOX8RGjjPrsmpzXevHdXbL6ofTq4+MnIY5 ffja9+cg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVFqi-007WGo-T4; Mon, 05 Sep 2022 17:25:30 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVDnV-005jlP-9E; Mon, 05 Sep 2022 15:14:03 +0000 Received: by mail-pl1-x633.google.com with SMTP id 9so5552287plj.11; Mon, 05 Sep 2022 08:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date; bh=BaV7TSh2pF8riJo3FYVJlB4Fd0IV89ZBF58eyTHpzCY=; b=hkkpU5LscmWAGSEo3MfEtadx9VW4xDHJEup50A1r2cVLlq4cuETMEDvzQMWJ+25cub uKJeKBqoA/7oOn5M03KfF2SrWzMp8y/6jxlU6IOGtXhf5NBV25gS8epBm0aJ0S2QGuaI RjUYEWJv07AS8q77FSCkemAnzO0cF5SSPIB8vUM+JQ9+01vDbgKIvCwDLFJ0pxGW/o9D wfMCMCN77OXaTjmH8xcwvQmxfsPP25DPJzASvB1sg54cKUVgwF0SrI+mVebrCUQXQcEH UD6AosLEX29RH6M8jzXceVG7LBfIA3BiQKPCSDkkI0IwATFYFoPoughaGzGm0KCEERIH sz6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date; bh=BaV7TSh2pF8riJo3FYVJlB4Fd0IV89ZBF58eyTHpzCY=; b=6jQcMaXjSA1QAelYr+o2/sP9iCyj0PRUIBdmNfOr/KFG0HmUaLEfajKRqxEdO82dk8 +5vxw5ey/hgTmiyrzaDM8M/kyI1a2NEYbTdvYybDAe5q8qbvTAFLALnUaBZGPFHuG0/M JqHeL84bR3XIml1C5yEethFOSEbAbjiddAFLjq7HrRwQUQE/8JdHT7bwlRJygtPDnlSB GNyyXauzjucwKazX/pgeM53gOC0tls11TJJrp1vWY3rchnRWd7dkyg+haRJIZUbIfy0i toWqQqIfW/Xydb5YG67De3LR0JE3Pbk0Zv4nl0Z+nXC+04GbdQN90dr0IHzQe84p3eiP 5DFw== X-Gm-Message-State: ACgBeo0kEdp2dJ43M3x9BX9tHRAipxvgHZk7Hb3X2PpLkcnbGamRGpY5 QD9AWpv8Vs3+kIIgw30AUMw= X-Google-Smtp-Source: AA6agR759HBK1+PQYcZT7IJSAKYI4KNMvzd+GSuzCkEXpLGsOPIUySqoQ8VGjyqne3MH/nAfFroOyA== X-Received: by 2002:a17:90b:164f:b0:1f5:4ced:ed81 with SMTP id il15-20020a17090b164f00b001f54ceded81mr19722762pjb.122.1662390835165; Mon, 05 Sep 2022 08:13:55 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id u15-20020a170903124f00b00176ba091cd3sm1684281plh.196.2022.09.05.08.13.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Sep 2022 08:13:48 -0700 (PDT) Message-ID: <75e60144-9fa2-d6ba-bc92-edd23f7e7189@roeck-us.net> Date: Mon, 5 Sep 2022 08:13:39 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v1 10/11] watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get() Content-Language: en-US To: Andy Shevchenko , Dmitry Torokhov 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> From: Guenter Roeck In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220905_081401_599216_71ED62B0 X-CRM114-Status: GOOD ( 24.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Alexandre Belloni , Vignesh Raghavendra , David Airlie , linux-pci , Linus Walleij , Alexandre Torgue , dri-devel , Liam Girdwood , linux-tegra , Thierry Reding , "open list:MEMORY TECHNOLOGY..." , Thomas Petazzoni , Miquel Raynal , linux-stm32@st-md-mailman.stormreply.com, Alyssa Rosenzweig , LINUXWATCHDOG , Rob Herring , Marc Zyngier , Bartosz Golaszewski , Jonathan Hunter , Lorenzo Pieralisi , Maxime Coquelin , Matti Vaittinen , "open list:GPIO SUBSYSTEM" , Mark Brown , Bjorn Helgaas , Wim Van Sebroeck , linux-arm Mailing List , Felipe Balbi , Greg Kroah-Hartman , USB , Linux Kernel Mailing List , Daniel Vetter , Richard Weinberger , =?UTF-8?Q?Pali_Roh=c3=a1r?= , Claudiu Beznea Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 9/5/22 04:09, Andy Shevchenko wrote: > On Mon, Sep 5, 2022 at 9:33 AM Dmitry Torokhov > wrote: >> >> I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() >> so that gpiolib can be cleaned a bit, so let's switch to the generic >> fwnode property API. >> >> While at it switch the rest of the calls to read properties in > > it, switch > >> bd9576_wdt_probe() to the generic device property API as well. > > ... > >> struct device *dev = &pdev->dev; > > struct device *parent = dev->parent; > > can make your code slightly neater. > > ... > >> + 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. > ... > >> - 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. Guenter >> - 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]; >> + } >> } > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel