From b95ac8b7b313ad3eadc9e8bb0ead155303b7fa92 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 16 Jul 2007 11:22:15 +1000 Subject: drm: detypedef drm.h and fixup all problems --- linux-core/drm_drawable.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'linux-core/drm_drawable.c') diff --git a/linux-core/drm_drawable.c b/linux-core/drm_drawable.c index 7129980b..5a2a14f9 100644 --- a/linux-core/drm_drawable.c +++ b/linux-core/drm_drawable.c @@ -44,7 +44,7 @@ int drm_adddraw(DRM_IOCTL_ARGS) { DRM_DEVICE; unsigned long irqflags; - drm_draw_t draw; + struct drm_draw draw; int new_id = 0; int ret; @@ -67,7 +67,7 @@ again: DRM_DEBUG("%d\n", draw.handle); - DRM_COPY_TO_USER_IOCTL((drm_draw_t __user *)data, draw, sizeof(draw)); + DRM_COPY_TO_USER_IOCTL((struct drm_draw __user *)data, draw, sizeof(draw)); return 0; } @@ -78,10 +78,10 @@ again: int drm_rmdraw(DRM_IOCTL_ARGS) { DRM_DEVICE; - drm_draw_t draw; + struct drm_draw draw; unsigned long irqflags; - DRM_COPY_FROM_USER_IOCTL(draw, (drm_draw_t __user *) data, + DRM_COPY_FROM_USER_IOCTL(draw, (struct drm_draw __user *) data, sizeof(draw)); spin_lock_irqsave(&dev->drw_lock, irqflags); @@ -99,13 +99,13 @@ int drm_rmdraw(DRM_IOCTL_ARGS) int drm_update_drawable_info(DRM_IOCTL_ARGS) { DRM_DEVICE; - drm_update_draw_t update; + struct drm_update_draw update; unsigned long irqflags; - drm_clip_rect_t *rects; + struct drm_clip_rect *rects; struct drm_drawable_info *info; int err; - DRM_COPY_FROM_USER_IOCTL(update, (drm_update_draw_t __user *) data, + DRM_COPY_FROM_USER_IOCTL(update, (struct drm_update_draw __user *) data, sizeof(update)); info = idr_find(&dev->drw_idr, update.handle); @@ -123,7 +123,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) switch (update.type) { case DRM_DRAWABLE_CLIPRECTS: if (update.num != info->num_rects) { - rects = drm_alloc(update.num * sizeof(drm_clip_rect_t), + rects = drm_alloc(update.num * sizeof(struct drm_clip_rect), DRM_MEM_BUFS); } else rects = info->rects; @@ -135,7 +135,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) } if (update.num && DRM_COPY_FROM_USER(rects, - (drm_clip_rect_t __user *) + (struct drm_clip_rect __user *) (unsigned long)update.data, update.num * sizeof(*rects))) { @@ -148,7 +148,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) if (rects != info->rects) { drm_free(info->rects, info->num_rects * - sizeof(drm_clip_rect_t), DRM_MEM_BUFS); + sizeof(struct drm_clip_rect), DRM_MEM_BUFS); } info->rects = rects; @@ -168,7 +168,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) error: if (rects != info->rects) - drm_free(rects, update.num * sizeof(drm_clip_rect_t), + drm_free(rects, update.num * sizeof(struct drm_clip_rect), DRM_MEM_BUFS); return err; @@ -177,7 +177,7 @@ error: /** * Caller must hold the drawable spinlock! */ -drm_drawable_info_t *drm_get_drawable_info(drm_device_t *dev, drm_drawable_t id) +struct drm_drawable_info *drm_get_drawable_info(drm_device_t *dev, drm_drawable_t id) { return idr_find(&dev->drw_idr, id); } @@ -189,7 +189,7 @@ static int drm_drawable_free(int idr, void *p, void *data) if (info) { drm_free(info->rects, info->num_rects * - sizeof(drm_clip_rect_t), DRM_MEM_BUFS); + sizeof(struct drm_clip_rect), DRM_MEM_BUFS); drm_free(info, sizeof(*info), DRM_MEM_BUFS); } -- cgit v1.2.3 From 21ee6fbfb8f2219a454458204afc9c5fcd89f9a8 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 16 Jul 2007 12:32:51 +1000 Subject: drm: remove drmP.h internal typedefs --- linux-core/drm_drawable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux-core/drm_drawable.c') diff --git a/linux-core/drm_drawable.c b/linux-core/drm_drawable.c index 5a2a14f9..d6cdba56 100644 --- a/linux-core/drm_drawable.c +++ b/linux-core/drm_drawable.c @@ -177,7 +177,7 @@ error: /** * Caller must hold the drawable spinlock! */ -struct drm_drawable_info *drm_get_drawable_info(drm_device_t *dev, drm_drawable_t id) +struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev, drm_drawable_t id) { return idr_find(&dev->drw_idr, id); } @@ -196,7 +196,7 @@ static int drm_drawable_free(int idr, void *p, void *data) return 0; } -void drm_drawable_free_all(drm_device_t *dev) +void drm_drawable_free_all(struct drm_device *dev) { idr_for_each(&dev->drw_idr, drm_drawable_free, NULL); idr_remove_all(&dev->drw_idr); -- cgit v1.2.3 From e39286eb5eab8846a228863abf8f1b8b07a9e29d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 19 Jul 2007 17:00:17 -0700 Subject: Remove DRM_ERR OS macro. This was used to make all ioctl handlers return -errno on linux and errno on *BSD. Instead, just return -errno in shared code, and flip sign on return from shared code to *BSD code. --- linux-core/drm_drawable.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'linux-core/drm_drawable.c') diff --git a/linux-core/drm_drawable.c b/linux-core/drm_drawable.c index d6cdba56..2787c9a3 100644 --- a/linux-core/drm_drawable.c +++ b/linux-core/drm_drawable.c @@ -130,7 +130,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) if (update.num && !rects) { DRM_ERROR("Failed to allocate cliprect memory\n"); - err = DRM_ERR(ENOMEM); + err = -ENOMEM; goto error; } @@ -140,7 +140,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) update.num * sizeof(*rects))) { DRM_ERROR("Failed to copy cliprects from userspace\n"); - err = DRM_ERR(EFAULT); + err = -EFAULT; goto error; } @@ -161,7 +161,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) break; default: DRM_ERROR("Invalid update type %d\n", update.type); - return DRM_ERR(EINVAL); + return -EINVAL; } return 0; -- cgit v1.2.3 From 5b38e134163cc375e91424c4688cc9328c6e9082 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 19 Jul 2007 17:11:11 -0700 Subject: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE. The data is now in kernel space, copied in/out as appropriate according to the This results in DRM_COPY_{TO,FROM}_USER going away, and error paths to deal with those failures. This also means that XFree86 4.2.0 support for i810 DRM is lost. --- linux-core/drm_drawable.c | 61 +++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 36 deletions(-) (limited to 'linux-core/drm_drawable.c') diff --git a/linux-core/drm_drawable.c b/linux-core/drm_drawable.c index 2787c9a3..1839c576 100644 --- a/linux-core/drm_drawable.c +++ b/linux-core/drm_drawable.c @@ -40,11 +40,10 @@ /** * Allocate drawable ID and memory to store information about it. */ -int drm_adddraw(DRM_IOCTL_ARGS) +int drm_adddraw(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; unsigned long irqflags; - struct drm_draw draw; + struct drm_draw *draw = data; int new_id = 0; int ret; @@ -63,11 +62,9 @@ again: spin_unlock_irqrestore(&dev->drw_lock, irqflags); - draw.handle = new_id; + draw->handle = new_id; - DRM_DEBUG("%d\n", draw.handle); - - DRM_COPY_TO_USER_IOCTL((struct drm_draw __user *)data, draw, sizeof(draw)); + DRM_DEBUG("%d\n", draw->handle); return 0; } @@ -75,69 +72,61 @@ again: /** * Free drawable ID and memory to store information about it. */ -int drm_rmdraw(DRM_IOCTL_ARGS) +int drm_rmdraw(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; - struct drm_draw draw; + struct drm_draw *draw = data; unsigned long irqflags; - DRM_COPY_FROM_USER_IOCTL(draw, (struct drm_draw __user *) data, - sizeof(draw)); - spin_lock_irqsave(&dev->drw_lock, irqflags); - drm_free(drm_get_drawable_info(dev, draw.handle), + drm_free(drm_get_drawable_info(dev, draw->handle), sizeof(struct drm_drawable_info), DRM_MEM_BUFS); - idr_remove(&dev->drw_idr, draw.handle); + idr_remove(&dev->drw_idr, draw->handle); spin_unlock_irqrestore(&dev->drw_lock, irqflags); - DRM_DEBUG("%d\n", draw.handle); + DRM_DEBUG("%d\n", draw->handle); return 0; } -int drm_update_drawable_info(DRM_IOCTL_ARGS) +int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; - struct drm_update_draw update; + struct drm_update_draw *update = data; unsigned long irqflags; struct drm_clip_rect *rects; struct drm_drawable_info *info; int err; - DRM_COPY_FROM_USER_IOCTL(update, (struct drm_update_draw __user *) data, - sizeof(update)); - - info = idr_find(&dev->drw_idr, update.handle); + info = idr_find(&dev->drw_idr, update->handle); if (!info) { info = drm_calloc(1, sizeof(*info), DRM_MEM_BUFS); if (!info) return -ENOMEM; - if (IS_ERR(idr_replace(&dev->drw_idr, info, update.handle))) { - DRM_ERROR("No such drawable %d\n", update.handle); + if (IS_ERR(idr_replace(&dev->drw_idr, info, update->handle))) { + DRM_ERROR("No such drawable %d\n", update->handle); drm_free(info, sizeof(*info), DRM_MEM_BUFS); return -EINVAL; } } - switch (update.type) { + switch (update->type) { case DRM_DRAWABLE_CLIPRECTS: - if (update.num != info->num_rects) { - rects = drm_alloc(update.num * sizeof(struct drm_clip_rect), + if (update->num != info->num_rects) { + rects = drm_alloc(update->num * sizeof(struct drm_clip_rect), DRM_MEM_BUFS); } else rects = info->rects; - if (update.num && !rects) { + if (update->num && !rects) { DRM_ERROR("Failed to allocate cliprect memory\n"); err = -ENOMEM; goto error; } - if (update.num && DRM_COPY_FROM_USER(rects, + if (update->num && DRM_COPY_FROM_USER(rects, (struct drm_clip_rect __user *) - (unsigned long)update.data, - update.num * + (unsigned long)update->data, + update->num * sizeof(*rects))) { DRM_ERROR("Failed to copy cliprects from userspace\n"); err = -EFAULT; @@ -152,15 +141,15 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) } info->rects = rects; - info->num_rects = update.num; + info->num_rects = update->num; spin_unlock_irqrestore(&dev->drw_lock, irqflags); DRM_DEBUG("Updated %d cliprects for drawable %d\n", - info->num_rects, update.handle); + info->num_rects, update->handle); break; default: - DRM_ERROR("Invalid update type %d\n", update.type); + DRM_ERROR("Invalid update type %d\n", update->type); return -EINVAL; } @@ -168,7 +157,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS) error: if (rects != info->rects) - drm_free(rects, update.num * sizeof(struct drm_clip_rect), + drm_free(rects, update->num * sizeof(struct drm_clip_rect), DRM_MEM_BUFS); return err; -- cgit v1.2.3