serial: icom: switch vague casts to container_of
authorJiri Slaby <jslaby@suse.cz>
Thu, 21 Apr 2022 08:58:00 +0000 (10:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 22 Apr 2022 14:19:52 +0000 (16:19 +0200)
commitf73989f58d54b5b01363a2627dd9c99710770d62
tree6772c5969dbbae6c8b04a25e32cea995fe9ba30c
parent74c778ec5a272cb100e8d4b7eee04220335794d2
serial: icom: switch vague casts to container_of

In icom, there is an ICOM_PORT macro to perform upcasts from struct
uart_port to struct icom_port. It's not completely safe and it works
only because the first member of icom_port is uart_port. Nowadays, we
use container_of for such an upcast instead.

So introduce a helper (to_icom_port()) with container_of in it and
convert all the ICOM_PORT users to the new helper. Apart from the code
and type safety, it's also clear what icom_port (the variable) is.
Unlike with the old ICOM_PORT (the macro with the cast).

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220421085808.24152-3-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/icom.c