diff options
Diffstat (limited to 'drivers/char/drm/drm_agpsupport.c')
-rw-r--r-- | drivers/char/drm/drm_agpsupport.c | 130 |
1 files changed, 40 insertions, 90 deletions
diff --git a/drivers/char/drm/drm_agpsupport.c b/drivers/char/drm/drm_agpsupport.c index 354f0e3674bf..214f4fbcba73 100644 --- a/drivers/char/drm/drm_agpsupport.c +++ b/drivers/char/drm/drm_agpsupport.c | |||
@@ -40,7 +40,7 @@ | |||
40 | * Get AGP information. | 40 | * Get AGP information. |
41 | * | 41 | * |
42 | * \param inode device inode. | 42 | * \param inode device inode. |
43 | * \param filp file pointer. | 43 | * \param file_priv DRM file private. |
44 | * \param cmd command. | 44 | * \param cmd command. |
45 | * \param arg pointer to a (output) drm_agp_info structure. | 45 | * \param arg pointer to a (output) drm_agp_info structure. |
46 | * \return zero on success or a negative number on failure. | 46 | * \return zero on success or a negative number on failure. |
@@ -71,20 +71,16 @@ int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info) | |||
71 | 71 | ||
72 | EXPORT_SYMBOL(drm_agp_info); | 72 | EXPORT_SYMBOL(drm_agp_info); |
73 | 73 | ||
74 | int drm_agp_info_ioctl(struct inode *inode, struct file *filp, | 74 | int drm_agp_info_ioctl(struct drm_device *dev, void *data, |
75 | unsigned int cmd, unsigned long arg) | 75 | struct drm_file *file_priv) |
76 | { | 76 | { |
77 | struct drm_file *priv = filp->private_data; | 77 | struct drm_agp_info *info = data; |
78 | struct drm_device *dev = priv->head->dev; | ||
79 | struct drm_agp_info info; | ||
80 | int err; | 78 | int err; |
81 | 79 | ||
82 | err = drm_agp_info(dev, &info); | 80 | err = drm_agp_info(dev, info); |
83 | if (err) | 81 | if (err) |
84 | return err; | 82 | return err; |
85 | 83 | ||
86 | if (copy_to_user((struct drm_agp_info __user *) arg, &info, sizeof(info))) | ||
87 | return -EFAULT; | ||
88 | return 0; | 84 | return 0; |
89 | } | 85 | } |
90 | 86 | ||
@@ -115,7 +111,7 @@ EXPORT_SYMBOL(drm_agp_acquire); | |||
115 | * Acquire the AGP device (ioctl). | 111 | * Acquire the AGP device (ioctl). |
116 | * | 112 | * |
117 | * \param inode device inode. | 113 | * \param inode device inode. |
118 | * \param filp file pointer. | 114 | * \param file_priv DRM file private. |
119 | * \param cmd command. | 115 | * \param cmd command. |
120 | * \param arg user argument. | 116 | * \param arg user argument. |
121 | * \return zero on success or a negative number on failure. | 117 | * \return zero on success or a negative number on failure. |
@@ -123,12 +119,10 @@ EXPORT_SYMBOL(drm_agp_acquire); | |||
123 | * Verifies the AGP device hasn't been acquired before and calls | 119 | * Verifies the AGP device hasn't been acquired before and calls |
124 | * \c agp_backend_acquire. | 120 | * \c agp_backend_acquire. |
125 | */ | 121 | */ |
126 | int drm_agp_acquire_ioctl(struct inode *inode, struct file *filp, | 122 | int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, |
127 | unsigned int cmd, unsigned long arg) | 123 | struct drm_file *file_priv) |
128 | { | 124 | { |
129 | struct drm_file *priv = filp->private_data; | 125 | return drm_agp_acquire((struct drm_device *) file_priv->head->dev); |
130 | |||
131 | return drm_agp_acquire((struct drm_device *) priv->head->dev); | ||
132 | } | 126 | } |
133 | 127 | ||
134 | /** | 128 | /** |
@@ -149,12 +143,9 @@ int drm_agp_release(struct drm_device * dev) | |||
149 | } | 143 | } |
150 | EXPORT_SYMBOL(drm_agp_release); | 144 | EXPORT_SYMBOL(drm_agp_release); |
151 | 145 | ||
152 | int drm_agp_release_ioctl(struct inode *inode, struct file *filp, | 146 | int drm_agp_release_ioctl(struct drm_device *dev, void *data, |
153 | unsigned int cmd, unsigned long arg) | 147 | struct drm_file *file_priv) |
154 | { | 148 | { |
155 | struct drm_file *priv = filp->private_data; | ||
156 | struct drm_device *dev = priv->head->dev; | ||
157 | |||
158 | return drm_agp_release(dev); | 149 | return drm_agp_release(dev); |
159 | } | 150 | } |
160 | 151 | ||
@@ -182,24 +173,19 @@ int drm_agp_enable(struct drm_device * dev, struct drm_agp_mode mode) | |||
182 | 173 | ||
183 | EXPORT_SYMBOL(drm_agp_enable); | 174 | EXPORT_SYMBOL(drm_agp_enable); |
184 | 175 | ||
185 | int drm_agp_enable_ioctl(struct inode *inode, struct file *filp, | 176 | int drm_agp_enable_ioctl(struct drm_device *dev, void *data, |
186 | unsigned int cmd, unsigned long arg) | 177 | struct drm_file *file_priv) |
187 | { | 178 | { |
188 | struct drm_file *priv = filp->private_data; | 179 | struct drm_agp_mode *mode = data; |
189 | struct drm_device *dev = priv->head->dev; | ||
190 | struct drm_agp_mode mode; | ||
191 | |||
192 | if (copy_from_user(&mode, (struct drm_agp_mode __user *) arg, sizeof(mode))) | ||
193 | return -EFAULT; | ||
194 | 180 | ||
195 | return drm_agp_enable(dev, mode); | 181 | return drm_agp_enable(dev, *mode); |
196 | } | 182 | } |
197 | 183 | ||
198 | /** | 184 | /** |
199 | * Allocate AGP memory. | 185 | * Allocate AGP memory. |
200 | * | 186 | * |
201 | * \param inode device inode. | 187 | * \param inode device inode. |
202 | * \param filp file pointer. | 188 | * \param file_priv file private pointer. |
203 | * \param cmd command. | 189 | * \param cmd command. |
204 | * \param arg pointer to a drm_agp_buffer structure. | 190 | * \param arg pointer to a drm_agp_buffer structure. |
205 | * \return zero on success or a negative number on failure. | 191 | * \return zero on success or a negative number on failure. |
@@ -241,35 +227,13 @@ int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request) | |||
241 | } | 227 | } |
242 | EXPORT_SYMBOL(drm_agp_alloc); | 228 | EXPORT_SYMBOL(drm_agp_alloc); |
243 | 229 | ||
244 | int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp, | ||
245 | unsigned int cmd, unsigned long arg) | ||
246 | { | ||
247 | struct drm_file *priv = filp->private_data; | ||
248 | struct drm_device *dev = priv->head->dev; | ||
249 | struct drm_agp_buffer request; | ||
250 | struct drm_agp_buffer __user *argp = (void __user *)arg; | ||
251 | int err; | ||
252 | |||
253 | if (copy_from_user(&request, argp, sizeof(request))) | ||
254 | return -EFAULT; | ||
255 | 230 | ||
256 | err = drm_agp_alloc(dev, &request); | 231 | int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, |
257 | if (err) | 232 | struct drm_file *file_priv) |
258 | return err; | 233 | { |
259 | 234 | struct drm_agp_buffer *request = data; | |
260 | if (copy_to_user(argp, &request, sizeof(request))) { | ||
261 | struct drm_agp_mem *entry; | ||
262 | list_for_each_entry(entry, &dev->agp->memory, head) { | ||
263 | if (entry->handle == request.handle) | ||
264 | break; | ||
265 | } | ||
266 | list_del(&entry->head); | ||
267 | drm_free_agp(entry->memory, entry->pages); | ||
268 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); | ||
269 | return -EFAULT; | ||
270 | } | ||
271 | 235 | ||
272 | return 0; | 236 | return drm_agp_alloc(dev, request); |
273 | } | 237 | } |
274 | 238 | ||
275 | /** | 239 | /** |
@@ -297,7 +261,7 @@ static struct drm_agp_mem *drm_agp_lookup_entry(struct drm_device * dev, | |||
297 | * Unbind AGP memory from the GATT (ioctl). | 261 | * Unbind AGP memory from the GATT (ioctl). |
298 | * | 262 | * |
299 | * \param inode device inode. | 263 | * \param inode device inode. |
300 | * \param filp file pointer. | 264 | * \param file_priv DRM file private. |
301 | * \param cmd command. | 265 | * \param cmd command. |
302 | * \param arg pointer to a drm_agp_binding structure. | 266 | * \param arg pointer to a drm_agp_binding structure. |
303 | * \return zero on success or a negative number on failure. | 267 | * \return zero on success or a negative number on failure. |
@@ -323,25 +287,20 @@ int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request) | |||
323 | } | 287 | } |
324 | EXPORT_SYMBOL(drm_agp_unbind); | 288 | EXPORT_SYMBOL(drm_agp_unbind); |
325 | 289 | ||
326 | int drm_agp_unbind_ioctl(struct inode *inode, struct file *filp, | ||
327 | unsigned int cmd, unsigned long arg) | ||
328 | { | ||
329 | struct drm_file *priv = filp->private_data; | ||
330 | struct drm_device *dev = priv->head->dev; | ||
331 | struct drm_agp_binding request; | ||
332 | 290 | ||
333 | if (copy_from_user | 291 | int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, |
334 | (&request, (struct drm_agp_binding __user *) arg, sizeof(request))) | 292 | struct drm_file *file_priv) |
335 | return -EFAULT; | 293 | { |
294 | struct drm_agp_binding *request = data; | ||
336 | 295 | ||
337 | return drm_agp_unbind(dev, &request); | 296 | return drm_agp_unbind(dev, request); |
338 | } | 297 | } |
339 | 298 | ||
340 | /** | 299 | /** |
341 | * Bind AGP memory into the GATT (ioctl) | 300 | * Bind AGP memory into the GATT (ioctl) |
342 | * | 301 | * |
343 | * \param inode device inode. | 302 | * \param inode device inode. |
344 | * \param filp file pointer. | 303 | * \param file_priv DRM file private. |
345 | * \param cmd command. | 304 | * \param cmd command. |
346 | * \param arg pointer to a drm_agp_binding structure. | 305 | * \param arg pointer to a drm_agp_binding structure. |
347 | * \return zero on success or a negative number on failure. | 306 | * \return zero on success or a negative number on failure. |
@@ -372,25 +331,20 @@ int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request) | |||
372 | } | 331 | } |
373 | EXPORT_SYMBOL(drm_agp_bind); | 332 | EXPORT_SYMBOL(drm_agp_bind); |
374 | 333 | ||
375 | int drm_agp_bind_ioctl(struct inode *inode, struct file *filp, | ||
376 | unsigned int cmd, unsigned long arg) | ||
377 | { | ||
378 | struct drm_file *priv = filp->private_data; | ||
379 | struct drm_device *dev = priv->head->dev; | ||
380 | struct drm_agp_binding request; | ||
381 | 334 | ||
382 | if (copy_from_user | 335 | int drm_agp_bind_ioctl(struct drm_device *dev, void *data, |
383 | (&request, (struct drm_agp_binding __user *) arg, sizeof(request))) | 336 | struct drm_file *file_priv) |
384 | return -EFAULT; | 337 | { |
338 | struct drm_agp_binding *request = data; | ||
385 | 339 | ||
386 | return drm_agp_bind(dev, &request); | 340 | return drm_agp_bind(dev, request); |
387 | } | 341 | } |
388 | 342 | ||
389 | /** | 343 | /** |
390 | * Free AGP memory (ioctl). | 344 | * Free AGP memory (ioctl). |
391 | * | 345 | * |
392 | * \param inode device inode. | 346 | * \param inode device inode. |
393 | * \param filp file pointer. | 347 | * \param file_priv DRM file private. |
394 | * \param cmd command. | 348 | * \param cmd command. |
395 | * \param arg pointer to a drm_agp_buffer structure. | 349 | * \param arg pointer to a drm_agp_buffer structure. |
396 | * \return zero on success or a negative number on failure. | 350 | * \return zero on success or a negative number on failure. |
@@ -419,18 +373,14 @@ int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request) | |||
419 | } | 373 | } |
420 | EXPORT_SYMBOL(drm_agp_free); | 374 | EXPORT_SYMBOL(drm_agp_free); |
421 | 375 | ||
422 | int drm_agp_free_ioctl(struct inode *inode, struct file *filp, | ||
423 | unsigned int cmd, unsigned long arg) | ||
424 | { | ||
425 | struct drm_file *priv = filp->private_data; | ||
426 | struct drm_device *dev = priv->head->dev; | ||
427 | struct drm_agp_buffer request; | ||
428 | 376 | ||
429 | if (copy_from_user | ||
430 | (&request, (struct drm_agp_buffer __user *) arg, sizeof(request))) | ||
431 | return -EFAULT; | ||
432 | 377 | ||
433 | return drm_agp_free(dev, &request); | 378 | int drm_agp_free_ioctl(struct drm_device *dev, void *data, |
379 | struct drm_file *file_priv) | ||
380 | { | ||
381 | struct drm_agp_buffer *request = data; | ||
382 | |||
383 | return drm_agp_free(dev, request); | ||
434 | } | 384 | } |
435 | 385 | ||
436 | /** | 386 | /** |