aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/savage_bci.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/savage_bci.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/savage_bci.c')
-rw-r--r--drivers/char/drm/savage_bci.c67
1 files changed, 26 insertions, 41 deletions
diff --git a/drivers/char/drm/savage_bci.c b/drivers/char/drm/savage_bci.c
index 18a3bc387817..59484d56b333 100644
--- a/drivers/char/drm/savage_bci.c
+++ b/drivers/char/drm/savage_bci.c
@@ -928,19 +928,15 @@ static int savage_do_cleanup_bci(struct drm_device * dev)
928 return 0; 928 return 0;
929} 929}
930 930
931static int savage_bci_init(DRM_IOCTL_ARGS) 931static int savage_bci_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
932{ 932{
933 DRM_DEVICE; 933 drm_savage_init_t *init = data;
934 drm_savage_init_t init;
935 934
936 LOCK_TEST_WITH_RETURN(dev, file_priv); 935 LOCK_TEST_WITH_RETURN(dev, file_priv);
937 936
938 DRM_COPY_FROM_USER_IOCTL(init, (drm_savage_init_t __user *) data, 937 switch (init->func) {
939 sizeof(init));
940
941 switch (init.func) {
942 case SAVAGE_INIT_BCI: 938 case SAVAGE_INIT_BCI:
943 return savage_do_init_bci(dev, &init); 939 return savage_do_init_bci(dev, init);
944 case SAVAGE_CLEANUP_BCI: 940 case SAVAGE_CLEANUP_BCI:
945 return savage_do_cleanup_bci(dev); 941 return savage_do_cleanup_bci(dev);
946 } 942 }
@@ -948,31 +944,25 @@ static int savage_bci_init(DRM_IOCTL_ARGS)
948 return -EINVAL; 944 return -EINVAL;
949} 945}
950 946
951static int savage_bci_event_emit(DRM_IOCTL_ARGS) 947static int savage_bci_event_emit(struct drm_device *dev, void *data, struct drm_file *file_priv)
952{ 948{
953 DRM_DEVICE;
954 drm_savage_private_t *dev_priv = dev->dev_private; 949 drm_savage_private_t *dev_priv = dev->dev_private;
955 drm_savage_event_emit_t event; 950 drm_savage_event_emit_t *event = data;
956 951
957 DRM_DEBUG("\n"); 952 DRM_DEBUG("\n");
958 953
959 LOCK_TEST_WITH_RETURN(dev, file_priv); 954 LOCK_TEST_WITH_RETURN(dev, file_priv);
960 955
961 DRM_COPY_FROM_USER_IOCTL(event, (drm_savage_event_emit_t __user *) data, 956 event->count = savage_bci_emit_event(dev_priv, event->flags);
962 sizeof(event)); 957 event->count |= dev_priv->event_wrap << 16;
963 958
964 event.count = savage_bci_emit_event(dev_priv, event.flags);
965 event.count |= dev_priv->event_wrap << 16;
966 DRM_COPY_TO_USER_IOCTL((drm_savage_event_emit_t __user *) data,
967 event, sizeof(event));
968 return 0; 959 return 0;
969} 960}
970 961
971static int savage_bci_event_wait(DRM_IOCTL_ARGS) 962static int savage_bci_event_wait(struct drm_device *dev, void *data, struct drm_file *file_priv)
972{ 963{
973 DRM_DEVICE;
974 drm_savage_private_t *dev_priv = dev->dev_private; 964 drm_savage_private_t *dev_priv = dev->dev_private;
975 drm_savage_event_wait_t event; 965 drm_savage_event_wait_t *event = data;
976 unsigned int event_e, hw_e; 966 unsigned int event_e, hw_e;
977 unsigned int event_w, hw_w; 967 unsigned int event_w, hw_w;
978 968
@@ -990,8 +980,8 @@ static int savage_bci_event_wait(DRM_IOCTL_ARGS)
990 if (hw_e > dev_priv->event_counter) 980 if (hw_e > dev_priv->event_counter)
991 hw_w--; /* hardware hasn't passed the last wrap yet */ 981 hw_w--; /* hardware hasn't passed the last wrap yet */
992 982
993 event_e = event.count & 0xffff; 983 event_e = event->count & 0xffff;
994 event_w = event.count >> 16; 984 event_w = event->count >> 16;
995 985
996 /* Don't need to wait if 986 /* Don't need to wait if
997 * - event counter wrapped since the event was emitted or 987 * - event counter wrapped since the event was emitted or
@@ -1033,41 +1023,36 @@ static int savage_bci_get_buffers(struct drm_device *dev,
1033 return 0; 1023 return 0;
1034} 1024}
1035 1025
1036int savage_bci_buffers(DRM_IOCTL_ARGS) 1026int savage_bci_buffers(struct drm_device *dev, void *data, struct drm_file *file_priv)
1037{ 1027{
1038 DRM_DEVICE;
1039 struct drm_device_dma *dma = dev->dma; 1028 struct drm_device_dma *dma = dev->dma;
1040 struct drm_dma d; 1029 struct drm_dma *d = data;
1041 int ret = 0; 1030 int ret = 0;
1042 1031
1043 LOCK_TEST_WITH_RETURN(dev, file_priv); 1032 LOCK_TEST_WITH_RETURN(dev, file_priv);
1044 1033
1045 DRM_COPY_FROM_USER_IOCTL(d, (struct drm_dma __user *) data, sizeof(d));
1046
1047 /* Please don't send us buffers. 1034 /* Please don't send us buffers.
1048 */ 1035 */
1049 if (d.send_count != 0) { 1036 if (d->send_count != 0) {
1050 DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n", 1037 DRM_ERROR("Process %d trying to send %d buffers via drmDMA\n",
1051 DRM_CURRENTPID, d.send_count); 1038 DRM_CURRENTPID, d->send_count);
1052 return -EINVAL; 1039 return -EINVAL;
1053 } 1040 }
1054 1041
1055 /* We'll send you buffers. 1042 /* We'll send you buffers.
1056 */ 1043 */
1057 if (d.request_count < 0 || d.request_count > dma->buf_count) { 1044 if (d->request_count < 0 || d->request_count > dma->buf_count) {
1058 DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", 1045 DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
1059 DRM_CURRENTPID, d.request_count, dma->buf_count); 1046 DRM_CURRENTPID, d->request_count, dma->buf_count);
1060 return -EINVAL; 1047 return -EINVAL;
1061 } 1048 }
1062 1049
1063 d.granted_count = 0; 1050 d->granted_count = 0;
1064 1051
1065 if (d.request_count) { 1052 if (d->request_count) {
1066 ret = savage_bci_get_buffers(dev, file_priv, &d); 1053 ret = savage_bci_get_buffers(dev, file_priv, d);
1067 } 1054 }
1068 1055
1069 DRM_COPY_TO_USER_IOCTL((struct drm_dma __user *) data, d, sizeof(d));
1070
1071 return ret; 1056 return ret;
1072} 1057}
1073 1058
@@ -1103,11 +1088,11 @@ void savage_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
1103 drm_core_reclaim_buffers(dev, file_priv); 1088 drm_core_reclaim_buffers(dev, file_priv);
1104} 1089}
1105 1090
1106drm_ioctl_desc_t savage_ioctls[] = { 1091struct drm_ioctl_desc savage_ioctls[] = {
1107 [DRM_IOCTL_NR(DRM_SAVAGE_BCI_INIT)] = {savage_bci_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, 1092 DRM_IOCTL_DEF(DRM_SAVAGE_BCI_INIT, savage_bci_init, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
1108 [DRM_IOCTL_NR(DRM_SAVAGE_BCI_CMDBUF)] = {savage_bci_cmdbuf, DRM_AUTH}, 1093 DRM_IOCTL_DEF(DRM_SAVAGE_BCI_CMDBUF, savage_bci_cmdbuf, DRM_AUTH),
1109 [DRM_IOCTL_NR(DRM_SAVAGE_BCI_EVENT_EMIT)] = {savage_bci_event_emit, DRM_AUTH}, 1094 DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_EMIT, savage_bci_event_emit, DRM_AUTH),
1110 [DRM_IOCTL_NR(DRM_SAVAGE_BCI_EVENT_WAIT)] = {savage_bci_event_wait, DRM_AUTH}, 1095 DRM_IOCTL_DEF(DRM_SAVAGE_BCI_EVENT_WAIT, savage_bci_event_wait, DRM_AUTH),
1111}; 1096};
1112 1097
1113int savage_max_ioctl = DRM_ARRAY_SIZE(savage_ioctls); 1098int savage_max_ioctl = DRM_ARRAY_SIZE(savage_ioctls);