diff options
Diffstat (limited to 'drivers/char/drm/via_dma.c')
-rw-r--r-- | drivers/char/drm/via_dma.c | 96 |
1 files changed, 39 insertions, 57 deletions
diff --git a/drivers/char/drm/via_dma.c b/drivers/char/drm/via_dma.c index 6d3e4eecf8f8..75d6b748c2c0 100644 --- a/drivers/char/drm/via_dma.c +++ b/drivers/char/drm/via_dma.c | |||
@@ -227,22 +227,18 @@ static int via_initialize(struct drm_device * dev, | |||
227 | return 0; | 227 | return 0; |
228 | } | 228 | } |
229 | 229 | ||
230 | static int via_dma_init(DRM_IOCTL_ARGS) | 230 | static int via_dma_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
231 | { | 231 | { |
232 | DRM_DEVICE; | ||
233 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 232 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
234 | drm_via_dma_init_t init; | 233 | drm_via_dma_init_t *init = data; |
235 | int retcode = 0; | 234 | int retcode = 0; |
236 | 235 | ||
237 | DRM_COPY_FROM_USER_IOCTL(init, (drm_via_dma_init_t __user *) data, | 236 | switch (init->func) { |
238 | sizeof(init)); | ||
239 | |||
240 | switch (init.func) { | ||
241 | case VIA_INIT_DMA: | 237 | case VIA_INIT_DMA: |
242 | if (!DRM_SUSER(DRM_CURPROC)) | 238 | if (!DRM_SUSER(DRM_CURPROC)) |
243 | retcode = -EPERM; | 239 | retcode = -EPERM; |
244 | else | 240 | else |
245 | retcode = via_initialize(dev, dev_priv, &init); | 241 | retcode = via_initialize(dev, dev_priv, init); |
246 | break; | 242 | break; |
247 | case VIA_CLEANUP_DMA: | 243 | case VIA_CLEANUP_DMA: |
248 | if (!DRM_SUSER(DRM_CURPROC)) | 244 | if (!DRM_SUSER(DRM_CURPROC)) |
@@ -326,29 +322,25 @@ int via_driver_dma_quiescent(struct drm_device * dev) | |||
326 | return 0; | 322 | return 0; |
327 | } | 323 | } |
328 | 324 | ||
329 | static int via_flush_ioctl(DRM_IOCTL_ARGS) | 325 | static int via_flush_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) |
330 | { | 326 | { |
331 | DRM_DEVICE; | ||
332 | 327 | ||
333 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 328 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
334 | 329 | ||
335 | return via_driver_dma_quiescent(dev); | 330 | return via_driver_dma_quiescent(dev); |
336 | } | 331 | } |
337 | 332 | ||
338 | static int via_cmdbuffer(DRM_IOCTL_ARGS) | 333 | static int via_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv) |
339 | { | 334 | { |
340 | DRM_DEVICE; | 335 | drm_via_cmdbuffer_t *cmdbuf = data; |
341 | drm_via_cmdbuffer_t cmdbuf; | ||
342 | int ret; | 336 | int ret; |
343 | 337 | ||
344 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 338 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
345 | 339 | ||
346 | DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t __user *) data, | 340 | DRM_DEBUG("via cmdbuffer, buf %p size %lu\n", cmdbuf->buf, |
347 | sizeof(cmdbuf)); | 341 | cmdbuf->size); |
348 | |||
349 | DRM_DEBUG("via cmdbuffer, buf %p size %lu\n", cmdbuf.buf, cmdbuf.size); | ||
350 | 342 | ||
351 | ret = via_dispatch_cmdbuffer(dev, &cmdbuf); | 343 | ret = via_dispatch_cmdbuffer(dev, cmdbuf); |
352 | if (ret) { | 344 | if (ret) { |
353 | return ret; | 345 | return ret; |
354 | } | 346 | } |
@@ -380,21 +372,17 @@ static int via_dispatch_pci_cmdbuffer(struct drm_device * dev, | |||
380 | return ret; | 372 | return ret; |
381 | } | 373 | } |
382 | 374 | ||
383 | static int via_pci_cmdbuffer(DRM_IOCTL_ARGS) | 375 | static int via_pci_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv) |
384 | { | 376 | { |
385 | DRM_DEVICE; | 377 | drm_via_cmdbuffer_t *cmdbuf = data; |
386 | drm_via_cmdbuffer_t cmdbuf; | ||
387 | int ret; | 378 | int ret; |
388 | 379 | ||
389 | LOCK_TEST_WITH_RETURN(dev, file_priv); | 380 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
390 | 381 | ||
391 | DRM_COPY_FROM_USER_IOCTL(cmdbuf, (drm_via_cmdbuffer_t __user *) data, | 382 | DRM_DEBUG("via_pci_cmdbuffer, buf %p size %lu\n", cmdbuf->buf, |
392 | sizeof(cmdbuf)); | 383 | cmdbuf->size); |
393 | 384 | ||
394 | DRM_DEBUG("via_pci_cmdbuffer, buf %p size %lu\n", cmdbuf.buf, | 385 | ret = via_dispatch_pci_cmdbuffer(dev, cmdbuf); |
395 | cmdbuf.size); | ||
396 | |||
397 | ret = via_dispatch_pci_cmdbuffer(dev, &cmdbuf); | ||
398 | if (ret) { | 386 | if (ret) { |
399 | return ret; | 387 | return ret; |
400 | } | 388 | } |
@@ -653,10 +641,9 @@ static void via_cmdbuf_reset(drm_via_private_t * dev_priv) | |||
653 | * User interface to the space and lag functions. | 641 | * User interface to the space and lag functions. |
654 | */ | 642 | */ |
655 | 643 | ||
656 | static int via_cmdbuf_size(DRM_IOCTL_ARGS) | 644 | static int via_cmdbuf_size(struct drm_device *dev, void *data, struct drm_file *file_priv) |
657 | { | 645 | { |
658 | DRM_DEVICE; | 646 | drm_via_cmdbuf_size_t *d_siz = data; |
659 | drm_via_cmdbuf_size_t d_siz; | ||
660 | int ret = 0; | 647 | int ret = 0; |
661 | uint32_t tmp_size, count; | 648 | uint32_t tmp_size, count; |
662 | drm_via_private_t *dev_priv; | 649 | drm_via_private_t *dev_priv; |
@@ -672,16 +659,13 @@ static int via_cmdbuf_size(DRM_IOCTL_ARGS) | |||
672 | return -EFAULT; | 659 | return -EFAULT; |
673 | } | 660 | } |
674 | 661 | ||
675 | DRM_COPY_FROM_USER_IOCTL(d_siz, (drm_via_cmdbuf_size_t __user *) data, | ||
676 | sizeof(d_siz)); | ||
677 | |||
678 | count = 1000000; | 662 | count = 1000000; |
679 | tmp_size = d_siz.size; | 663 | tmp_size = d_siz->size; |
680 | switch (d_siz.func) { | 664 | switch (d_siz->func) { |
681 | case VIA_CMDBUF_SPACE: | 665 | case VIA_CMDBUF_SPACE: |
682 | while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz.size) | 666 | while (((tmp_size = via_cmdbuf_space(dev_priv)) < d_siz->size) |
683 | && count--) { | 667 | && count--) { |
684 | if (!d_siz.wait) { | 668 | if (!d_siz->wait) { |
685 | break; | 669 | break; |
686 | } | 670 | } |
687 | } | 671 | } |
@@ -691,9 +675,9 @@ static int via_cmdbuf_size(DRM_IOCTL_ARGS) | |||
691 | } | 675 | } |
692 | break; | 676 | break; |
693 | case VIA_CMDBUF_LAG: | 677 | case VIA_CMDBUF_LAG: |
694 | while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz.size) | 678 | while (((tmp_size = via_cmdbuf_lag(dev_priv)) > d_siz->size) |
695 | && count--) { | 679 | && count--) { |
696 | if (!d_siz.wait) { | 680 | if (!d_siz->wait) { |
697 | break; | 681 | break; |
698 | } | 682 | } |
699 | } | 683 | } |
@@ -705,28 +689,26 @@ static int via_cmdbuf_size(DRM_IOCTL_ARGS) | |||
705 | default: | 689 | default: |
706 | ret = -EFAULT; | 690 | ret = -EFAULT; |
707 | } | 691 | } |
708 | d_siz.size = tmp_size; | 692 | d_siz->size = tmp_size; |
709 | 693 | ||
710 | DRM_COPY_TO_USER_IOCTL((drm_via_cmdbuf_size_t __user *) data, d_siz, | ||
711 | sizeof(d_siz)); | ||
712 | return ret; | 694 | return ret; |
713 | } | 695 | } |
714 | 696 | ||
715 | drm_ioctl_desc_t via_ioctls[] = { | 697 | struct drm_ioctl_desc via_ioctls[] = { |
716 | [DRM_IOCTL_NR(DRM_VIA_ALLOCMEM)] = {via_mem_alloc, DRM_AUTH}, | 698 | DRM_IOCTL_DEF(DRM_VIA_ALLOCMEM, via_mem_alloc, DRM_AUTH), |
717 | [DRM_IOCTL_NR(DRM_VIA_FREEMEM)] = {via_mem_free, DRM_AUTH}, | 699 | DRM_IOCTL_DEF(DRM_VIA_FREEMEM, via_mem_free, DRM_AUTH), |
718 | [DRM_IOCTL_NR(DRM_VIA_AGP_INIT)] = {via_agp_init, DRM_AUTH|DRM_MASTER}, | 700 | DRM_IOCTL_DEF(DRM_VIA_AGP_INIT, via_agp_init, DRM_AUTH|DRM_MASTER), |
719 | [DRM_IOCTL_NR(DRM_VIA_FB_INIT)] = {via_fb_init, DRM_AUTH|DRM_MASTER}, | 701 | DRM_IOCTL_DEF(DRM_VIA_FB_INIT, via_fb_init, DRM_AUTH|DRM_MASTER), |
720 | [DRM_IOCTL_NR(DRM_VIA_MAP_INIT)] = {via_map_init, DRM_AUTH|DRM_MASTER}, | 702 | DRM_IOCTL_DEF(DRM_VIA_MAP_INIT, via_map_init, DRM_AUTH|DRM_MASTER), |
721 | [DRM_IOCTL_NR(DRM_VIA_DEC_FUTEX)] = {via_decoder_futex, DRM_AUTH}, | 703 | DRM_IOCTL_DEF(DRM_VIA_DEC_FUTEX, via_decoder_futex, DRM_AUTH), |
722 | [DRM_IOCTL_NR(DRM_VIA_DMA_INIT)] = {via_dma_init, DRM_AUTH}, | 704 | DRM_IOCTL_DEF(DRM_VIA_DMA_INIT, via_dma_init, DRM_AUTH), |
723 | [DRM_IOCTL_NR(DRM_VIA_CMDBUFFER)] = {via_cmdbuffer, DRM_AUTH}, | 705 | DRM_IOCTL_DEF(DRM_VIA_CMDBUFFER, via_cmdbuffer, DRM_AUTH), |
724 | [DRM_IOCTL_NR(DRM_VIA_FLUSH)] = {via_flush_ioctl, DRM_AUTH}, | 706 | DRM_IOCTL_DEF(DRM_VIA_FLUSH, via_flush_ioctl, DRM_AUTH), |
725 | [DRM_IOCTL_NR(DRM_VIA_PCICMD)] = {via_pci_cmdbuffer, DRM_AUTH}, | 707 | DRM_IOCTL_DEF(DRM_VIA_PCICMD, via_pci_cmdbuffer, DRM_AUTH), |
726 | [DRM_IOCTL_NR(DRM_VIA_CMDBUF_SIZE)] = {via_cmdbuf_size, DRM_AUTH}, | 708 | DRM_IOCTL_DEF(DRM_VIA_CMDBUF_SIZE, via_cmdbuf_size, DRM_AUTH), |
727 | [DRM_IOCTL_NR(DRM_VIA_WAIT_IRQ)] = {via_wait_irq, DRM_AUTH}, | 709 | DRM_IOCTL_DEF(DRM_VIA_WAIT_IRQ, via_wait_irq, DRM_AUTH), |
728 | [DRM_IOCTL_NR(DRM_VIA_DMA_BLIT)] = {via_dma_blit, DRM_AUTH}, | 710 | DRM_IOCTL_DEF(DRM_VIA_DMA_BLIT, via_dma_blit, DRM_AUTH), |
729 | [DRM_IOCTL_NR(DRM_VIA_BLIT_SYNC)] = {via_dma_blit_sync, DRM_AUTH} | 711 | DRM_IOCTL_DEF(DRM_VIA_BLIT_SYNC, via_dma_blit_sync, DRM_AUTH) |
730 | }; | 712 | }; |
731 | 713 | ||
732 | int via_max_ioctl = DRM_ARRAY_SIZE(via_ioctls); | 714 | int via_max_ioctl = DRM_ARRAY_SIZE(via_ioctls); |