From 46754246bddd1c15d61e915bd860448bab8d7400 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 19 Nov 2015 02:21:30 +0100 Subject: Driver versioning --- driver/ioctl.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'driver/ioctl.c') diff --git a/driver/ioctl.c b/driver/ioctl.c index a78d366..e003476 100644 --- a/driver/ioctl.c +++ b/driver/ioctl.c @@ -28,6 +28,9 @@ #include #include #include +#include + +#include "../pcilib/version.h" #include "config.h" /* Configuration for the driver */ #include "compat.h" /* Compatibility functions/definitions */ @@ -407,6 +410,53 @@ static int ioctl_clear_ioq(pcidriver_privdata_t *privdata, unsigned long arg) } +/** + * + * Gets the device and API versions. + * + * @see pcilib_driver_version_t + * + */ +static int ioctl_version(pcidriver_privdata_t *privdata, unsigned long arg) +{ + int ret; + pcilib_driver_version_t info; + + info = (pcilib_driver_version_t) { + .version = PCILIB_VERSION, + .interface = PCIDRIVER_INTERFACE_VERSION, + .ioctls = PCIDRIVER_IOC_MAX + 1 + }; + + WRITE_TO_USER(pcilib_driver_version_t, info); + + return 0; +} + + +/** + * + * Gets current device and driver configuration + * + * @see pcilib_device_state_t + * + */ +static int ioctl_device_state(pcidriver_privdata_t *privdata, unsigned long arg) +{ + int ret; + pcilib_device_state_t info; + + info = (pcilib_device_state_t) { + .iommu = iommu_present(privdata->pdev->dev.bus), + .dma_mask = privdata->pdev->dma_mask + }; + + WRITE_TO_USER(pcilib_device_state_t, info); + + return 0; +} + + /** * * Sets DMA mask for the following DMA mappings. @@ -491,8 +541,14 @@ long pcidriver_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) case PCIDRIVER_IOC_CLEAR_IOQ: return ioctl_clear_ioq(privdata, arg); + + case PCIDRIVER_IOC_VERSION: + return ioctl_version(privdata, arg); + + case PCIDRIVER_IOC_DEVICE_STATE: + return ioctl_device_state(privdata, arg); - case PCIDRIVER_IOC_SET_DMA_MASK: + case PCIDRIVER_IOC_DMA_MASK: return ioctl_set_dma_mask(privdata, arg); default: -- cgit v1.2.3