aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_drawable.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-09-02 22:06:45 -0400
committerDave Airlie <airlied@optimus.(none)>2007-10-14 20:38:20 -0400
commitc153f45f9b7e30289157bba3ff5682291df16caa (patch)
tree33f21e1ebd83ec548751f3d490afe6230ab99972 /drivers/char/drm/drm_drawable.c
parentb589ee5943a9610ebaea6e4e3433f2ae4d812b0b (diff)
drm: 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 t 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 DR is lost. Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_drawable.c')
-rw-r--r--drivers/char/drm/drm_drawable.c61
1 files changed, 25 insertions, 36 deletions
diff --git a/drivers/char/drm/drm_drawable.c b/drivers/char/drm/drm_drawable.c
index 2787c9a3ab44..1839c57663c5 100644
--- a/drivers/char/drm/drm_drawable.c
+++ b/drivers/char/drm/drm_drawable.c
@@ -40,11 +40,10 @@
40/** 40/**
41 * Allocate drawable ID and memory to store information about it. 41 * Allocate drawable ID and memory to store information about it.
42 */ 42 */
43int drm_adddraw(DRM_IOCTL_ARGS) 43int drm_adddraw(struct drm_device *dev, void *data, struct drm_file *file_priv)
44{ 44{
45 DRM_DEVICE;
46 unsigned long irqflags; 45 unsigned long irqflags;
47 struct drm_draw draw; 46 struct drm_draw *draw = data;
48 int new_id = 0; 47 int new_id = 0;
49 int ret; 48 int ret;
50 49
@@ -63,11 +62,9 @@ again:
63 62
64 spin_unlock_irqrestore(&dev->drw_lock, irqflags); 63 spin_unlock_irqrestore(&dev->drw_lock, irqflags);
65 64
66 draw.handle = new_id; 65 draw->handle = new_id;
67 66
68 DRM_DEBUG("%d\n", draw.handle); 67 DRM_DEBUG("%d\n", draw->handle);
69
70 DRM_COPY_TO_USER_IOCTL((struct drm_draw __user *)data, draw, sizeof(draw));
71 68
72 return 0; 69 return 0;
73} 70}
@@ -75,69 +72,61 @@ again:
75/** 72/**
76 * Free drawable ID and memory to store information about it. 73 * Free drawable ID and memory to store information about it.
77 */ 74 */
78int drm_rmdraw(DRM_IOCTL_ARGS) 75int drm_rmdraw(struct drm_device *dev, void *data, struct drm_file *file_priv)
79{ 76{
80 DRM_DEVICE; 77 struct drm_draw *draw = data;
81 struct drm_draw draw;
82 unsigned long irqflags; 78 unsigned long irqflags;
83 79
84 DRM_COPY_FROM_USER_IOCTL(draw, (struct drm_draw __user *) data,
85 sizeof(draw));
86
87 spin_lock_irqsave(&dev->drw_lock, irqflags); 80 spin_lock_irqsave(&dev->drw_lock, irqflags);
88 81
89 drm_free(drm_get_drawable_info(dev, draw.handle), 82 drm_free(drm_get_drawable_info(dev, draw->handle),
90 sizeof(struct drm_drawable_info), DRM_MEM_BUFS); 83 sizeof(struct drm_drawable_info), DRM_MEM_BUFS);
91 84
92 idr_remove(&dev->drw_idr, draw.handle); 85 idr_remove(&dev->drw_idr, draw->handle);
93 86
94 spin_unlock_irqrestore(&dev->drw_lock, irqflags); 87 spin_unlock_irqrestore(&dev->drw_lock, irqflags);
95 DRM_DEBUG("%d\n", draw.handle); 88 DRM_DEBUG("%d\n", draw->handle);
96 return 0; 89 return 0;
97} 90}
98 91
99int drm_update_drawable_info(DRM_IOCTL_ARGS) 92int drm_update_drawable_info(struct drm_device *dev, void *data, struct drm_file *file_priv)
100{ 93{
101 DRM_DEVICE; 94 struct drm_update_draw *update = data;
102 struct drm_update_draw update;
103 unsigned long irqflags; 95 unsigned long irqflags;
104 struct drm_clip_rect *rects; 96 struct drm_clip_rect *rects;
105 struct drm_drawable_info *info; 97 struct drm_drawable_info *info;
106 int err; 98 int err;
107 99
108 DRM_COPY_FROM_USER_IOCTL(update, (struct drm_update_draw __user *) data, 100 info = idr_find(&dev->drw_idr, update->handle);
109 sizeof(update));
110
111 info = idr_find(&dev->drw_idr, update.handle);
112 if (!info) { 101 if (!info) {
113 info = drm_calloc(1, sizeof(*info), DRM_MEM_BUFS); 102 info = drm_calloc(1, sizeof(*info), DRM_MEM_BUFS);
114 if (!info) 103 if (!info)
115 return -ENOMEM; 104 return -ENOMEM;
116 if (IS_ERR(idr_replace(&dev->drw_idr, info, update.handle))) { 105 if (IS_ERR(idr_replace(&dev->drw_idr, info, update->handle))) {
117 DRM_ERROR("No such drawable %d\n", update.handle); 106 DRM_ERROR("No such drawable %d\n", update->handle);
118 drm_free(info, sizeof(*info), DRM_MEM_BUFS); 107 drm_free(info, sizeof(*info), DRM_MEM_BUFS);
119 return -EINVAL; 108 return -EINVAL;
120 } 109 }
121 } 110 }
122 111
123 switch (update.type) { 112 switch (update->type) {
124 case DRM_DRAWABLE_CLIPRECTS: 113 case DRM_DRAWABLE_CLIPRECTS:
125 if (update.num != info->num_rects) { 114 if (update->num != info->num_rects) {
126 rects = drm_alloc(update.num * sizeof(struct drm_clip_rect), 115 rects = drm_alloc(update->num * sizeof(struct drm_clip_rect),
127 DRM_MEM_BUFS); 116 DRM_MEM_BUFS);
128 } else 117 } else
129 rects = info->rects; 118 rects = info->rects;
130 119
131 if (update.num && !rects) { 120 if (update->num && !rects) {
132 DRM_ERROR("Failed to allocate cliprect memory\n"); 121 DRM_ERROR("Failed to allocate cliprect memory\n");
133 err = -ENOMEM; 122 err = -ENOMEM;
134 goto error; 123 goto error;
135 } 124 }
136 125
137 if (update.num && DRM_COPY_FROM_USER(rects, 126 if (update->num && DRM_COPY_FROM_USER(rects,
138 (struct drm_clip_rect __user *) 127 (struct drm_clip_rect __user *)
139 (unsigned long)update.data, 128 (unsigned long)update->data,
140 update.num * 129 update->num *
141 sizeof(*rects))) { 130 sizeof(*rects))) {
142 DRM_ERROR("Failed to copy cliprects from userspace\n"); 131 DRM_ERROR("Failed to copy cliprects from userspace\n");
143 err = -EFAULT; 132 err = -EFAULT;
@@ -152,15 +141,15 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS)
152 } 141 }
153 142
154 info->rects = rects; 143 info->rects = rects;
155 info->num_rects = update.num; 144 info->num_rects = update->num;
156 145
157 spin_unlock_irqrestore(&dev->drw_lock, irqflags); 146 spin_unlock_irqrestore(&dev->drw_lock, irqflags);
158 147
159 DRM_DEBUG("Updated %d cliprects for drawable %d\n", 148 DRM_DEBUG("Updated %d cliprects for drawable %d\n",
160 info->num_rects, update.handle); 149 info->num_rects, update->handle);
161 break; 150 break;
162 default: 151 default:
163 DRM_ERROR("Invalid update type %d\n", update.type); 152 DRM_ERROR("Invalid update type %d\n", update->type);
164 return -EINVAL; 153 return -EINVAL;
165 } 154 }
166 155
@@ -168,7 +157,7 @@ int drm_update_drawable_info(DRM_IOCTL_ARGS)
168 157
169error: 158error:
170 if (rects != info->rects) 159 if (rects != info->rects)
171 drm_free(rects, update.num * sizeof(struct drm_clip_rect), 160 drm_free(rects, update->num * sizeof(struct drm_clip_rect),
172 DRM_MEM_BUFS); 161 DRM_MEM_BUFS);
173 162
174 return err; 163 return err;