Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

accel/rocket: factor out code with find_core_for_dev in rocket_remove

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 <quentin.schulz@cherry.de>
Reviewed-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Signed-off-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Link: https://patch.msgid.link/20251215-rocket-reuse-find-core-v1-1-be86a1d2734c@cherry.de

authored by

Quentin Schulz and committed by
Tomeu Vizoso
57d8ae15 34f4495a

+8 -7
+8 -7
drivers/accel/rocket/rocket_drv.c
··· 193 193 return ret; 194 194 } 195 195 196 + static int find_core_for_dev(struct device *dev); 197 + 196 198 static void rocket_remove(struct platform_device *pdev) 197 199 { 198 200 struct device *dev = &pdev->dev; 201 + int core = find_core_for_dev(dev); 199 202 200 - for (unsigned int core = 0; core < rdev->num_cores; core++) { 201 - if (rdev->cores[core].dev == dev) { 202 - rocket_core_fini(&rdev->cores[core]); 203 - rdev->num_cores--; 204 - break; 205 - } 206 - } 203 + if (core < 0) 204 + return; 205 + 206 + rocket_core_fini(&rdev->cores[core]); 207 + rdev->num_cores--; 207 208 208 209 if (rdev->num_cores == 0) { 209 210 /* Last core removed, deinitialize DRM device. */