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: 3497091 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BF8ADC02DC for ; Thu, 16 Jan 2014 05:07:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED83420179 for ; Thu, 16 Jan 2014 05:07:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08E3320171 for ; Thu, 16 Jan 2014 05:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750974AbaAPFHg (ORCPT ); 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UKj6NrR/9Go/0K0CPrla4QWllPW1qE3tm3J73CqsukY=; b=kYxLotkyPcPf4jgzBaXL+ARfc+V7dPavbB2EW3SLj7JtvDulqwhK4teFLrUlikLNOf qk5v9UKlYyvZgWD8iVJXFVfK/9oRgII9mjGyEwrDt30e0K2wehBMT1ILYO5lBprR7ZaP 9K8o/9638Nf1T/FU9d02DNXzqEf3g3pY5MdKZkuDqnWIUCRsF5ZryHZEc3yoXKGtcJtt 6LLgTl0QK2aigB0pnYzHMRQILxtwysxjwBFPKM4Y3Xjmrl4bXWH24Z2rHq25A/mVQeCa CSE1HcdtvpKCNz0fSucTICasjFr42ka+o4HXwG3QTCXKE/KUuOV6AztvLFZgs7ZtLxdq 1iCw== X-Gm-Message-State: ALoCoQn9Nr9WlaLBu1T3eEnbwZWge3cZB+mf+0iauRzG/uyMOdwRWuXGsCSG2WLmygUMPD19LI79 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: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;