From patchwork Tue Apr 9 08:35:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viorel Suman X-Patchwork-Id: 10890913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE38A17E0 for ; Tue, 9 Apr 2019 10:31:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D567D28868 for ; Tue, 9 Apr 2019 10:31:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C95D0288B4; Tue, 9 Apr 2019 10:31:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E955428868 for ; Tue, 9 Apr 2019 10:31:53 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 85B3C921; Tue, 9 Apr 2019 10:36:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 85B3C921 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554799049; bh=tejNIkdH+Y6L6QP7yjVOSlBhjLPhRV50Sz8tjIMK4G4=; h=From:To:Date:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fdeNysh/lyNPh+5MKT5y4E6TNobHFrzgGsVUAIlXLoeGpvdKzsjyrv8XABd98vLLg pgrrz8+iKUggVLycF89mYUdJ+wNIniAeOSSHZcSLJxdkjznXLfYly8XXFwXVbPo0jJ wFLjsmI5m7hqbcTKZ9lVqX0f3hSGIRi4imXBuwg0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 49DEEF896F7; Tue, 9 Apr 2019 10:35:46 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1F50DF89636; Tue, 9 Apr 2019 10:35:41 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50060.outbound.protection.outlook.com [40.107.5.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 38D0BF80C17 for ; Tue, 9 Apr 2019 10:35:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 38D0BF80C17 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="s//d2iWU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yIOi0aXOnk4Ww6rHMC2vDAB6JLRJtoOZy4BXUig/maw=; b=s//d2iWUNDoxj79YjldQ5B+CUim78lR/AvTKeZo9N8G10+0Cxf6Ud4p8Rh7+RvjmZWEqhKhNTiV6ljgg+uI/NtZ4uGlTIa+LB6GkN4Z2FahU5XpOcF1zp6BlIGOYei0gcX0LTEfn5LB/QTNYJTGhm423LGS+H/jWOCwtnH4xSgU= Received: from VI1PR04MB4704.eurprd04.prod.outlook.com (20.177.48.157) by VI1PR04MB3982.eurprd04.prod.outlook.com (10.171.182.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.21; Tue, 9 Apr 2019 08:35:34 +0000 Received: from VI1PR04MB4704.eurprd04.prod.outlook.com ([fe80::2594:3cf0:20a2:8888]) by VI1PR04MB4704.eurprd04.prod.outlook.com ([fe80::2594:3cf0:20a2:8888%3]) with mapi id 15.20.1792.009; Tue, 9 Apr 2019 08:35:34 +0000 From: Viorel Suman To: Timur Tabi , Nicolin Chen , Xiubo Li , Fabio Estevam , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shawn Guo , Sascha Hauer , Julia Lawall Thread-Topic: [PATCH 1/2] ASoC: fsl_audmix: remove "model" attribute Thread-Index: AQHU7q8zRh1FbGktNEKV0aDW74+Gjw== Date: Tue, 9 Apr 2019 08:35:34 +0000 Message-ID: <1554798876-20653-2-git-send-email-viorel.suman@nxp.com> References: <1554798876-20653-1-git-send-email-viorel.suman@nxp.com> In-Reply-To: <1554798876-20653-1-git-send-email-viorel.suman@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VE1PR03CA0004.eurprd03.prod.outlook.com (2603:10a6:802:a0::16) To VI1PR04MB4704.eurprd04.prod.outlook.com (2603:10a6:803:52::29) authentication-results: spf=none (sender IP is ) smtp.mailfrom=viorel.suman@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [212.146.100.6] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 32fb50fb-c1f4-4720-c217-08d6bcc65523 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VI1PR04MB3982; x-ms-traffictypediagnostic: VI1PR04MB3982: x-microsoft-antispam-prvs: x-forefront-prvs: 000227DA0C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(376002)(346002)(39860400002)(199004)(189003)(11346002)(6512007)(8936002)(97736004)(486006)(8676002)(7416002)(81166006)(476003)(305945005)(446003)(53936002)(68736007)(7736002)(50226002)(6436002)(66066001)(86362001)(2616005)(316002)(6486002)(14454004)(36756003)(4326008)(2906002)(54906003)(106356001)(110136005)(71190400001)(105586002)(5660300002)(71200400001)(44832011)(186003)(6116002)(25786009)(3846002)(256004)(102836004)(26005)(52116002)(76176011)(99286004)(6506007)(386003)(81156014)(478600001)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB3982; H:VI1PR04MB4704.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: erAkZZad/AtxST3YHyiC93GrsR3wN3y5oKHmUIjrD3eNjClG3ktw0YE4TAtp0tmGQoWKQ7x89WvBQdLtTPvEwx+/JaIoamp0guogdLhyKIIbcEwzMhKygFDOBR4ecH9yRXBotuW/y6qyTYs/vQeGKT10lsuMMtHpNcSmUxOzwQkEdMQEGJ0PTDNJHatflgR2ULizBZeNCqreMlY57oRcl9w5Ehm+gksPO0qE4EkdMkHka87DGCaLa9/sSN64cjPgPGecKBPDyx/VhXnLxDYRniDBPscro7R/f4lPCQXVkss1alaGQZCaNuH1rqHmEOqep+svLpVOruTLulNQQCRSUIwZDtVT1EZQPjMkMLY9S3a8ufrwsFT57+V/LhQWF0TyQlgRmUhJllwm1j6QMLNjT7SpPxVWBsIi5cGyaUy3Zkg= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 32fb50fb-c1f4-4720-c217-08d6bcc65523 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2019 08:35:34.3781 (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-Transport-CrossTenantHeadersStamped: VI1PR04MB3982 Cc: "alsa-devel@alsa-project.org" , Viorel Suman , "linux-kernel@vger.kernel.org" , Viorel Suman , dl-linux-imx , Pengutronix Kernel Team , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Subject: [alsa-devel] [PATCH 1/2] ASoC: fsl_audmix: remove "model" attribute X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use "of_device_id.data" to specify the machine driver, instead of "model" DTS attribute. Signed-off-by: Viorel Suman --- sound/soc/fsl/fsl_audmix.c | 61 ++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/sound/soc/fsl/fsl_audmix.c b/sound/soc/fsl/fsl_audmix.c index dabde03..2d10d8b 100644 --- a/sound/soc/fsl/fsl_audmix.c +++ b/sound/soc/fsl/fsl_audmix.c @@ -445,61 +445,70 @@ static const struct regmap_config fsl_audmix_regmap_config = { .cache_type = REGCACHE_FLAT, }; +static const struct of_device_id fsl_audmix_ids[] = { + { + .compatible = "fsl,imx8qm-audmix", + .data = "imx-audmix", + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, fsl_audmix_ids); + static int fsl_audmix_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct fsl_audmix *priv; struct resource *res; + const char *mdrv; + const struct of_device_id *of_id; void __iomem *regs; int ret; - const char *sprop; - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + of_id = of_match_device(fsl_audmix_ids, dev); + if (!of_id || !of_id->data) + return -EINVAL; + + mdrv = of_id->data; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; /* Get the addresses */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - regs = devm_ioremap_resource(&pdev->dev, res); + regs = devm_ioremap_resource(dev, res); if (IS_ERR(regs)) return PTR_ERR(regs); - priv->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "ipg", regs, + priv->regmap = devm_regmap_init_mmio_clk(dev, "ipg", regs, &fsl_audmix_regmap_config); if (IS_ERR(priv->regmap)) { - dev_err(&pdev->dev, "failed to init regmap\n"); + dev_err(dev, "failed to init regmap\n"); return PTR_ERR(priv->regmap); } - priv->ipg_clk = devm_clk_get(&pdev->dev, "ipg"); + priv->ipg_clk = devm_clk_get(dev, "ipg"); if (IS_ERR(priv->ipg_clk)) { - dev_err(&pdev->dev, "failed to get ipg clock\n"); + dev_err(dev, "failed to get ipg clock\n"); return PTR_ERR(priv->ipg_clk); } platform_set_drvdata(pdev, priv); - pm_runtime_enable(&pdev->dev); + pm_runtime_enable(dev); - ret = devm_snd_soc_register_component(&pdev->dev, &fsl_audmix_component, + ret = devm_snd_soc_register_component(dev, &fsl_audmix_component, fsl_audmix_dai, ARRAY_SIZE(fsl_audmix_dai)); if (ret) { - dev_err(&pdev->dev, "failed to register ASoC DAI\n"); + dev_err(dev, "failed to register ASoC DAI\n"); return ret; } - sprop = of_get_property(pdev->dev.of_node, "model", NULL); - if (sprop) { - priv->pdev = platform_device_register_data(&pdev->dev, sprop, 0, - NULL, 0); - if (IS_ERR(priv->pdev)) { - ret = PTR_ERR(priv->pdev); - dev_err(&pdev->dev, - "failed to register platform %s: %d\n", sprop, - ret); - } - } else { - dev_err(&pdev->dev, "[model] attribute missing.\n"); - ret = -EINVAL; + priv->pdev = platform_device_register_data(dev, mdrv, 0, NULL, 0); + if (IS_ERR(priv->pdev)) { + ret = PTR_ERR(priv->pdev); + dev_err(dev, "failed to register platform %s: %d\n", + mdrv, ret); } return ret; @@ -553,12 +562,6 @@ static const struct dev_pm_ops fsl_audmix_pm = { pm_runtime_force_resume) }; -static const struct of_device_id fsl_audmix_ids[] = { - { .compatible = "fsl,imx8qm-audmix", }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, fsl_audmix_ids); - static struct platform_driver fsl_audmix_driver = { .probe = fsl_audmix_probe, .remove = fsl_audmix_remove, From patchwork Tue Apr 9 08:35:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viorel Suman X-Patchwork-Id: 10890825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0819139A for ; Tue, 9 Apr 2019 09:16:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF2E328862 for ; Tue, 9 Apr 2019 09:16:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B11772889B; Tue, 9 Apr 2019 09:16:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A856528891 for ; Tue, 9 Apr 2019 09:16:53 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9F7F79EB; Tue, 9 Apr 2019 10:37:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9F7F79EB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554799094; bh=eivAh2+RwpBUASw2HHTHjlIyeGtvPiTxIZhFBIjKXTo=; h=From:To:Date:References:In-Reply-To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OgFQJ57E+8yYag7RXbPnOYYXTw50OZcAmck994it1bOiPHYJKT3n6E3JEXOiF9+TI dJET/aMw9nJE+k1XPtVaoxVSqKazdTK5+RC+YPOMZi3V1369PfRxktvnhFWMPneCGN IBDSquHUn/rRTj2AHcHG4ZIcv3APqpTRsppBJAzA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D94ADF8971B; Tue, 9 Apr 2019 10:35:48 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8A0AFF896F7; Tue, 9 Apr 2019 10:35:43 +0200 (CEST) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70055.outbound.protection.outlook.com [40.107.7.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2E0B7F80C17 for ; Tue, 9 Apr 2019 10:35:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2E0B7F80C17 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="s6Zl0Dk4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZkFS7fOKXY4eaBsvRVjQ21ozJNA3OcWuRPR29jAgAek=; b=s6Zl0Dk4SVWxtKS8ffhG9CEATj0dMzwXIWJoV1mKkEZo640uyei2Of0eHaioZoKMUA56ENBA4CKyG6hXeMVVHtL/KPdZ+uxOBLQLRnTp63wyPdAEZJr8p2a4y0z35UIV/SJJQZHYhmT3Yr0dlRNM+omRsJC/qflgxdim2y9KmPg= Received: from VI1PR04MB4704.eurprd04.prod.outlook.com (20.177.48.157) by VI1PR04MB3983.eurprd04.prod.outlook.com (10.171.182.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.16; Tue, 9 Apr 2019 08:35:35 +0000 Received: from VI1PR04MB4704.eurprd04.prod.outlook.com ([fe80::2594:3cf0:20a2:8888]) by VI1PR04MB4704.eurprd04.prod.outlook.com ([fe80::2594:3cf0:20a2:8888%3]) with mapi id 15.20.1792.009; Tue, 9 Apr 2019 08:35:35 +0000 From: Viorel Suman To: Timur Tabi , Nicolin Chen , Xiubo Li , Fabio Estevam , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shawn Guo , Sascha Hauer , Julia Lawall Thread-Topic: [PATCH 2/2] ASoC: imx-audmix: fix object reference leaks in probe Thread-Index: AQHU7q8zoMDMeUy2P0Ct5Mpi9gwjqg== Date: Tue, 9 Apr 2019 08:35:35 +0000 Message-ID: <1554798876-20653-3-git-send-email-viorel.suman@nxp.com> References: <1554798876-20653-1-git-send-email-viorel.suman@nxp.com> In-Reply-To: <1554798876-20653-1-git-send-email-viorel.suman@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VE1PR03CA0004.eurprd03.prod.outlook.com (2603:10a6:802:a0::16) To VI1PR04MB4704.eurprd04.prod.outlook.com (2603:10a6:803:52::29) authentication-results: spf=none (sender IP is ) smtp.mailfrom=viorel.suman@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [212.146.100.6] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4cf04229-6667-4b5f-24d4-08d6bcc655fa x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600139)(711020)(4605104)(4618075)(2017052603328)(7193020); SRVR:VI1PR04MB3983; x-ms-traffictypediagnostic: VI1PR04MB3983: x-microsoft-antispam-prvs: x-forefront-prvs: 000227DA0C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(376002)(366004)(39860400002)(396003)(136003)(189003)(199004)(305945005)(5660300002)(106356001)(4326008)(68736007)(105586002)(52116002)(14454004)(97736004)(186003)(36756003)(110136005)(54906003)(53936002)(81156014)(7736002)(8676002)(81166006)(25786009)(6486002)(50226002)(6512007)(7416002)(6436002)(8936002)(99286004)(2616005)(66066001)(11346002)(3846002)(6116002)(256004)(446003)(316002)(476003)(86362001)(2906002)(71190400001)(71200400001)(386003)(6506007)(486006)(478600001)(102836004)(76176011)(26005)(44832011)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB3983; H:VI1PR04MB4704.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: qits80QiWfjSpVuTC3sU4QBS6qrmvpG0fLKd4Hig4iMmY7NO0/0jbYdA7iWHtp2nJXbGYozP+UJWcafdx+KpdLnt0+pFB0a0NEGPhavWzINaUZmNdFO7RLOOy4pbXX6h3ssaECJVfNuX8Rr++RX6GEdnZQTWwqueyb52J92Prz+OZrUeuG6Lpq2xDpA3UMaaBCvMEmxADitfF4EGaa/VjBKBlXI2fDOXx6ELglBjx7443mwjIUBbG1ql30BfF/qJREtax85PXeDh7BuXuycUUnRhlz4pPP5gdUpoiV85Pj5sRtdN1JfNtK41Ofe1NOyV1TVyuLms9U/5Cnf24NHs18+1+9xZGJjDqYh8mdJCuuX7JLp+r1gnQ2IZ89e6kwhftuxiTcAwGzQBkG32J+i5n//UwcwXottYnZMGn3AyAlQ= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cf04229-6667-4b5f-24d4-08d6bcc655fa X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2019 08:35:35.4839 (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-Transport-CrossTenantHeadersStamped: VI1PR04MB3983 Cc: "alsa-devel@alsa-project.org" , Viorel Suman , "linux-kernel@vger.kernel.org" , Viorel Suman , dl-linux-imx , Pengutronix Kernel Team , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Subject: [alsa-devel] [PATCH 2/2] ASoC: imx-audmix: fix object reference leaks in probe X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Release the reference to the underlying device taken by of_find_device_by_node() call. Signed-off-by: Viorel Suman --- sound/soc/fsl/imx-audmix.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c index 7983bd3..7c24095 100644 --- a/sound/soc/fsl/imx-audmix.c +++ b/sound/soc/fsl/imx-audmix.c @@ -20,10 +20,7 @@ #include "fsl_audmix.h" struct imx_audmix { - struct platform_device *pdev; struct snd_soc_card card; - struct platform_device *audmix_pdev; - struct platform_device *out_pdev; struct clk *cpu_mclk; int num_dai; struct snd_soc_dai_link *dai; @@ -144,7 +141,7 @@ static struct snd_soc_ops imx_audmix_be_ops = { static int imx_audmix_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct device_node *audmix_np = NULL, *out_cpu_np = NULL; + struct device_node *audmix_np = NULL; struct platform_device *audmix_pdev = NULL; struct platform_device *cpu_pdev; struct of_phandle_args args; @@ -171,6 +168,7 @@ static int imx_audmix_probe(struct platform_device *pdev) np->full_name); return -EINVAL; } + put_device(&audmix_pdev->dev); num_dai = of_count_phandle_with_args(audmix_np, "dais", NULL); if (num_dai != FSL_AUDMIX_MAX_DAIS) { @@ -216,6 +214,7 @@ static int imx_audmix_probe(struct platform_device *pdev) dev_err(&pdev->dev, "failed to find SAI platform device\n"); return -EINVAL; } + put_device(&cpu_pdev->dev); dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%s", fe_name_pref, args.np->full_name + 1); @@ -223,7 +222,14 @@ static int imx_audmix_probe(struct platform_device *pdev) dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name); if (i == 0) { - out_cpu_np = args.np; + priv->cpu_mclk = devm_clk_get(&cpu_pdev->dev, "mclk1"); + if (IS_ERR(priv->cpu_mclk)) { + ret = PTR_ERR(priv->cpu_mclk); + dev_err(&cpu_pdev->dev, + "failed to get DAI mclk1: %d\n", ret); + return -EINVAL; + } + capture_dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s", dai_name, "CPU-Capture"); @@ -275,21 +281,6 @@ static int imx_audmix_probe(struct platform_device *pdev) priv->dapm_routes[2 * num_dai + i].sink = capture_dai_name; } - cpu_pdev = of_find_device_by_node(out_cpu_np); - if (!cpu_pdev) { - dev_err(&pdev->dev, "failed to find SAI platform device\n"); - return -EINVAL; - } - priv->cpu_mclk = devm_clk_get(&cpu_pdev->dev, "mclk1"); - if (IS_ERR(priv->cpu_mclk)) { - ret = PTR_ERR(priv->cpu_mclk); - dev_err(&cpu_pdev->dev, "failed to get DAI mclk1: %d\n", ret); - return -EINVAL; - } - - priv->audmix_pdev = audmix_pdev; - priv->out_pdev = cpu_pdev; - priv->card.dai_link = priv->dai; priv->card.num_links = priv->num_dai; priv->card.codec_conf = priv->dai_conf;