[5] staging: vchiq_arm: add compat create_service ioctl
Dan Carpenter
dan.carpenter at oracle.com
Mon Jan 23 03:43:04 PST 2017
This implements the compat IOCTL for VCHIQ_IOC_CREATE_SERVICE32
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index 0ffe4bf8d826..6ea33cdf3976 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -47,6 +47,7 @@
#include <linux/list.h>
#include <linux/of.h>
#include <linux/platform_device.h>
+#include <linux/compat.h>
#include <soc/bcm2835/raspberrypi-firmware.h>
#include "vchiq_core.h"
@@ -587,6 +588,53 @@ vchiq_ioctl_create_service(struct file *file, unsigned int cmd,
return do_ioctl_create_service(file, &args, &uargs->handle);
}
+#if defined(CONFIG_COMPAT)
+struct vchiq_service_base32 {
+ int fourcc;
+ compat_uptr_t callback;
+ compat_uptr_t userdata;
+};
+
+struct vchiq_service_params32 {
+ int fourcc;
+ compat_uptr_t callback;
+ compat_uptr_t userdata;
+ short version; /* Increment for non-trivial changes */
+ short version_min; /* Update for incompatible changes */
+};
+
+struct vchiq_create_service32 {
+ struct vchiq_service_params32 params;
+ int is_open;
+ int is_vchi;
+ unsigned int handle; /* OUT */
+};
+
+#define VCHIQ_IOC_CREATE_SERVICE32 \
+ _IOWR(VCHIQ_IOC_MAGIC, 2, struct vchiq_create_service32)
+
+static int
+vchiq_ioctl_create_service_compat(struct file *file, unsigned int cmd,
+ struct vchiq_create_service32 *uargs)
+{
+ struct vchiq_create_service32 args32;
+ VCHIQ_CREATE_SERVICE_T args;
+
+ if (copy_from_user(&args32, uargs, sizeof(args32)))
+ return -EFAULT;
+
+ args.params.fourcc = args32.params.fourcc;
+ args.params.callback = compat_ptr(args32.params.callback);
+ args.params.userdata = compat_ptr(args32.params.userdata);
+ args.params.version = args32.params.version;
+ args.params.version_min = args32.params.version_min;
+ args.is_open = args32.is_open;
+ args.is_vchi = args32.is_vchi;
+
+ return do_ioctl_create_service(file, &args, &uargs->handle);
+}
+#endif
+
/****************************************************************************
*
* vchiq_ioctl
@@ -1218,6 +1266,20 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return ret;
}
+#if defined(CONFIG_COMPAT)
+static long
+vchiq_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ switch (cmd) {
+ case VCHIQ_IOC_CREATE_SERVICE32:
+ return vchiq_ioctl_create_service_compat(file, cmd,
+ (void __user *)arg);
+ default:
+ return vchiq_ioctl(file, cmd, arg);
+ }
+}
+#endif
+
/****************************************************************************
*
* vchiq_open
@@ -1672,6 +1734,9 @@ static const struct file_operations
vchiq_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = vchiq_ioctl,
+#if defined(CONFIG_COMPAT)
+ .compat_ioctl = vchiq_ioctl_compat,
+#endif
.open = vchiq_open,
.release = vchiq_release,
.read = vchiq_read
More information about the linux-rpi-kernel
mailing list