From patchwork Wed Nov 12 20:53:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Cernekee X-Patchwork-Id: 40691 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0677724493 for ; Wed, 12 Nov 2014 20:54:40 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id e51sf8601408eek.6 for ; Wed, 12 Nov 2014 12:54:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=KQkD5/qfZbMy6Aw2kc6mHQXZdq+94WAndLlELs9ePrc=; b=aHGGEXDK9gKySuF4bOcAY+0+yom3rlHH6FN2w6c30bgm7YVZni4EFZQQWEIXlYIgKn f7y0yplcgUILuLXlZBLsLwF87sw4dr9hWYTylF3PsEStIMyDx//tyQyzKjcAiekabDvJ gURy1yxHmOOFGAhFMjSqVA4//2LQc80wFRkCpkW7jYmsu/VchtWko2OYq0HP6dRC9rRP hy74pKGaij5XkXOXnTd8J1GwbKcT3khG0KHVoM4EISFyKXGLEKONVT2WuvCjDeW6VK2x lKnni0w3JfTAA6XxwkenwYz22XMml2QWM8p6LxRTxthIjsWaf8WaSWDkqOO90LJJn5hZ pChA== X-Gm-Message-State: ALoCoQnPeowyelV5E7M6FXrLAF/VtTpsntLpRqu/VEnTj+iXiMku+C7lMyFtqkZUDFjwShIv1dUJ X-Received: by 10.112.154.194 with SMTP id vq2mr2306292lbb.10.1415825679205; Wed, 12 Nov 2014 12:54:39 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.131 with SMTP id e3ls756307lam.31.gmail; Wed, 12 Nov 2014 12:54:38 -0800 (PST) X-Received: by 10.112.136.164 with SMTP id qb4mr44759676lbb.62.1415825678317; Wed, 12 Nov 2014 12:54:38 -0800 (PST) Received: from mail-la0-x229.google.com (mail-la0-x229.google.com. [2a00:1450:4010:c03::229]) by mx.google.com with ESMTPS id la7si36150431lab.98.2014.11.12.12.54.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 12:54:38 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::229 as permitted sender) client-ip=2a00:1450:4010:c03::229; Received: by mail-la0-f41.google.com with SMTP id gf13so117895lab.0 for ; Wed, 12 Nov 2014 12:54:38 -0800 (PST) X-Received: by 10.152.5.38 with SMTP id p6mr44011155lap.44.1415825678188; Wed, 12 Nov 2014 12:54:38 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp491584lbc; Wed, 12 Nov 2014 12:54:37 -0800 (PST) X-Received: by 10.66.139.106 with SMTP id qx10mr22241485pab.138.1415825676195; Wed, 12 Nov 2014 12:54:36 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gq2si23651537pbc.217.2014.11.12.12.54.35 for ; Wed, 12 Nov 2014 12:54:36 -0800 (PST) Received-SPF: none (google.com: linux-serial-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753365AbaKLUyf (ORCPT ); Wed, 12 Nov 2014 15:54:35 -0500 Received: from mail-pd0-f179.google.com ([209.85.192.179]:53931 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753248AbaKLUye (ORCPT ); Wed, 12 Nov 2014 15:54:34 -0500 Received: by mail-pd0-f179.google.com with SMTP id g10so12864776pdj.24 for ; Wed, 12 Nov 2014 12:54:33 -0800 (PST) X-Received: by 10.70.63.9 with SMTP id c9mr50651450pds.104.1415825673832; Wed, 12 Nov 2014 12:54:33 -0800 (PST) Received: from localhost (b32.net. [192.81.132.72]) by mx.google.com with ESMTPSA id z15sm23050495pdi.6.2014.11.12.12.54.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 12:54:33 -0800 (PST) From: Kevin Cernekee To: gregkh@linuxfoundation.org, jslaby@suse.cz, robh@kernel.org Cc: arnd@arndb.de, daniel@zonque.org, haojian.zhuang@gmail.com, robert.jarzmik@free.fr, grant.likely@linaro.org, f.fainelli@gmail.com, mbizon@freebox.fr, jogo@openwrt.org, linux-mips@linux-mips.org, linux-serial@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH V2 01/10] tty: Fallback to use dynamic major number Date: Wed, 12 Nov 2014 12:53:58 -0800 Message-Id: <1415825647-6024-2-git-send-email-cernekee@gmail.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1415825647-6024-1-git-send-email-cernekee@gmail.com> References: <1415825647-6024-1-git-send-email-cernekee@gmail.com> Sender: linux-serial-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-serial@vger.kernel.org X-Original-Sender: cernekee@gmail.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::229 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Tushar Behera In a multi-platform scenario, the hard-coded major/minor numbers in serial drivers may conflict with each other. A typical scenario is observed with amba-pl011 and samsung-uart drivers, both of these drivers use same set of major/minor numbers. If both of these drivers are enabled, probe of samsung-uart driver fails because the desired node is busy. The issue is fixed by adding a fallback in driver core, so that we can use dynamic major number in case device node allocation fails for hard-coded major/minor number. Signed-off-by: Tushar Behera [cernekee: fix checkpatch warnings] Signed-off-by: Kevin Cernekee --- drivers/tty/tty_io.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 0508a1d..a6d4d9a 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3365,6 +3365,22 @@ int tty_register_driver(struct tty_driver *driver) dev_t dev; struct device *d; + if (driver->major) { + dev = MKDEV(driver->major, driver->minor_start); + error = register_chrdev_region(dev, driver->num, driver->name); + /* In case of error, fall back to dynamic allocation */ + if (error < 0) { + pr_warn("Default device node (%d:%d) for %s is busy, using dynamic major number\n", + driver->major, driver->minor_start, + driver->name); + driver->major = 0; + } + } + + /* + * Don't replace the following check with an else to above if statement, + * as it may also be called as a fallback. + */ if (!driver->major) { error = alloc_chrdev_region(&dev, driver->minor_start, driver->num, driver->name); @@ -3372,9 +3388,6 @@ int tty_register_driver(struct tty_driver *driver) driver->major = MAJOR(dev); driver->minor_start = MINOR(dev); } - } else { - dev = MKDEV(driver->major, driver->minor_start); - error = register_chrdev_region(dev, driver->num, driver->name); } if (error < 0) goto err;