From patchwork Thu Jan 16 05:03:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 23248 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C68C9202DA for ; Thu, 16 Jan 2014 05:07:39 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id z10sf4433204pdj.5 for ; Wed, 15 Jan 2014 21:07: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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=yCpy0C6eutweMvxfls38bUBsps4pJEvBc5Fe3JLdoBE=; b=A4ZKFknFCp53CMdBeb++Cz8JxCKCrvPXTEI/fitozNHKjzOcxIwyPDa3DGUC2Xh7mI 2BjcOiMmeqADjFuqLwVYw9IEBghJMUfKUIgpGHvQ/UlHi+RKNo3QvJg5hgOHKGyCJ5g0 fx/ws+alViry//n7F4TOnZueoTEUWeo/i1J4L2BK3ilK9qfbL4yIN8QoDAm3fHFoAHig Mpwfg3wivcg30QFPrk0QZXQl+0C8MjHqYFTPX+kY6Tzy37pRLLyRJX598VTQCV1KpZ8M /JEpo0oTvJGhEWmOja77/ArE/LVwtUsuKDIOfMfONIkuLQSqk0KoVDRJVFpe3sTHxOjK vwpA== X-Gm-Message-State: ALoCoQlwi1FNiD6qCl5T4Cm4x7K5CHfmKxkZ/MrvrnhosnNbSohi0csLsXbahKipMqCl+stQvkBv X-Received: by 10.66.121.133 with SMTP id lk5mr2319799pab.37.1389848859033; Wed, 15 Jan 2014 21:07:39 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.4.138 with SMTP id k10ls742217qek.13.gmail; Wed, 15 Jan 2014 21:07:38 -0800 (PST) X-Received: by 10.58.50.71 with SMTP id a7mr36706veo.32.1389848858896; Wed, 15 Jan 2014 21:07:38 -0800 (PST) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id n8si2727461vdv.68.2014.01.15.21.07.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 21:07:38 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id c14so805263vea.33 for ; Wed, 15 Jan 2014 21:07:38 -0800 (PST) X-Received: by 10.221.42.8 with SMTP id tw8mr4899162vcb.12.1389848858609; Wed, 15 Jan 2014 21:07: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.59.13.131 with SMTP id ey3csp321817ved; Wed, 15 Jan 2014 21:07:38 -0800 (PST) X-Received: by 10.66.179.143 with SMTP id dg15mr7240952pac.52.1389848857567; Wed, 15 Jan 2014 21:07:37 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fu1si5837946pbc.74.2014.01.15.21.07.37; Wed, 15 Jan 2014 21:07:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750974AbaAPFHg (ORCPT + 8 others); Thu, 16 Jan 2014 00:07:36 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:43968 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750736AbaAPFHf (ORCPT ); Thu, 16 Jan 2014 00:07:35 -0500 Received: by mail-pa0-f52.google.com with SMTP id bj1so645384pad.25 for ; Wed, 15 Jan 2014 21:07:35 -0800 (PST) X-Received: by 10.66.142.170 with SMTP id rx10mr7478045pab.117.1389848855355; Wed, 15 Jan 2014 21:07:35 -0800 (PST) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id sg1sm11968446pbb.16.2014.01.15.21.07.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 21:07:34 -0800 (PST) From: Tushar Behera To: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: jslaby@suse.cz, gregkh@linuxfoundation.org, broonie@kernel.org Subject: [PATCH] tty: Fallback to use dynamic major number Date: Thu, 16 Jan 2014 10:33:22 +0530 Message-Id: <1389848602-30985-1-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tushar.behera@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org 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: , 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 --- Hi Greg, This is my second attempt at getting this fixed. Let me know if you are okay with this. Initial approach to fix this problem was by forcing samsung-uart driver to use dynamic major number, but it was rejected [1] because of possible user-space breakage. Current approach falls back to dynamic major number as a fallback in case of failure. [1] https://lkml.org/lkml/2013/12/27/2 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 c74a00a..0c692be 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -3341,6 +3341,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 node\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); @@ -3348,9 +3364,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;