From patchwork Fri Oct 18 13:58:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 837030 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 902B941C6A for ; Fri, 18 Oct 2024 13:58:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729259912; cv=none; b=o6uFMk4zvy0y2mCnSKGdvJOvMUmMZ9rAq6Y0NXB5x/6AEZrmNYObFAnNA+p1IybmRbj/2Wc8MwoTFvnEf6uG4MwKCjfqbbzimnCzszy0s0nGuxkDNKpxK/RDI5a6+mslIlzE6CbYcw6I2dmBeIApaIlV1rimB2zJJCiaT/PJqhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729259912; c=relaxed/simple; bh=wBLpiz04Ca7AiprvaTVLIOO2ByK1wMfBF+jrOyeSimE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=kpKvV7zDzdu5RpYBTBxYooqqRt/mRbIcU/bhi6GOlO9OugNwTZJrGUeim/U/IhHCoe8KSe7H5RrFJ/l12Z84fJgBcCdjnLyRO65U8OHgqWbieSALFgSpYfcskHo/9ynCuorM0rtw/ZOqa0ceqavdgU4knPPlmL1jvy9WRZNb+nk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bL5KtE1+; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bL5KtE1+" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-71e625b00bcso1624025b3a.3 for ; Fri, 18 Oct 2024 06:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729259910; x=1729864710; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Lvk4D67JdYF7234jET9PdYl3FpeiKeSOpTItXtjBTeM=; b=bL5KtE1+wHLJ4SsYRjztA8YIsu8TRNQbAXAQdcGug11sMGI0i8VP9uKPmBKj1KU86Y 8mF2I+pxktIkZrbJZDtYEY3ZkNkk03BAYlfW4+2XVSSa8Z0QFmF67w/R4PmxpXN9cL1p UElsziBnb25Ry70W3Y3zyYgW8VxjbCw8s2S6t4J2KA1GO09H1gYtDoJdbnXQ/VQ3yLo7 vbTjeZvCnnyAqZsyAd7zeGczlMahnZUXAYVs/tsssAu0cTOT0nmCAGuuVeUhWF51DMka 1xLaCAfvoLlsW2z81Fcd1fNl54BQKanCPKF+iWQk1ZcUNi3bVSJDojhDIojS9raftlW9 Ig2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729259910; x=1729864710; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Lvk4D67JdYF7234jET9PdYl3FpeiKeSOpTItXtjBTeM=; b=hjNwRWhvhEXINFy2TF8UyssCufHgWD3E5DcjI2KVSg5fPYUKlG23E99awlsaVQhWDQ Trom0nKdtgXsyY13cJnNzIPpbo4DODQlqiiMvOioDA+IwQlpzZpm9gwDoR3ywrLQ177C 4SAj/OruLBkWvFNSvmGln6KZSrswVgViJ+G4KQwxOpHemFWlntJ4oF+L0KQx94nHMawP XiDwJsVebTyC+AM5PCxfqHCc1JbmwJ+9yYB2APLNRnvHU6+Y7rqD1XlAMWYKzMCJ6cjf gyMF+sHmAh92C9SS78Gt3c2SMmj7gc3Bo66gHMxrCHNvR4TAMV5ftrDWgrv3fRjkpDHs 6yuQ== X-Forwarded-Encrypted: i=1; AJvYcCUZSh+6XppA7G4/qxGf4ffhQ9bygy5QSherNG1HVqwBhzSQKhgamq1S+wP1Lt3hmdWyPAci6Ne3Z2ZiHyzXlQ==@vger.kernel.org X-Gm-Message-State: AOJu0YxHoN8hTyOoywTrQnSxdnpt/sBxL0UdfjBRe2ikLj59cKj1pWY/ e5hVZNK5rhvOpo0DMn3YxYdPzRl5OWFo29qA6uCnUwHwjp2XWeZcBpuj9A== X-Google-Smtp-Source: AGHT+IEHY0yNud14gDjBKaoqvJwyIfEZ3KCqQodwI4PenjTGlvHeiridY3OlzBSCPQ52T+YwcYaD/g== X-Received: by 2002:a05:6a00:1705:b0:71e:55e2:2c43 with SMTP id d2e1a72fcca58-71ea324c73fmr3163820b3a.14.1729259909618; Fri, 18 Oct 2024 06:58:29 -0700 (PDT) Received: from fabio-Precision-3551.. ([2804:14c:485:4b61:ad3c:ece1:18ac:9bc9]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ea3311f16sm1448482b3a.40.2024.10.18.06.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 06:58:29 -0700 (PDT) From: Fabio Estevam To: wim@linux-watchdog.org Cc: linux@roeck-us.net, support.opensource@diasemi.com, linux-watchdog@vger.kernel.org, Fabio Estevam Subject: [PATCH v2 1/2] watchdog: da9063: Do not use a global variable Date: Fri, 18 Oct 2024 10:58:20 -0300 Message-Id: <20241018135821.274376-1-festevam@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-watchdog@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Fabio Estevam Using the 'use_sw_pm' variable as global is not recommended as it prevents multi instances of the driver to run. Make it a member of the da9063 structure instead. Signed-off-by: Fabio Estevam Reviewed-by: Guenter Roeck --- Changes since v1: - None. drivers/watchdog/da9063_wdt.c | 9 +++++---- include/linux/mfd/da9063/core.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c index 684667469b10..69f884cf1a7b 100644 --- a/drivers/watchdog/da9063_wdt.c +++ b/drivers/watchdog/da9063_wdt.c @@ -27,7 +27,6 @@ * others: timeout = 2048 ms * 2^(TWDSCALE-1). */ static const unsigned int wdt_timeout[] = { 0, 2, 4, 8, 16, 32, 65, 131 }; -static bool use_sw_pm; #define DA9063_TWDSCALE_DISABLE 0 #define DA9063_TWDSCALE_MIN 1 @@ -230,7 +229,7 @@ static int da9063_wdt_probe(struct platform_device *pdev) if (!wdd) return -ENOMEM; - use_sw_pm = device_property_present(dev, "dlg,use-sw-pm"); + da9063->use_sw_pm = device_property_present(dev, "dlg,use-sw-pm"); wdd->info = &da9063_watchdog_info; wdd->ops = &da9063_watchdog_ops; @@ -267,8 +266,9 @@ static int da9063_wdt_probe(struct platform_device *pdev) static int __maybe_unused da9063_wdt_suspend(struct device *dev) { struct watchdog_device *wdd = dev_get_drvdata(dev); + struct da9063 *da9063 = watchdog_get_drvdata(wdd); - if (!use_sw_pm) + if (!da9063->use_sw_pm) return 0; if (watchdog_active(wdd)) @@ -280,8 +280,9 @@ static int __maybe_unused da9063_wdt_suspend(struct device *dev) static int __maybe_unused da9063_wdt_resume(struct device *dev) { struct watchdog_device *wdd = dev_get_drvdata(dev); + struct da9063 *da9063 = watchdog_get_drvdata(wdd); - if (!use_sw_pm) + if (!da9063->use_sw_pm) return 0; if (watchdog_active(wdd)) diff --git a/include/linux/mfd/da9063/core.h b/include/linux/mfd/da9063/core.h index 8db52324f416..eae82f421414 100644 --- a/include/linux/mfd/da9063/core.h +++ b/include/linux/mfd/da9063/core.h @@ -78,6 +78,7 @@ struct da9063 { enum da9063_type type; unsigned char variant_code; unsigned int flags; + bool use_sw_pm; /* Control interface */ struct regmap *regmap; From patchwork Fri Oct 18 13:58:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 837512 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCD3F41C6A for ; Fri, 18 Oct 2024 13:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729259914; cv=none; b=PuNqxeJuDx88RmLUn8wYL/pTBNAZ4q2rYM3sc1syMc6Cd/O/jvAdxB6D+QRlxBBNocK+bnbdNV/UMlEas+ys5VNOx+UiBB2kod0eY886w088x1YHHCAsDsgWEI61eUi2saG7FVY4rnb/n6ArOgVi0Cq5Ohh2VBMHbvrdQxE33Bc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729259914; c=relaxed/simple; bh=4ljERmlq04NIdijeXAfR6GU1swblTXcTV9ZTQN2WuDE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dxla7WJQUa5vyNIBrt24kJVWA+suryHAh7bDvbZe6UYzRvctwRTmuDDQzEnPJLYoiwba8p9z/buNz2fdHhOUBO4+5afcVmn49AZ4IRmhlXhuNYgfUgpDOFDlNhTF0F/RZPCpgEb7En3KAMLqEyCMsTsCj9fTa2DYjXzCcA6+jkA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dJc0oCQ6; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dJc0oCQ6" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-7e6d04f74faso1467033a12.1 for ; Fri, 18 Oct 2024 06:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729259912; x=1729864712; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XMtFa5Iav8nOY6O1wrCG9UoNgb0eztQLEetiKJzPO18=; b=dJc0oCQ6rL83RYfVAAKa4bVr0Ucyb/V/DVaeGP2fgmWGojvgkuPQTC5YIOLPnndawb abs2+bCXBYLNVIERrMFBtDFUf6F7CMmRdQHYf38xWVdQeN9pbocUya8oXfvk9VP7mxHt H3QbnL9luiyQ7LyDGpiJX1drdbUfGLOpXZSVBkmEsVkAZY8IngYmKRZuzbj1DpNCkHUR Ok6Lyn3/hv7GPMC5y4dsiIhbD8tsd+FRMkmGguCZCkEV1p+z/D0sMWDIGoqSgeYvziyI bya25VSOQbfVOCVuCGE3p+sFHQeUvLhDVhZLemAlcN8lLZ2piEC+vNTOdM7nf3loDJDu mAhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729259912; x=1729864712; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XMtFa5Iav8nOY6O1wrCG9UoNgb0eztQLEetiKJzPO18=; b=qYrghcF98TV0OAZ6n744LEoF618hpJ+8OoQtoeK+A3sT6EV/kD5RTCLS3Xg0De4Qpg 5C6nCD2gb36fBV/kE1haQz2MxF97DgjZfkqkE3okj1oTITgo1Th6x7qHy3AS5gQC/mez +FC5Vzu5A4FGJqbxswhxDJvR/AMt1qptOLS7sLkBgKZDdbsKZPeWlo+f40JStpU9R4na Aamh88wqri0ioMp3cL6fhjHPP+27AcRL6OZXlvXS65O865+3IMrXL3hwfQtOt88KShvw nPhzzSWWiV1otx2OamrfGZ+rh/raEx2ZTMT/gd1rFygQMkeSiV8uyV3s5LYwsJYsxknX Rz7g== X-Forwarded-Encrypted: i=1; AJvYcCW2pvmBz+n8Urx9+8BR5wflJa/aMNodCilXSYgVcPaFcDU4ZxmzspgOvbDO1oodutnzlYGYGMlEeMu4B3oieA==@vger.kernel.org X-Gm-Message-State: AOJu0YxOMBp0iMkt+WBl4y1UZuheqKWlmN0xMQydgQPOY77I5wbbV55r pS172cSGivjnc2M3/VcNSkHa0BA9L+pWYbPyRGD3gH2yAiX5J7+NRM7nyw== X-Google-Smtp-Source: AGHT+IEoH0yNBqudmkqHpcZUevIZLctpochodWVQDQQWLMhz5itszleTzEY2cpd6anBEdyKGEDRExQ== X-Received: by 2002:a05:6a20:d80d:b0:1d9:761:8ad8 with SMTP id adf61e73a8af0-1d92cb8c2a8mr3342046637.21.1729259911970; Fri, 18 Oct 2024 06:58:31 -0700 (PDT) Received: from fabio-Precision-3551.. ([2804:14c:485:4b61:ad3c:ece1:18ac:9bc9]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ea3311f16sm1448482b3a.40.2024.10.18.06.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 06:58:31 -0700 (PDT) From: Fabio Estevam To: wim@linux-watchdog.org Cc: linux@roeck-us.net, support.opensource@diasemi.com, linux-watchdog@vger.kernel.org, Fabio Estevam Subject: [PATCH v2 2/2] watchdog: da9063: Remove __maybe_unused notations Date: Fri, 18 Oct 2024 10:58:21 -0300 Message-Id: <20241018135821.274376-2-festevam@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241018135821.274376-1-festevam@gmail.com> References: <20241018135821.274376-1-festevam@gmail.com> Precedence: bulk X-Mailing-List: linux-watchdog@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Fabio Estevam Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to handle the .suspend/.resume callbacks. These macros allow the suspend and resume functions to be automatically dropped by the compiler when CONFIG_SUSPEND is disabled, without having to use __maybe_unused notation. Signed-off-by: Fabio Estevam --- Changes since v1: - Newly introduced. drivers/watchdog/da9063_wdt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c index 69f884cf1a7b..92e1b78ff481 100644 --- a/drivers/watchdog/da9063_wdt.c +++ b/drivers/watchdog/da9063_wdt.c @@ -263,7 +263,7 @@ static int da9063_wdt_probe(struct platform_device *pdev) return devm_watchdog_register_device(dev, wdd); } -static int __maybe_unused da9063_wdt_suspend(struct device *dev) +static int da9063_wdt_suspend(struct device *dev) { struct watchdog_device *wdd = dev_get_drvdata(dev); struct da9063 *da9063 = watchdog_get_drvdata(wdd); @@ -277,7 +277,7 @@ static int __maybe_unused da9063_wdt_suspend(struct device *dev) return 0; } -static int __maybe_unused da9063_wdt_resume(struct device *dev) +static int da9063_wdt_resume(struct device *dev) { struct watchdog_device *wdd = dev_get_drvdata(dev); struct da9063 *da9063 = watchdog_get_drvdata(wdd); @@ -291,14 +291,14 @@ static int __maybe_unused da9063_wdt_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(da9063_wdt_pm_ops, - da9063_wdt_suspend, da9063_wdt_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(da9063_wdt_pm_ops, da9063_wdt_suspend, + da9063_wdt_resume); static struct platform_driver da9063_wdt_driver = { .probe = da9063_wdt_probe, .driver = { .name = DA9063_DRVNAME_WATCHDOG, - .pm = &da9063_wdt_pm_ops, + .pm = pm_sleep_ptr(&da9063_wdt_pm_ops), }, }; module_platform_driver(da9063_wdt_driver);