Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751740AbdFFMqd (ORCPT ); Tue, 6 Jun 2017 08:46:33 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:33307 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751585AbdFFMqW (ORCPT ); Tue, 6 Jun 2017 08:46:22 -0400 MIME-Version: 1.0 In-Reply-To: <6faa7b93-a355-f7ba-e5e9-12f2414ac695@suse.de> References: <20170603135111.5444-1-asarai@suse.de> <20170603135111.5444-2-asarai@suse.de> <6faa7b93-a355-f7ba-e5e9-12f2414ac695@suse.de> From: Arnd Bergmann Date: Tue, 6 Jun 2017 14:46:20 +0200 X-Google-Sender-Auth: R6Vewl9M6cNqc8Mmqc9xy7qmFGY Message-ID: Subject: Re: [PATCH v3 1/2] tty: add compat_ioctl callbacks To: Aleksa Sarai Cc: Greg Kroah-Hartman , Jiri Slaby , Linux Kernel Mailing List , linux-alpha@vger.kernel.org, "open list:RALINK MIPS ARCHITECTURE" , Parisc List , linuxppc-dev , linux-sh@vger.kernel.org, sparclinux , linux-xtensa@linux-xtensa.org, linux-arch , Christian Brauner , Valentin Rothberg Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1457 Lines: 41 On Tue, Jun 6, 2017 at 1:05 PM, Aleksa Sarai wrote: >>> diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c >>> index 65799575c666..2a6bd9ae3f8b 100644 >>> --- a/drivers/tty/pty.c >>> +++ b/drivers/tty/pty.c >>> @@ -481,6 +481,16 @@ static int pty_bsd_ioctl(struct tty_struct *tty, >>> return -ENOIOCTLCMD; >>> } >>> >>> +static long pty_bsd_compat_ioctl(struct tty_struct *tty, >>> + unsigned int cmd, unsigned long arg) >>> +{ >>> + /* >>> + * PTY ioctls don't require any special translation between >>> 32-bit and >>> + * 64-bit userspace, they are already compatible. >>> + */ >>> + return pty_bsd_ioctl(tty, cmd, arg); >>> +} >>> + >> >> >> This looks correct but unnecessary, you can simply point both >> function pointers to the same function: > > > They have different types, since they have different return types: > > int (*ioctl)(struct tty_struct *tty, > unsigned int cmd, unsigned long arg); > long (*compat_ioctl)(struct tty_struct *tty, > unsigned int cmd, unsigned long arg); > > If you like, I can change (*ioctl) to return longs as well, and then change > all of the call-sites (since unlocked_ioctl also returns long). Ah, my mistake. In most other data structures that have a compat_ioctl callback pointer, the prototypes are the same, and I had not realized that tty_operations is an exception. Arnd