@@ -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)
@@ -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);
@@ -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 */
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 <ben-linux@fluff.org> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org> --- 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(-)