From patchwork Fri Jul 15 11:27:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 9231719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 098F260865 for ; Fri, 15 Jul 2016 11:27:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDA632819A for ; Fri, 15 Jul 2016 11:27:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E18ED28325; Fri, 15 Jul 2016 11:27:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DEF72819A for ; Fri, 15 Jul 2016 11:27:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932732AbcGOL12 (ORCPT ); Fri, 15 Jul 2016 07:27:28 -0400 Received: from lb1-smtp-cloud6.xs4all.net ([194.109.24.24]:41950 "EHLO lb1-smtp-cloud6.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932682AbcGOL11 (ORCPT ); Fri, 15 Jul 2016 07:27:27 -0400 Received: from tschai.lan ([90.149.38.145]) by smtp-cloud6.xs4all.net with ESMTP id JzTN1t00737uBN201zTR1X; Fri, 15 Jul 2016 13:27:25 +0200 Received: from [127.0.0.1] (localhost [127.0.0.1]) by tschai.lan (Postfix) with ESMTPSA id 1B01D180A30; Fri, 15 Jul 2016 13:27:22 +0200 (CEST) To: linux-input Cc: Linux Media Mailing List From: Hans Verkuil Subject: [RFC PATCH] serio: add hangup support Message-ID: <287a7f88-5d45-bb45-c98e-22a2313ab780@xs4all.nl> Date: Fri, 15 Jul 2016 13:27:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0 MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For the upcoming 4.8 kernel I made a driver for the Pulse-Eight USB CEC adapter. This is a usb device that shows up as a ttyACM0 device. It requires that you run inputattach in order to communicate with it via serio. This all works well, but it would be nice to have a udev rule to automatically start inputattach. That too works OK, but the problem comes when the USB device is unplugged: the tty hangup is never handled by the serio framework so the inputattach utility never exits and you have to kill it manually. By adding this hangup callback the inputattach utility now exists as soon as I unplug the USB device. Is this the correct approach? BTW, the new driver is found here: https://git.linuxtv.org/media_tree.git/tree/drivers/staging/media/pulse8-cec Regards, Hans Signed-off-by: Hans Verkuil --- -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c index 9c927d3..a615846 100644 --- a/drivers/input/serio/serport.c +++ b/drivers/input/serio/serport.c @@ -248,6 +248,14 @@ static long serport_ldisc_compat_ioctl(struct tty_struct *tty, } #endif +static int serport_ldisc_hangup(struct tty_struct * tty) +{ + struct serport *serport = (struct serport *) tty->disc_data; + + serport_serio_close(serport->serio); + return 0; +} + static void serport_ldisc_write_wakeup(struct tty_struct * tty) { struct serport *serport = (struct serport *) tty->disc_data; @@ -274,6 +282,7 @@ static struct tty_ldisc_ops serport_ldisc = { .compat_ioctl = serport_ldisc_compat_ioctl, #endif .receive_buf = serport_ldisc_receive, + .hangup = serport_ldisc_hangup, .write_wakeup = serport_ldisc_write_wakeup };