Re: [PATCH 1/3] scsi: ufshcd: switch to a version macro

From: Christoph Hellwig
Date: Tue Mar 09 2021 - 04:33:04 EST


On Mon, Mar 08, 2021 at 10:42:43AM +0000, Caleb Connolly wrote:
> >> +#define UFSHCI_VER(major, minor) \
> >> + ((major << 8) + (minor << 4))
> > This needs braces around major and minor. Or better just convert it
> > to an inline function (and use a lower case name).
>
> Other (similar) implementations, like NVME_VS() use a macro here, is an
> inline function just personal preference?
>
> I'm perfectly happy either way, so I'll switch to your suggestion.

In general inline functions are always preferred over non-trivial
macros. Macros are required for a few cases where e.g. otherwise the
include dependencies would turn into a nightmare.