Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2649817ybf; Mon, 2 Mar 2020 12:59:13 -0800 (PST) X-Google-Smtp-Source: ADFU+vuxV2m8YqVaeXGdWVFfvGqpyJndYRmgFd5rKYvDW1Vd6eBowkH4V0Dkl1IB1qcEOestjfg2 X-Received: by 2002:a05:6830:1b76:: with SMTP id d22mr771432ote.343.1583182753351; Mon, 02 Mar 2020 12:59:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1583182753; cv=pass; d=google.com; s=arc-20160816; b=VRdVo5cGtNYU7hzG0iTHtKJnOn489xBb0fBwrGucRM273DiaHx9zWivM2Uj+ALQRXM 8gHXmYv3654fq9gCHfYC89PqQHQYC0JXQM5zZ+PNJTpx8JZuylNBDxqh3ultdYoqnVLE DOeJopOM8Q04qIgv78iqr+ZeWYKVwSA2eEfr9vN4zn60+Rrgqil6abfJAtykYvmVk4QX 5hAw0YSs5ibWgiQsq6j97zXrGxlM2m8dMC9/rsgxKuPRDhda2l93p8N5w5atvIq7KVXj 4bvowdCgmrXnOLO6fmCv9AgEzBwt7Gw4/eCE0UkRgcNa1q1JttKLrAzeE3mCKXT2NL34 yRPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=803tOpKNryfd+LRf5X50v4ZX+8USha0Nl2DXCGQHcXc=; b=Pskk4ixjrK1hPUagUqsZbPtOaeaRR+9RVuPyYjMjUtRBPp1m1+aCuYUi03bZ7YSy5/ FlSx6DeymwBKh8n8ceMHaz+gHABfUphaE6opECv+9wDAMI+MEGRpkBqXtwkJFXwS/y+i SGFcHSpTrAaDk0fyprvOhWgBuxAGxnYII7GRRqratahMRIMrQYPFEN60EMKn8Zkktj+o dwEchgTdxOrTP9O0MCYK8spjf8kzAYZSroJEw9HZlC6/goBtF/X5m83h56K+dN/rTniz fHSi0gRbKCYE5D3M/If2JBBcgfwbENe4EaBZspBtCoFJapFAS3VNI0gKXDCHGb8fCw19 MXTA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=kncJTKfI; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si1396642otm.54.2020.03.02.12.59.01; Mon, 02 Mar 2020 12:59:13 -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=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=kncJTKfI; arc=pass (i=1 spf=pass spfdomain=oss.nxp.com dkim=pass dkdomain=oss.nxp.com dmarc=pass fromdomain=oss.nxp.com); 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726946AbgCBU5r (ORCPT + 99 others); Mon, 2 Mar 2020 15:57:47 -0500 Received: from mail-eopbgr50043.outbound.protection.outlook.com ([40.107.5.43]:50336 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726690AbgCBU5q (ORCPT ); Mon, 2 Mar 2020 15:57:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MTtiE8Tfrg26XWJ2oP5tKGxKA27buOG1M4oJGG9cc/hTL0U7TyO3CRMeka57tnDbBCxkyzYzQQP2tvnFcpYPNgTKV5qhwrQMScnmH0KFRboBRcbETBtaUhdi5swcRw5pcT9yOo4B7sNYEPZYglQD20VAChtGIjolAhjuMn6dCJHT3/Pf+VWZngJ9NfIDEn7rTEIuhDOhpyr6J6tJAJF/koHFTzlTh3aWtmmEQSnRrCj26nUGmH+Te1qi2Y5g00On8dl9yvO2lEmBGgKPvKwsIVYnlVBqb5L/rlrbFV7j/9hQ/R3mziNwnDuL48BSLq032M7RHLMSrTGXvs1q5HbOcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=803tOpKNryfd+LRf5X50v4ZX+8USha0Nl2DXCGQHcXc=; b=VlOg0FF0FK1r0rizyZrc0fPNs64n74v5FnOzYj9kkoHruz0XH156UgNwNylmj+wgKy8LLCJDlRQpqtZ8Dna2xBHcKqyaPWVKwog1leMA0Q6PNd/hzKDeNvwnlUDZJCnsHyZRMOr6mBXij9PRWQ2/Ed3mh48G/SYgELniRVKZpeAAx50gNNDsYZPP9yAiPEhmGisEqSG++fiX+0fRR8odY+MtBgdZCH4X3qDyxx4zIc7X8h542tyg0rvMWPfuuDkqzSVhwH6oB9YPod2NvNY4ay8B6RS0tII/rVHsb4qyeCUz2gtUy1ywuVQ0dm5kl4R13xKIJ9ed1VDIIPx8259L5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=803tOpKNryfd+LRf5X50v4ZX+8USha0Nl2DXCGQHcXc=; b=kncJTKfIMdHhMivHoP4EpuucOmLBmNHILGdFBh1Kx0XwGwbt+Jptb2sHXHUBNlGujd44qKt86bgagT3e1HIwSt8+Lx8FvYg7SZTRiRlOjj5yHOkc20riP4XDKqW/nrqI3P8FOBj0JAJRVGwgj7N+sakRw+6OTcjY89jGinRV5VU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=daniel.baluta@oss.nxp.com; Received: from VI1PR0402MB3839.eurprd04.prod.outlook.com (52.134.16.147) by VI1PR0402MB3453.eurprd04.prod.outlook.com (52.134.3.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.18; Mon, 2 Mar 2020 20:57:40 +0000 Received: from VI1PR0402MB3839.eurprd04.prod.outlook.com ([fe80::35d0:31bc:91d9:ceb0]) by VI1PR0402MB3839.eurprd04.prod.outlook.com ([fe80::35d0:31bc:91d9:ceb0%7]) with mapi id 15.20.2772.019; Mon, 2 Mar 2020 20:57:40 +0000 From: Daniel Baluta To: rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz Cc: gregkh@linuxfoundation.org, khilman@kernel.org, ulf.hansson@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, daniel.baluta@gmail.com, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, aisheng.dong@nxp.com, shengjiu.wang@nxp.com, paul.olaru@nxp.com, ranjani.sridharan@linux.intel.com, Daniel Baluta Subject: [RFC PATCH 2/2] ASoC: SOF: Use multi PM domains helpers Date: Mon, 2 Mar 2020 22:57:00 +0200 Message-Id: <20200302205700.29746-3-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200302205700.29746-1-daniel.baluta@oss.nxp.com> References: <20200302205700.29746-1-daniel.baluta@oss.nxp.com> Content-Type: text/plain X-ClientProxiedBy: AM4PR05CA0031.eurprd05.prod.outlook.com (2603:10a6:205::44) To VI1PR0402MB3839.eurprd04.prod.outlook.com (2603:10a6:803:21::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from fsr-ub1864-103.ro-buh02.nxp.com (89.37.124.34) by AM4PR05CA0031.eurprd05.prod.outlook.com (2603:10a6:205::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.15 via Frontend Transport; Mon, 2 Mar 2020 20:57:39 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [89.37.124.34] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 92c5647e-2ef1-46b5-dcfb-08d7beec58a8 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3453:|VI1PR0402MB3453: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:525; X-Forefront-PRVS: 033054F29A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(396003)(376002)(346002)(136003)(366004)(199004)(189003)(2906002)(26005)(6486002)(4326008)(6506007)(5660300002)(186003)(16526019)(478600001)(7416002)(6666004)(1076003)(2616005)(66946007)(66556008)(66476007)(44832011)(8936002)(8676002)(86362001)(81166006)(81156014)(6512007)(52116002)(956004)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0402MB3453;H:VI1PR0402MB3839.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:0;MX:1; Received-SPF: None (protection.outlook.com: oss.nxp.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n/FB799LRjlYE0GyFkBKCEh59RV3CF8U+3+dAe/x9Bgd3SK/FX1lreV47ohXr7IPXe9fnd7mNtUrc2qDGbbAVgQFZkolXJgV8WorvkD0aoTJZMRkD1GF7WFR6lYWjf7eCFH5mMGiW0pCWKS5f4GSLAS/quLnP/Lo7aAoQcfq+ig7PMdmg/x6YvvSF4/DwnrwayWS7+1HTPARp+SNWJ0H1Xj9gmuC8zNXyLiMQHxiOxWsvS5Z8WkVvoLOk2noUI0agnmL+pgZJ4vNCXkJDIeDzQKVk8Wr+NBkIfzk1txDhqe/qkubkZf2DR7cpfMTDx81qlm8QSmm4djGemtv2pDi+SweadIGA/lIcPApMk1hRliLrT6Gy5FTd7QjrgScTFyQ5HER04obTXufi7ipK/XQ04ESaTshVb6pUAsMdPWR6nZQPs1LCvugUd2aZkHzwqDh X-MS-Exchange-AntiSpam-MessageData: pGohPEcW6nSL9dhwc16tQKGDoodAup31FfJo/y2dW3F0JCIGUbqoFRTpaGh55I/kdONVlX0/emVNQKG7hZtPfXma71SrVisLR35SROGh69uyJWDdLSHQiaP4OZVHosJ9si5plY71GeTK6gkp4Mz+Aw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92c5647e-2ef1-46b5-dcfb-08d7beec58a8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2020 20:57:40.7364 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sOPLTXokLxIM8TkqJZ+OScPig77PaBE2ZRTUdVahy98nAPrKLoxpCYBpGqty/TCGCD69Discp1FVaCRO8HFB/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3453 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Baluta Use dev_multi_pm_attach / dev_multi_pm_detach instead of the hardcoded version. Signed-off-by: Daniel Baluta --- sound/soc/sof/imx/imx8.c | 54 +++++----------------------------------- 1 file changed, 6 insertions(+), 48 deletions(-) diff --git a/sound/soc/sof/imx/imx8.c b/sound/soc/sof/imx/imx8.c index b692752b2178..ca740538a2d5 100644 --- a/sound/soc/sof/imx/imx8.c +++ b/sound/soc/sof/imx/imx8.c @@ -51,10 +51,7 @@ struct imx8_priv { struct imx_sc_ipc *sc_ipc; /* Power domain handling */ - int num_domains; - struct device **pd_dev; - struct device_link **link; - + struct dev_multi_pm_domain_data *mpd; }; static void imx8_get_reply(struct snd_sof_dev *sdev) @@ -207,7 +204,6 @@ static int imx8_probe(struct snd_sof_dev *sdev) struct resource res; u32 base, size; int ret = 0; - int i; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -218,39 +214,9 @@ static int imx8_probe(struct snd_sof_dev *sdev) priv->sdev = sdev; /* power up device associated power domains */ - priv->num_domains = of_count_phandle_with_args(np, "power-domains", - "#power-domain-cells"); - if (priv->num_domains < 0) { - dev_err(sdev->dev, "no power-domains property in %pOF\n", np); - return priv->num_domains; - } - - priv->pd_dev = devm_kmalloc_array(&pdev->dev, priv->num_domains, - sizeof(*priv->pd_dev), GFP_KERNEL); - if (!priv->pd_dev) - return -ENOMEM; - - priv->link = devm_kmalloc_array(&pdev->dev, priv->num_domains, - sizeof(*priv->link), GFP_KERNEL); - if (!priv->link) - return -ENOMEM; - - for (i = 0; i < priv->num_domains; i++) { - priv->pd_dev[i] = dev_pm_domain_attach_by_id(&pdev->dev, i); - if (IS_ERR(priv->pd_dev[i])) { - ret = PTR_ERR(priv->pd_dev[i]); - goto exit_unroll_pm; - } - priv->link[i] = device_link_add(&pdev->dev, priv->pd_dev[i], - DL_FLAG_STATELESS | - DL_FLAG_PM_RUNTIME | - DL_FLAG_RPM_ACTIVE); - if (!priv->link[i]) { - ret = -ENOMEM; - dev_pm_domain_detach(priv->pd_dev[i], false); - goto exit_unroll_pm; - } - } + priv->mpd = dev_multi_pm_attach(&pdev->dev); + if (IS_ERR(priv->mpd)) + return PTR_ERR(priv->mpd); ret = imx_scu_get_handle(&priv->sc_ipc); if (ret) { @@ -329,25 +295,17 @@ static int imx8_probe(struct snd_sof_dev *sdev) exit_pdev_unregister: platform_device_unregister(priv->ipc_dev); exit_unroll_pm: - while (--i >= 0) { - device_link_del(priv->link[i]); - dev_pm_domain_detach(priv->pd_dev[i], false); - } - + dev_multi_pm_detach(priv->mpd); return ret; } static int imx8_remove(struct snd_sof_dev *sdev) { struct imx8_priv *priv = (struct imx8_priv *)sdev->private; - int i; platform_device_unregister(priv->ipc_dev); - for (i = 0; i < priv->num_domains; i++) { - device_link_del(priv->link[i]); - dev_pm_domain_detach(priv->pd_dev[i], false); - } + dev_multi_pm_detach(priv->mpd); return 0; } -- 2.17.1