From patchwork Mon Sep 26 19:07:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: thomas.abraham@linaro.org X-Patchwork-Id: 4340 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id F1EAF23F57 for ; Mon, 26 Sep 2011 19:07:32 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id E6966A18626 for ; Mon, 26 Sep 2011 19:07:32 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 23so8789249fxe.11 for ; Mon, 26 Sep 2011 12:07:32 -0700 (PDT) Received: by 10.223.5.76 with SMTP id 12mr10931810fau.103.1317064052786; Mon, 26 Sep 2011 12:07:32 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.3.234 with SMTP id f10cs48414laf; Mon, 26 Sep 2011 12:07:32 -0700 (PDT) Received: by 10.236.146.4 with SMTP id q4mr18214888yhj.17.1317064050684; Mon, 26 Sep 2011 12:07:30 -0700 (PDT) Received: from mailout4.samsung.com (mailout4.samsung.com. [203.254.224.34]) by mx.google.com with ESMTP id j50si12588403yhe.102.2011.09.26.12.07.30; Mon, 26 Sep 2011 12:07:30 -0700 (PDT) Received-SPF: neutral (google.com: 203.254.224.34 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) client-ip=203.254.224.34; Authentication-Results: mx.google.com; spf=neutral (google.com: 203.254.224.34 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) smtp.mail=thomas.abraham@linaro.org Received: from epcpsbgm1.samsung.com (mailout4.samsung.com [203.254.224.34]) by mailout4.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTP id <0LS500HZL94F7IJ0@mailout4.samsung.com> for patches@linaro.org; Tue, 27 Sep 2011 04:07:29 +0900 (KST) X-AuditID: cbfee61a-b7cf1ae00000208e-5f-4e80cd712d27 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (MMPCPMTA) with SMTP id FC.37.08334.17DC08E4; Tue, 27 Sep 2011 04:07:29 +0900 (KST) Received: from localhost.localdomain ([107.108.73.37]) by mmp2.samsung.com (Oracle Communications Messaging Exchange Server 7u4-19.01 64bit (built Sep 7 2010)) with ESMTPA id <0LS5008Q69489390@mmp2.samsung.com> for patches@linaro.org; Tue, 27 Sep 2011 04:07:29 +0900 (KST) From: Thomas Abraham To: linux-serial@vger.kernel.org, devicetree-discuss@lists.ozlabs.org Cc: linux-arm-kernel@lists.infradead.org, alan@linux.intel.com, grant.likely@secretlab.ca, linux-samsung-soc@vger.kernel.org, kgene.kim@samsung.com, ben-linux@fluff.org, patches@linaro.org Subject: [PATCH 1/9] serial: samsung: Keep a copy of the location of platform data in driver's private data Date: Tue, 27 Sep 2011 00:37:10 +0530 Message-id: <1317064038-32428-2-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.6.6.rc2 In-reply-to: <1317064038-32428-1-git-send-email-thomas.abraham@linaro.org> References: <1317064038-32428-1-git-send-email-thomas.abraham@linaro.org> X-Brightmail-Tracker: AAAAAA== Add a pointer to the location of the platform data in the driver's private data. When instantiated using device tree, pdev->dev->platform_data does not necessarily point to a valid instance of platform data. The platform data pointer in the driver's private data could be set to pdev->dev->platform_data or platform data instance created from device tree. Cc: Ben Dooks Signed-off-by: Thomas Abraham --- drivers/tty/serial/s5pv210.c | 12 ++++++++++-- drivers/tty/serial/samsung.c | 16 ++++++++++++---- drivers/tty/serial/samsung.h | 4 +++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/s5pv210.c b/drivers/tty/serial/s5pv210.c index 8b0b888..03b249e 100644 --- a/drivers/tty/serial/s5pv210.c +++ b/drivers/tty/serial/s5pv210.c @@ -28,9 +28,13 @@ static int s5pv210_serial_setsource(struct uart_port *port, struct s3c24xx_uart_clksrc *clk) { - struct s3c2410_uartcfg *cfg = port->dev->platform_data; + struct s3c24xx_uart_port *ourport; + struct s3c2410_uartcfg *cfg; unsigned long ucon = rd_regl(port, S3C2410_UCON); + ourport = container_of(port, struct s3c24xx_uart_port, port); + cfg = ourport->cfg; + if (cfg->flags & NO_NEED_CHECK_CLKSRC) return 0; @@ -51,9 +55,13 @@ static int s5pv210_serial_setsource(struct uart_port *port, static int s5pv210_serial_getsource(struct uart_port *port, struct s3c24xx_uart_clksrc *clk) { - struct s3c2410_uartcfg *cfg = port->dev->platform_data; + struct s3c24xx_uart_port *ourport; + struct s3c2410_uartcfg *cfg; u32 ucon = rd_regl(port, S3C2410_UCON); + ourport = container_of(port, struct s3c24xx_uart_port, port); + cfg = ourport->cfg; + clk->divisor = 1; if (cfg->flags & NO_NEED_CHECK_CLKSRC) diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index b31f1c3..51cfb9f 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -190,10 +190,13 @@ static inline struct s3c24xx_uart_info *s3c24xx_port_to_info(struct uart_port *p static inline struct s3c2410_uartcfg *s3c24xx_port_to_cfg(struct uart_port *port) { + struct s3c24xx_uart_port *ourport; + if (port->dev == NULL) return NULL; - return (struct s3c2410_uartcfg *)port->dev->platform_data; + ourport = container_of(port, struct s3c24xx_uart_port, port); + return ourport->cfg; } static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport, @@ -1125,7 +1128,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, struct platform_device *platdev) { struct uart_port *port = &ourport->port; - struct s3c2410_uartcfg *cfg; + struct s3c2410_uartcfg *cfg = platdev->dev.platform_data; struct resource *res; int ret; @@ -1134,11 +1137,16 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, if (platdev == NULL) return -ENODEV; - cfg = s3c24xx_dev_to_cfg(&platdev->dev); - if (port->mapbase != 0) return 0; + /* + * If platform data is supplied, keep a copy of the location of + * platform data in the driver's private data. + */ + if (cfg) + ourport->cfg = cfg; + if (cfg->hwport > CONFIG_SERIAL_SAMSUNG_UARTS) { printk(KERN_ERR "%s: port %d bigger than %d\n", __func__, cfg->hwport, CONFIG_SERIAL_SAMSUNG_UARTS); diff --git a/drivers/tty/serial/samsung.h b/drivers/tty/serial/samsung.h index 8e87b78..6c9cb9d 100644 --- a/drivers/tty/serial/samsung.h +++ b/drivers/tty/serial/samsung.h @@ -48,6 +48,9 @@ struct s3c24xx_uart_port { struct clk *baudclk; struct uart_port port; + /* reference to platform data */ + struct s3c2410_uartcfg *cfg; + #ifdef CONFIG_CPU_FREQ struct notifier_block freq_transition; #endif @@ -56,7 +59,6 @@ struct s3c24xx_uart_port { /* conversion functions */ #define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev) -#define s3c24xx_dev_to_cfg(__dev) (struct s3c2410_uartcfg *)((__dev)->platform_data) /* register access controls */