[PATCH v3 0/4] tty: TX helpers
Arnd Bergmann
arnd at arndb.de
Wed Sep 7 06:47:37 PDT 2022
On Wed, Sep 7, 2022, at 2:56 PM, Ilpo Järvinen wrote:
> On Wed, 7 Sep 2022, Greg Kroah-Hartman wrote:
>> Ok, no, I don't understand what Arnd meant here then :(
>
> I think he did just 2 things (compared with 2/4 of this series):
>
> - __DEFINE_UART_PORT_TX_HELPER() doesn't create a function but just wraps
> the macro body with ({ }). Therefore, a driver must use it inside
> a function rather than the macro creating a new function with name.
> - Use lowercase instead of uppercase (this is a trivial change)
>
> When a driver is using these "function" that are just made look functions
> but are macros for real, it will not add function-pointer-indirection-call
> per character but pulls the whole loop from the macro into the function
> in the driver and injects those putchar, etc. directly into that loop.
> ...It is just like read_poll_timeout() constructs the loop.
Right, the example I was thinking of was wait_event(), which is
another common macro that takes expressions as arguments but gets
used like a function call. Same thing really.
Note that even with an always_inline function that takes a
function pointer argument, anything from gcc-4.7 up has no
problem inlining through that, so it should not be any less
efficient though it might not help readability either.
See https://godbolt.org/z/o8GGG8TzM for an example of that.
Arnd
More information about the linux-riscv
mailing list