From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751513AbbJBVqW (ORCPT ); Fri, 2 Oct 2015 17:46:22 -0400 Received: from www.eclis.ch ([217.162.2.166]:36213 "EHLO mail.eclis.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305AbbJBVqU (ORCPT ); Fri, 2 Oct 2015 17:46:20 -0400 From: Jean-Christian de Rivaz To: Thomas Osterried , David Ranch , Ralf Baechle DL5RB , Greg Kroah-Hartman , Jiri Slaby , Peter Hurley Cc: linux-hams@trinnet.net, linux-hams@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] Add poll method to mkiss let notify hangup to the user process. Date: Fri, 2 Oct 2015 23:46:13 +0200 Message-Id: <1443822373-18395-1-git-send-email-jc@eclis.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <560EBE07.70801@eclis.ch> References: <560EBE07.70801@eclis.ch> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Without this the application that use the mkiss line discipline have no way to terminate in case the corresponding serial device is removed, for example when a USB TNC is unplugged. The application must wait on poll(). The kissattach application must be patched to take advantage of this feature. Signed-off-by: Jean-Christian de Rivaz --- drivers/net/hamradio/mkiss.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index fba41e9..50cd36c 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c @@ -893,6 +893,20 @@ static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file, #endif /* + * Waiting until hangup is the only allowed operation. This is used + * to notify the application in case the serial deivce is removed + * (ex. USB). The tty_ldisc_hangup() will wake up the process. + */ +static unsigned int mkiss_poll(struct tty_struct *tty, struct file *file, + poll_table *wait) +{ + poll_wait(file, &tty->read_wait, wait); + poll_wait(file, &tty->write_wait, wait); + + return 0; +} + +/* * Handle the 'receiver data ready' interrupt. * This function is called by the 'tty_io' module in the kernel when * a block of data has been received, which can now be decapsulated @@ -969,6 +983,7 @@ static struct tty_ldisc_ops ax_ldisc = { #ifdef CONFIG_COMPAT .compat_ioctl = mkiss_compat_ioctl, #endif + .poll = mkiss_poll, .receive_buf = mkiss_receive_buf, .write_wakeup = mkiss_write_wakeup }; -- 1.7.10.4