[PATCH v2] staging: most: net: Replace macros HB and LB with static inline functions

Brent Pappas posted 1 patch 3 years, 6 months ago
[PATCH v2] staging: most: net: Replace macros HB and LB with static inline functions
Posted by Brent Pappas 3 years, 6 months ago
Replace function-like macros "HB" and "LB" with static inline functions
to comply with preferred Linux coding style standards.

Signed-off-by: Brent Pappas <pappasbrent@knights.ucf.edu>
---
Changelog:
V1 -> V2: Resent diff from a mail client that would not replace tabs
          with spaces so that patch can be successfully applied.

diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c
index 1d1fe8bff7ee..8a8fbc274b73 100644
--- a/drivers/staging/most/net/net.c
+++ b/drivers/staging/most/net/net.c
@@ -36,8 +36,8 @@
 #define PMS_TELID_MASK		0x0F
 #define PMS_TELID_SHIFT		4
 
-#define HB(value)		((u8)((u16)(value) >> 8))
-#define LB(value)		((u8)(value))
+static inline u8 HB(unsigned int value)		{ return ((u8)((u16)(value) >> 8)); }
+static inline u8 LB(unsigned int value)		{ return ((u8)(value)); }
 
 #define EXTRACT_BIT_SET(bitset_name, value) \
 	(((value) >> bitset_name##_SHIFT) & bitset_name##_MASK)
Re: [PATCH v2] staging: most: net: Replace macros HB and LB with static inline functions
Posted by Nam Cao 3 years, 6 months ago
On Thu, Oct 06, 2022 at 01:02:34PM -0400, Brent Pappas wrote:
> Replace function-like macros "HB" and "LB" with static inline functions
> to comply with preferred Linux coding style standards.
> 
> Signed-off-by: Brent Pappas <pappasbrent@knights.ucf.edu>
> ---
> Changelog:
> V1 -> V2: Resent diff from a mail client that would not replace tabs
>           with spaces so that patch can be successfully applied.
> 
> diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c
> index 1d1fe8bff7ee..8a8fbc274b73 100644
> --- a/drivers/staging/most/net/net.c
> +++ b/drivers/staging/most/net/net.c
> @@ -36,8 +36,8 @@
>  #define PMS_TELID_MASK		0x0F
>  #define PMS_TELID_SHIFT		4
>  
> -#define HB(value)		((u8)((u16)(value) >> 8))
> -#define LB(value)		((u8)(value))
> +static inline u8 HB(unsigned int value)		{ return ((u8)((u16)(value) >> 8)); }
> +static inline u8 LB(unsigned int value)		{ return ((u8)(value)); }
>  
>  #define EXTRACT_BIT_SET(bitset_name, value) \
>  	(((value) >> bitset_name##_SHIFT) & bitset_name##_MASK) 

Sorry but I still can't apply your patch :(. I think you accidentally
added a trailing space character (at the last line).

Perhaps it's a good idea to send the patch to yourself, download the
email and try applying if it works, before sending it out.

Best regards,
Nam
[PATCH v3] Replace macros HB and LB with static inline functions
Posted by Brent Pappas 3 years, 6 months ago
Replace function-like macros "HB" and "LB" with static inline functions
to comply with preferred Linux coding style standards.

Signed-off-by: Brent Pappas <bpappas@pappasbrent.com>
---
Changelog:
V1 -> V2: Resent diff from a mail client that would not replace tabs
          with spaces so that patch can be successfully applied.
V2 -> V3: Created patch using git format-patch.
		  Tested downloading and applying patch.
          Sent patch using git send-email.

 drivers/staging/most/net/net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c
index 1d1fe8bff7ee..8a8fbc274b73 100644
--- a/drivers/staging/most/net/net.c
+++ b/drivers/staging/most/net/net.c
@@ -36,8 +36,8 @@
 #define PMS_TELID_MASK		0x0F
 #define PMS_TELID_SHIFT		4
 
-#define HB(value)		((u8)((u16)(value) >> 8))
-#define LB(value)		((u8)(value))
+static inline u8 HB(unsigned int value)		{ return ((u8)((u16)(value) >> 8)); }
+static inline u8 LB(unsigned int value)		{ return ((u8)(value)); }
 
 #define EXTRACT_BIT_SET(bitset_name, value) \
 	(((value) >> bitset_name##_SHIFT) & bitset_name##_MASK)
-- 
2.34.1
Re: [PATCH v3] Replace macros HB and LB with static inline functions
Posted by Greg KH 3 years, 5 months ago
On Thu, Oct 06, 2022 at 07:07:57PM -0400, Brent Pappas wrote:
> Replace function-like macros "HB" and "LB" with static inline functions
> to comply with preferred Linux coding style standards.
> 
> Signed-off-by: Brent Pappas <bpappas@pappasbrent.com>
> ---
> Changelog:
> V1 -> V2: Resent diff from a mail client that would not replace tabs
>           with spaces so that patch can be successfully applied.
> V2 -> V3: Created patch using git format-patch.
> 		  Tested downloading and applying patch.
>           Sent patch using git send-email.
> 
>  drivers/staging/most/net/net.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c
> index 1d1fe8bff7ee..8a8fbc274b73 100644
> --- a/drivers/staging/most/net/net.c
> +++ b/drivers/staging/most/net/net.c
> @@ -36,8 +36,8 @@
>  #define PMS_TELID_MASK		0x0F
>  #define PMS_TELID_SHIFT		4
>  
> -#define HB(value)		((u8)((u16)(value) >> 8))
> -#define LB(value)		((u8)(value))
> +static inline u8 HB(unsigned int value)		{ return ((u8)((u16)(value) >> 8)); }
> +static inline u8 LB(unsigned int value)		{ return ((u8)(value)); }

If you use one less tab, you will not go over the 90 column limit,
right?

Only 1 tab is needed.

thanks,

greg k-h