Re: [PATCH v1 2/4] serial: sc16is7xx: Respect clock-frequency property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> If the property is provided and there are no other possibilities to detect
> UART clock frequency, use it as a fallback.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
>  drivers/tty/serial/sc16is7xx.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
> index 268098681856..2f8ca1dec493 100644
> --- a/drivers/tty/serial/sc16is7xx.c
> +++ b/drivers/tty/serial/sc16is7xx.c
> @@ -17,6 +17,7 @@
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/of_device.h>
> +#include <linux/property.h>
>  #include <linux/regmap.h>
>  #include <linux/serial_core.h>
>  #include <linux/serial.h>
> @@ -1179,7 +1180,8 @@ static int sc16is7xx_probe(struct device *dev,
>  			   struct regmap *regmap, int irq, unsigned long flags)
>  {
>  	struct sched_param sched_param = { .sched_priority = MAX_RT_PRIO / 2 };
> -	unsigned long freq, *pfreq = dev_get_platdata(dev);
> +	unsigned long freq = 0, *pfreq = dev_get_platdata(dev);
> +	u32 uartclk = 0;
>  	int i, ret;
>  	struct sc16is7xx_port *s;
>  
> @@ -1195,10 +1197,17 @@ static int sc16is7xx_probe(struct device *dev,
>  		return -ENOMEM;
>  	}
>  
> +	/* Always ask for fixed clock rate from a property. */
> +	device_property_read_u32(dev, "clock-frequency", &uartclk);
> +
>  	s->clk = devm_clk_get(dev, NULL);
>  	if (IS_ERR(s->clk)) {
> +		if (uartclk)
> +			freq = uartclk;
>  		if (pfreq)
>  			freq = *pfreq;
> +		if (freq)
> +			dev_dbg(dev, "Clock frequency: %luHz\n", freq);
>  		else
>  			return PTR_ERR(s->clk);
>  	} else {
> -- 
> 2.19.2
> 

Tested-By: Georgii Staroselskii <georgii.staroselskii@xxxxxxxxx>



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux