Skip to contentSkip to conversation

drm/vgem: Checkpatch cleanup for vgem

PATCH New Rodrigo Siqueira 1 participant 6 messages Mar 8, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drm/vgem: Checkpatch cleanup for vgem

This patchset fixes warnings and errors found by checkpatch.pl in the drm/vgem:

* Removes assignment in if condition;
* Removes '(' from the end of line;
* Adds spaces around operators;
* Replaces uint32_t for u32;
* Indents switch and case at the same level.

Rodrigo Siqueira (5):
drm/vgem: Indent switch and case at the same level drm/vgem: Remove assignment in if condition drm/vgem: Replace uint32_t for u32 drm/vgem: Add space around operators drm/vgem: Remove '(' from the end of line

 drivers/gpu/drm/vgem/vgem_drv.c   | 21 +++++++++++++--------
 drivers/gpu/drm/vgem/vgem_fence.c | 11 +++++++----
 2 files changed, 20 insertions(+), 12 deletions(-)
Signature · 1 line
2.16.2
#1 lore raw

PATCH 1/5 drm/vgem: Indent switch and case at the same level

This patch fixes the checkpatch.pl errors:

vgem_drv.c:97: ERROR: switch and case should be at the same indent vgem_drv.c:97: ERROR: trailing statements should be on next line

---
 drivers/gpu/drm/vgem/vgem_drv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/vgem/vgem_drv.c +3 -2
index 2524ff116f00..5767030d04a8 100644
@@ -94,7 +94,8 @@ static int vgem_gem_fault(struct vm_fault *vmf)
 		if (!IS_ERR(page)) {
 			vmf->page = page;
 			ret = 0;
-		} else switch (PTR_ERR(page)) {
+		} else {
+			switch (PTR_ERR(page)) {
 			case -ENOSPC:
 			case -ENOMEM:
 				ret = VM_FAULT_OOM;
@@ -110,8 +111,8 @@ static int vgem_gem_fault(struct vm_fault *vmf)
 				WARN_ON(PTR_ERR(page));
 				ret = VM_FAULT_SIGBUS;
 				break;
+			}
 		}
-
 	}
 	return ret;
 }
Signature · 1 line
2.16.2
#2 lore raw

PATCH 2/5 drm/vgem: Remove assignment in if condition

In reply to Rodrigo Siqueira

This patch fixes the checkpatch.pl error:

vgem_fence.c:196: ERROR: do not use assignment in if condition

---
 drivers/gpu/drm/vgem/vgem_fence.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/vgem/vgem_fence.c +6 -3
index b28876c222b4..f5b659463b00 100644
@@ -191,10 +191,13 @@ int vgem_fence_attach_ioctl(struct drm_device *dev,
 	/* Expose the fence via the dma-buf */
 	ret = 0;
 	reservation_object_lock(resv, NULL);
-	if (arg->flags & VGEM_FENCE_WRITE)
+	if (arg->flags & VGEM_FENCE_WRITE) {
 		reservation_object_add_excl_fence(resv, fence);
-	else if ((ret = reservation_object_reserve_shared(resv)) == 0)
-		reservation_object_add_shared_fence(resv, fence);
+	} else {
+		ret = reservation_object_reserve_shared(resv);
+		if (!ret)
+			reservation_object_add_shared_fence(resv, fence);
+	}
 	reservation_object_unlock(resv);
 
 	/* Record the fence in our idr for later signaling */
Signature · 1 line
2.16.2
#3 lore raw

PATCH 3/5 drm/vgem: Replace uint32_t for u32

In reply to Rodrigo Siqueira

This patch fixes the checkpatch.pl check:

vgem_drv.c:229: CHECK: Prefer kernel type 'u32' over 'uint32_t'

---
 drivers/gpu/drm/vgem/vgem_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vgem/vgem_drv.c +1 -1
index 5767030d04a8..bf704ed51da4 100644
@@ -226,7 +226,7 @@ static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
 }
 
 static int vgem_gem_dumb_map(struct drm_file *file, struct drm_device *dev,
-			     uint32_t handle, uint64_t *offset)
+			     u32 handle, uint64_t *offset)
 {
 	struct drm_gem_object *obj;
 	int ret;
Signature · 1 line
2.16.2
#4 lore raw

PATCH 4/5 drm/vgem: Add space around operators

In reply to Rodrigo Siqueira

This patch fixes the checkpatch.pl check and warning:

vgem_fence.c:28: CHECK: spaces preferred around that '*' (ctx:VxV) vgem_drv.c:255: CHECK: spaces preferred around that '|' (ctx:VxV) vgem_drv.c:256: WARNING: line over 80 characters

---
 drivers/gpu/drm/vgem/vgem_drv.c   | 8 ++++++--
 drivers/gpu/drm/vgem/vgem_fence.c | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/vgem/vgem_drv.c +6 -2
index bf704ed51da4..6e6084e3204a 100644
@@ -252,8 +252,12 @@ static int vgem_gem_dumb_map(struct drm_file *file, struct drm_device *dev,
 }
 
 static struct drm_ioctl_desc vgem_ioctls[] = {
-	DRM_IOCTL_DEF_DRV(VGEM_FENCE_ATTACH, vgem_fence_attach_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
-	DRM_IOCTL_DEF_DRV(VGEM_FENCE_SIGNAL, vgem_fence_signal_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(VGEM_FENCE_ATTACH,
+			  vgem_fence_attach_ioctl,
+			  DRM_AUTH | DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(VGEM_FENCE_SIGNAL,
+			  vgem_fence_signal_ioctl,
+			  DRM_AUTH | DRM_RENDER_ALLOW),
 };
 
 static int vgem_mmap(struct file *filp, struct vm_area_struct *vma)
drivers/gpu/drm/vgem/vgem_fence.c +1 -1
index f5b659463b00..d0bcb5fb33d1 100644
@@ -25,7 +25,7 @@
 
 #include "vgem_drv.h"
 
-#define VGEM_FENCE_TIMEOUT (10*HZ)
+#define VGEM_FENCE_TIMEOUT (10 * HZ)
 
 struct vgem_fence {
 	struct dma_fence base;
Signature · 1 line
2.16.2
#5 lore raw

PATCH 5/5 drm/vgem: Remove '(' from the end of line

In reply to Rodrigo Siqueira

This patch fixes the checkpatch.pl check:

vgem_drv.c:91: CHECK: Lines should not end with a '('

---
 drivers/gpu/drm/vgem/vgem_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/vgem/vgem_drv.c +3 -3
index 6e6084e3204a..4ddf3b8c3875 100644
@@ -87,10 +87,10 @@ static int vgem_gem_fault(struct vm_fault *vmf)
 	mutex_unlock(&obj->pages_lock);
 	if (ret) {
 		struct page *page;
+		struct address_space *mapping;
 
-		page = shmem_read_mapping_page(
-					file_inode(obj->base.filp)->i_mapping,
-					page_offset);
+		mapping = file_inode(obj->base.filp)->i_mapping;
+		page = shmem_read_mapping_page(mapping, page_offset);
 		if (!IS_ERR(page)) {
 			vmf->page = page;
 			ret = 0;
Signature · 1 line
2.16.2