Commit b8c8a859 authored by Wambui Karuga's avatar Wambui Karuga Committed by Daniel Vetter

drm: use DIV_ROUND_UP helper macro for calculations

Replace open coded divisor calculations with the DIV_ROUND_UP kernel
macro for better readability.
Issue found using coccinelle:
@@
expression n,d;
@@
(
- ((n + d - 1) / d)
+ DIV_ROUND_UP(n,d)
|
- ((n + (d - 1)) / d)
+ DIV_ROUND_UP(n,d)
)
Signed-off-by: default avatarWambui Karuga <wambui.karugax@gmail.com>
Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20191025094907.3582-1-wambui.karugax@gmail.com
parent ff1fd294
...@@ -212,7 +212,7 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request) ...@@ -212,7 +212,7 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; pages = DIV_ROUND_UP(request->size, PAGE_SIZE);
type = (u32) request->type; type = (u32) request->type;
memory = agp_allocate_memory(dev->agp->bridge, pages, type); memory = agp_allocate_memory(dev->agp->bridge, pages, type);
if (!memory) { if (!memory) {
...@@ -325,7 +325,7 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request) ...@@ -325,7 +325,7 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request)
entry = drm_agp_lookup_entry(dev, request->handle); entry = drm_agp_lookup_entry(dev, request->handle);
if (!entry || entry->bound) if (!entry || entry->bound)
return -EINVAL; return -EINVAL;
page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE; page = DIV_ROUND_UP(request->offset, PAGE_SIZE);
retcode = drm_bind_agp(entry->memory, page); retcode = drm_bind_agp(entry->memory, page);
if (retcode) if (retcode)
return retcode; return retcode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment