Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2359472imu; Thu, 17 Jan 2019 12:47:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN6qhsrD0QUNRYsBew8e3H2wxNYpXJXgfcmJpZu55raVAN4TwrU0Ro9y8cmFYcM6eIFXssfp X-Received: by 2002:a63:f34b:: with SMTP id t11mr14805385pgj.341.1547758022137; Thu, 17 Jan 2019 12:47:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547758022; cv=none; d=google.com; s=arc-20160816; b=h5g+uZNfFlu1R1WAbEV0USUynPS/1dR6gTn3dl98KiD9bIAobsTZ9ASMWpN0rnoaxw 6WRm2GA4Sslvp7wAofIWNZ+99ZQXX8aw8MiPv5YkDsCfBiyyOEx+IqJK4q//Tfp0ZeRG vfo2F9tfCgl4zf8OGuHc8f3u7+YVQ1yt8BpCxmzy+XHL0K9jSHDkBRR/ydOfeBr1x1ra Sbndx0wQLt8HHRHMDfHSv4sIVjmYEa/qj7w/WMrlFGIG773Qg4ImxXQaGZ2lutbDMBBc 6WRZqrJo/1hrREJEQBTWZpgb4NYEcbO6g2ZVKN1bWRKDN0RYFu+aaVLESZhrA1nCJ1x2 fpIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qe7NUhaOauVMHMbVmvcb9y61t5wbJ0dPWB9PLPVTivk=; b=PuiK2lrhbMDohcpHknEG8v1gwzIGAjMsT/usbT/f5ei4ON6VbIBfAHsYE25Gg2OD0n 9mA4W6OsO7X5WfvtNnhhrsFMFfrJBHWd42b4EyLnSpD1AaXCd6hXJHRWLCfd/DAVd6F2 pW4LreLkhZtSJ03Jf4CS7ygY0vzZt6/63Y/5eQdpn0JExXkWN9dsX+mgk7dt8R9gsk8O OwQ9Ogia/+oXYvJz8RPaITj3oRtqaTJ0ZJw67PNEkNQBXnHUaIVIpdoccuvb/Pl8QfNI UroVf6+k9L12DS/KkjsgTgsvvjSyXfkaOnxLfGPJgEXx3m2Bfh3WRbI5HpCOK7TpwdzT bSJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UK4FSuyw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si2443584plt.44.2019.01.17.12.46.42; Thu, 17 Jan 2019 12:47:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@google.com header.s=20161025 header.b=UK4FSuyw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728423AbfAQTJp (ORCPT + 99 others); Thu, 17 Jan 2019 14:09:45 -0500 Received: from mail-yb1-f194.google.com ([209.85.219.194]:35526 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728347AbfAQTJp (ORCPT ); Thu, 17 Jan 2019 14:09:45 -0500 Received: by mail-yb1-f194.google.com with SMTP id h81so3119049ybg.2 for ; Thu, 17 Jan 2019 11:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qe7NUhaOauVMHMbVmvcb9y61t5wbJ0dPWB9PLPVTivk=; b=UK4FSuywOA+U0Swg9Voygjxj28BHGHk/5iFcLo3SkApIegWZaXrpAT+73yUEbAQxY/ fon1c6ftGSi9sS0xVvgLRwMoD6rEkpuMTE+RIMQ/Nr8ouBIodb1VSiV8PJzvDKmZbCiP 5dffp0I4TZ2BOM50VIabdYfcI5LJR8HHRShnTkk0e8KRX6L41BghlD/s4NFH13yCuo7z RGaM5V2w0ie7f07OykvIgt2MA7QJcfGRTaMZ3PQWrIEfyNpBEmHIok+dbcSMgYRzPnoZ 4JPTFUM+bFpAZEp9ENaxDD+uJBsEcCqtqzU1R1Kt+2VfxZS7WFUHtSBt2mzdwodaIY1z jCng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qe7NUhaOauVMHMbVmvcb9y61t5wbJ0dPWB9PLPVTivk=; b=T+RRnda/5osOBhiamShsx0Oe4LQImNI6XZ04GYA5irOV+3OjO1YO3m/HeMrWhIfWA+ hBPTDbG+hCxWbN3P9AAtkitf/HwKjKxNOMD/BNMSkLVeLvKjBCIBlQbvHsTQa/tlU4Y+ y4r35/KBT4k2cO3Evc+eYRgiDjiz0EiEIUA9Bwu7Me70kBh9ecpjRCf9ilTusk2J0FBr llzqACC/KMkDjUvBMz+KNSIQJWE1tWPKs1F+2Y5pM+dnNDd+DfbFZQXR0xq9n4R8vsi1 JJuTHpRTcmy2/DjqwXxU0g+mtMV99y2J3FiDxNeFrlcex3y8GKeXcu1Ah0fIZFJVWeK8 29nQ== X-Gm-Message-State: AJcUukcadqnXCceyzTn6BQMDQMkQyg9DA+HxZ89Rtkj5dxWFDF04p6Uc c0NxYAPZnZfCHYfDchcjthp43oaweaMl39TdvDCcDA== X-Received: by 2002:a25:8685:: with SMTP id z5mr3246200ybk.247.1547752183617; Thu, 17 Jan 2019 11:09:43 -0800 (PST) MIME-Version: 1.0 References: <20190117151942.6092-1-saiprakash.ranjan@codeaurora.org> <154775022743.169631.1716489383315213219@swboyd.mtv.corp.google.com> In-Reply-To: <154775022743.169631.1716489383315213219@swboyd.mtv.corp.google.com> From: Guenter Roeck Date: Thu, 17 Jan 2019 11:09:31 -0800 Message-ID: Subject: Re: [PATCHv2] watchdog: qcom: Add suspend/resume support To: Stephen Boyd Cc: Guenter Roeck , Guenter Roeck , Sai Prakash Ranjan , Wim Van Sebroeck , linux-watchdog@vger.kernel.org, Rajendra Nayak , Vivek Gautam , Sibi Sankar , Doug Anderson , linux-arm-kernel@lists.infradead.org, linux-kernel , linux-arm-msm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 17, 2019 at 10:37 AM Stephen Boyd wrote: > > Quoting Sai Prakash Ranjan (2019-01-17 07:19:42) > > diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c > > index 780971318810..5dfd604477a4 100644 > > --- a/drivers/watchdog/qcom-wdt.c > > +++ b/drivers/watchdog/qcom-wdt.c > > @@ -245,6 +245,28 @@ static int qcom_wdt_remove(struct platform_device *pdev) > > return 0; > > } > > > > +static int __maybe_unused qcom_wdt_suspend(struct device *dev) > > +{ > > + struct qcom_wdt *wdt = dev_get_drvdata(dev); > > + > > + if (watchdog_active(&wdt->wdd)) > > + qcom_wdt_stop(&wdt->wdd); > > + > > + return 0; > > +} > > + > > +static int __maybe_unused qcom_wdt_resume(struct device *dev) > > +{ > > + struct qcom_wdt *wdt = dev_get_drvdata(dev); > > + > > + if (watchdog_active(&wdt->wdd)) > > + qcom_wdt_start(&wdt->wdd); > > + > > + return 0; > > +} > > This looks fairly generic. For example, the Mediatek driver also stops > and starts (but also pings after starting). Grepping for 'active' in > drivers/watchdog/ finds more examples. Could there be some functions in > watchdog core that do the common things like watchdog_stop() and > watchdog_start() and watchdog_start_and_ping()? Or maybe a bit can be > set during registration so that the 'struct class watchdog_class' can > get PM ops to stop and start on suspend/resume of the watchdog character > device? > > Nothing is wrong with the patch, I'm just bemoaning the amount of code > duplication here. > Patch(es) to add the functionality to the watchdog core are welcome; it should be possible to move the functionality into the core (maybe to be enabled with a new watchdog API call). Doing it using the class device sounds like an excellent idea. This should be straightforward to implement, though the question of "should we ping on resume or not" might be an endless source for bike shedding fun. Guenter