From patchwork Tue Mar 22 22:29:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12789330 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 E322EC433EF for ; Tue, 22 Mar 2022 22:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235088AbiCVWbe (ORCPT ); Tue, 22 Mar 2022 18:31:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238017AbiCVWbe (ORCPT ); Tue, 22 Mar 2022 18:31:34 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4726448E49 for ; Tue, 22 Mar 2022 15:30:05 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id d5so12992482lfj.9 for ; Tue, 22 Mar 2022 15:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version:organization :content-transfer-encoding; bh=WDZwzOksGqQgVAFZZ36dR9dDLRM2t7nrAA8OpwXT/x4=; b=RLQuDw/EePVKm588I3/ZlKZQf7XopBpfj3Bfft0yBiFLv0+Dl7zgi+2RD2lGYp+uIz OGujiiZFZuWt9N2sGbaU9kBLDL9d6GEhQv8bpHcn6ErHVZ57P6bT7A81z9XIBu0zhO/I XZ1WmLK/cfqQoHtcpRdKOUs0KykMq+6M1qB546KMmE4EXOwCRTCEZ9Lm1KCNK2Ef9p1n L9X8Lu/l71aQZFyMkvCijSAND+784147B8dT/6q4lGFG3C03axDVhQo7iF8B35kGBeOo IB4+oLwX8HTMINtiX4bGNY+0F/oVJ6Rq+u3WjecCAmyLIziRT2DgNGCCIeR2ONFlrEmg BYFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :organization:content-transfer-encoding; bh=WDZwzOksGqQgVAFZZ36dR9dDLRM2t7nrAA8OpwXT/x4=; b=I7/gu53j18PKkKaVf0T8QvH5Izi3S06EhGNgR2/rjT8E+4DptrVPLvuG5f+6KUiJ+r BtCW9Yz8lmPI3H/zcu+bivHMRp2U8R2NUsTmjmrwRn9+mmkz5HvKC3et7i4mS6UwhOrD 3d1CvUFikMmH8Zt220T9XSkTMqjlviNeBTZRQ1v0gfjAAJPytye9LiKVt2Fb2ddR7pSE uaHlwgT51EolryEDb5a495SQeqUDIWvpzeh1l4NE6j8tcEr6wvtjQgEh0sJVorMfAHUL gXCodmRUTnUVKG24TCdynxlIybzlZdAe98X4d1bw2c4b+CplrYSae/bUJ0JZvqGpmiW+ GfIA== X-Gm-Message-State: AOAM530CBbYCWJAW4hVKlsNt7yxPeL8EBH6Ko9Pqm1t+m5Ro8nI48jzw 7KEUR/Iym/yxrRXQjkV11HtXw+MObO66Pg== X-Google-Smtp-Source: ABdhPJxK6lqc4QDK3tUQ7+6y03+fLRl5ZCEGr5mNG56Ty4ZkHYr14RFvjNOP9aSVXw4yyaGVmRvEIQ== X-Received: by 2002:ac2:5feb:0:b0:448:2707:6bfd with SMTP id s11-20020ac25feb000000b0044827076bfdmr20426934lfg.380.1647988203557; Tue, 22 Mar 2022 15:30:03 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id g10-20020a19ac0a000000b00441e497867fsm2321462lfc.93.2022.03.22.15.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 15:30:03 -0700 (PDT) From: Tobias Waldekranz To: Wim Van Sebroeck , Guenter Roeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] watchdog: gpio_wdt: Support GPO lines with the toggle algorithm Date: Tue, 22 Mar 2022 23:29:11 +0100 Message-Id: <20220322222911.519238-1-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Support using GPO lines (i.e. GPIOs that are output-only) with gpio_wdt using the "toggle" algorithm. Since its inception, gpio_wdt has configured its GPIO line as an input when using the "toggle" algorithm, even though it is used as an output when kicking. This needlessly barred hardware with output-only pins from using the driver. Signed-off-by: Tobias Waldekranz --- Hi, This patch has been in our downstream tree for a long time. We need it because our kick GPIO can't be used as an input. What I really can't figure out is why the driver would request the pin as in input, when it's always going to end up being used as an output anyway. So I thought I'd send it upstream in the hopes of either getting it merged, or an explanation as to why it is needed. drivers/watchdog/gpio_wdt.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c index 0923201ce874..f7686688e0e2 100644 --- a/drivers/watchdog/gpio_wdt.c +++ b/drivers/watchdog/gpio_wdt.c @@ -108,7 +108,6 @@ static int gpio_wdt_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct gpio_wdt_priv *priv; - enum gpiod_flags gflags; unsigned int hw_margin; const char *algo; int ret; @@ -122,17 +121,15 @@ static int gpio_wdt_probe(struct platform_device *pdev) ret = of_property_read_string(np, "hw_algo", &algo); if (ret) return ret; - if (!strcmp(algo, "toggle")) { + + if (!strcmp(algo, "toggle")) priv->hw_algo = HW_ALGO_TOGGLE; - gflags = GPIOD_IN; - } else if (!strcmp(algo, "level")) { + else if (!strcmp(algo, "level")) priv->hw_algo = HW_ALGO_LEVEL; - gflags = GPIOD_OUT_LOW; - } else { + else return -EINVAL; - } - priv->gpiod = devm_gpiod_get(dev, NULL, gflags); + priv->gpiod = devm_gpiod_get(dev, NULL, GPIOD_OUT_LOW); if (IS_ERR(priv->gpiod)) return PTR_ERR(priv->gpiod);