2022-08-25 09:20:18

by Ilpo Järvinen

[permalink] [raw]
Subject: [PATCH 1/3] serial: Create uart_xmit_advance()

A very common pattern in the drivers is to advance xmit tail
index and do bookkeeping of Tx'ed characters. Create
uart_xmit_advance() to handle it.

Fixes: e9ea096dd225 ("serial: tegra: add serial driver")
Fixes: 2d908b38d409 ("serial: Add Tegra Combined UART driver")
Signed-off-by: Ilpo Järvinen <[email protected]>
---
include/linux/serial_core.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index aef3145f2032..ffc7b8cb7a7f 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -616,6 +616,23 @@ struct uart_state {
/* number of characters left in xmit buffer before we ask for more */
#define WAKEUP_CHARS 256

+/**
+ * uart_xmit_advance - Advance xmit buffer and account Tx'ed chars
+ * @up: uart_port structure describing the port
+ * @chars: number of characters sent
+ *
+ * This function advances the tail of circular xmit buffer by the number of
+ * @chars transmitted and handles accounting of transmitted bytes (into
+ * @up's icount.tx).
+ */
+static inline void uart_xmit_advance(struct uart_port *up, unsigned int chars)
+{
+ struct circ_buf *xmit = &up->state->xmit;
+
+ xmit->tail = (xmit->tail + chars) & (UART_XMIT_SIZE - 1);
+ up->icount.tx += chars;
+}
+
struct module;
struct tty_driver;

--
2.30.2


2022-08-30 12:39:04

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 1/3] serial: Create uart_xmit_advance()

On Thu, Aug 25, 2022 at 12:17:05PM +0300, Ilpo J?rvinen wrote:
> A very common pattern in the drivers is to advance xmit tail
> index and do bookkeeping of Tx'ed characters. Create
> uart_xmit_advance() to handle it.
>
> Fixes: e9ea096dd225 ("serial: tegra: add serial driver")
> Fixes: 2d908b38d409 ("serial: Add Tegra Combined UART driver")

This commit only adds a new function, it does not "Fix" anything :(

2022-08-30 12:53:25

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 1/3] serial: Create uart_xmit_advance()

On Tue, Aug 30, 2022 at 03:38:27PM +0300, Andy Shevchenko wrote:
> On Tue, Aug 30, 2022 at 3:31 PM Greg Kroah-Hartman
> <[email protected]> wrote:
> >
> > On Thu, Aug 25, 2022 at 12:17:05PM +0300, Ilpo J?rvinen wrote:
> > > A very common pattern in the drivers is to advance xmit tail
> > > index and do bookkeeping of Tx'ed characters. Create
> > > uart_xmit_advance() to handle it.
> > >
> > > Fixes: e9ea096dd225 ("serial: tegra: add serial driver")
> > > Fixes: 2d908b38d409 ("serial: Add Tegra Combined UART driver")
> >
> > This commit only adds a new function, it does not "Fix" anything :(
>
> I'm wondering how to tell stable maintainers about dependencies of
> (not yet applied) patches? In practice I saw that contributors use
> Fixes tag for the entire chain (for the preparatory patches + the real
> fix) when it's not easy / in a nice way to rebase to have a one-patch
> fix followed by refactoring, etc.

It's as if no one has ever had this issue before and wrote it down for
all to read and know what to do in the future.

{sigh}

Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

If you don't know the git id, just use the subject line and it should
work the same.

greg "why even write documentation?" k-h

2022-08-30 12:53:29

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 1/3] serial: Create uart_xmit_advance()

On Tue, Aug 30, 2022 at 3:31 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> On Thu, Aug 25, 2022 at 12:17:05PM +0300, Ilpo Järvinen wrote:
> > A very common pattern in the drivers is to advance xmit tail
> > index and do bookkeeping of Tx'ed characters. Create
> > uart_xmit_advance() to handle it.
> >
> > Fixes: e9ea096dd225 ("serial: tegra: add serial driver")
> > Fixes: 2d908b38d409 ("serial: Add Tegra Combined UART driver")
>
> This commit only adds a new function, it does not "Fix" anything :(

I'm wondering how to tell stable maintainers about dependencies of
(not yet applied) patches? In practice I saw that contributors use
Fixes tag for the entire chain (for the preparatory patches + the real
fix) when it's not easy / in a nice way to rebase to have a one-patch
fix followed by refactoring, etc.

--
With Best Regards,
Andy Shevchenko

2022-08-30 12:58:33

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 1/3] serial: Create uart_xmit_advance()

On Tue, Aug 30, 2022 at 3:48 PM Greg Kroah-Hartman
<[email protected]> wrote:
> On Tue, Aug 30, 2022 at 03:38:27PM +0300, Andy Shevchenko wrote:
> > On Tue, Aug 30, 2022 at 3:31 PM Greg Kroah-Hartman
> > <[email protected]> wrote:
> > > On Thu, Aug 25, 2022 at 12:17:05PM +0300, Ilpo Järvinen wrote:

...

> > I'm wondering how to tell stable maintainers about dependencies of
> > (not yet applied) patches? In practice I saw that contributors use
> > Fixes tag for the entire chain (for the preparatory patches + the real
> > fix) when it's not easy / in a nice way to rebase to have a one-patch
> > fix followed by refactoring, etc.
>
> It's as if no one has ever had this issue before and wrote it down for
> all to read and know what to do in the future.
>
> {sigh}
>
> Please read:
> https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> for how to do this properly.
>
> If you don't know the git id, just use the subject line and it should
> work the same.
>
> greg "why even write documentation?" k-h

It's good we have it, thanks for writing!
From time to time even experienced developers need to re-read documentation.

--
With Best Regards,
Andy Shevchenko