From patchwork Wed Nov 12 08:46:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Cernekee X-Patchwork-Id: 40643 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BD71524493 for ; Wed, 12 Nov 2014 08:47:14 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf6426792lbj.3 for ; Wed, 12 Nov 2014 00:47:13 -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=ImF7ubL1+rsgaKmhG3VE/DQ2JSU1NBRK6rwqyqueltshsffSl0YjHPrTep3tnIXEad 9LU2krRve5q7fEiqk4e05S5se+j16i0EcbwHJWxsqBhqBHejzMzDKqo8FnQ0rF0S47fz 4Yhu8Bs6hiX34OSRFdLawJ96ZaPKRSydQ8yBmi41C1Nji0c/x3QtA6a4ZRr6ZmwMzrcI H1P8xZ6r5gosH/YiNsJFnmF0Cc330k/cA6diWBxZTtWcNBgeTTqQZCk4LwUpuFo1UH4E X/K8XpzBXEfA4GvRfV0Qk5oLiVW6il0kY9kWH03VBdSL7qgGllZA8pTixXsHLHg7nKu8 9/ow== X-Gm-Message-State: ALoCoQlm9bNEYKpd/J+bwsqMqlFAueceOVwPxp8c+hDnThXXxhhzKpIi8RxWD8zN8rzFFBq4kofD X-Received: by 10.194.133.40 with SMTP id oz8mr7646074wjb.2.1415782033717; Wed, 12 Nov 2014 00:47:13 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.138 with SMTP id q10ls694512laj.83.gmail; Wed, 12 Nov 2014 00:47:13 -0800 (PST) X-Received: by 10.112.199.40 with SMTP id jh8mr41234765lbc.5.1415782033198; Wed, 12 Nov 2014 00:47:13 -0800 (PST) Received: from mail-lb0-x22c.google.com (mail-lb0-x22c.google.com. [2a00:1450:4010:c04::22c]) by mx.google.com with ESMTPS id kr10si34090450lac.72.2014.11.12.00.47.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 00:47:13 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22c as permitted sender) client-ip=2a00:1450:4010:c04::22c; Received: by mail-lb0-f172.google.com with SMTP id u10so1499140lbd.31 for ; Wed, 12 Nov 2014 00:47:13 -0800 (PST) X-Received: by 10.112.62.166 with SMTP id z6mr13889187lbr.74.1415782033049; Wed, 12 Nov 2014 00:47:13 -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 ew9csp389323lbc; Wed, 12 Nov 2014 00:47:12 -0800 (PST) X-Received: by 10.68.239.162 with SMTP id vt2mr46024889pbc.105.1415782031120; Wed, 12 Nov 2014 00:47:11 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4si22210212pdp.184.2014.11.12.00.47.10 for ; Wed, 12 Nov 2014 00:47:11 -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 S1752062AbaKLIrI (ORCPT ); Wed, 12 Nov 2014 03:47:08 -0500 Received: from mail-pd0-f169.google.com ([209.85.192.169]:51401 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752032AbaKLIrH (ORCPT ); Wed, 12 Nov 2014 03:47:07 -0500 Received: by mail-pd0-f169.google.com with SMTP id y10so11868872pdj.0 for ; Wed, 12 Nov 2014 00:47:06 -0800 (PST) X-Received: by 10.66.124.228 with SMTP id ml4mr46017995pab.42.1415782026679; Wed, 12 Nov 2014 00:47:06 -0800 (PST) Received: from localhost (b32.net. [192.81.132.72]) by mx.google.com with ESMTPSA id p10sm18804833pds.63.2014.11.12.00.47.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 00:47:06 -0800 (PST) From: Kevin Cernekee To: gregkh@linuxfoundation.org, jslaby@suse.cz, robh@kernel.org Cc: tushar.behera@linaro.org, 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/RFC 1/8] tty: Fallback to use dynamic major number Date: Wed, 12 Nov 2014 00:46:26 -0800 Message-Id: <1415781993-7755-2-git-send-email-cernekee@gmail.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1415781993-7755-1-git-send-email-cernekee@gmail.com> References: <1415781993-7755-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:c04::22c 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;