mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-03 19:24:02 +08:00
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>
This commit is contained in:
parent
659d73ada5
commit
4d84e970d0
@ -28,9 +28,13 @@
|
|||||||
static int s5pv210_serial_setsource(struct uart_port *port,
|
static int s5pv210_serial_setsource(struct uart_port *port,
|
||||||
struct s3c24xx_uart_clksrc *clk)
|
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);
|
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)
|
if (cfg->flags & NO_NEED_CHECK_CLKSRC)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -51,9 +55,13 @@ static int s5pv210_serial_setsource(struct uart_port *port,
|
|||||||
static int s5pv210_serial_getsource(struct uart_port *port,
|
static int s5pv210_serial_getsource(struct uart_port *port,
|
||||||
struct s3c24xx_uart_clksrc *clk)
|
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);
|
u32 ucon = rd_regl(port, S3C2410_UCON);
|
||||||
|
|
||||||
|
ourport = container_of(port, struct s3c24xx_uart_port, port);
|
||||||
|
cfg = ourport->cfg;
|
||||||
|
|
||||||
clk->divisor = 1;
|
clk->divisor = 1;
|
||||||
|
|
||||||
if (cfg->flags & NO_NEED_CHECK_CLKSRC)
|
if (cfg->flags & NO_NEED_CHECK_CLKSRC)
|
||||||
|
@ -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)
|
static inline struct s3c2410_uartcfg *s3c24xx_port_to_cfg(struct uart_port *port)
|
||||||
{
|
{
|
||||||
|
struct s3c24xx_uart_port *ourport;
|
||||||
|
|
||||||
if (port->dev == NULL)
|
if (port->dev == NULL)
|
||||||
return 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,
|
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 platform_device *platdev)
|
||||||
{
|
{
|
||||||
struct uart_port *port = &ourport->port;
|
struct uart_port *port = &ourport->port;
|
||||||
struct s3c2410_uartcfg *cfg;
|
struct s3c2410_uartcfg *cfg = platdev->dev.platform_data;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -1134,11 +1137,16 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
|
|||||||
if (platdev == NULL)
|
if (platdev == NULL)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
cfg = s3c24xx_dev_to_cfg(&platdev->dev);
|
|
||||||
|
|
||||||
if (port->mapbase != 0)
|
if (port->mapbase != 0)
|
||||||
return 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) {
|
if (cfg->hwport > CONFIG_SERIAL_SAMSUNG_UARTS) {
|
||||||
printk(KERN_ERR "%s: port %d bigger than %d\n", __func__,
|
printk(KERN_ERR "%s: port %d bigger than %d\n", __func__,
|
||||||
cfg->hwport, CONFIG_SERIAL_SAMSUNG_UARTS);
|
cfg->hwport, CONFIG_SERIAL_SAMSUNG_UARTS);
|
||||||
|
@ -48,6 +48,9 @@ struct s3c24xx_uart_port {
|
|||||||
struct clk *baudclk;
|
struct clk *baudclk;
|
||||||
struct uart_port port;
|
struct uart_port port;
|
||||||
|
|
||||||
|
/* reference to platform data */
|
||||||
|
struct s3c2410_uartcfg *cfg;
|
||||||
|
|
||||||
#ifdef CONFIG_CPU_FREQ
|
#ifdef CONFIG_CPU_FREQ
|
||||||
struct notifier_block freq_transition;
|
struct notifier_block freq_transition;
|
||||||
#endif
|
#endif
|
||||||
@ -56,7 +59,6 @@ struct s3c24xx_uart_port {
|
|||||||
/* conversion functions */
|
/* conversion functions */
|
||||||
|
|
||||||
#define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev)
|
#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 */
|
/* register access controls */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user