From patchwork Wed May 21 21:39:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tilman Schmidt X-Patchwork-Id: 351330 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 569B0140083 for ; Thu, 22 May 2014 07:42:34 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753800AbaEUVma (ORCPT ); Wed, 21 May 2014 17:42:30 -0400 Received: from mail.pxnet.com ([89.1.7.7]:54227 "EHLO mail.pxnet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753790AbaEUVm3 (ORCPT ); Wed, 21 May 2014 17:42:29 -0400 Received: from xenon.ts.pxnet.com (p57A57697.dip0.t-ipconnect.de [87.165.118.151]) (user=ts author=<> mech=DIGEST-MD5 bits=0) by mail.pxnet.com (8.13.8/8.13.8) with ESMTP id s4LLdaAH027258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 21 May 2014 23:39:57 +0200 Received: by xenon.ts.pxnet.com (Postfix, from userid 1000) id A043A140073; Wed, 21 May 2014 23:39:26 +0200 (CEST) To: netdev@vger.kernel.org CC: Paul Bolle , isdn4linux@listserv.isdn4linux.de, "Keil, Karsten" , Jiri Slaby , Greg Kroah-Hartman Message-Id: <243519fa733359d22ce008b795f5686411e6038a.1400449372.git.tilman@imap.cc> In-Reply-To: References: From: Tilman Schmidt Subject: [PATCH 3/4] tty: allow tty drivers to rename their device nodes Date: Wed, 21 May 2014 23:39:26 +0200 (CEST) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (mail.pxnet.com [89.1.7.7]); Wed, 21 May 2014 23:40:18 +0200 (CEST) X-Scanned-By: MIMEDefang 2.70 on 89.1.7.7 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Paul Bolle The device nodes for tty drivers are named using a straightforward scheme: tty_driver->name with an (increasing) digit appended. But the capi driver (a part of one of the current ISDN subsystems) requires a different naming scheme for its "capi_nc" tty_driver: /dev/capi/0 /dev/capi/1 [...] So add a devnode() callback to struct tty_driver to allow tty drivers to use a more elaborate naming scheme. And let tty_devnode(), the devnode() callback for the "tty" class, call that new callback if a tty driver uses one. This allows the capi driver to add a callback to enable its scheme. Signed-off-by: Paul Bolle Signed-off-by: Tilman Schmidt --- drivers/tty/tty_io.c | 16 ++++++++++++++-- include/linux/tty_driver.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 3411071..32d7878 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3504,12 +3504,24 @@ void __init console_init(void) static char *tty_devnode(struct device *dev, umode_t *mode) { + struct tty_driver *driver = NULL; + int unused; + char *ret = NULL; + + mutex_lock(&tty_mutex); + driver = get_tty_driver(dev->devt, &unused); + mutex_unlock(&tty_mutex); + if (driver && driver->devnode) + ret = driver->devnode(dev, mode); + if (driver) + tty_driver_kref_put(driver); + if (!mode) - return NULL; + return ret; if (dev->devt == MKDEV(TTYAUX_MAJOR, 0) || dev->devt == MKDEV(TTYAUX_MAJOR, 2)) *mode = 0666; - return NULL; + return ret; } static int __init tty_class_init(void) diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 756a609..91265bf 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -294,6 +294,7 @@ struct tty_driver { struct module *owner; const char *driver_name; const char *name; + char *(*devnode)(struct device *dev, umode_t *mode); int name_base; /* offset of printed name */ int major; /* major device number */ int minor_start; /* start of minor device number */