From patchwork Mon Jan 20 09:02:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 23367 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f72.google.com (mail-pb0-f72.google.com [209.85.160.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 472EB2107B for ; Mon, 20 Jan 2014 09:08:07 +0000 (UTC) Received: by mail-pb0-f72.google.com with SMTP id up15sf15323637pbc.11 for ; Mon, 20 Jan 2014 01:08:06 -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=NUjUGfabtHQUNzpd+hQc7RzLFXRA8i4EhPlQfvHqpPo=; b=UkATlXnfWJ/XCVslCV/9eC2X0adWMm6yylEOI9n8o2wCgHnNpzKieVV6tft6hDio2+ MxLaLf3CDJH7tey5NZrVy0s1mx0y1XRMmHR8KBLgDebAlGRoU0JfguLGiCb+w/YpXcc2 Y/NyDgh6xFJS9eCKR9WVXmK/26GAhdye0O/wSTMP6rgnJZ+D7fsmWegQcfw/0Q0vT7Cx D7cCMqwxXxS7x/9Hav8gdCQYU2sXMuFmpPMxGyT+rZGFEcg7dHB9DAKNWQgp9sBcz015 7YaI8Ny+wDVlp8pw8G2VXTx7XOf8m5FDN7XkUuPvlcscfONosLBpgTcybFnyqzUPe4Zh s49g== X-Gm-Message-State: ALoCoQnFC/t8/wXXm9FnTEVCmIdCIhgpU2Icjsn+c3D6wTZD8YL+XLa/fnAzJ53NjyjRNuKbDMjJ X-Received: by 10.66.146.65 with SMTP id ta1mr6325090pab.19.1390208886459; Mon, 20 Jan 2014 01:08:06 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.137 with SMTP id x9ls881735qgx.53.gmail; Mon, 20 Jan 2014 01:08:06 -0800 (PST) X-Received: by 10.52.26.148 with SMTP id l20mr275336vdg.28.1390208886280; Mon, 20 Jan 2014 01:08:06 -0800 (PST) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by mx.google.com with ESMTPS id sg4si133505vdc.27.2014.01.20.01.08.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 01:08:06 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.45 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.45; Received: by mail-vb0-f45.google.com with SMTP id m10so2701578vbh.32 for ; Mon, 20 Jan 2014 01:08:06 -0800 (PST) X-Received: by 10.59.0.193 with SMTP id ba1mr9642109ved.12.1390208886179; Mon, 20 Jan 2014 01:08:06 -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.220.174.196 with SMTP id u4csp48188vcz; Mon, 20 Jan 2014 01:08:05 -0800 (PST) X-Received: by 10.67.8.102 with SMTP id dj6mr17460120pad.10.1390208884775; Mon, 20 Jan 2014 01:08:04 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ye6si613657pbc.80.2014.01.20.01.08.04; Mon, 20 Jan 2014 01:08:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-serial-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 S1753154AbaATJHr (ORCPT + 2 others); Mon, 20 Jan 2014 04:07:47 -0500 Received: from mail-pb0-f50.google.com ([209.85.160.50]:57442 "EHLO mail-pb0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752917AbaATJHH (ORCPT ); Mon, 20 Jan 2014 04:07:07 -0500 Received: by mail-pb0-f50.google.com with SMTP id rq2so6732126pbb.23 for ; Mon, 20 Jan 2014 01:07:07 -0800 (PST) X-Received: by 10.66.66.202 with SMTP id h10mr17569189pat.70.1390208827229; Mon, 20 Jan 2014 01:07:07 -0800 (PST) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id by1sm1235086pbd.25.2014.01.20.01.07.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 01:07:06 -0800 (PST) From: Tushar Behera To: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: jslaby@suse.cz, gregkh@linuxfoundation.org, linux@arm.linux.org.uk, ben.dooks@codethink.co.uk, broonie@kernel.org Subject: [PATCH 1/2] serial: samsung: Move uart_register_driver call to device probe Date: Mon, 20 Jan 2014 14:32:34 +0530 Message-Id: <1390208555-27770-2-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1390208555-27770-1-git-send-email-tushar.behera@linaro.org> References: <1390208555-27770-1-git-send-email-tushar.behera@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-serial@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.212.45 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: , uart_register_driver call binds the driver to a specific device node through tty_register_driver call. This should typically happen during device probe call. In a multiplatform scenario, it is possible that multiple serial drivers are part of the kernel. Currently the driver registration fails if multiple serial drivers with same default major/minor numbers are included in the kernel. A typical case is observed with amba-pl011 and samsung-uart drivers. Signed-off-by: Tushar Behera --- drivers/tty/serial/samsung.c | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index c1af04d..f8f41dc 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -1283,6 +1283,14 @@ static int s3c24xx_serial_probe(struct platform_device *pdev) if (ret < 0) goto probe_err; + if (!s3c24xx_uart_drv.state) { + ret = uart_register_driver(&s3c24xx_uart_drv); + if (ret < 0) { + pr_err("Failed to register Samsung UART driver\n"); + return ret; + } + } + dbg("%s: adding port\n", __func__); uart_add_one_port(&s3c24xx_uart_drv, &ourport->port); platform_set_drvdata(pdev, &ourport->port); @@ -1315,6 +1323,8 @@ static int s3c24xx_serial_remove(struct platform_device *dev) uart_remove_one_port(&s3c24xx_uart_drv, port); } + uart_unregister_driver(&s3c24xx_uart_drv); + return 0; } @@ -1814,35 +1824,7 @@ static struct platform_driver samsung_serial_driver = { }, }; -/* module initialisation code */ - -static int __init s3c24xx_serial_modinit(void) -{ - int ret; - - ret = uart_register_driver(&s3c24xx_uart_drv); - if (ret < 0) { - pr_err("Failed to register Samsung UART driver\n"); - return ret; - } - - ret = platform_driver_register(&samsung_serial_driver); - if (ret < 0) { - pr_err("Failed to register platform driver\n"); - uart_unregister_driver(&s3c24xx_uart_drv); - } - - return ret; -} - -static void __exit s3c24xx_serial_modexit(void) -{ - platform_driver_unregister(&samsung_serial_driver); - uart_unregister_driver(&s3c24xx_uart_drv); -} - -module_init(s3c24xx_serial_modinit); -module_exit(s3c24xx_serial_modexit); +module_platform_driver(samsung_serial_driver); MODULE_ALIAS("platform:samsung-uart"); MODULE_DESCRIPTION("Samsung SoC Serial port driver");