Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1937477lqg; Mon, 4 Mar 2024 08:07:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWltJEz4WhFcyEdLGSDUOc3MqnW0XGsYRz4d0/MMLWd9XAd59HnKbUisHvirQQYEQWpfmScuZdmp+b8LFcezn+6LJbO8ve0gOTkXMTLuA== X-Google-Smtp-Source: AGHT+IEOe+AAHq0u//MDsc/IYQCXb2y+//Skniw9j5X5e+Q1mj2G9VYm0G+IBxW3CncuOiGGk/ZK X-Received: by 2002:a05:6a21:3947:b0:1a1:44c9:2d8d with SMTP id ac7-20020a056a21394700b001a144c92d8dmr8586627pzc.37.1709568448812; Mon, 04 Mar 2024 08:07:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709568448; cv=pass; d=google.com; s=arc-20160816; b=V7eWdFAUGRhGFZXwpGdjiunac5OofPkm05/TCKf2lUcjqrJsOp10j5zs144+u/rvQD RB9iBV0kEvpNDWedgUsegZjD/vKylvYsYjoymG0MAki0b+AzyBfIBjjppiHQEpxZOnRL 5oa8TKkjWj4Tw1jyy90QC/ycHdqnDSrCVqPKyEdmN6bQNw3a684NkbaBREKFrvYvoJSO tHc0V4TD2CZkQP9MUf6BDimCXPQcrJ6SpEhGhtTmlbSTy372hGmPN2FZ82SBRznI6YGM W93EWp6NSfkpsy+pr1VXWcd6ceOHGSb84yuPLGQEBAxzieTFeH6dWAbIra9L6blbAwdh TVtA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=aDSdXnXZZ/5NY8WXefk2LzOT1GQOCIJxtJenx3zvKZU=; fh=IdcPguBdl6oDYUsmgxrzqe5bef7Dh5cZ5ixdfnbmY2g=; b=KzaDEKWjt17AL+q590V03ZN6hmO20dxgrbAWdHDJx3Rj1TbJYIqcaeMmkR1OZJ1FTG XlK76ZDyrUxcOqJpFDbG1f6Lu8QtjlUShLCrcSm1Mb8K8cHoBmKL4AesKMhBwalQ7pnN NGEq8//8Bd6V/e5vQ3ihQtlnYfLBXbFAiLMxCM0nPwGLAf1kNH1+xZR27sM0KXwPbuWU pnVt2tL8thusQv2wktIJDQTX+JVjn+lJSbCrbAsSaxRTSgp0zr++wHG3j5Y22XRLBric 4QXymEASaf5lzFc0ma1906VBrrpUQqRIwTLHLcIO2Jn9kRHRorHlFMPxluvZttWxZ3K2 xwmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=L9gcfnpx; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90841-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id r11-20020a62e40b000000b006e50c3638d6si8433345pfh.120.2024.03.04.08.07.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:07:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90841-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=L9gcfnpx; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90841-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90841-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AFFE2B2038B for ; Mon, 4 Mar 2024 15:37:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF8804C635; Mon, 4 Mar 2024 15:36:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="L9gcfnpx" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F109481A5; Mon, 4 Mar 2024 15:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566577; cv=none; b=IA3kg4hkJa75HdqSFzIDqSGAPfDtSFu5kQM4fObTvWcRzLjgOOpj3V8ik1ghvdJi8ahLGM1pHclKydQ+1Kr3ezLhq5RrteiliBjJP1l12XAB9066uz+I4nYrX+hHzY110LkRM3G+wtX59ssO8TqxQg8OUHt07SxFacPCTKbzD0E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566577; c=relaxed/simple; bh=q5g9w2LIy+fdicX1VZH/5+1jD99A7D83QQXIBIrBT58=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WNVd8fCnEgBaKem2EAIV3goq244+Xtl5Ss44lrRRai0ESVkNkxuRdE8XOu+IBwp9RgLioVkQ6TmARO3pJd0cNVwz8ljfX7cGxKbbikYelqb/sfsCkymDVnak+kiVaJ66gmIwHkQeVyrzV0xPHgRWEa/UmpHAkKtkqGwWDu+uSWM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=L9gcfnpx; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 2CF251BF206; Mon, 4 Mar 2024 15:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aDSdXnXZZ/5NY8WXefk2LzOT1GQOCIJxtJenx3zvKZU=; b=L9gcfnpxclDI7aWK0k287Bw2zily1E6V4OBDUOmCgHFuMwtlTLxsZXjhY0yAaIolBQ/H5Z p6H3l71mRdh6Ugil8bst7Tyatr8UzCpkqRWriNLmgtQk08Mo2S+iLQii4tL6w6iGLUsSYI DPifmPExQfvsmXkFGv/1Olrn4v0CLoa/KmNqQYcYW50cRLQYwHRxgbEabXrm9OyBZgElBm cHb2Dmxdx60kEc2kIVWS8cjZDN1rgmuwPLcpPK2RPt93wrZpd2o27drdMriPh2Yx8OMRP4 Y0yyD4GTAGcNTvsTK1g6tV7cdAoXe2bKuLUEoO2izsXueMBvAmAubNEv42SSTw== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:45 +0100 Subject: [PATCH v4 02/18] pinctrl: pinctrl-single: move suspend()/resume() callbacks to noirq Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240102-j7200-pcie-s2r-v4-2-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard , Andy Shevchenko X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com The goal is to extend the active period of pinctrl. Some devices may need active pinctrl after suspend() and/or before resume(). So move suspend()/resume() to suspend_noirq()/resume_noirq() in order to have active pinctrl until suspend_noirq() (included), and from resume_noirq() (included). The deprecated API has been removed to use the new one (dev_pm_ops struct). No need to check the pointer returned by dev_get_drvdata(), as platform_set_drvdata() is called during the probe. Reviewed-by: Linus Walleij Reviewed-by: Andy Shevchenko Signed-off-by: Thomas Richard --- drivers/pinctrl/pinctrl-single.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 19cc0db771a5..0dd4b0e11adf 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -1625,7 +1625,6 @@ static int pcs_irq_init_chained_handler(struct pcs_device *pcs, return 0; } -#ifdef CONFIG_PM static int pcs_save_context(struct pcs_device *pcs) { int i, mux_bytes; @@ -1690,14 +1689,9 @@ static void pcs_restore_context(struct pcs_device *pcs) } } -static int pinctrl_single_suspend(struct platform_device *pdev, - pm_message_t state) +static int pinctrl_single_suspend_noirq(struct device *dev) { - struct pcs_device *pcs; - - pcs = platform_get_drvdata(pdev); - if (!pcs) - return -EINVAL; + struct pcs_device *pcs = dev_get_drvdata(dev); if (pcs->flags & PCS_CONTEXT_LOSS_OFF) { int ret; @@ -1710,20 +1704,19 @@ static int pinctrl_single_suspend(struct platform_device *pdev, return pinctrl_force_sleep(pcs->pctl); } -static int pinctrl_single_resume(struct platform_device *pdev) +static int pinctrl_single_resume_noirq(struct device *dev) { - struct pcs_device *pcs; - - pcs = platform_get_drvdata(pdev); - if (!pcs) - return -EINVAL; + struct pcs_device *pcs = dev_get_drvdata(dev); if (pcs->flags & PCS_CONTEXT_LOSS_OFF) pcs_restore_context(pcs); return pinctrl_force_default(pcs->pctl); } -#endif + +static DEFINE_NOIRQ_DEV_PM_OPS(pinctrl_single_pm_ops, + pinctrl_single_suspend_noirq, + pinctrl_single_resume_noirq); /** * pcs_quirk_missing_pinctrl_cells - handle legacy binding @@ -1986,11 +1979,8 @@ static struct platform_driver pcs_driver = { .driver = { .name = DRIVER_NAME, .of_match_table = pcs_of_match, + .pm = pm_sleep_ptr(&pinctrl_single_pm_ops), }, -#ifdef CONFIG_PM - .suspend = pinctrl_single_suspend, - .resume = pinctrl_single_resume, -#endif }; module_platform_driver(pcs_driver); -- 2.39.2