Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/xe: use devm_add_action_or_reset() helper
@ 2024-09-11 10:22 He Lugang
  2024-09-13 21:07 ` ✓ CI.Patch_applied: success for " Patchwork
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: He Lugang @ 2024-09-11 10:22 UTC (permalink / raw)
  To: lucas.demarchi, thomas.hellstrom, rodrigo.vivi, maarten.lankhorst,
	mripard, tzimmermann, airlied, simona
  Cc: intel-xe, dri-devel, He Lugang

Use devm_add_action_or_reset() to release resources in case of failure,
because the cleanup function will be automatically called.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: He Lugang <helugang@uniontech.com>
---
v2:move devm_add_action_or_reset after sysfs_create_files to avoid removing
the sysfs files that hadn't been created.
---
 drivers/gpu/drm/xe/xe_gt_freq.c  | 4 ++--
 drivers/gpu/drm/xe/xe_gt_sysfs.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gt_freq.c b/drivers/gpu/drm/xe/xe_gt_freq.c
index 68a5778b4319..ab76973f3e1e 100644
--- a/drivers/gpu/drm/xe/xe_gt_freq.c
+++ b/drivers/gpu/drm/xe/xe_gt_freq.c
@@ -237,11 +237,11 @@ int xe_gt_freq_init(struct xe_gt *gt)
 	if (!gt->freq)
 		return -ENOMEM;
 
-	err = devm_add_action(xe->drm.dev, freq_fini, gt->freq);
+	err = sysfs_create_files(gt->freq, freq_attrs);
 	if (err)
 		return err;
 
-	err = sysfs_create_files(gt->freq, freq_attrs);
+	err = devm_add_action_or_reset(xe->drm.dev, freq_fini, gt->freq);
 	if (err)
 		return err;
 
diff --git a/drivers/gpu/drm/xe/xe_gt_sysfs.c b/drivers/gpu/drm/xe/xe_gt_sysfs.c
index a05c3699e8b9..ec2b8246204b 100644
--- a/drivers/gpu/drm/xe/xe_gt_sysfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_sysfs.c
@@ -51,5 +51,5 @@ int xe_gt_sysfs_init(struct xe_gt *gt)
 
 	gt->sysfs = &kg->base;
 
-	return devm_add_action(xe->drm.dev, gt_sysfs_fini, gt);
+	return devm_add_action_or_reset(xe->drm.dev, gt_sysfs_fini, gt);
 }
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-09-16 16:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-11 10:22 [PATCH v2] drm/xe: use devm_add_action_or_reset() helper He Lugang
2024-09-13 21:07 ` ✓ CI.Patch_applied: success for " Patchwork
2024-09-13 21:08 ` ✓ CI.checkpatch: " Patchwork
2024-09-13 21:09 ` ✓ CI.KUnit: " Patchwork
2024-09-13 21:20 ` ✓ CI.Build: " Patchwork
2024-09-13 21:23 ` ✓ CI.Hooks: " Patchwork
2024-09-13 21:24 ` ✓ CI.checksparse: " Patchwork
2024-09-13 21:42 ` ✓ CI.BAT: " Patchwork
2024-09-14 19:10 ` ✗ CI.FULL: failure " Patchwork
2024-09-16 16:38 ` [PATCH v2] " Rodrigo Vivi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox