public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] staging: most: dim2: replace macro with static inline function
@ 2026-01-23  5:47 Ethan Tidmore
  2026-01-23  9:02 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Ethan Tidmore @ 2026-01-23  5:47 UTC (permalink / raw)
  To: parthiban.veerasooran, christian.gromm, gregkh
  Cc: linux-staging, linux-kernel, Ethan Tidmore

Replace unsafe macro with static inline function to avoid side effects.

Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 drivers/staging/most/dim2/dim2.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/most/dim2/dim2.c b/drivers/staging/most/dim2/dim2.c
index dad2abe6c0c9..a075a2df349e 100644
--- a/drivers/staging/most/dim2/dim2.c
+++ b/drivers/staging/most/dim2/dim2.c
@@ -113,10 +113,12 @@ static inline struct dim2_hdm *iface_to_hdm(struct most_interface *iface)
 	return container_of(iface, struct dim2_hdm, most_iface);
 }
 
-/* Macro to identify a network status message */
-#define PACKET_IS_NET_INFO(p)  \
-	(((p)[1] == 0x18) && ((p)[2] == 0x05) && ((p)[3] == 0x0C) && \
-	 ((p)[13] == 0x3C) && ((p)[14] == 0x00) && ((p)[15] == 0x0A))
+/* Identify a network status message */
+static inline bool packet_is_net_info(const u8 *p)
+{
+	return p[1] == 0x18 && p[2] == 0x05 && p[3] == 0x0C &&
+		p[13] == 0x3C && p[14] == 0x00 && p[15] == 0x0A;
+}
 
 static ssize_t state_show(struct device *dev, struct device_attribute *attr,
 			  char *buf)
@@ -304,7 +306,7 @@ static void service_done_flag(struct dim2_hdm *dev, int ch_idx)
 
 		if (hdm_ch->data_type == MOST_CH_ASYNC &&
 		    hdm_ch->direction == MOST_CH_RX &&
-		    PACKET_IS_NET_INFO(data)) {
+		    packet_is_net_info(data)) {
 			retrieve_netinfo(dev, mbo);
 
 			spin_lock_irqsave(&dim_lock, flags);
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] staging: most: dim2: replace macro with static inline function
  2026-01-23  5:47 [PATCH v1] staging: most: dim2: replace macro with static inline function Ethan Tidmore
@ 2026-01-23  9:02 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-01-23  9:02 UTC (permalink / raw)
  To: Ethan Tidmore
  Cc: parthiban.veerasooran, christian.gromm, gregkh, linux-staging,
	linux-kernel

On Thu, Jan 22, 2026 at 11:47:08PM -0600, Ethan Tidmore wrote:
> Replace unsafe macro with static inline function to avoid side effects.
> 
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
>  drivers/staging/most/dim2/dim2.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/most/dim2/dim2.c b/drivers/staging/most/dim2/dim2.c
> index dad2abe6c0c9..a075a2df349e 100644
> --- a/drivers/staging/most/dim2/dim2.c
> +++ b/drivers/staging/most/dim2/dim2.c
> @@ -113,10 +113,12 @@ static inline struct dim2_hdm *iface_to_hdm(struct most_interface *iface)
>  	return container_of(iface, struct dim2_hdm, most_iface);
>  }
>  
> -/* Macro to identify a network status message */
> -#define PACKET_IS_NET_INFO(p)  \
> -	(((p)[1] == 0x18) && ((p)[2] == 0x05) && ((p)[3] == 0x0C) && \
> -	 ((p)[13] == 0x3C) && ((p)[14] == 0x00) && ((p)[15] == 0x0A))
> +/* Identify a network status message */
> +static inline bool packet_is_net_info(const u8 *p)

These days we tend not to mark functions as inline since the compiler
is smart enough to do it on it's own and it's mostly going to ignore
our inlining suggestions anyway.  If it really matters in benchmarking
the use the __always_inline annotation.

> +{
> +	return p[1] == 0x18 && p[2] == 0x05 && p[3] == 0x0C &&
> +		p[13] == 0x3C && p[14] == 0x00 && p[15] == 0x0A;

This should be aligned slight differently.
[tab][space x 7]p[13] == 0x3C && p[14] == 0x00 && p[15] == 0x0A;

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-23  9:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23  5:47 [PATCH v1] staging: most: dim2: replace macro with static inline function Ethan Tidmore
2026-01-23  9:02 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox