Re: [PATCH v1 20/31] serial: 8250: add optional callbacks for rx_trig_bytes
From: Andy Shevchenko
Date: Sun Nov 30 2025 - 20:58:56 EST
On Sun, Nov 30, 2025 at 12:45 PM Crescent Hsieh
<crescentcy.hsieh@xxxxxxxx> wrote:
>
> The rx_trig_bytes sysfs attribute adjusts the UART RX FIFO trigger
> level. Some modern 8250 variants require programming device-specific
> registers to change this threshold, which the generic (FCR-based) path
> does not cover.
>
> This patch adds two optional uart_port callbacks:
> - set_rxtrig(port, bytes): program a device-specific RX trigger threshold
> - get_rxtrig(port): read back the current RX trigger threshold
>
> When these callbacks are provided, the 8250 core will use them to
> set/read the hardware-specific threshold. If the callbacks are not
> implemented, the code falls back to the legacy generic path, so existing
> drivers keep their current behavior.
>
> No functional change for drivers that do not implement the new
> callbacks.
...
> - rxtrig_bytes = do_serial8250_get_rxtrig(port);
> + if (uport->get_rxtrig)
> + rxtrig_bytes = uport->get_rxtrig(uport);
> + else
> + rxtrig_bytes = do_serial8250_get_rxtrig(port);
> +
Unneeded blank line.
> if (rxtrig_bytes < 0)
> return rxtrig_bytes;
...
> - ret = do_serial8250_set_rxtrig(port, bytes);
> + if (uport->set_rxtrig)
> + ret = uport->set_rxtrig(uport, bytes);
> + else
> + ret = do_serial8250_set_rxtrig(port, bytes);
> +
Ditto.
> if (ret < 0)
> return ret;
--
With Best Regards,
Andy Shevchenko