diff options
author | Thomas Abraham <thomas.abraham@linaro.org> | 2011-10-24 05:47:25 -0400 |
---|---|---|
committer | Kukjin Kim <kgene.kim@samsung.com> | 2011-12-22 20:06:54 -0500 |
commit | 4d84e970d0faec772a9eaa818feee38aeca121b2 (patch) | |
tree | 40ae3a08e363625388ca0fa39591fb590b374bee /drivers/tty | |
parent | 659d73ada5d6869dc18838c9125731a750389019 (diff) |
serial: samsung: Keep a copy of the location of platform data in driver's private data
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 <ben-linux@fluff.org>
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/s5pv210.c | 12 | ||||
-rw-r--r-- | drivers/tty/serial/samsung.c | 16 | ||||
-rw-r--r-- | 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 8b0b888a1b76..03b249e35bf1 100644 --- a/drivers/tty/serial/s5pv210.c +++ b/drivers/tty/serial/s5pv210.c | |||
@@ -28,9 +28,13 @@ | |||
28 | static int s5pv210_serial_setsource(struct uart_port *port, | 28 | static int s5pv210_serial_setsource(struct uart_port *port, |
29 | struct s3c24xx_uart_clksrc *clk) | 29 | struct s3c24xx_uart_clksrc *clk) |
30 | { | 30 | { |
31 | struct s3c2410_uartcfg *cfg = port->dev->platform_data; | 31 | struct s3c24xx_uart_port *ourport; |
32 | struct s3c2410_uartcfg *cfg; | ||
32 | unsigned long ucon = rd_regl(port, S3C2410_UCON); | 33 | unsigned long ucon = rd_regl(port, S3C2410_UCON); |
33 | 34 | ||
35 | ourport = container_of(port, struct s3c24xx_uart_port, port); | ||
36 | cfg = ourport->cfg; | ||
37 | |||
34 | if (cfg->flags & NO_NEED_CHECK_CLKSRC) | 38 | if (cfg->flags & NO_NEED_CHECK_CLKSRC) |
35 | return 0; | 39 | return 0; |
36 | 40 | ||
@@ -51,9 +55,13 @@ static int s5pv210_serial_setsource(struct uart_port *port, | |||
51 | static int s5pv210_serial_getsource(struct uart_port *port, | 55 | static int s5pv210_serial_getsource(struct uart_port *port, |
52 | struct s3c24xx_uart_clksrc *clk) | 56 | struct s3c24xx_uart_clksrc *clk) |
53 | { | 57 | { |
54 | struct s3c2410_uartcfg *cfg = port->dev->platform_data; | 58 | struct s3c24xx_uart_port *ourport; |
59 | struct s3c2410_uartcfg *cfg; | ||
55 | u32 ucon = rd_regl(port, S3C2410_UCON); | 60 | u32 ucon = rd_regl(port, S3C2410_UCON); |
56 | 61 | ||
62 | ourport = container_of(port, struct s3c24xx_uart_port, port); | ||
63 | cfg = ourport->cfg; | ||
64 | |||
57 | clk->divisor = 1; | 65 | clk->divisor = 1; |
58 | 66 | ||
59 | if (cfg->flags & NO_NEED_CHECK_CLKSRC) | 67 | if (cfg->flags & NO_NEED_CHECK_CLKSRC) |
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index b31f1c3a2c4c..51cfb9f11665 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 | |||
190 | 190 | ||
191 | static inline struct s3c2410_uartcfg *s3c24xx_port_to_cfg(struct uart_port *port) | 191 | static inline struct s3c2410_uartcfg *s3c24xx_port_to_cfg(struct uart_port *port) |
192 | { | 192 | { |
193 | struct s3c24xx_uart_port *ourport; | ||
194 | |||
193 | if (port->dev == NULL) | 195 | if (port->dev == NULL) |
194 | return NULL; | 196 | return NULL; |
195 | 197 | ||
196 | return (struct s3c2410_uartcfg *)port->dev->platform_data; | 198 | ourport = container_of(port, struct s3c24xx_uart_port, port); |
199 | return ourport->cfg; | ||
197 | } | 200 | } |
198 | 201 | ||
199 | static int s3c24xx_serial_rx_fifocnt(struct s3c24xx_uart_port *ourport, | 202 | 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, | |||
1125 | struct platform_device *platdev) | 1128 | struct platform_device *platdev) |
1126 | { | 1129 | { |
1127 | struct uart_port *port = &ourport->port; | 1130 | struct uart_port *port = &ourport->port; |
1128 | struct s3c2410_uartcfg *cfg; | 1131 | struct s3c2410_uartcfg *cfg = platdev->dev.platform_data; |
1129 | struct resource *res; | 1132 | struct resource *res; |
1130 | int ret; | 1133 | int ret; |
1131 | 1134 | ||
@@ -1134,11 +1137,16 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, | |||
1134 | if (platdev == NULL) | 1137 | if (platdev == NULL) |
1135 | return -ENODEV; | 1138 | return -ENODEV; |
1136 | 1139 | ||
1137 | cfg = s3c24xx_dev_to_cfg(&platdev->dev); | ||
1138 | |||
1139 | if (port->mapbase != 0) | 1140 | if (port->mapbase != 0) |
1140 | return 0; | 1141 | return 0; |
1141 | 1142 | ||
1143 | /* | ||
1144 | * If platform data is supplied, keep a copy of the location of | ||
1145 | * platform data in the driver's private data. | ||
1146 | */ | ||
1147 | if (cfg) | ||
1148 | ourport->cfg = cfg; | ||
1149 | |||
1142 | if (cfg->hwport > CONFIG_SERIAL_SAMSUNG_UARTS) { | 1150 | if (cfg->hwport > CONFIG_SERIAL_SAMSUNG_UARTS) { |
1143 | printk(KERN_ERR "%s: port %d bigger than %d\n", __func__, | 1151 | printk(KERN_ERR "%s: port %d bigger than %d\n", __func__, |
1144 | cfg->hwport, CONFIG_SERIAL_SAMSUNG_UARTS); | 1152 | cfg->hwport, CONFIG_SERIAL_SAMSUNG_UARTS); |
diff --git a/drivers/tty/serial/samsung.h b/drivers/tty/serial/samsung.h index 8e87b788e5c6..6c9cb9d5ccdb 100644 --- a/drivers/tty/serial/samsung.h +++ b/drivers/tty/serial/samsung.h | |||
@@ -48,6 +48,9 @@ struct s3c24xx_uart_port { | |||
48 | struct clk *baudclk; | 48 | struct clk *baudclk; |
49 | struct uart_port port; | 49 | struct uart_port port; |
50 | 50 | ||
51 | /* reference to platform data */ | ||
52 | struct s3c2410_uartcfg *cfg; | ||
53 | |||
51 | #ifdef CONFIG_CPU_FREQ | 54 | #ifdef CONFIG_CPU_FREQ |
52 | struct notifier_block freq_transition; | 55 | struct notifier_block freq_transition; |
53 | #endif | 56 | #endif |
@@ -56,7 +59,6 @@ struct s3c24xx_uart_port { | |||
56 | /* conversion functions */ | 59 | /* conversion functions */ |
57 | 60 | ||
58 | #define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev) | 61 | #define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev) |
59 | #define s3c24xx_dev_to_cfg(__dev) (struct s3c2410_uartcfg *)((__dev)->platform_data) | ||
60 | 62 | ||
61 | /* register access controls */ | 63 | /* register access controls */ |
62 | 64 | ||