From patchwork Fri Sep 5 13:04:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Sung X-Patchwork-Id: 4851971 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 527C6C0338 for ; Fri, 5 Sep 2014 13:05:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B324120114 for ; Fri, 5 Sep 2014 13:05:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59150200FF for ; Fri, 5 Sep 2014 13:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932184AbaIENFa (ORCPT ); Fri, 5 Sep 2014 09:05:30 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:62964 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932083AbaIENF3 (ORCPT ); Fri, 5 Sep 2014 09:05:29 -0400 Received: by mail-pa0-f42.google.com with SMTP id lf10so22252795pab.15 for ; Fri, 05 Sep 2014 06:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=7DDkLyslZQLnJZaWyJFQK5qwnI4DoriHVKrIOHSaEMk=; b=RbOPB2NGkvUImgN+gknqNlQuscbiQbRP+SPqIONUjudKUnzZhlXFHLZFTXyyHRuaHe Yb7QrrJfO3IZn56KsPNgWAuyClw6Y58pX5jUWWNLP2Q0iyMffFLyrlDBUnoGBSHJZLX6 abDX7cWgbf3d4b/pGD0Ns8CYMsREvzStUzoJlUKR/mFh2uI1p3923n+iepJX8vQ+p+q+ DqRXKu6KTgqj/h8UjUZpPe5ZT1v5c228TYZClLsTr/m5w+7/yIMMm9UeBMAVqvTb3Luw +EPMke1k4Tzgc3KfQfCUKry8022VCF934l1XhnidVeSbJNfRcMfKN0/clg0OmckCxhFa lpjA== X-Received: by 10.70.89.3 with SMTP id bk3mr21211835pdb.41.1409922326886; Fri, 05 Sep 2014 06:05:26 -0700 (PDT) Received: from localhost.localdomain ([210.68.37.194]) by mx.google.com with ESMTPSA id jw6sm1719823pbc.79.2014.09.05.06.05.25 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 06:05:26 -0700 (PDT) From: John Sung To: Dmitry Torokhov , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: penmount.touch@gmail.com Subject: [PATCH] Input: serport: Add compat_ioctl routine to support 32bit inputtattach in 64bit systems Date: Fri, 5 Sep 2014 21:04:37 +0800 Message-Id: <1409922277-4497-1-git-send-email-penmount.touch@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When running a 32-bit inputattach utility in a 64-bit system, there will be error code "inputattach: can't set device type". This is caused by the serport device driver not supporting compat_ioctl, so that SPIOCSTYPE ioctl fails. Signed-off-by: John Sung --- drivers/input/serio/serport.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c index 0cb7ef5..4b68c29 100644 --- a/drivers/input/serio/serport.c +++ b/drivers/input/serio/serport.c @@ -22,6 +22,8 @@ #include #include +#include + MODULE_AUTHOR("Vojtech Pavlik "); MODULE_DESCRIPTION("Input device TTY line discipline"); MODULE_LICENSE("GPL"); @@ -31,6 +33,8 @@ MODULE_ALIAS_LDISC(N_MOUSE); #define SERPORT_ACTIVE 2 #define SERPORT_DEAD 3 +#define SPIOCSTYPE32 (_IOW('q', 0x01, compat_ulong_t)) + struct serport { struct tty_struct *tty; wait_queue_head_t wait; @@ -221,6 +225,25 @@ static int serport_ldisc_ioctl(struct tty_struct * tty, struct file * file, unsi return -EINVAL; } +static long serport_ldisc_compat_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) +{ + struct serport *serport = (struct serport*) tty->disc_data; + unsigned long type; + + if (cmd == SPIOCSTYPE32) { + if (get_user(type, (unsigned long __user *) arg)) + return -EFAULT; + + serport->id.proto = type & 0x000000ff; + serport->id.id = (type & 0x0000ff00) >> 8; + serport->id.extra = (type & 0x00ff0000) >> 16; + + return 0; + } + + return -EINVAL; +} + static void serport_ldisc_write_wakeup(struct tty_struct * tty) { struct serport *serport = (struct serport *) tty->disc_data; @@ -243,6 +266,7 @@ static struct tty_ldisc_ops serport_ldisc = { .close = serport_ldisc_close, .read = serport_ldisc_read, .ioctl = serport_ldisc_ioctl, + .compat_ioctl = serport_ldisc_compat_ioctl, .receive_buf = serport_ldisc_receive, .write_wakeup = serport_ldisc_write_wakeup };