aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@collabora.co.uk>2009-11-17 17:41:24 -0500
committerDave Airlie <airlied@redhat.com>2009-11-17 19:02:50 -0500
commit140a45fc3253746e1e42feafc63509df5d90889e (patch)
treeb125bf5e9f686399920b4e394e65a88568823d5e /drivers
parent156822f7175d9ceb9d7e808502d3c5de8841e047 (diff)
drm: replace DRM_COPY macro w/ a function
Don't inline it; the compiler can figure it out. Comments added that are based upon my interpretation of the code. Hopefully they're correct. :) Signed-off-by: Andres Salomon <dilinger@collabora.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/drm_drv.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 43297ca45f3e..ec0e3ae8c09d 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -368,14 +368,25 @@ module_exit(drm_core_exit);
368/** 368/**
369 * Copy and IOCTL return string to user space 369 * Copy and IOCTL return string to user space
370 */ 370 */
371#define DRM_COPY(name, value) \ 371static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
372 len = strlen(value); \ 372{
373 if (len > name##_len) len = name##_len; \ 373 int len;
374 name##_len = strlen(value); \ 374
375 if (len && name) { \ 375 /* don't overflow userbuf */
376 if (copy_to_user(name, value, len)) \ 376 len = strlen(value);
377 return -EFAULT; \ 377 if (len > *buf_len)
378 } 378 len = *buf_len;
379
380 /* let userspace know exact length of driver value (which could be
381 * larger than the userspace-supplied buffer) */
382 *buf_len = strlen(value);
383
384 /* finally, try filling in the userbuf */
385 if (len && buf)
386 if (copy_to_user(buf, value, len))
387 return -EFAULT;
388 return 0;
389}
379 390
380/** 391/**
381 * Get version information 392 * Get version information
@@ -392,14 +403,13 @@ static int drm_version(struct drm_device *dev, void *data,
392 struct drm_file *file_priv) 403 struct drm_file *file_priv)
393{ 404{
394 struct drm_version *version = data; 405 struct drm_version *version = data;
395 int len;
396 406
397 version->version_major = dev->driver->major; 407 version->version_major = dev->driver->major;
398 version->version_minor = dev->driver->minor; 408 version->version_minor = dev->driver->minor;
399 version->version_patchlevel = dev->driver->patchlevel; 409 version->version_patchlevel = dev->driver->patchlevel;
400 DRM_COPY(version->name, dev->driver->name); 410 drm_copy_field(version->name, &version->name_len, dev->driver->name);
401 DRM_COPY(version->date, dev->driver->date); 411 drm_copy_field(version->date, &version->date_len, dev->driver->date);
402 DRM_COPY(version->desc, dev->driver->desc); 412 drm_copy_field(version->desc, &version->desc_len, dev->driver->desc);
403 413
404 return 0; 414 return 0;
405} 415}