From nobody Sun Feb 8 21:37:10 2026 Received: from smtp-190b.mail.infomaniak.ch (smtp-190b.mail.infomaniak.ch [185.125.25.11]) (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 50AAA32D440 for ; Mon, 15 Dec 2025 17:08:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765818510; cv=none; b=gZPG0tAQ3u3FxfrPcFISAgNHb6PfMr8Lv5kEMiC0bSYLPUwntT9DyMA35Jge/aPctPqCJZI7svg2EwuUSRPWlzhv6pR/P7+mj9Q593CtIIYmlkt/r4VGFInZA7i2a0hA0LrHR7jLRsrkPYitwLPAATvm3yfB21gCeZI2flnwb8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765818510; c=relaxed/simple; bh=E/ArJhonsgEzCCHpKlE7Hq4mLFzgmU72OVHUEuay7fA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=ksBH7gHEP5XZdzjWzjus9tkGcCRrZOjbKOBplrjMz1WVe1HugZmbofBSzWxXQyiQCfxmaqy1hOd9K+CireYY9hFPYRxOPuJeLGIavcADrVULFoO3xNIMbj7yqhHmbuInP6wwFkWAUL/7rnQrIhvEkVNaIVl5BlCHf3AxYqrwj1c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0leil.net; spf=pass smtp.mailfrom=0leil.net; arc=none smtp.client-ip=185.125.25.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0leil.net Received: from smtp-4-0001.mail.infomaniak.ch (smtp-4-0001.mail.infomaniak.ch [10.7.10.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4dVRN82ltkzPZS; Mon, 15 Dec 2025 18:08:24 +0100 (CET) Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4dVRN61zzfzF7B; Mon, 15 Dec 2025 18:08:22 +0100 (CET) From: Quentin Schulz Date: Mon, 15 Dec 2025 18:07:56 +0100 Subject: [PATCH] accel/rocket: factor out code with find_core_for_dev in rocket_remove Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251215-rocket-reuse-find-core-v1-1-be86a1d2734c@cherry.de> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/x3MQQqDMBBG4avIrDtgQkXxKsWFTn51EJIysVIQ7 25w+S3eOynDFJn66iTDoVlTLHCvimQd4wLWUEy+9o3zrmFLsmFnwy+DZ42BJRm4g0wtgn/LOFG Jv4ZZ/8/4M1zXDRIOJDFoAAAA X-Change-ID: 20251215-rocket-reuse-find-core-8ecb7ed24cab To: Tomeu Vizoso , Oded Gabbay Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Quentin Schulz X-Mailer: b4 0.14.3 X-Infomaniak-Routing: alpha From: Quentin Schulz There already is a function to return the offset of the core for a given struct device, so let's reuse that function instead of reimplementing the same logic. There's one change in behavior when a struct device is passed which doesn't match any core's. Before, we would continue through rocket_remove() but now we exit early, to match what other callers of find_core_for_dev() (rocket_device_runtime_resume/suspend()) are doing. This however should never happen. Aside from that, no intended change in behavior. Signed-off-by: Quentin Schulz --- drivers/accel/rocket/rocket_drv.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocke= t_drv.c index 5c0b63f0a8f00..28bf6c602f802 100644 --- a/drivers/accel/rocket/rocket_drv.c +++ b/drivers/accel/rocket/rocket_drv.c @@ -180,17 +180,18 @@ static int rocket_probe(struct platform_device *pdev) return rocket_core_init(&rdev->cores[core]); } =20 +static int find_core_for_dev(struct device *dev); + static void rocket_remove(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; + int core =3D find_core_for_dev(dev); =20 - for (unsigned int core =3D 0; core < rdev->num_cores; core++) { - if (rdev->cores[core].dev =3D=3D dev) { - rocket_core_fini(&rdev->cores[core]); - rdev->num_cores--; - break; - } - } + if (core < 0) + return; + + rocket_core_fini(&rdev->cores[core]); + rdev->num_cores--; =20 if (rdev->num_cores =3D=3D 0) { /* Last core removed, deinitialize DRM device. */ --- base-commit: a619746d25c8adafe294777cc98c47a09759b3ed change-id: 20251215-rocket-reuse-find-core-8ecb7ed24cab Best regards, --=20 Quentin Schulz