netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Paolo Abeni <pabeni@redhat.com>, Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Rasesh Mody <rmody@marvell.com>,
	GR-Linux-NIC-Dev@marvell.com, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH net v1 1/1] bnx2: Fix unused data compilation warning
Date: Tue, 4 Mar 2025 08:35:24 -0800	[thread overview]
Message-ID: <20250304083524.3fe2ced4@kernel.org> (raw)
In-Reply-To: <Z8cC_xMScZ9rq47q@smile.fi.intel.com>

On Tue, 4 Mar 2025 15:41:19 +0200 Andy Shevchenko wrote:
> > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > > index b79925b1c433..927884f10b0f 100644
> > > --- a/include/linux/dma-mapping.h
> > > +++ b/include/linux/dma-mapping.h
> > > @@ -629,7 +629,7 @@ static inline int dma_mmap_wc(struct device *dev,
> > >  #else
> > >  #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
> > >  #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
> > > -#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
> > > +#define dma_unmap_addr(PTR, ADDR_NAME)           (((PTR)->ADDR_NAME), 0)
> > >  #define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
> > >  #define dma_unmap_len(PTR, LEN_NAME)             (0)
> > >  #define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
> > > ---
> > > 
> > > Would that work?  
> 
> Actually it won't work because the variable is under the same ifdeffery.
> What will work is to spreading the ifdeffery to the users, but it doesn't any
> better than __maybe_unsused, which is compact hack (yes, I admit that it is not
> the nicest solution, but it's spread enough in the kernel).

I meant something more like (untested):

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index b79925b1c433..a7ebcede43f6 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -629,10 +629,10 @@ static inline int dma_mmap_wc(struct device *dev,
 #else
 #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
 #define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
-#define dma_unmap_addr(PTR, ADDR_NAME)           (0)
-#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { } while (0)
-#define dma_unmap_len(PTR, LEN_NAME)             (0)
-#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { } while (0)
+#define dma_unmap_addr(PTR, ADDR_NAME)           ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
+#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL)  do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
+#define dma_unmap_len(PTR, LEN_NAME)             ({ typeof(PTR) __p __maybe_unused = PTR; 0; )}
+#define dma_unmap_len_set(PTR, LEN_NAME, VAL)    do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
 #endif
 
 #endif /* _LINUX_DMA_MAPPING_H */


I just don't know how much code out there depends on PTR not
existing if !CONFIG_NEED_DMA_MAP_STATE

  reply	other threads:[~2025-03-04 16:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28 10:05 [PATCH net v1 1/1] bnx2: Fix unused data compilation warning Andy Shevchenko
2025-03-04  1:21 ` Jakub Kicinski
2025-03-04 10:56   ` Andy Shevchenko
2025-03-04 11:39     ` Paolo Abeni
2025-03-04 11:58       ` Andy Shevchenko
2025-03-04 13:41         ` Andy Shevchenko
2025-03-04 16:35           ` Jakub Kicinski [this message]
2025-03-05 10:00             ` Andy Shevchenko
2025-03-11 12:51               ` Marek Szyprowski
2025-03-12 16:20                 ` Andy Shevchenko
2025-04-14 10:08                   ` Andy Shevchenko
2025-04-15  9:43                     ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250304083524.3fe2ced4@kernel.org \
    --to=kuba@kernel.org \
    --cc=GR-Linux-NIC-Dev@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rmody@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).