From patchwork Sat Jan 5 01:09:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 154812 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1190792ljp; Fri, 4 Jan 2019 17:11:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Ea7knX1v/y55DNNA/f4n030ldJQj621aQbW5H/9LQmWci0NtrlqzixzghmoGMnR4R4s3q X-Received: by 2002:a17:902:9a04:: with SMTP id v4mr53611406plp.34.1546650678791; Fri, 04 Jan 2019 17:11:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546650678; cv=none; d=google.com; s=arc-20160816; b=0w+HssPKGttVs7W4o0TmvB5ASmU/Wlm7wCHKI2lNzdPpn10oD0G+YZ6kRQYZ2iyzyE uO+phu1s3omnVkaxK5TCUTrG2WVcSp/wyPP2zMFCuxyJbMCOl/r/L4SJ+P03iEG0PnXA yFOw9/E6epDJeAaVpSH4j7A5yo5yE9NXyGCHWVyO4ysd49UXf6Ttmq0Rj3eKrxwlm+IU vuojPQ8IgPZipnbTs+hk0Oi/1OvMc8ckZ+5uLkARH31ipDl7PpKJVCs6+DU7V1XB86yr uJDjtbi8tACjjV2BeoMxIDEb/e+4+FmxtgR9CePIr0FG5SFDZ6boyNdOfiypl5LIDoTj cKZQ== 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=FRhuQE1jrZ/KxZQU0NrmODSbsXVqSL3bpErcmoZcIEg=; b=W/s7y4inT7bLlPecSturUgGL4L05tv1OooNBd8u1+LgyrsO7NOy16ZzExYhnJTFmkZ vu1aozEccM95x+H/c8fAsovOPtqb7n0nqnjnQa5v0tJNkAXPtCzEoaewPMauQgWdSkkI Cm4IXANqcT4bbg/FEYlF6u/kCmfHYgx4LycUn+Qs5Sg2Ry5G87Du63k2M43wsU1uO5yn bajk+3ftFs+Ry3g/YJI7n0nE5UhEeZ8ckl8F2PEtweV9wCuQtQ169zomCrv4xMyPIkRx G0kIxUHRxA+KeE3WuZSVsJLT0UUzSOyXGLQsBAZybHWhn2TvxbRVpdP2ZwV5QFv58Eiw TBlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XzROmLVP; 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 y12si35654211plk.174.2019.01.04.17.11.18 for ; Fri, 04 Jan 2019 17:11:18 -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=XzROmLVP; 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 S1726229AbfAEBLR (ORCPT ); Fri, 4 Jan 2019 20:11:17 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38967 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726170AbfAEBLR (ORCPT ); Fri, 4 Jan 2019 20:11:17 -0500 Received: by mail-lj1-f193.google.com with SMTP id t9-v6so33837898ljh.6 for ; Fri, 04 Jan 2019 17:11:15 -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=FRhuQE1jrZ/KxZQU0NrmODSbsXVqSL3bpErcmoZcIEg=; b=XzROmLVPlYKqUQhH+czUDUvuUuK6V2GQPUGp2TNeOwHovVJmEoDrlub6awtFUzSvMC prfM2aGFabd72FX1Mi3tKBYEI0iHGj333g1yrfNTiQeqJH2ksVDz4GQMur7rVQLFjZuZ I1iYnr6EoW6U2bY3S2wZlDHDuMsoLW6YDtjqo= 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=FRhuQE1jrZ/KxZQU0NrmODSbsXVqSL3bpErcmoZcIEg=; b=jTBvYogJ+QK6VIYM+O+T0N9bf+kjCMu0D7UcWTZwUBaHh0RiejGhRq8HzrcNRkZlWK wYULkJu0ATa+ebRKy1XfIpRN/l/7VUCBHpLDVp0ayJLZR7t2hT6JSl1sNQzp0wfyJFPG 9OatdpcGArqE0Ak/n4s5YbNmXLesX6Rk83GgXtCeEnu7fcXbRI7DticU77w3ArDb/VG/ oVaEVmgYeazPTAvTM8UEOqCR0pIkIYaeicyxQR27e+sV3sQpdCqtNG7sB54rXyRMtyAY 4w0E0QOBZb64BEpIH3gWu4brqUrW+B5Qqc50OelwnczhXC44XHQioNH50sZpb0YgnmoY pvGw== X-Gm-Message-State: AJcUukfI5kDsKfjFIyRqLa9m6FL4YF8E4ggiSPAWjR23nZKthEy80xRP 9PiEjRWXkJVbWAAYp2S3AG2L5eiKTDtYbLVv X-Received: by 2002:a2e:87c3:: with SMTP id v3-v6mr33018367ljj.13.1546650674975; Fri, 04 Jan 2019 17:11:14 -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 l21-v6sm12666569ljj.48.2019.01.04.17.11.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Jan 2019 17:11:13 -0800 (PST) From: Linus Walleij To: Wim Van Sebroeck , Guenter Roeck Cc: linux-watchdog@vger.kernel.org, Linus Walleij , Richard Fitzgerald , Charles Keepax , Mark Brown Subject: [PATCH] watchdog: wm831x: Use GPIO descriptor Date: Sat, 5 Jan 2019 02:09:08 +0100 Message-Id: <20190105010908.26623-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The WM831x watchdog driver passes a global GPIO number from platform data into this driver, this is discouraged so pass a GPIO descriptor instead. More thorough approaches are possible passing descriptors associated with the device through machine descriptor tables, but no boardfiles in the kernel currently use this driver so it is hard to test. Cc: Richard Fitzgerald Cc: Charles Keepax Cc: Mark Brown Signed-off-by: Linus Walleij --- drivers/watchdog/wm831x_wdt.c | 23 ++++++----------------- include/linux/mfd/wm831x/pdata.h | 3 ++- 2 files changed, 8 insertions(+), 18 deletions(-) -- 2.19.2 diff --git a/drivers/watchdog/wm831x_wdt.c b/drivers/watchdog/wm831x_wdt.c index 116c2f47b463..998a39f83c48 100644 --- a/drivers/watchdog/wm831x_wdt.c +++ b/drivers/watchdog/wm831x_wdt.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -29,7 +29,7 @@ struct wm831x_wdt_drvdata { struct watchdog_device wdt; struct wm831x *wm831x; struct mutex lock; - int update_gpio; + struct gpio_desc *update_gpiod; int update_state; }; @@ -103,8 +103,8 @@ static int wm831x_wdt_ping(struct watchdog_device *wdt_dev) mutex_lock(&driver_data->lock); - if (driver_data->update_gpio) { - gpio_set_value_cansleep(driver_data->update_gpio, + if (driver_data->update_gpiod) { + gpiod_set_value_cansleep(driver_data->update_gpiod, driver_data->update_state); driver_data->update_state = !driver_data->update_state; ret = 0; @@ -239,19 +239,8 @@ static int wm831x_wdt_probe(struct platform_device *pdev) reg |= pdata->secondary << WM831X_WDOG_SECACT_SHIFT; reg |= pdata->software << WM831X_WDOG_RST_SRC_SHIFT; - if (pdata->update_gpio) { - ret = devm_gpio_request_one(&pdev->dev, - pdata->update_gpio, - GPIOF_OUT_INIT_LOW, - "Watchdog update"); - if (ret < 0) { - dev_err(wm831x->dev, - "Failed to request update GPIO: %d\n", - ret); - return ret; - } - - driver_data->update_gpio = pdata->update_gpio; + if (pdata->update_gpiod) { + driver_data->update_gpiod = pdata->update_gpiod; /* Make sure the watchdog takes hardware updates */ reg |= WM831X_WDOG_RST_SRC; diff --git a/include/linux/mfd/wm831x/pdata.h b/include/linux/mfd/wm831x/pdata.h index dcc9631b3052..ea7e9ad10a14 100644 --- a/include/linux/mfd/wm831x/pdata.h +++ b/include/linux/mfd/wm831x/pdata.h @@ -15,6 +15,7 @@ #ifndef __MFD_WM831X_PDATA_H__ #define __MFD_WM831X_PDATA_H__ +struct gpio_desc; struct wm831x; struct regulator_init_data; @@ -95,7 +96,7 @@ enum wm831x_watchdog_action { struct wm831x_watchdog_pdata { enum wm831x_watchdog_action primary, secondary; - int update_gpio; + struct gpio_desc *update_gpiod; unsigned int software:1; };