* [PATCH V2] serial: 8250_pnp: Support configurable clock frequency
@ 2021-07-05 13:00 Huacai Chen
2021-07-12 20:34 ` andy
0 siblings, 1 reply; 5+ messages in thread
From: Huacai Chen @ 2021-07-05 13:00 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: linux-serial, Xuefeng Li, Jiaxun Yang, Jianmin Lv, Huacai Chen
From: Jianmin Lv <lvjianmin@loongson.cn>
ACPI-based Loongson boards need configurable rather than fixed clock
frequency for serial ports.
Signed-off-by: Jianmin Lv <lvjianmin@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
V2: Remove unnecessary braces for single statement blocks
drivers/tty/serial/8250/8250_pnp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_pnp.c b/drivers/tty/serial/8250/8250_pnp.c
index de90d681b64c..5f8fc724ba46 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -15,6 +15,7 @@
#include <linux/kernel.h>
#include <linux/serial_core.h>
#include <linux/bitops.h>
+#include <linux/property.h>
#include <asm/byteorder.h>
@@ -474,7 +475,8 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
uart.port.flags |= UPF_SHARE_IRQ;
- uart.port.uartclk = 1843200;
+ if (device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk))
+ uart.port.uartclk = 1843200;
uart.port.dev = &dev->dev;
line = serial8250_register_8250_port(&uart);
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH V2] serial: 8250_pnp: Support configurable clock frequency
2021-07-05 13:00 [PATCH V2] serial: 8250_pnp: Support configurable clock frequency Huacai Chen
@ 2021-07-12 20:34 ` andy
2021-07-14 2:36 ` 陈华才
0 siblings, 1 reply; 5+ messages in thread
From: andy @ 2021-07-12 20:34 UTC (permalink / raw)
To: Huacai Chen
Cc: Greg Kroah-Hartman, linux-serial, Xuefeng Li, Jiaxun Yang, Jianmin Lv
Mon, Jul 05, 2021 at 09:00:10PM +0800, Huacai Chen kirjoitti:
> From: Jianmin Lv <lvjianmin@loongson.cn>
>
> ACPI-based Loongson boards need configurable rather than fixed clock
> frequency for serial ports.
...
> #include <linux/kernel.h>
> #include <linux/serial_core.h>
> #include <linux/bitops.h>
> +#include <linux/property.h>
Can you try to keep it ordered (to some extend), please?
...
> uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
> if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
> uart.port.flags |= UPF_SHARE_IRQ;
> - uart.port.uartclk = 1843200;
> + if (device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk))
> + uart.port.uartclk = 1843200;
> uart.port.dev = &dev->dev;
You can avoid conditional completely by calling
device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk);
here.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH V2] serial: 8250_pnp: Support configurable clock frequency
2021-07-12 20:34 ` andy
@ 2021-07-14 2:36 ` 陈华才
2021-07-14 8:57 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: 陈华才 @ 2021-07-14 2:36 UTC (permalink / raw)
To: andy
Cc: Greg Kroah-Hartman, linux-serial, Xuefeng Li, Jiaxun Yang,
Jianmin Lv, chenhuacai
Hi, Andy
> -----原始邮件-----
> 发件人: andy@surfacebook.localdomain
> 发送时间: 2021-07-13 04:34:41 (星期二)
> 收件人: "Huacai Chen" <chenhuacai@loongson.cn>
> 抄送: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, linux-serial@vger.kernel.org, "Xuefeng Li" <lixuefeng@loongson.cn>, "Jiaxun Yang" <jiaxun.yang@flygoat.com>, "Jianmin Lv" <lvjianmin@loongson.cn>
> 主题: Re: [PATCH V2] serial: 8250_pnp: Support configurable clock frequency
>
> Mon, Jul 05, 2021 at 09:00:10PM +0800, Huacai Chen kirjoitti:
> > From: Jianmin Lv <lvjianmin@loongson.cn>
> >
> > ACPI-based Loongson boards need configurable rather than fixed clock
> > frequency for serial ports.
>
> ...
>
> > #include <linux kernel.h="">
> > #include <linux serial_core.h="">
> > #include <linux bitops.h="">
> > +#include <linux property.h="">
>
> Can you try to keep it ordered (to some extend), please?
Existing headers is not in order, should I sort them completely?
>
> ...
>
> > uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
> > if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
> > uart.port.flags |= UPF_SHARE_IRQ;
> > - uart.port.uartclk = 1843200;
> > + if (device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk))
> > + uart.port.uartclk = 1843200;
> > uart.port.dev = &dev->dev;
>
> You can avoid conditional completely by calling
>
> device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk);
I want to get the property by this function, and set to default value (1843200) if fails. If remove the condition, how to set the default? Thanks.
Huacai
>
> here.
>
> --
> With Best Regards,
> Andy Shevchenko
>
</linux></linux></linux></linux></lvjianmin@loongson.cn></lvjianmin@loongson.cn></jiaxun.yang@flygoat.com></lixuefeng@loongson.cn></gregkh@linuxfoundation.org></chenhuacai@loongson.cn>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH V2] serial: 8250_pnp: Support configurable clock frequency
2021-07-14 2:36 ` 陈华才
@ 2021-07-14 8:57 ` Andy Shevchenko
2021-07-15 4:46 ` Huacai Chen
0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2021-07-14 8:57 UTC (permalink / raw)
To: 陈华才
Cc: andy, Greg Kroah-Hartman, linux-serial, Xuefeng Li, Jiaxun Yang,
Jianmin Lv, chenhuacai
On Wed, Jul 14, 2021 at 5:36 AM 陈华才 <chenhuacai@loongson.cn> wrote:
...
> > > #include <linux kernel.h="">
> > > #include <linux serial_core.h="">
> > > #include <linux bitops.h="">
> > > +#include <linux property.h="">
> >
> > Can you try to keep it ordered (to some extend), please?
> Existing headers is not in order,
That's why I added in the parentheses "to some extent".
> should I sort them completely?
Just put property.h before serial_core.h.
...
> > > uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
> > > if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
> > > uart.port.flags |= UPF_SHARE_IRQ;
> > > - uart.port.uartclk = 1843200;
> > > + if (device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk))
> > > + uart.port.uartclk = 1843200;
> > > uart.port.dev = &dev->dev;
> >
> > You can avoid conditional completely by calling
> >
> > device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk);
> I want to get the property by this function, and set to default value (1843200) if fails. If remove the condition, how to set the default? Thanks.
As I explained above.
x = $default_value;
device_property_read_u32(..., &x);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH V2] serial: 8250_pnp: Support configurable clock frequency
2021-07-14 8:57 ` Andy Shevchenko
@ 2021-07-15 4:46 ` Huacai Chen
0 siblings, 0 replies; 5+ messages in thread
From: Huacai Chen @ 2021-07-15 4:46 UTC (permalink / raw)
To: Andy Shevchenko
Cc: 陈华才,
andy, Greg Kroah-Hartman, linux-serial, Xuefeng Li, Jiaxun Yang,
Jianmin Lv
Hi, Andy,
On Wed, Jul 14, 2021 at 4:58 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Wed, Jul 14, 2021 at 5:36 AM 陈华才 <chenhuacai@loongson.cn> wrote:
>
> ...
>
> > > > #include <linux kernel.h="">
> > > > #include <linux serial_core.h="">
> > > > #include <linux bitops.h="">
> > > > +#include <linux property.h="">
> > >
> > > Can you try to keep it ordered (to some extend), please?
> > Existing headers is not in order,
>
> That's why I added in the parentheses "to some extent".
>
> > should I sort them completely?
>
> Just put property.h before serial_core.h.
>
> ...
>
> > > > uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
> > > > if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
> > > > uart.port.flags |= UPF_SHARE_IRQ;
> > > > - uart.port.uartclk = 1843200;
> > > > + if (device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk))
> > > > + uart.port.uartclk = 1843200;
> > > > uart.port.dev = &dev->dev;
> > >
> > > You can avoid conditional completely by calling
> > >
> > > device_property_read_u32(&dev->dev, "clock-frequency", &uart.port.uartclk);
> > I want to get the property by this function, and set to default value (1843200) if fails. If remove the condition, how to set the default? Thanks.
>
> As I explained above.
>
> x = $default_value;
> device_property_read_u32(..., &x);
I know, thanks.
Huacai
>
> --
> With Best Regards,
> Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-15 4:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 13:00 [PATCH V2] serial: 8250_pnp: Support configurable clock frequency Huacai Chen
2021-07-12 20:34 ` andy
2021-07-14 2:36 ` 陈华才
2021-07-14 8:57 ` Andy Shevchenko
2021-07-15 4:46 ` Huacai Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).