Re: [PATCH v1 1/1] serial: max3100: Convert to_max3100_port() to be static inline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 10, 2024 at 05:11:35PM +0300, Andy Shevchenko wrote:
> As Jiri rightfully pointed out the current to_max3100_port() macro
> implementation is fragile in a sense that it expects the variable
> name to be port, otherwise it blow up the build.
> 
> Change this to be static inline to prevent bad compilation.

Is there a problem today?  If not, this line isn't needed, as it sounds
like you are fixing a problem here, when all you are doing is making it
"nicer", right?

> Suggested-by: Jiri Slaby <jirislaby@xxxxxxxxxx>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
>  drivers/tty/serial/max3100.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
> index 1e6b5763ce3f..07ee001640bb 100644
> --- a/drivers/tty/serial/max3100.c
> +++ b/drivers/tty/serial/max3100.c
> @@ -111,7 +111,10 @@ struct max3100_port {
>  	struct timer_list	timer;
>  };
>  
> -#define to_max3100_port(port)	container_of(port, struct max3100_port, port)
> +static inline struct max3100_port *to_max3100_port(struct uart_port *port)
> +{
> +	return container_of(port, struct max3100_port, port);

Note, the one reason you might want to do this as a #define is if you
use container_of_const() which has to be a #define.  So the fact that
this was a define to start with is normal and not really a big deal.

thanks,

greg k-h




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux