From patchwork Fri Sep 6 07:06:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huan Yang X-Patchwork-Id: 13793491 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2060.outbound.protection.outlook.com [40.107.255.60]) (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 3907C3B1A2; Fri, 6 Sep 2024 07:06:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725606419; cv=fail; b=JeE2MERE+uCBkXia6hM2/uZ/caJqI0b4NJrfKFyT6uEPwzccfWfYg3W49L43XSxkzbPg2i9lk8pjDCoNmNj9TH0iy1ybiBuC9nC7FC4cC7oEYPrWRl8XHdD4wPsq238jUGBxpB346jmGZ+auArH6P2yzIwDxO3UZTAPupuUwynQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725606419; c=relaxed/simple; bh=DF5wnb9IM6IIe09EzkoMUCYsqQg2g3pCaEUVFsYRjQw=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=ohy+024AIvYGFGdd2aL7yM6ibzZJFOKfxo/F5MWKHaWzURUqjbIgGYNAAre/fNsA9Dr8dBuhZLzOGwMRaGhbospifZ73LOyN/eO0Htwm4dsZJt1Vk4/rQG/BzndcYecuBqCWB4ARr19Fy1t1HFAiUYhcPEU/SDXBKCHSiKB0Nvo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=ACmq6nCo; arc=fail smtp.client-ip=40.107.255.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="ACmq6nCo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rY90ilKgzgrmkkte7owGvWMs/pX3jLByR0quvWX6V6ap57tY1km3bO7tphxBO29DRGUNUE8t13gV1PqGsO0DvLIaqT7FgPROT+3YwMrdjJ0tfDP4lUlEEbxC3VN6QjLBUnl8gbWMpctRfhZ/mfbyHfLZJOYZxkzXZw9U7PLsWx7gG173sRDhsuqLfyQQZGkAPPy4gpy/YPDSFcOBChYizU5OVUd6Dk2U7E+DRVVCzwqA90AUANcVC+buQqQR3lFxWSxjGMVZV+OJqFDvMC//m3Vr9Kfy6KOEsE1raY+gQmNSmg11prGodslFCsYtLmMTXlW0lZkYN6FZQNBS1El79g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WX/51u266mKj0LoSdOlTNhnqP4a2UU3yNggL/C+HHwg=; b=XjzzxzEHweQjjDG9/W/R80q3T1rjUSn6u9Bj5Qmx6PG+WEoDJQIEbkRPBvrBZjY4OyMZITN15arFtPJN/1S83ZT9Yon2Ev+Sd4B4JFwJNtX72L5UWSHXlYZF69oPwce3+iQ/JxlUGZfK6oGb+Af4wyx+AD4pYNc0CHrzk/TCgfVS7OZwf/stkMIQJvuwOQKY/DVFNuuUnWxM6BG8XcLyumpX5IEAz5s1C5IsDmgMbOtC1rCQEk0vXs0zif9KLRsFH5aQvepnsooCwFMFfMh6r+izVnSioIVm9eZ7e5Phr6M4rill5tqLhdjnc6v2ujYcXMRirKQYzqeJzD+gaE7qQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WX/51u266mKj0LoSdOlTNhnqP4a2UU3yNggL/C+HHwg=; b=ACmq6nCo3LZocjXCXXqw0+PawZSqYrJ2yhzEhA3gH9vsUfx6gFt7pk/5n8ePzFh0xW5NstMyGwMUe0CSojLyseszWF2gIoGoDRw3syuM+MZyDtQRtXcTLb+gLEIibKldJzSFGC7nQJbD7ALT2A78CtObYJCCUFNChKxC6J1SMLIYTTS59WjT/bLJSeMs2MVq2ATyXfNJNFWzYwWLE1JiUKY5ycGxK9LxxgDPeMVHTOzmB16N92ejIGoYHLxuDdxZO+IhB4dCGoxJ/5OEaRP2edl3+x2t4pZuPIWeS8uCAHxMN0zzStFpINjCxCPGtSL9ruRyeNvNDSluyw98r28quA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from PUZPR06MB5676.apcprd06.prod.outlook.com (2603:1096:301:f8::10) by TYZPR06MB5298.apcprd06.prod.outlook.com (2603:1096:400:1f5::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.28; Fri, 6 Sep 2024 07:06:53 +0000 Received: from PUZPR06MB5676.apcprd06.prod.outlook.com ([fe80::a00b:f422:ac44:636f]) by PUZPR06MB5676.apcprd06.prod.outlook.com ([fe80::a00b:f422:ac44:636f%6]) with mapi id 15.20.7939.017; Fri, 6 Sep 2024 07:06:53 +0000 From: Huan Yang To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Michal Simek , Huan Yang , linux-sound@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com Subject: [PATCH] soc: xilinx: Use devm_clk_get_enabled() helpers Date: Fri, 6 Sep 2024 15:06:39 +0800 Message-ID: <20240906070641.2466518-1-link@vivo.com> X-Mailer: git-send-email 2.45.2 X-ClientProxiedBy: SI1PR02CA0058.apcprd02.prod.outlook.com (2603:1096:4:1f5::9) To PUZPR06MB5676.apcprd06.prod.outlook.com (2603:1096:301:f8::10) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PUZPR06MB5676:EE_|TYZPR06MB5298:EE_ X-MS-Office365-Filtering-Correlation-Id: b850c356-8b6b-403b-65ef-08dcce427c81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: 0MpAUafs1fKG1PMJOoSPim9gxqEoTwEn0b3JrlHMKvnz76f9DuFsaHshLFob/aYJmrkm00kAuy0c7tlRcxSYj96lU8J8Qf296wCWp8X9l9wOo8zR4zWQTs8Gf5mQdp+MRcNh1ITOnuWZgEjUgT+24QLU0Ihll3BMfzFrqhy0FRRCU73eqKB9BJOQ8jXKr6vX3f+zfi3PZ8YwNotLVK6gYCsEhGcUw9nmQv0CUZeYZpZsFDBF4kSKg7Qq1KwZi5GGXtNe2nhCbIOQHxKXL+mcImt4ht4lBRR7pEXfY+Jjl9OG2hh7DPCTiGnCTnueYoS+TfZ++eXZMaZj4R+eSYBrsnWqtSvgvRrDw6Js8V97MZBiJWBAtBCgffT7SLIN5NzefN+peYcnYV1AV0plxk5fd/dXpWBKPw7q+dWLYvKzzJqfEHDqhTdkvZpL7G1fYUS8dOlqVGIJ1Bl4h+m5eBY7XuLHWMFFbyqWH6N9+ZEji4+LuMg+Ntm3H/styKZ9zPMCvJMq6zreDfcamdhXjrd7V+rFIh37u7MZo1kdTinCHb1btgr8QOLV4zoCqjneVTFA5BTLU7AxUER+PYvLK9PAhKa/WIM1TWm2vfgFZzrY4K7rJOlORPb1DuunHHm4iSZK4IvzaveG/MhYTvbucMfg5tY9UF+KAoPwhWAj4w9Kh6qt405+zvprDND4b9Zvtf7Ge6C3KOzB/AEelF2DJqUhtvH+WZy0EHp5MzHDE9Q2k0ib4bstRuL5SKutL+wkv712Wh+xmofCSKbTVVwKDWTPBjvhxMYfDeEThJetMboq3nRGenlldqB20K3hDjbA5WVl4NjfkcsuZy4qy8jMwOHKVea+Gyxv1QNjD73Ri260bGxqFH8BW0x8OKra4SzoY9VCTSny3EhnA5cEmYJzcf4UQG2WMBWlptpGg6JUxaRQ0pAG9E7dn16er1MZ+i60PYSzzNh2okAakpLVvFE3AvNlHEG1mx39H2iQoALk/S6ZSC4haVJQHJwW1SteDKFa3BvRCetEr4ngu3niYPdjPDdtdko5kaqC4JOkMr9VKeDOk40sjDFz7tb0NE5MQGXkwLdxeHB/yQ3uWo7mWpyrrOdxgAXt1e8d3J0Zm3wjrAEtUNldSkPLFcgAaMkt74LMcPbBGXLGy3RQWJTSW/+y6cU8vxxJ05P0Duhusikett9r69qO8vBGol64jg7/Yd7UwaHNR4dGtXwqQWjoyAn/AhG6s1hIGqrs4fRayoyT8bo072MjO/+OvLg4VBmLf3nZ2mDVIcjaoJEs1hF0UiM+t+tWMo+b7mnHuJQMEjHCK+CHTjWdlTkVnfJIirZAn3pjb+cIU+8LmEr84WKNXxgf5qyzeIRaA8NGy3h01a4YHB/932Yr7opljoETh6RhvYuZJAe0agYgmbjzqmB1gF9OArjwDA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR06MB5676.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(366016)(376014)(38350700014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dcvV2/iL88q2xoZbXBZhSPN/Qn2X426Zg30W7+esm//0jma0/tiMyDuPL6ugzYuKVXqhXRxJ9ocXTv5y5tJ9f+/l1tIrTFSzvglxvnikBGYGaMz5caw37fq1IAx06T7fg4wUnsfcg5wfbxJyf9YpR5agCTgxZ9dU32tyQQ2YfBN79OZEl4lS+50d8IQ+rVgBsP5QttvM0PAwVVpb9CFX+f9vdo51d4nslFvpzAb5BlficLQQF/RnqbAhQaVmtsB8kgpVIgZRx8kCgCQCBNa1OcZutYk4Qw8VbjwhDJUPmiSN2n2ZcO1O18LVBKWNpdYQqYUmV6P2ysPmqzvejmqPDVBO0Tn890Lv66anD4hnxTVz6iQ4WZV1L2t9Ca0vyS4NyR12orBt6VsEUISrnYCvl7l8uj0yCL7w7XgOv+K979pLb68xAq4Rt9pPclFHZRm6rBfh7+UFMlxFqHdlisBIaVX5+PEtwK2yrxwHkyNlSZTbbs+lsGVkPxTA38tvcrngPptRYZXJFWMlHD6HvmowCMOfmxXJ7TjmK7lFlqR8jKm/FlGAbd68CgMAX6JEc6kV/GUfX8Dt7JIV X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b850c356-8b6b-403b-65ef-08dcce427c81 X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5676.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 07:06:53.4169 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: M76ShvazGf/D9ruftM1szu8U5YdIlGOvMTQY8YknRK17LCPdvxgM+eExG1ccPnm7ZqJB6pa8nh26zvZbXsgs8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB5298 The devm_clk_get_enabled() helpers: - call devm_clk_get() - call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids the calls to clk_disable_unprepare(). Due to clk only used in probe, not in suspend\resume, clk pointer can remove from spdif_dev_data, this can save a little memory. Signed-off-by: Huan Yang --- sound/soc/xilinx/xlnx_spdif.c | 44 +++++++++++------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) base-commit: ad40aff1edffeccc412cde93894196dca7bc739e diff --git a/sound/soc/xilinx/xlnx_spdif.c b/sound/soc/xilinx/xlnx_spdif.c index d52d5fc7b5b8..1ac4bb4b76e8 100644 --- a/sound/soc/xilinx/xlnx_spdif.c +++ b/sound/soc/xilinx/xlnx_spdif.c @@ -48,7 +48,6 @@ struct spdif_dev_data { u32 aclk; bool rx_chsts_updated; void __iomem *base; - struct clk *axi_clk; wait_queue_head_t chsts_q; }; @@ -240,49 +239,44 @@ static int xlnx_spdif_probe(struct platform_device *pdev) int ret; struct snd_soc_dai_driver *dai_drv; struct spdif_dev_data *ctx; - struct device *dev = &pdev->dev; struct device_node *node = dev->of_node; + struct clk *clk; ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; - ctx->axi_clk = devm_clk_get(dev, "s_axi_aclk"); - if (IS_ERR(ctx->axi_clk)) { - ret = PTR_ERR(ctx->axi_clk); + clk = devm_clk_get_enabled(dev, "s_axi_aclk"); + if (IS_ERR(clk)) { + ret = PTR_ERR(clk); dev_err(dev, "failed to get s_axi_aclk(%d)\n", ret); return ret; } - ret = clk_prepare_enable(ctx->axi_clk); - if (ret) { - dev_err(dev, "failed to enable s_axi_aclk(%d)\n", ret); - return ret; - } ctx->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(ctx->base)) { - ret = PTR_ERR(ctx->base); - goto clk_err; - } + if (IS_ERR(ctx->base)) + return PTR_ERR(ctx->base); + ret = of_property_read_u32(node, "xlnx,spdif-mode", &ctx->mode); if (ret < 0) { dev_err(dev, "cannot get SPDIF mode\n"); - goto clk_err; + return ret; } + if (ctx->mode) { dai_drv = &xlnx_spdif_tx_dai; } else { ret = platform_get_irq(pdev, 0); if (ret < 0) - goto clk_err; + return ret; + ret = devm_request_irq(dev, ret, xlnx_spdifrx_irq_handler, 0, "XLNX_SPDIF_RX", ctx); if (ret) { dev_err(dev, "spdif rx irq request failed\n"); - ret = -ENODEV; - goto clk_err; + return -ENODEV; } init_waitqueue_head(&ctx->chsts_q); @@ -292,7 +286,7 @@ static int xlnx_spdif_probe(struct platform_device *pdev) ret = of_property_read_u32(node, "xlnx,aud_clk_i", &ctx->aclk); if (ret < 0) { dev_err(dev, "cannot get aud_clk_i value\n"); - goto clk_err; + return ret; } dev_set_drvdata(dev, ctx); @@ -301,31 +295,21 @@ static int xlnx_spdif_probe(struct platform_device *pdev) dai_drv, 1); if (ret) { dev_err(dev, "SPDIF component registration failed\n"); - goto clk_err; + return ret; } writel(XSPDIF_SOFT_RESET_VALUE, ctx->base + XSPDIF_SOFT_RESET_REG); dev_info(dev, "%s DAI registered\n", dai_drv->name); -clk_err: - clk_disable_unprepare(ctx->axi_clk); return ret; } -static void xlnx_spdif_remove(struct platform_device *pdev) -{ - struct spdif_dev_data *ctx = dev_get_drvdata(&pdev->dev); - - clk_disable_unprepare(ctx->axi_clk); -} - static struct platform_driver xlnx_spdif_driver = { .driver = { .name = "xlnx-spdif", .of_match_table = xlnx_spdif_of_match, }, .probe = xlnx_spdif_probe, - .remove_new = xlnx_spdif_remove, }; module_platform_driver(xlnx_spdif_driver);