/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to driver/ioctl.c

  • Committer: Suren A. Chilingaryan
  • Date: 2015-11-19 01:21:30 UTC
  • Revision ID: csa@suren.me-20151119012130-e7qfp7563fqxqhiy
Driver versioning

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <linux/interrupt.h>
29
29
#include <linux/wait.h>
30
30
#include <linux/sched.h>
 
31
#include <linux/iommu.h>
 
32
 
 
33
#include "../pcilib/version.h"
31
34
 
32
35
#include "config.h"                     /* Configuration for the driver */
33
36
#include "compat.h"                     /* Compatibility functions/definitions */
409
412
 
410
413
/**
411
414
 *
 
415
 * Gets the device and API versions.
 
416
 *
 
417
 * @see pcilib_driver_version_t
 
418
 *
 
419
 */
 
420
static int ioctl_version(pcidriver_privdata_t *privdata, unsigned long arg)
 
421
{
 
422
        int ret;
 
423
        pcilib_driver_version_t info;
 
424
 
 
425
        info = (pcilib_driver_version_t) {
 
426
            .version = PCILIB_VERSION,
 
427
            .interface = PCIDRIVER_INTERFACE_VERSION,
 
428
            .ioctls = PCIDRIVER_IOC_MAX + 1
 
429
        };
 
430
 
 
431
        WRITE_TO_USER(pcilib_driver_version_t, info);
 
432
 
 
433
        return 0;
 
434
}
 
435
 
 
436
 
 
437
/**
 
438
 *
 
439
 * Gets current device and driver configuration
 
440
 *
 
441
 * @see pcilib_device_state_t
 
442
 *
 
443
 */
 
444
static int ioctl_device_state(pcidriver_privdata_t *privdata, unsigned long arg)
 
445
{
 
446
        int ret;
 
447
        pcilib_device_state_t info;
 
448
 
 
449
        info = (pcilib_device_state_t) {
 
450
            .iommu = iommu_present(privdata->pdev->dev.bus),
 
451
            .dma_mask = privdata->pdev->dma_mask
 
452
        };
 
453
 
 
454
        WRITE_TO_USER(pcilib_device_state_t, info);
 
455
 
 
456
        return 0;
 
457
}
 
458
 
 
459
 
 
460
/**
 
461
 *
412
462
 * Sets DMA mask for the following DMA mappings.
413
463
 *
414
464
 * @param arg Not a pointer, but a number of bits
491
541
 
492
542
                case PCIDRIVER_IOC_CLEAR_IOQ:
493
543
                        return ioctl_clear_ioq(privdata, arg);
494
 
 
495
 
                case PCIDRIVER_IOC_SET_DMA_MASK:
 
544
                
 
545
                case PCIDRIVER_IOC_VERSION:
 
546
                        return ioctl_version(privdata, arg);
 
547
 
 
548
                case PCIDRIVER_IOC_DEVICE_STATE:
 
549
                        return ioctl_device_state(privdata, arg);
 
550
 
 
551
                case PCIDRIVER_IOC_DMA_MASK:
496
552
                        return ioctl_set_dma_mask(privdata, arg);
497
553
 
498
554
                default: