aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/via_irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/drm/via_irq.c')
-rw-r--r--drivers/char/drm/via_irq.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/drivers/char/drm/via_irq.c b/drivers/char/drm/via_irq.c
index 8dc99b5fbab6..9c1d52bc92d7 100644
--- a/drivers/char/drm/via_irq.c
+++ b/drivers/char/drm/via_irq.c
@@ -205,13 +205,13 @@ via_driver_irq_wait(struct drm_device * dev, unsigned int irq, int force_sequenc
205 205
206 if (!dev_priv) { 206 if (!dev_priv) {
207 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 207 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
208 return DRM_ERR(EINVAL); 208 return -EINVAL;
209 } 209 }
210 210
211 if (irq >= drm_via_irq_num) { 211 if (irq >= drm_via_irq_num) {
212 DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__, 212 DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__,
213 irq); 213 irq);
214 return DRM_ERR(EINVAL); 214 return -EINVAL;
215 } 215 }
216 216
217 real_irq = dev_priv->irq_map[irq]; 217 real_irq = dev_priv->irq_map[irq];
@@ -219,7 +219,7 @@ via_driver_irq_wait(struct drm_device * dev, unsigned int irq, int force_sequenc
219 if (real_irq < 0) { 219 if (real_irq < 0) {
220 DRM_ERROR("%s Video IRQ %d not available on this hardware.\n", 220 DRM_ERROR("%s Video IRQ %d not available on this hardware.\n",
221 __FUNCTION__, irq); 221 __FUNCTION__, irq);
222 return DRM_ERR(EINVAL); 222 return -EINVAL;
223 } 223 }
224 224
225 masks = dev_priv->irq_masks; 225 masks = dev_priv->irq_masks;
@@ -331,11 +331,9 @@ void via_driver_irq_uninstall(struct drm_device * dev)
331 } 331 }
332} 332}
333 333
334int via_wait_irq(DRM_IOCTL_ARGS) 334int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
335{ 335{
336 DRM_DEVICE; 336 drm_via_irqwait_t *irqwait = data;
337 drm_via_irqwait_t __user *argp = (void __user *)data;
338 drm_via_irqwait_t irqwait;
339 struct timeval now; 337 struct timeval now;
340 int ret = 0; 338 int ret = 0;
341 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; 339 drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
@@ -343,42 +341,39 @@ int via_wait_irq(DRM_IOCTL_ARGS)
343 int force_sequence; 341 int force_sequence;
344 342
345 if (!dev->irq) 343 if (!dev->irq)
346 return DRM_ERR(EINVAL); 344 return -EINVAL;
347 345
348 DRM_COPY_FROM_USER_IOCTL(irqwait, argp, sizeof(irqwait)); 346 if (irqwait->request.irq >= dev_priv->num_irqs) {
349 if (irqwait.request.irq >= dev_priv->num_irqs) {
350 DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__, 347 DRM_ERROR("%s Trying to wait on unknown irq %d\n", __FUNCTION__,
351 irqwait.request.irq); 348 irqwait->request.irq);
352 return DRM_ERR(EINVAL); 349 return -EINVAL;
353 } 350 }
354 351
355 cur_irq += irqwait.request.irq; 352 cur_irq += irqwait->request.irq;
356 353
357 switch (irqwait.request.type & ~VIA_IRQ_FLAGS_MASK) { 354 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
358 case VIA_IRQ_RELATIVE: 355 case VIA_IRQ_RELATIVE:
359 irqwait.request.sequence += atomic_read(&cur_irq->irq_received); 356 irqwait->request.sequence += atomic_read(&cur_irq->irq_received);
360 irqwait.request.type &= ~_DRM_VBLANK_RELATIVE; 357 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
361 case VIA_IRQ_ABSOLUTE: 358 case VIA_IRQ_ABSOLUTE:
362 break; 359 break;
363 default: 360 default:
364 return DRM_ERR(EINVAL); 361 return -EINVAL;
365 } 362 }
366 363
367 if (irqwait.request.type & VIA_IRQ_SIGNAL) { 364 if (irqwait->request.type & VIA_IRQ_SIGNAL) {
368 DRM_ERROR("%s Signals on Via IRQs not implemented yet.\n", 365 DRM_ERROR("%s Signals on Via IRQs not implemented yet.\n",
369 __FUNCTION__); 366 __FUNCTION__);
370 return DRM_ERR(EINVAL); 367 return -EINVAL;
371 } 368 }
372 369
373 force_sequence = (irqwait.request.type & VIA_IRQ_FORCE_SEQUENCE); 370 force_sequence = (irqwait->request.type & VIA_IRQ_FORCE_SEQUENCE);
374 371
375 ret = via_driver_irq_wait(dev, irqwait.request.irq, force_sequence, 372 ret = via_driver_irq_wait(dev, irqwait->request.irq, force_sequence,
376 &irqwait.request.sequence); 373 &irqwait->request.sequence);
377 do_gettimeofday(&now); 374 do_gettimeofday(&now);
378 irqwait.reply.tval_sec = now.tv_sec; 375 irqwait->reply.tval_sec = now.tv_sec;
379 irqwait.reply.tval_usec = now.tv_usec; 376 irqwait->reply.tval_usec = now.tv_usec;
380
381 DRM_COPY_TO_USER_IOCTL(argp, irqwait, sizeof(irqwait));
382 377
383 return ret; 378 return ret;
384} 379}