From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965339AbdIYXFV (ORCPT ); Mon, 25 Sep 2017 19:05:21 -0400 Received: from www.llwyncelyn.cymru ([82.70.14.225]:42746 "EHLO fuzix.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934948AbdIYXFT (ORCPT ); Mon, 25 Sep 2017 19:05:19 -0400 Date: Tue, 26 Sep 2017 00:05:16 +0100 From: Alan Cox To: Ulf Samuelsson Cc: linux-kernel@vger.kernel.org Subject: Re: RFC: mcu_tty: Trying to open /dev/ttyUSB0 and lock access from a kernel driver Message-ID: <20170926000516.7b556e58@alans-desktop> In-Reply-To: References: Organization: Intel Corporation X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 25 Sep 2017 15:01:13 +0200 Ulf Samuelsson wrote: > Trying to open /dev/ttyUSB from a kernel driver (which works), but > locking the > serial port so noone else can access it does not work. > Any advice would be appreciated. File locks are advisory only. For the rest of it you might want to take a look at how the gsm mux driver works (the protocol stuff is scary but you can ignore that end). It plugs a line discipline into a tty and that muxes out as a collection of ttys and shows how it's meant to be done. That also means you have an owning process with the port open that can do locking on it and/or route any raw read/writes to the master port into the bit bucket. Alan