From patchwork Sun Dec 2 13:03:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152660 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5726538ljp; Sun, 2 Dec 2018 05:05:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wgp2mEaVGNJ9+kbUCYu5bfi0ACalU6735HhqUvOU7H4QFt/HTsrMu9sEqfg4J/KMI8Jzz1 X-Received: by 2002:a63:561b:: with SMTP id k27mr10236570pgb.271.1543755956339; Sun, 02 Dec 2018 05:05:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543755956; cv=none; d=google.com; s=arc-20160816; b=1DlY8enYEKVqnAKdcX+TdM+WQY2fmKgDfX6kd/qY/7n3Ou7ZMWE9PDAjr1YUcPuuT1 ZGpTCwV5XpuKusanXkcilHtZkYW9EBNoV/6rl21rGUznj7oUZO6ZinHHoDtoylrGOci3 w1KoezAnhgMoDIrPbbCn78IDUjWhss25991+l5SS9CxyPp1ESU276zNpB3/l+F2X+2KK +cvgRwqJk1+USzheQezLWSsiwav3TeF+tBNiAwgMkbmTTvCdw6Boa92qrKEEL5hoHnO2 FB0nk8rTceNzhbddFP+6iHfpBochltvuosWOqITypTWwimDcSlOZ3B1JjtYd1yNnF+QQ UFYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=OJb2pYg+EPZTaEulA89RH4d8Q2e8WDePiPKU8MRmjcM=; b=bX0+zggxLJGnhXNwODDeVBQEIR0ivF2nsoK/dNFY3my3ByVBbj1eaqam7ZMFAcEwcw 6t7C+LwmPXthQbfV9k64MB4L9TVP5Y+E8Fl6uT2v40QsAFR5frd1Kko7T4y903YxFmzS r+k6mNOgHSEo8YBJcGuVMe3otlqAhayMBeGS13rHm++diPXY472yJ6ZRUw/eFcd/XArR zHQ2btKV5fQEoyohChT1shDAM61z5aIG0xSmgiar6knxRtZRfcK3gd52iaaQXljRf5bm xuHB6yTw5LxLh0jXXtYUrkZAgnpl8EoOLJV2JtBUDEP7mACqNmd3Vbx3qPFjuixJ/s5k Hp2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gUUJsuYx; spf=pass (google.com: best guess record for domain of linux-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h19si10102465pgb.231.2018.12.02.05.05.56 for ; Sun, 02 Dec 2018 05:05:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gUUJsuYx; spf=pass (google.com: best guess record for domain of linux-watchdog-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725844AbeLBNF7 (ORCPT ); Sun, 2 Dec 2018 08:05:59 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:41170 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725843AbeLBNF7 (ORCPT ); Sun, 2 Dec 2018 08:05:59 -0500 Received: by mail-lj1-f196.google.com with SMTP id z80-v6so8849984ljb.8 for ; Sun, 02 Dec 2018 05:05:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OJb2pYg+EPZTaEulA89RH4d8Q2e8WDePiPKU8MRmjcM=; b=gUUJsuYxN/yN2qtnJz9fZiR0YNG0uwD7B+CRyK4zdyx4PUDkikvUmV51V+p4F6Ad5N OWJqswSKXdsZd2h0cBgQUd1B0hV+43+K1BXGuDnNLPjHrNdvUmNrKHkm1DsrAzqEU+sn Emn7Kiqn2cRvbf0k/1qu7g7CFMlpSnmmPUidY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OJb2pYg+EPZTaEulA89RH4d8Q2e8WDePiPKU8MRmjcM=; b=iKH5WGI+19khG7NGTzucVssJNNlFFvSDfm5QQGfSY57DTYFctUXbZaJYIO39fQcvth FY+u/RXsD951PKokQhinLNGBwRv2KolWevycbJltGSmUxlYfvWPL7cUG/5iOSFAddQrH 6draJWQiQK0jRgr/yXInyT4SBGpEBZ4fLYWrA2j4RLitWK2zvIRiS7sNiIjLxaYIoS2T TbT2zYh7q0pz9q0OEV86TCpJFFGEvrDEVWskVgNNdD+fDfSJCcfrdjqzYD/tghxMOx9b JeQagorL34VgtdpHU+sKMz/Rmk7Yi1Nfl+GcVPKZNanH+AeKOH2+7k3IlwcFnPoLHPRC Y/Ng== X-Gm-Message-State: AA+aEWa0gLu0WYgqkWZVMTpzd8C1M7wNHWxtepfcY/Hx1PqHyT6RAof/ JrpFiJ1wj0YRKhC1eDq95MrNsw== X-Received: by 2002:a2e:7c13:: with SMTP id x19-v6mr7861560ljc.83.1543755953554; Sun, 02 Dec 2018 05:05:53 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id d15-v6sm1885289lja.38.2018.12.02.05.05.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Dec 2018 05:05:52 -0800 (PST) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck Cc: linux-watchdog@vger.kernel.org, Linus Walleij , Florian Fainelli Subject: [PATCH] watchdog: mtx-1: Convert to use GPIO descriptor Date: Sun, 2 Dec 2018 14:03:49 +0100 Message-Id: <20181202130349.30464-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org This converts the MTX-1 driver to grab a GPIO descriptor associated with the device instead of using a resource with a global GPIO number. The board using this driver appears to be out-of-tree (OpenWRT), but the users can be easily augmented by adding a machine descriptor table before registering the device. Cc: Florian Fainelli Signed-off-by: Linus Walleij --- drivers/watchdog/mtx-1_wdt.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) -- 2.19.1 diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c index 1fa7d2b32494..522a2b98ec16 100644 --- a/drivers/watchdog/mtx-1_wdt.c +++ b/drivers/watchdog/mtx-1_wdt.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include @@ -55,7 +55,7 @@ static struct { int queue; int default_ticks; unsigned long inuse; - unsigned gpio; + struct gpio_desc *gpiod; unsigned int gstate; } mtx1_wdt_device; @@ -67,7 +67,7 @@ static void mtx1_wdt_trigger(struct timer_list *unused) /* toggle wdt gpio */ mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate; - gpio_set_value(mtx1_wdt_device.gpio, mtx1_wdt_device.gstate); + gpiod_set_value(mtx1_wdt_device.gpiod, mtx1_wdt_device.gstate); if (mtx1_wdt_device.queue && ticks) mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); @@ -90,7 +90,7 @@ static void mtx1_wdt_start(void) if (!mtx1_wdt_device.queue) { mtx1_wdt_device.queue = 1; mtx1_wdt_device.gstate = 1; - gpio_set_value(mtx1_wdt_device.gpio, 1); + gpiod_set_value(mtx1_wdt_device.gpio, 1); mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); } mtx1_wdt_device.running++; @@ -105,7 +105,7 @@ static int mtx1_wdt_stop(void) if (mtx1_wdt_device.queue) { mtx1_wdt_device.queue = 0; mtx1_wdt_device.gstate = 0; - gpio_set_value(mtx1_wdt_device.gpio, 0); + gpiod_set_value(mtx1_wdt_device.gpio, 0); } ticks = mtx1_wdt_device.default_ticks; spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags); @@ -198,12 +198,11 @@ static int mtx1_wdt_probe(struct platform_device *pdev) { int ret; - mtx1_wdt_device.gpio = pdev->resource[0].start; - ret = devm_gpio_request_one(&pdev->dev, mtx1_wdt_device.gpio, - GPIOF_OUT_INIT_HIGH, "mtx1-wdt"); - if (ret < 0) { + mtx1_wdt_device.gpiod = devm_gpiod_get(&pdev->dev, + NULL, GPIOD_OUT_HIGH); + if (IS_ERR(mtx1_wdt_device.gpiod)) { dev_err(&pdev->dev, "failed to request gpio"); - return ret; + return PTR_ERR(mtx1_wdt_device.gpiod); } spin_lock_init(&mtx1_wdt_device.lock);