From patchwork Thu Dec 22 19:14:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13080250 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 980B2C4332F for ; Thu, 22 Dec 2022 19:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CkNBkOMC7CoIVM8F2Ripv56m64n/kH/3hMZamOdjXak=; b=dB1a/nC1LCFpVd Do1w+6vhKaU9KyD3YrvUDOoaLIvznI4bOQuvyB0rPgjRJSck4OAeHyCjekGdLYf4uZPOx16xxTy4N gkokmjaMtD3rnpBb6hBx1X8f+6i3jHRg/2QAjgJxNKpYQtiVxlGsPvJhHK85sTpclgJ/LXi7kVnfk TTqOvIGmIpKlJfjQb/Q9S07oBjmnIgyy6CLHJRLIJqvpMipWji9uI0gSiSOTk3BMklkKS+OUgM7cT 1928k6BgwBB0eTOeqrNbI45o5+dM16hwLa/ARuz3jMMaYBSM79eVkTM0tlI4Lrhg2WtZIfBXiYa55 u6oJjWcqE5eyFm2JVr9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8R2l-00FoPU-Rk; Thu, 22 Dec 2022 19:15:52 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8R2G-00FoAe-6V; Thu, 22 Dec 2022 19:15:21 +0000 Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:d076:4da6:b729:f032:ed0a]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 42193890; Thu, 22 Dec 2022 20:15:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671736518; bh=6uYCqoGzATUwi33s8qwvH2BR201HZIZgkpsRD/uga5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ngtNY6j8Irf0q8DYlJnrYOOiK2jqTxM+kAzkuHj3rAgfw3ZJABT0ddX64ZpV3JJ1P NM9rWtLFodm8PIs2zQIisV8Iswy9mhy0JyIS0qXs3yVy1vdnZ5zXj2speGm+fyQJju VmkFWDDPv1gYfAVBZ0PMD60gGTEPetazrd/wcVY0= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Greg Kroah-Hartman , Adrien Thierry , Stefan Wahren , Florian Fainelli , Dan Carpenter , Nicolas Saenz Julienne , Phil Elwell , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v2 1/4] staging: vc04_services: Stop leaking platform device on error path Date: Fri, 23 Dec 2022 00:44:57 +0530 Message-Id: <20221222191500.515795-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221222191500.515795-1-umang.jain@ideasonboard.com> References: <20221222191500.515795-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221222_111520_423831_63758A7F X-CRM114-Status: UNSURE ( 9.72 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org vchiq driver registers the child platform devices in vchiq_register_child(). However, in the registration error code path, currently the driver is leaking platform devices by not destroying the return platform device. Plug this leak using platform_device_put() as mentioned in the documentation for platform_device_register(). Signed-off-by: Umang Jain --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index dc33490ba7fb..fc7ea7ba97b2 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1779,6 +1779,7 @@ vchiq_register_child(struct platform_device *pdev, const char *name) child = platform_device_register_full(&pdevinfo); if (IS_ERR(child)) { dev_warn(&pdev->dev, "%s not registered\n", name); + platform_device_put(child); child = NULL; } From patchwork Thu Dec 22 19:14:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13080251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3688C4332F for ; Thu, 22 Dec 2022 19:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RX42qjvMrl5gaazbbP/UOaU1sOgY8JV3Zfa6It5GMVU=; b=X7XrVtyKzkgsVW PS110yjsJ1zk4poRI5eeL8INE9I+bAHwg9LswObyuMQuS/CNuUjYzWP2MRZd5AvX3AQyPbKdC4Y7H PIEHXc5Ku8huHo5EpAFeSVnl77SsuuPWA+AIy9adxBTzzot/ts13XW/wXgRTbSwn3tkyG8APCaPeO 9y6foGbaAAVC+FQrBDkJZ2SGsKCXBgSztD5OFDKGX3u98OimEVrybDY/wxBaT4DnAJlMdzdrxzMdL noKn9cRFrAwb30x5Uyx5ujXjGbfpSJO57Q6gB/nIAxfZo6sezqb91J/9A2L4ZEE/yOzSZP34xBP8g rQ2LNy0vj1hNzPSkCfzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8R2y-00FoV3-Vw; Thu, 22 Dec 2022 19:16:05 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8R2M-00FoDx-6b; Thu, 22 Dec 2022 19:15:27 +0000 Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:d076:4da6:b729:f032:ed0a]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 49B6E89F; Thu, 22 Dec 2022 20:15:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671736524; bh=ZVkLGUNPuXKW9TCCk2CvFJa796G8cO0C9Y1XT9ye/iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e4std9e1LWG4Z+fh4/ZeD7HFUx10A7JSRR2HuymdcZYROvVfrwjbticYFHytoJJnp vNfowK277ndSn0PNfBxt3BOKF4jjGA0NIPpvfXar9wSqXQpowknm4mdOB1HwIqU7n/ 8Bn5vQv1ia7ly4RIZLI2fiu0hwoHCIO/Q+CsRF3w= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Greg Kroah-Hartman , Adrien Thierry , Stefan Wahren , Florian Fainelli , Dan Carpenter , Nicolas Saenz Julienne , Phil Elwell , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v2 2/4] staging: vchiq: Do not assign default dma_mask explicitly Date: Fri, 23 Dec 2022 00:44:58 +0530 Message-Id: <20221222191500.515795-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221222191500.515795-1-umang.jain@ideasonboard.com> References: <20221222191500.515795-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221222_111526_429923_B709DCCB X-CRM114-Status: UNSURE ( 9.35 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The vchiq driver assigns DMA_BIT_MASK(32) to the child platform devices it registers. By default, platform_device_register_* helpers assign DMA_BIT_MASK(32) dma_mask to the platform devices it registers. It is unnecessary to define it explicitly in struct platform_device_info hence, drop this explicit dma_mask assignment. This will help simplying the vchiq_register_child() going forwards. No functional changes intended in this patch. Signed-off-by: Umang Jain --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index fc7ea7ba97b2..3c4766375daa 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1774,7 +1774,6 @@ vchiq_register_child(struct platform_device *pdev, const char *name) pdevinfo.parent = &pdev->dev; pdevinfo.name = name; pdevinfo.id = PLATFORM_DEVID_NONE; - pdevinfo.dma_mask = DMA_BIT_MASK(32); child = platform_device_register_full(&pdevinfo); if (IS_ERR(child)) { From patchwork Thu Dec 22 19:14:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13080252 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41B21C4332F for ; Thu, 22 Dec 2022 19:17:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hgwi9CsUKa78HZMhW7a51eKtPJp3qcJInu05lK3OR58=; b=IlGpa/lo0UP/S+ 5y3sMZ4BnQRuvSayh0z1OWNKMDAfU1HJp0m5DpvHkzjH5Ovb0hIBsywzMUwJmIJHb8NxNXaX2DKnn SCwL7KgxLYzNhxXDBYs3LvhHNnCaCuS2Ro4OypyL/IjosmyXDfVGgnzcTOzt+i7w3zSHOVeCEVYiP mWtw2IutUctdC5AzyZnedPgkwdMkdKJYPOJi+TR0tcPu4d+tYZA9gxKJai98rsYhziINxsnj4xlG+ uTE8KLva5PTc+G/LHt9wcCQAKLfRbO51mevPR/etIaoQ9GAaygeLxy8Lahw3vu1g0tbAoQyThCZvu 3Jxhm+Z3RKtb2Txxdxdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8R3B-00FoYX-3l; Thu, 22 Dec 2022 19:16:17 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8R2R-00FoGt-V1; Thu, 22 Dec 2022 19:15:33 +0000 Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:d076:4da6:b729:f032:ed0a]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 56073471; Thu, 22 Dec 2022 20:15:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671736530; bh=bqvMP11pqYGYAC5IZOywqjG3I9GF/0iY9Gg7h2H8QBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tl8lcCTtBojKEuNJ8j+cnCa7NsqslZ/z3PEjsWPTzSUny88AVie/m6bS1/CJfboa4 yhk8NKmdqAN/+nuzHtsQhOui3SeFIdyhWigmoReRGlfp5e52gmnIvExLyXf5cvh27u m+01+akz6BoJrrgkRVYJEjxXAwz10DXh4qkfN1qU= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Greg Kroah-Hartman , Adrien Thierry , Stefan Wahren , Florian Fainelli , Dan Carpenter , Nicolas Saenz Julienne , Phil Elwell , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v2 3/4] staging: vchiq: Simplify platform devices registration Date: Fri, 23 Dec 2022 00:44:59 +0530 Message-Id: <20221222191500.515795-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221222191500.515795-1-umang.jain@ideasonboard.com> References: <20221222191500.515795-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221222_111532_166583_75DF1859 X-CRM114-Status: GOOD ( 10.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The child platform devices registered by the vchiq driver currently populates a struct platform_device_info with a name and parent device and uses platform_device_register_full() to its registration. It can be simplified by using platform_device_register_data() directly (which encapsulates populating the platform_device_info struct and a platform_device_register_full() call in itself). Signed-off-by: Umang Jain --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 3c4766375daa..ba34e4d603d4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1766,16 +1766,10 @@ MODULE_DEVICE_TABLE(of, vchiq_of_match); static struct platform_device * vchiq_register_child(struct platform_device *pdev, const char *name) { - struct platform_device_info pdevinfo; struct platform_device *child; - memset(&pdevinfo, 0, sizeof(pdevinfo)); - - pdevinfo.parent = &pdev->dev; - pdevinfo.name = name; - pdevinfo.id = PLATFORM_DEVID_NONE; - - child = platform_device_register_full(&pdevinfo); + child = platform_device_register_data(&pdev->dev, name, PLATFORM_DEVID_NONE, + NULL, 0); if (IS_ERR(child)) { dev_warn(&pdev->dev, "%s not registered\n", name); platform_device_put(child); From patchwork Thu Dec 22 19:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13080253 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83274C001B2 for ; Thu, 22 Dec 2022 19:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1WkJ0jza1V+JPopJ3zSK09xxWgNhvyYc0IG51bUJ1LU=; b=O7JYNtpKG9L1CM sjtqy1+5yJnZ59xnCp4nEDMHXxK8uxQY+2C34Rk0GwvIkaMAn/SjcDPe1u7b2t6OzEYzH4Ajpcj9i ss4Fu7SH/LWvN0UhJ/lazW6i0Vcsdqst2urlMmKU+RSYthsOpxAgFldHj1sUd/kwvuIdACH25H+F+ HSzKOpF7Tp9o64pfj65JzaHGMDNYZepX5xq+mdy6GQwes4kk9X59FMdiig1V0gjeRLMPL3DZCnVWB ft5mm4THs5d4VqVcH9KFSqz3Hqbq/krxwPWFOB0ZHRcrA8eFCqe/sncGAqnNOLXfvmWBfCDyhPuk2 vFCso6GollCOv0gK49PA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8R3T-00FoiI-9d; Thu, 22 Dec 2022 19:16:35 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8R2X-00FoJO-Qb; Thu, 22 Dec 2022 19:15:39 +0000 Received: from umang.jainideasonboard.com (unknown [IPv6:2401:4900:1f3f:d076:4da6:b729:f032:ed0a]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5558AD1D; Thu, 22 Dec 2022 20:15:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671736536; bh=UfLBAATkzD9U4stHiW/1mzjiTeAr0HmtQX04bnFhvF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aITi7TmA0EOroVzsJ9FqxJ9gy86SyUVUC++vZHXksel5bCRccVmDOWyJ1AKMjRP6l eWO0vHChMq/M/Zu1NQDBBqlHF54SlBUCc0nG7AFaTKZPdlgPte+Kr2UxaiYctcWfkh Dv/0GvVDWBScvp380GaZb/IE9nRaPY5XoK7Dch6s= From: Umang Jain To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Cc: Greg Kroah-Hartman , Adrien Thierry , Stefan Wahren , Florian Fainelli , Dan Carpenter , Nicolas Saenz Julienne , Phil Elwell , Dave Stevenson , Kieran Bingham , Laurent Pinchart , Umang Jain Subject: [PATCH v2 4/4] staging: vchiq: Rework child platform device (un)register Date: Fri, 23 Dec 2022 00:45:00 +0530 Message-Id: <20221222191500.515795-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221222191500.515795-1-umang.jain@ideasonboard.com> References: <20221222191500.515795-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221222_111538_029842_CE4D15D8 X-CRM114-Status: GOOD ( 15.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch reworks how the child platform devices are (un)registered by the vchiq driver. It drops the global references to the child platform devices thereby reducing the scope of platform device access to probe() function only. It does so, by maintaining an array of platform device names and registering each of them through vchiq_register_child(). In addition to that, any new child platform device can be (un)regsitered easily by just appending to the child platform devices' array. For platform device unregisterion, device_for_each_child() helper is used to call vchiq_unregister_child() on each of the child platform device of vchiq driver. This is part of an effort to address TODO item "Get rid of all non essential global structures and create a proper per device structure" Signed-off-by: Umang Jain --- .../interface/vchiq_arm/vchiq_arm.c | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index ba34e4d603d4..d04dbea833ac 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -65,9 +65,6 @@ int vchiq_susp_log_level = VCHIQ_LOG_ERROR; DEFINE_SPINLOCK(msg_queue_spinlock); struct vchiq_state g_state; -static struct platform_device *bcm2835_camera; -static struct platform_device *bcm2835_audio; - struct vchiq_drvdata { const unsigned int cache_line_size; struct rpi_firmware *fw; @@ -1763,7 +1760,7 @@ static const struct of_device_id vchiq_of_match[] = { }; MODULE_DEVICE_TABLE(of, vchiq_of_match); -static struct platform_device * +static void vchiq_register_child(struct platform_device *pdev, const char *name) { struct platform_device *child; @@ -1773,10 +1770,18 @@ vchiq_register_child(struct platform_device *pdev, const char *name) if (IS_ERR(child)) { dev_warn(&pdev->dev, "%s not registered\n", name); platform_device_put(child); - child = NULL; } +} - return child; +static int +vchiq_unregister_child(struct device *dev, void *data) +{ + struct platform_device *pdev; + + pdev = to_platform_device(dev); + platform_device_unregister(pdev); + + return 0; } static int vchiq_probe(struct platform_device *pdev) @@ -1784,6 +1789,10 @@ static int vchiq_probe(struct platform_device *pdev) struct device_node *fw_node; const struct of_device_id *of_id; struct vchiq_drvdata *drvdata; + const char *const vchiq_devices[] = { + "bcm2835_audio", + "bcm2835-camera", + }; int err; of_id = of_match_node(vchiq_of_match, pdev->dev.of_node); @@ -1826,8 +1835,8 @@ static int vchiq_probe(struct platform_device *pdev) goto error_exit; } - bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); - bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio"); + for (unsigned int i = 0; i < ARRAY_SIZE(vchiq_devices); i++) + vchiq_register_child(pdev, vchiq_devices[i]); return 0; @@ -1839,8 +1848,7 @@ static int vchiq_probe(struct platform_device *pdev) static int vchiq_remove(struct platform_device *pdev) { - platform_device_unregister(bcm2835_audio); - platform_device_unregister(bcm2835_camera); + device_for_each_child(&pdev->dev, NULL, vchiq_unregister_child); vchiq_debugfs_deinit(); vchiq_deregister_chrdev();