From patchwork Tue Aug 2 23:08:26 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: 3229 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 606B923F46 for ; Tue, 2 Aug 2011 23:08:50 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id 19162A1815B for ; Tue, 2 Aug 2011 23:08:50 +0000 (UTC) Received: by qyk30 with SMTP id 30so269154qyk.11 for ; Tue, 02 Aug 2011 16:08:49 -0700 (PDT) Received: by 10.229.241.19 with SMTP id lc19mr3018773qcb.45.1312326529531; Tue, 02 Aug 2011 16:08:49 -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.229.6.73 with SMTP id 9cs141326qcy; Tue, 2 Aug 2011 16:08:49 -0700 (PDT) Received: by 10.216.168.16 with SMTP id j16mr2256621wel.10.1312326528556; Tue, 02 Aug 2011 16:08:48 -0700 (PDT) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id w54si419332wec.67.2011.08.02.16.08.48 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 02 Aug 2011 16:08:48 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of thomas.abraham@linaro.org) smtp.mail=thomas.abraham@linaro.org Received: by wwe6 with SMTP id 6so258578wwe.31 for ; Tue, 02 Aug 2011 16:08:48 -0700 (PDT) Received: by 10.227.58.130 with SMTP id g2mr7822593wbh.44.1312326528065; Tue, 02 Aug 2011 16:08:48 -0700 (PDT) Received: from localhost.localdomain ([109.234.204.184]) by mx.google.com with ESMTPS id b13sm192251wbh.24.2011.08.02.16.08.46 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 02 Aug 2011 16:08:47 -0700 (PDT) From: Thomas Abraham To: devicetree-discuss@lists.ozlabs.org Cc: grant.likely@secretlab.ca, linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, linux-samsung-soc@vger.kernel.org, kgene.kim@samsung.com, patches@linaro.org, Ben Dooks Subject: [PATCH 1/4] serial: samsung: Keep a copy of the location of platform data in driver's private data Date: Wed, 3 Aug 2011 00:08:26 +0100 Message-Id: <1312326509-2723-2-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1312326509-2723-1-git-send-email-thomas.abraham@linaro.org> References: <1312326509-2723-1-git-send-email-thomas.abraham@linaro.org> In preparation for the device tree support in the driver, a copy of the platform data pointer is maintained in the driver's private data. With device tree support, the driver can parse the platform data from the device tree and create a dynamic platform data structure. Having a pointer in the driver's private data that points to the platform data in use simplifies the device tree support addition to the driver. 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..fb0806c 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->info->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->info->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 afc6294..47fee73 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -169,10 +169,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->info->cfg; } static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport, @@ -1053,7 +1056,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; @@ -1062,11 +1065,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) + info->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 a69d9a5..b1ff17a 100644 --- a/drivers/tty/serial/samsung.h +++ b/drivers/tty/serial/samsung.h @@ -24,6 +24,9 @@ struct s3c24xx_uart_info { unsigned int has_divslot:1; + /* reference to platform data */ + struct s3c2410_uartcfg *cfg; + /* clock source control */ int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk); @@ -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 */