Thread: [Linux1394-cvslog] rev 784 - trunk
Brought to you by:
aeb,
bencollins
From: SVN U. <ben...@li...> - 2003-02-14 00:54:32
|
Author: bencollins Date: 2003-02-13 19:53:59 -0500 (Thu, 13 Feb 2003) New Revision: 784 Modified: trunk/dv1394.c Log: Add ioctl32 translations. Modified: trunk/dv1394.c ============================================================================== --- trunk/dv1394.c (original) +++ trunk/dv1394.c 2003-02-13 19:54:00.000000000 -0500 @@ -111,6 +111,8 @@ #include <linux/wrapper.h> #include <linux/vmalloc.h> #include <linux/string.h> +#include <linux/ioctl32.h> +#include <linux/compat.h> #include "ieee1394.h" #include "ieee1394_types.h" @@ -2907,6 +2909,90 @@ .host_reset = dv1394_host_reset, }; +#ifdef CONFIG_COMPAT + +#define DV1394_IOC32_INIT _IOW('#', 0x06, struct dv1394_init32) +#define DV1394_IOC32_GET_STATUS _IOR('#', 0x0c, struct dv1394_status32) + +struct dv1394_init32 { + u32 api_version; + u32 channel; + u32 n_frames; + u32 format; + u32 cip_n; + u32 cip_d; + u32 syt_offset; +}; + +struct dv1394_status32 { + struct dv1394_init32 init; + s32 active_frame; + u32 first_clear_frame; + u32 n_clear_frames; + u32 dropped_frames; +}; + +static int handle_dv1394_init(unsigned int fd, unsigned int cmd, unsigned long arg, + struct file *file) +{ + struct dv1394_init32 dv32; + struct dv1394_init dv; + mm_segment_t old_fs; + int ret; + + if (copy_from_user(&dv32, (void *)arg, sizeof(dv32))) + return -EFAULT; + + dv.api_version = dv32.api_version; + dv.channel = dv32.channel; + dv.n_frames = dv32.n_frames; + dv.format = dv32.format; + dv.cip_n = (unsigned long)dv32.cip_n; + dv.cip_d = (unsigned long)dv32.cip_d; + dv.syt_offset = dv32.syt_offset; + + old_fs = get_fs(); + set_fs(KERNEL_DS); + ret = sys_ioctl(fd, DV1394_IOC_INIT, (unsigned long) &dv); + set_fs(old_fs); + + return ret; +} + +static int handle_dv1394_get_status(unsigned int fd, unsigned int cmd, unsigned long arg, + struct file *file) +{ + struct dv1394_status32 dv32; + struct dv1394_status dv; + mm_segment_t old_fs; + int ret; + + old_fs = get_fs(); + set_fs(KERNEL_DS); + ret = sys_ioctl(fd, DV1394_IOC_GET_STATUS, (unsigned long) &dv); + set_fs(old_fs); + + if (!ret) { + dv32.init.api_version = dv.init.api_version; + dv32.init.channel = dv.init.channel; + dv32.init.n_frames = dv.init.n_frames; + dv32.init.format = dv.init.format; + dv32.init.cip_n = (u32)dv.init.cip_n; + dv32.init.cip_d = (u32)dv.init.cip_d; + dv32.init.syt_offset = dv.init.syt_offset; + dv32.active_frame = dv.active_frame; + dv32.first_clear_frame = dv.first_clear_frame; + dv32.n_clear_frames = dv.n_clear_frames; + dv32.dropped_frames = dv.dropped_frames; + + if (copy_to_user((struct dv1394_status32 *)arg, &dv32, sizeof(dv32))) + ret = -EFAULT; + } + + return ret; +} +#endif /* CONFIG_COMPAT */ + /*** KERNEL MODULE HANDLERS ************************************************/ @@ -2917,6 +3003,16 @@ static void __exit dv1394_exit_module(void) { +#ifdef CONFIG_COMPAT + unregister_ioctl32_conversion(DV1394_IOC_SHUTDOWN); + unregister_ioctl32_conversion(DV1394_IOC_SUBMIT_FRAMES); + unregister_ioctl32_conversion(DV1394_IOC_WAIT_FRAMES); + unregister_ioctl32_conversion(DV1394_IOC_RECEIVE_FRAMES); + unregister_ioctl32_conversion(DV1394_IOC_START_RECEIVE); + unregister_ioctl32_conversion(DV1394_IOC32_INIT); + unregister_ioctl32_conversion(DV1394_IOC32_GET_STATUS); +#endif + hpsb_unregister_highlevel (hl_handle); ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_DV1394); #ifdef CONFIG_DEVFS_FS @@ -2967,9 +3063,21 @@ return -ENOMEM; } +#ifdef CONFIG_COMPAT + /* First compatible ones */ + register_ioctl32_conversion(DV1394_IOC_SHUTDOWN, NULL); + register_ioctl32_conversion(DV1394_IOC_SUBMIT_FRAMES, NULL); + register_ioctl32_conversion(DV1394_IOC_WAIT_FRAMES, NULL); + register_ioctl32_conversion(DV1394_IOC_RECEIVE_FRAMES, NULL); + register_ioctl32_conversion(DV1394_IOC_START_RECEIVE, NULL); + + /* These need to be handled by translation */ + register_ioctl32_conversion(DV1394_IOC32_INIT, handle_dv1394_init); + register_ioctl32_conversion(DV1394_IOC32_GET_STATUS, handle_dv1394_get_status); +#endif + return 0; } module_init(dv1394_init_module); module_exit(dv1394_exit_module); - |