From patchwork Mon Aug 27 19:56:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 145213 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp343463ljw; Mon, 27 Aug 2018 12:59:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY7bPIXfRwOmzd+jFhFHAD4vav42tMELZGfg+rdkXk3ErtEDWfAW8XnUDofT0KVcYRq24Rf X-Received: by 2002:a63:c114:: with SMTP id w20-v6mr13045719pgf.234.1535399959907; Mon, 27 Aug 2018 12:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535399959; cv=none; d=google.com; s=arc-20160816; b=mGMoiumsJnOOY7E1LPElX8Al4NuQviJ/P8EriOutXcYftkb2t/3QY92q54fX/wIepo eKmSNxCmIKOkFmGqlv/YJ2GDPWJLYEGHwLQ5ShxdiPSkIcekFo2NR/+0gMzYJ/7VIzuv tqO8kNq22iTRnLYptDxoueJvTlj0/tMFeAi9FXUrz24dL9mujQ/mOsBGE+xJRbujz/ff tEiePK+z+YjCCFXc2y5CV8KQOLy3aQ9d47E2h7+tH9yqxC9w8ILnhQOdU4MHKzTptAwh RbUe44Vi+lKOLZGVTdptNoTAwtnnXJ1kKzF9LH/jDkWWd2a6XVBKCPzqAB9roh4kxhK8 pDHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=fUKnCpShPhJdPGRkPID93xXcqPbF0KSUkPkfV6/YTJA=; b=qcnoNHOb9BgdeJOdiNrbDoYbCU/3+ElCg9iNY5UA5lflZTtc2996DifVcwaplfLu4w D68dN7krRBSu2mxgXGyGCdH3dnX9oH/diCboACIzV8cJi0/MgzNU+gyrVU6Aoedd/lhw TB4qWgXZhHMLgnLd7qxwA1kNN6ACN0cKXzb1ocTkKSD6vcmLi0mzcR+E2YUWWPghN4iT 7QB0xg7X9L/XubVUNmUIpQBRJPKpAqGJqUljtRUjLAFkmpDmug7RnpN6gZqwtAAAh/tG Tv+5cVYIYjMaDjuaon6sJUyMMYfqTmAoPZBZsHBFBwW4oETJX1qUyNL1O716ZV4m252x f2Sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6-v6si124043pla.398.2018.08.27.12.59.19; Mon, 27 Aug 2018 12:59:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727547AbeH0XrU (ORCPT + 32 others); Mon, 27 Aug 2018 19:47:20 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:39627 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726826AbeH0XrU (ORCPT ); Mon, 27 Aug 2018 19:47:20 -0400 Received: from wuerfel.lan ([109.193.40.16]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0Li23m-1fZ5cK2Etu-00nD7R; Mon, 27 Aug 2018 21:59:02 +0200 From: Arnd Bergmann To: linux-media@vger.kernel.org Cc: y2038@lists.linaro.org, awalls@md.metrocast.net, hans.verkuil@cisco.com, mchehab@kernel.org, Arnd Bergmann , Alexander Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 5/5] media: dvb: move compat handlers into drivers Date: Mon, 27 Aug 2018 21:56:25 +0200 Message-Id: <20180827195649.4170969-5-arnd@arndb.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827195649.4170969-1-arnd@arndb.de> References: <20180827195649.4170969-1-arnd@arndb.de> X-Provags-ID: V03:K1:Ze3Fi6oCnqWzqCWinKMeBn/hCvpKRm5eJE/FVqmNpZddz+b0wdU OxEwqEwGphhAlRsLKacj1/2r4JNV4lj5wU+zsZcstNcreP5rr4BNjoCgKhBAuGe0tszWPNE ToHXUMIA+tkmOgWAIcPHrY+BITffHLTKuoS1q0be9YLktJDvmwzQwX9Q3cGfmnrHtzZvCS2 mlShDy45z/DsLuIYpKhjw== X-UI-Out-Filterresults: notjunk:1; V01:K0:YPqcsUVoVwc=:QtWRYBzERocYcc6+54c0Mx tsMeTv8Ix8UeCitjOi3dBb3LzQKpIneWNYoEPbVQwP8leh+hAuap4avdEZhHQTrTgmhHmyNL4 POmRR61qiUucel/1sQuM3duEQzjIlStbWoERb3f7xwowZ6JX5dvbpfITDaxyUWI6EVgO61VVc t9pFesuMGgfJTWtuC3LGitvVZOTWyUyMStd3s8/ZxkXPFnATbOm2AtHV+vMmu77qNviUYDjNx zsxH1hAF127TmIe01JU5NSe7Go5aFsELWdlJG2kzjHEsGDgk2MLK3PrKNU/70l1knHKvWuJKd JTc4/Ve1PzszZRaM014iHBsY9YSKsbsb+77T/x7coQuBlN6ZHdnEz4ycB03f0ytIyijGHrVvS qcNm1dSsMoNh5UAYorBQ045QYHJ7KnKNlwnuARhYONjPJe7kHdcM60KhtiBPZA6uyULeznWEZ ECP7dSTKLzwmrovhbV1rZMH/pVCf3EbxmKEvzLeELMl49aXNbBtPXGkUVZzeox8b1+rmqMaCf lRHGIWZ98wSfB1xDjyozsH0ysUBUL8wt4zzh3VWQmL/rYKamAS+0Rey8CR0YmB9VE4t4Xt3TT xgBb0jOjdMPXctiRPSkH5TEftk6fcrdQ3Zz7pJbT+HApk78uaoxMw786I8VoU2s81w10hKleH a9An13k2ramajW9HbkvvZ8sJSVP2sPMClViLRx3pVBXsQcxa+v82YiE3hOIugGd3xc4M= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The VIDEO_STILLPICTURE is only implemented by one driver, while VIDEO_GET_EVENT has two users in tree. In both cases, it is fairly easy to handle the compat ioctls in the native handler rather than relying on translation in fs/compat_ioctls. In effect, this means that now the drivers implement both structure layouts in both native and compat mode, but I don't see anything wrong with that. Signed-off-by: Arnd Bergmann --- drivers/media/pci/ivtv/ivtv-ioctl.c | 34 ++++++++++++- drivers/media/pci/ttpci/av7110_av.c | 56 ++++++++++++++++++++- fs/compat_ioctl.c | 78 ----------------------------- 3 files changed, 87 insertions(+), 81 deletions(-) -- 2.18.0 diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c index 4cdc6d2be85d..785dbd4be420 100644 --- a/drivers/media/pci/ivtv/ivtv-ioctl.c +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c @@ -36,6 +36,7 @@ #include #include #ifdef CONFIG_VIDEO_IVTV_DEPRECATED_IOCTLS +#include #include #include #endif @@ -1627,6 +1628,21 @@ static __inline__ void warn_deprecated_ioctl(const char *name) pr_warn_once("warning: the %s ioctl is deprecated. Don't use it, as it will be removed soon\n", name); } + +#ifdef CONFIG_COMPAT +struct compat_video_event { + __s32 type; + /* unused, make sure to use atomic time for y2038 if it ever gets used */ + compat_long_t timestamp; + union { + video_size_t size; + unsigned int frame_rate; /* in frames per 1000sec */ + unsigned char vsync_field; /* unknown/odd/even/progressive */ + } u; +}; +#define VIDEO_GET_EVENT32 _IOR('o', 28, struct compat_video_event) +#endif + #endif static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) @@ -1749,7 +1765,13 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) return ivtv_video_command(itv, id, dc, try); } +#ifdef CONFIG_COMPAT + case VIDEO_GET_EVENT32: +#endif case VIDEO_GET_EVENT: { +#ifdef CONFIG_COMPAT + struct compat_video_event *ev32 = arg; +#endif struct video_event *ev = arg; DEFINE_WAIT(wait); @@ -1763,14 +1785,22 @@ static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) if (test_and_clear_bit(IVTV_F_I_EV_DEC_STOPPED, &itv->i_flags)) ev->type = VIDEO_EVENT_DECODER_STOPPED; else if (test_and_clear_bit(IVTV_F_I_EV_VSYNC, &itv->i_flags)) { + unsigned char vsync_field; + ev->type = VIDEO_EVENT_VSYNC; - ev->u.vsync_field = test_bit(IVTV_F_I_EV_VSYNC_FIELD, &itv->i_flags) ? + vsync_field = test_bit(IVTV_F_I_EV_VSYNC_FIELD, &itv->i_flags) ? VIDEO_VSYNC_FIELD_ODD : VIDEO_VSYNC_FIELD_EVEN; if (itv->output_mode == OUT_UDMA_YUV && (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) == IVTV_YUV_MODE_PROGRESSIVE) { - ev->u.vsync_field = VIDEO_VSYNC_FIELD_PROGRESSIVE; + vsync_field = VIDEO_VSYNC_FIELD_PROGRESSIVE; } +#ifdef CONFIG_COMPAT + if (cmd == VIDEO_GET_EVENT32) + ev32->u.vsync_field = vsync_field; + else +#endif + ev->u.vsync_field = vsync_field; } if (ev->type) return 0; diff --git a/drivers/media/pci/ttpci/av7110_av.c b/drivers/media/pci/ttpci/av7110_av.c index e738b2cef6f6..fd49ee5a380a 100644 --- a/drivers/media/pci/ttpci/av7110_av.c +++ b/drivers/media/pci/ttpci/av7110_av.c @@ -932,7 +932,6 @@ static int dvb_video_get_event (struct av7110 *av7110, struct video_event *event return 0; } - /****************************************************************************** * DVB device file operations ******************************************************************************/ @@ -1095,6 +1094,42 @@ static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len return 0; } +#ifdef CONFIG_COMPAT +struct compat_video_still_picture { + compat_uptr_t iFrame; + int32_t size; +}; +#define VIDEO_STILLPICTURE32 _IOW('o', 30, struct compat_video_still_picture) + +struct compat_video_event { + __s32 type; + /* unused, make sure to use atomic time for y2038 if it ever gets used */ + compat_long_t timestamp; + union { + video_size_t size; + unsigned int frame_rate; /* in frames per 1000sec */ + unsigned char vsync_field; /* unknown/odd/even/progressive */ + } u; +}; +#define VIDEO_GET_EVENT32 _IOR('o', 28, struct compat_video_event) + +static int dvb_compat_video_get_event(struct av7110 *av7110, + struct compat_video_event *event, int flags) +{ + struct video_event ev; + int ret; + + ret = dvb_video_get_event(av7110, &ev, flags); + + *event = (struct compat_video_event) { + .type = ev.type, + .timestamp = ev.timestamp, + .u.size = ev.u.size, + }; + + return ret; +} +#endif static int dvb_video_ioctl(struct file *file, unsigned int cmd, void *parg) @@ -1184,6 +1219,12 @@ static int dvb_video_ioctl(struct file *file, memcpy(parg, &av7110->videostate, sizeof(struct video_status)); break; +#ifdef CONFIG_COMPAT + case VIDEO_GET_EVENT32: + ret = dvb_compat_video_get_event(av7110, parg, file->f_flags); + break; +#endif + case VIDEO_GET_EVENT: ret = dvb_video_get_event(av7110, parg, file->f_flags); break; @@ -1226,6 +1267,19 @@ static int dvb_video_ioctl(struct file *file, 1, (u16) arg); break; +#ifdef CONFIG_COMPAT + case VIDEO_STILLPICTURE32: + { + struct compat_video_still_picture *pic = + (struct compat_video_still_picture *) parg; + av7110->videostate.stream_source = VIDEO_SOURCE_MEMORY; + dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout); + ret = play_iframe(av7110, compat_ptr(pic->iFrame), + pic->size, file->f_flags & O_NONBLOCK); + break; + } +#endif + case VIDEO_STILLPICTURE: { struct video_still_picture *pic = diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 7a1fac9cd1c2..5b2e22e7a316 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -103,11 +103,6 @@ #include -#define __DVB_CORE__ -#include -#include -#include -#include #include @@ -133,73 +128,6 @@ static int do_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return vfs_ioctl(file, cmd, arg); } -struct compat_video_event { - int32_t type; - compat_time_t timestamp; - union { - video_size_t size; - unsigned int frame_rate; - } u; -}; -#define VIDEO_GET_EVENT32 _IOR('o', 28, struct compat_video_event) - -static int do_video_get_event(struct file *file, - unsigned int cmd, struct compat_video_event __user *up) -{ - struct video_event __user *kevent = - compat_alloc_user_space(sizeof(*kevent)); - int err; - - if (kevent == NULL) - return -EFAULT; - - err = do_ioctl(file, VIDEO_GET_EVENT, (unsigned long)kevent); - if (!err) { - err = convert_in_user(&kevent->type, &up->type); - err |= convert_in_user(&kevent->timestamp, &up->timestamp); - err |= convert_in_user(&kevent->u.size.w, &up->u.size.w); - err |= convert_in_user(&kevent->u.size.h, &up->u.size.h); - err |= convert_in_user(&kevent->u.size.aspect_ratio, - &up->u.size.aspect_ratio); - if (err) - err = -EFAULT; - } - - return err; -} - -struct compat_video_still_picture { - compat_uptr_t iFrame; - int32_t size; -}; -#define VIDEO_STILLPICTURE32 _IOW('o', 30, struct compat_video_still_picture) - -static int do_video_stillpicture(struct file *file, - unsigned int cmd, struct compat_video_still_picture __user *up) -{ - struct video_still_picture __user *up_native; - compat_uptr_t fp; - int32_t size; - int err; - - err = get_user(fp, &up->iFrame); - err |= get_user(size, &up->size); - if (err) - return -EFAULT; - - up_native = - compat_alloc_user_space(sizeof(struct video_still_picture)); - - err = put_user(compat_ptr(fp), &up_native->iFrame); - err |= put_user(size, &up_native->size); - if (err) - return -EFAULT; - - err = do_ioctl(file, VIDEO_STILLPICTURE, (unsigned long) up_native); - - return err; -} - #ifdef CONFIG_BLOCK typedef struct sg_io_hdr32 { compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */ @@ -1250,12 +1178,6 @@ static long do_ioctl_trans(unsigned int cmd, case RTC_EPOCH_READ32: case RTC_EPOCH_SET32: return rtc_ioctl(file, cmd, argp); - - /* dvb */ - case VIDEO_GET_EVENT32: - return do_video_get_event(file, cmd, argp); - case VIDEO_STILLPICTURE32: - return do_video_stillpicture(file, cmd, argp); } /*