Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1445357lqb; Sun, 26 May 2024 01:01:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTuY3yrrruWPDIifdOzd2XDeswusJ1M9Gh5zZTfycci08m6A2m8L7DEwFgN4NMLYU+KLhoM8AubkB73r9odd9vp2ZHWu4F+as6TJBtNg== X-Google-Smtp-Source: AGHT+IFT+w0dh2QPf2lUtu5gAxaH02oeFgaLJHnQzl7i/QZpiiaoSk5+91pJNgu3YhPoD1Lhosmh X-Received: by 2002:a05:6a21:778c:b0:1ac:e379:52fd with SMTP id adf61e73a8af0-1b212cff407mr10232829637.14.1716710507600; Sun, 26 May 2024 01:01:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716710507; cv=pass; d=google.com; s=arc-20160816; b=YF40EnGO497Ti7X4zsABT+rrLDWX74HW8+SigXhwzHqxPJVzXbu3ZpGbp1ohEpqjcK b+Jrf9/IJw9CX47uITMG8QfXOj3kZJ86ZhK6ttHBYQQRBQ4ssFy0pAOBBYpvutqr/ALE BFe4xIV2lIQCmaqW7IkJ7Sn7p5cDRukQj6rE4LyJyZvQWlA0sVW9tPO5EIvz/x2gczvx 1Et+CWABvYYYJlxwkO+wn/Wk3opn5W8grPeplHpAnRvuSr0qoD0vnAvy7shtdNP8cmQu S14mD1VSFSXW8EvlJ0DiE143jsrYJQwvAmXo34QlB3HwBW70+5/i5bRwxulNd82kEl6Q WzOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=hCZf5B7Epe9+DdIH1wmQifOFMMbDVPfjY6bD0iQQskA=; fh=YW5smIVMRLpbWnLRjvhSpU8t4PLD0BKjznNUr9wl3Ng=; b=UixXqz5ygPQToOBFXPh1Wt6oglyjE1tUzy8EMzv/8AClqV/49UB/Oa1Oq4rj0BCvny auh+IQkZTB11qOeMxDBVdeFsnFenViAq1OkdGCA7/+ZANJSZS0Y9fkiAbn1ytvZVflCI Ot5w2dBOr5DWPAQ2GHYfScTF2bzn+5/O6KrPl/kSUeM8HgDTWli40HJrJkDz/6SqnP4G x6/3aJqzHTY4H5NZEtCcLjdSPZoErDIhwBKIcSjn4KpSoKHCo4p1r4clRLBqTy/J3F17 g4ip1mw/T+6gUOsgRmN7hoKRT+I39LzQd2McjwrTQ2mfJm4C+E571/wyqp1Wbz+19hCQ lueA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=HU6QDevo; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-189602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f8fd9e35f4si4190940b3a.365.2024.05.26.01.01.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 01:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=HU6QDevo; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-189602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C94572811BF for ; Sun, 26 May 2024 08:01:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1B478F62; Sun, 26 May 2024 08:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="HU6QDevo" Received: from msa.smtpout.orange.fr (msa-208.smtpout.orange.fr [193.252.23.208]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FD767462; Sun, 26 May 2024 08:01:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.252.23.208 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716710490; cv=none; b=UE4LRd0kFiy1XXOFVC5MeEIz7bLW9yUgHGR2aTMbSEQRCKZrG/zIcfbgd1ge/E7Y800FvP7JXg38QZdMa5u1zytVmKbDtjCSnYf/B/u/asZo1TSANTyVGNfACJrM10SHZPtQyVcTk/jSM7DqczoOvvBlT4+54lUO7qlTEqYGU/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716710490; c=relaxed/simple; bh=YceaYbK69STYG1+34LgP3lcfEJ/qdP71K3CN/adN8Uc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DoiZPQuizG/2xI6UahJ3H34H/usQwMA19ItBGz8jv3uL2Uf8RogQTGtdyVFHiAmfX8LpSopRgcStIC+3gSy3IpNorp7/ZjH+o3ISwsA53dP5UXgMcjo0/t3pk0lGQUagp6hkjmoP/G6iVYtjMFN1rmIcaRuXC0tJ9GZJc+Oceuo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=HU6QDevo; arc=none smtp.client-ip=193.252.23.208 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from fedora.home ([86.243.17.157]) by smtp.orange.fr with ESMTPA id B8nVshp7epUD1B8nVsPLZD; Sun, 26 May 2024 10:00:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1716710408; bh=hCZf5B7Epe9+DdIH1wmQifOFMMbDVPfjY6bD0iQQskA=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=HU6QDevomlXJ4SNuMksWg9zoDyFOIVAe1o5eMzgLYS8SIbuKQ06Hysame496qhyxD ts1E1A29UuIAbP06wMyoiAdVylOFEZJWTkD3QuWsWjlHGK/9PuxDn3QoWvyG7VTzf1 n1K68OInv4vpPcy+lNWaq011Je5+eFNQT4zMAOz8MlzUASHS1wYOuQAI6BuMl6MeOB t6QlYgUiT7m/ezXBs1cq8CjXbopiiezH4LMTaAiCiqQeTKmiXAP1M71gU3JXav2K2q Vx4+2Dt+m+cKxgudkYrinv9NhSH7LtWbdYaDqqrzaxPg0bRZGbuwBs9hR8xxIH3lWV sBLRh7uWF62hA== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 26 May 2024 10:00:08 +0200 X-ME-IP: 86.243.17.157 From: Christophe JAILLET To: sakari.ailus@linux.intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, hdegoede@redhat.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2 1/2] media: intel/ipu6: Move isys_remove() close to isys_probe() Date: Sun, 26 May 2024 09:59:56 +0200 Message-ID: <15a056198775689cb533a7b0ea7e100559a2465d.1716710255.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In preparation to fixing a leak in isys_probe(), move isys_remove(). The fix will introduce a new function that will also be called from isys_remove(). The code needs to be rearranged to avoid a forward declaration. Having the .remove function close to the .probe function is also more standard. Signed-off-by: Christophe JAILLET --- Changes in v2: - new patch --- drivers/media/pci/intel/ipu6/ipu6-isys.c | 70 ++++++++++++------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys.c b/drivers/media/pci/intel/ipu6/ipu6-isys.c index 5992138c7290..7ce2047a09b5 100644 --- a/drivers/media/pci/intel/ipu6/ipu6-isys.c +++ b/drivers/media/pci/intel/ipu6/ipu6-isys.c @@ -925,41 +925,6 @@ static const struct dev_pm_ops isys_pm_ops = { .resume = isys_resume, }; -static void isys_remove(struct auxiliary_device *auxdev) -{ - struct ipu6_bus_device *adev = auxdev_to_adev(auxdev); - struct ipu6_isys *isys = dev_get_drvdata(&auxdev->dev); - struct ipu6_device *isp = adev->isp; - struct isys_fw_msgs *fwmsg, *safe; - unsigned int i; - - list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head) - dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs), - fwmsg, fwmsg->dma_addr, 0); - - list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist_fw, head) - dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs), - fwmsg, fwmsg->dma_addr, 0); - - isys_unregister_devices(isys); - isys_notifier_cleanup(isys); - - cpu_latency_qos_remove_request(&isys->pm_qos); - - if (!isp->secure_mode) { - ipu6_cpd_free_pkg_dir(adev); - ipu6_buttress_unmap_fw_image(adev, &adev->fw_sgt); - release_firmware(adev->fw); - } - - for (i = 0; i < IPU6_ISYS_MAX_STREAMS; i++) - mutex_destroy(&isys->streams[i].mutex); - - isys_iwake_watermark_cleanup(isys); - mutex_destroy(&isys->stream_mutex); - mutex_destroy(&isys->mutex); -} - static int alloc_fw_msg_bufs(struct ipu6_isys *isys, int amount) { struct device *dev = &isys->adev->auxdev.dev; @@ -1167,6 +1132,41 @@ static int isys_probe(struct auxiliary_device *auxdev, return ret; } +static void isys_remove(struct auxiliary_device *auxdev) +{ + struct ipu6_bus_device *adev = auxdev_to_adev(auxdev); + struct ipu6_isys *isys = dev_get_drvdata(&auxdev->dev); + struct ipu6_device *isp = adev->isp; + struct isys_fw_msgs *fwmsg, *safe; + unsigned int i; + + list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head) + dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs), + fwmsg, fwmsg->dma_addr, 0); + + list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist_fw, head) + dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs), + fwmsg, fwmsg->dma_addr, 0); + + isys_unregister_devices(isys); + isys_notifier_cleanup(isys); + + cpu_latency_qos_remove_request(&isys->pm_qos); + + if (!isp->secure_mode) { + ipu6_cpd_free_pkg_dir(adev); + ipu6_buttress_unmap_fw_image(adev, &adev->fw_sgt); + release_firmware(adev->fw); + } + + for (i = 0; i < IPU6_ISYS_MAX_STREAMS; i++) + mutex_destroy(&isys->streams[i].mutex); + + isys_iwake_watermark_cleanup(isys); + mutex_destroy(&isys->stream_mutex); + mutex_destroy(&isys->mutex); +} + struct fwmsg { int type; char *msg; -- 2.45.1