Skip to contentSkip to conversation

drm/i915/gem: Use list_entry to access list members

PATCH Superseded Guenter Roeck 2 participants 3 messages May 23, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/gem: Use list_entry to access list members

Use list_entry() instead of container_of() to access list members. Also drop unnecessary and misleading NULL checks on the result of list_entry().

---
 drivers/gpu/drm/i915/gvt/dmabuf.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/gvt/dmabuf.c +5 -12
index d4f883f35b95..4241af5074a9 100644
@@ -148,7 +148,7 @@ static void dmabuf_gem_object_free(struct kref *kref)
 
 	if (vgpu && vgpu->active && !list_empty(&vgpu->dmabuf_obj_list_head)) {
 		list_for_each(pos, &vgpu->dmabuf_obj_list_head) {
-			dmabuf_obj = container_of(pos,
+			dmabuf_obj = list_entry(pos,
 					struct intel_vgpu_dmabuf_obj, list);
 			if (dmabuf_obj == obj) {
 				list_del(pos);
@@ -357,10 +357,8 @@ pick_dmabuf_by_info(struct intel_vgpu *vgpu,
 	struct intel_vgpu_dmabuf_obj *ret = NULL;
 
 	list_for_each(pos, &vgpu->dmabuf_obj_list_head) {
-		dmabuf_obj = container_of(pos, struct intel_vgpu_dmabuf_obj,
-						list);
-		if ((dmabuf_obj == NULL) ||
-		    (dmabuf_obj->info == NULL))
+		dmabuf_obj = list_entry(pos, struct intel_vgpu_dmabuf_obj, list);
+		if (dmabuf_obj->info == NULL)
 			continue;
 
 		fb_info = (struct intel_vgpu_fb_info *)dmabuf_obj->info;
@@ -387,11 +385,7 @@ pick_dmabuf_by_num(struct intel_vgpu *vgpu, u32 id)
 	struct intel_vgpu_dmabuf_obj *ret = NULL;
 
 	list_for_each(pos, &vgpu->dmabuf_obj_list_head) {
-		dmabuf_obj = container_of(pos, struct intel_vgpu_dmabuf_obj,
-						list);
-		if (!dmabuf_obj)
-			continue;
-
+		dmabuf_obj = list_entry(pos, struct intel_vgpu_dmabuf_obj, list);
 		if (dmabuf_obj->dmabuf_id == id) {
 			ret = dmabuf_obj;
 			break;
@@ -600,8 +594,7 @@ void intel_vgpu_dmabuf_cleanup(struct intel_vgpu *vgpu)
 
 	mutex_lock(&vgpu->dmabuf_lock);
 	list_for_each_safe(pos, n, &vgpu->dmabuf_obj_list_head) {
-		dmabuf_obj = container_of(pos, struct intel_vgpu_dmabuf_obj,
-						list);
+		dmabuf_obj = list_entry(pos, struct intel_vgpu_dmabuf_obj, list);
 		dmabuf_obj->vgpu = NULL;
 
 		idr_remove(&vgpu->object_idr, dmabuf_obj->dmabuf_id);
Signature · 6 lines
2.25.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gem: Use list_entry to access list members

== Series Details ==

== Series Details ==

Series: drm/i915/gem: Use list_entry to access list members
URL : https://patchwork.freedesktop.org/series/90449/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
ea9ca76d0bd2 drm/i915/gem: Use list_entry to access list members
-:22: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#22: FILE: drivers/gpu/drm/i915/gvt/dmabuf.c:152:
+			dmabuf_obj = list_entry(pos,
 					struct intel_vgpu_dmabuf_obj, list);

-:34: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!dmabuf_obj->info" #34: FILE: drivers/gpu/drm/i915/gvt/dmabuf.c:361:
+ if (dmabuf_obj->info == NULL)

total: 0 errors, 0 warnings, 2 checks, 41 lines checked

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/gem: Use list_entry to access list members

In reply to Guenter Roeck
== Series Details ==

== Series Details ==

Series: drm/i915/gem: Use list_entry to access list members
URL : https://patchwork.freedesktop.org/series/90449/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_10123 -> Patchwork_20176
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/index.html

Known issues
------------

Here are the changes found in Patchwork_20176 that come from known issues:

### IGT changes ###

#### Warnings ####

* igt@i915_selftest@live@execlists:
- fi-cfl-8109u: [DMESG-FAIL][1] ([i915#3462]) -> [INCOMPLETE][2] ([i915#3462])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-cfl-8109u/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-cfl-8109u/igt@i915_selftest@[email protected]
- fi-icl-u2: [INCOMPLETE][3] ([i915#2782] / [i915#3462]) -> [DMESG-FAIL][4] ([i915#3462])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-icl-u2/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-icl-u2/igt@i915_selftest@[email protected]
- fi-bsw-kefka: [DMESG-FAIL][5] ([i915#3462]) -> [INCOMPLETE][6] ([i915#2782] / [i915#2940] / [i915#3462])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-bsw-kefka/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-bsw-kefka/igt@i915_selftest@[email protected]

* igt@runner@aborted:
- fi-bsw-kefka: [FAIL][7] ([i915#1436]) -> [FAIL][8] ([fdo#109271] / [i915#1436])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-bsw-kefka/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-bsw-kefka/igt@[email protected]
- fi-skl-6600u: [FAIL][9] ([i915#1436] / [i915#3363]) -> [FAIL][10] ([i915#1436] / [i915#2426] / [i915#3363])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-skl-6600u/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-skl-6600u/igt@[email protected]
- fi-cfl-8109u: [FAIL][11] ([i915#2426] / [i915#3363]) -> [FAIL][12] ([i915#3363])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-cfl-8109u/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-cfl-8109u/igt@[email protected]
- fi-icl-u2: [FAIL][13] ([i915#2782] / [i915#3363]) -> [FAIL][14] ([i915#2426] / [i915#2782] / [i915#3363])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-icl-u2/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-icl-u2/igt@[email protected]
- fi-glk-dsi: [FAIL][15] ([i915#3363] / [k.org#202321]) -> [FAIL][16] ([i915#2426] / [i915#3363] / [k.org#202321])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-glk-dsi/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-glk-dsi/igt@[email protected]
- fi-bsw-nick: [FAIL][17] ([i915#1436]) -> [FAIL][18] ([fdo#109271] / [i915#1436])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-bsw-nick/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-bsw-nick/igt@[email protected]
- fi-kbl-soraka: [FAIL][19] ([i915#1436] / [i915#3363]) -> [FAIL][20] ([i915#1436] / [i915#2426] / [i915#3363])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-kbl-soraka/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-kbl-soraka/igt@[email protected]
- fi-kbl-guc: [FAIL][21] ([i915#1436] / [i915#3363]) -> [FAIL][22] ([i915#1436] / [i915#2426] / [i915#3363])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10123/fi-kbl-guc/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/fi-kbl-guc/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
[i915#2426]: https://gitlab.freedesktop.org/drm/intel/issues/2426
[i915#2782]: https://gitlab.freedesktop.org/drm/intel/issues/2782
[i915#2940]: https://gitlab.freedesktop.org/drm/intel/issues/2940
[i915#3303]: https://gitlab.freedesktop.org/drm/intel/issues/3303
[i915#3363]: https://gitlab.freedesktop.org/drm/intel/issues/3363
[i915#3462]: https://gitlab.freedesktop.org/drm/intel/issues/3462
[k.org#202321]: https://bugzilla.kernel.org/show_bug.cgi?id=202321

Participating hosts (42 -> 39)
------------------------------

Missing (3): fi-bsw-cyan fi-bdw-samus fi-hsw-4200u

Build changes
-------------

* Linux: CI_DRM_10123 -> Patchwork_20176

CI-20190529: 20190529
CI_DRM_10123: 6b2a86ddd31f336e2d0884889bd642650f1d805f @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6092: d87087c321da07035d4f96d98c34e451b3ccb809 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_20176: ea9ca76d0bd231ce437c086bfb725a4d78a43086 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

ea9ca76d0bd2 drm/i915/gem: Use list_entry to access list members

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_20176/index.html

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx