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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74A54C433FE for ; Tue, 3 May 2022 03:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229603AbiECEBc (ORCPT ); Tue, 3 May 2022 00:01:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbiECEBb (ORCPT ); Tue, 3 May 2022 00:01:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AFE636B77; Mon, 2 May 2022 20:58:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 253EBB81BE4; Tue, 3 May 2022 03:57:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 589D6C385A9; Tue, 3 May 2022 03:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651550277; bh=Cl5mLzkG+TTdpfzZTrXfX/qXJHGfkfoAd8qQBoaXi2o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YcJ69Mxs/0egoH/KoOxPB3yexeKFIvfqicqjGmBmRqA1j0B0WFCNgHAopqYY+yRQy mzbbT/hsRO8kK+0jXsHqc+Golxqn2efytgtN6PsVYY3FodNNrGRhMd3CxxkuPqTqJL m0KcR1SWkduqZlmLQ8yT5r2X93ZuAvjHcdT7XUs6lKdOGMx38ZRrn7K/JLTY4xH/Id asLXU4pqHu6fV5WS2uf/SipLHO6i8LWMomfFKzTGRWpvazPmiZzCsFcOIuWEt1Vop9 DtVgViFpNQ9E9kMYMaHPdzmlvehvI1YqBf4fOAIuXM3aasfbiz0coNItX3TcB+BWWK Cfs51zkdijRGw== Date: Tue, 3 May 2022 11:57:53 +0800 From: Tzung-Bi Shih To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Wim Van Sebroeck , Guenter Roeck , Rob Herring , linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Message-ID: References: <20220429131349.21229-1-pali@kernel.org> <20220429131349.21229-2-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220429131349.21229-2-pali@kernel.org> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Fri, Apr 29, 2022 at 03:13:49PM +0200, Pali Rohár wrote: > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include It would be better to keep them alphabetically. Anyway, they aren't sorted originally... > +static void max63xx_gpio_ping(struct max63xx_wdt *wdt) > +{ > + spin_lock(&wdt->lock); Does it really need to acquire the lock? It looks like the lock is to prevent concurrent accesses to the mmap in max63xx_mmap_ping() and max63xx_mmap_set(). > + gpiod_set_value_cansleep(wdt->gpio_wdi, 1); > + udelay(1); Doesn't it need to include for udelay()? > @@ -225,10 +240,19 @@ static int max63xx_wdt_probe(struct platform_device *pdev) > return -EINVAL; > } > > + wdt->gpio_wdi = devm_gpiod_get(dev, NULL, GPIOD_FLAGS_BIT_DIR_OUT); > + if (IS_ERR(wdt->gpio_wdi) && PTR_ERR(wdt->gpio_wdi) != -ENOENT) Use devm_gpiod_get_optional() to make the intent clear. Also, it gets rid of the check for -ENOENT. > + return dev_err_probe(dev, PTR_ERR(wdt->gpio_wdi), > + "unable to request gpio: %ld\n", > + PTR_ERR(wdt->gpio_wdi)); It doesn't need to again print for PTR_ERR(wdt->gpio_wdi). dev_err_probe() prints the error. > err = max63xx_mmap_init(pdev, wdt); > if (err) > return err; > > + if (!IS_ERR(wdt->gpio_wdi)) > + wdt->ping = max63xx_gpio_ping; Thus, the max63xx_gpio_ping() overrides max63xx_mmap_ping() if the GPIO was provided? It would be better to mention the behavior in the commit message. Also, could both the assignments of `wdt->gpio_wdi` and `wdt->ping` happen after max63xx_mmap_init()?