linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Nathan Chancellor <natechancellor@gmail.com>,
	Sangbeom Kim <sbkim73@samsung.com>
Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-clk@vger.kernel.org,
	Nick Desaulniers <ndesaulniers@google.com>,
	Nathan Chancellor <natechancellor@gmail.com>
Subject: Re: [PATCH] clk: s2mps11: Add used attribute to s2mps11_dt_match
Date: Thu, 18 Oct 2018 13:29:57 -0700	[thread overview]
Message-ID: <153989459788.53599.2276628850158968119@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <20181018191340.30440-1-natechancellor@gmail.com>

Quoting Nathan Chancellor (2018-10-18 12:13:40)
> Clang warns after commit 8985167ecf57 ("clk: s2mps11: Fix matching when
> built as module and DT node contains compatible"):
> 
> drivers/clk/clk-s2mps11.c:242:34: warning: variable 's2mps11_dt_match'
> is not needed and will not be emitted [-Wunneeded-internal-declaration]
> static const struct of_device_id s2mps11_dt_match[] = {
>                                  ^
> 1 warning generated.
> 
> This warning happens when a variable is used in some construct that
> doesn't require a reference to that variable to be emitted in the symbol
> table; in this case, it's MODULE_DEVICE_TABLE, which only needs to hold
> the data of the variable, not the variable itself.
> 
> $ nm -S drivers/clk/clk-s2mps11.o | rg s2mps11_dt_match
> 00000078 000003d4 R __mod_of__s2mps11_dt_match_device_table
> 
> Normally, with device ID table variables, it means that the variable
> just needs to be tied to the device declaration at the bottom of the
> file, like s2mps11_clk_id:
> 
> $ nm -S drivers/clk/clk-s2mps11.o | rg s2mps11_clk_id
> 00000000 00000078 R __mod_platform__s2mps11_clk_id_device_table
> 00000000 00000078 r s2mps11_clk_id
> 
> However, because the comment above this deliberately doesn't want this
> variable added to .of_match_table, we need to mark s2mps11_dt_match as
> __used to silence this warning. This makes it clear to Clang that the
> variable is used for something, even if a reference to it isn't being
> emitted.
> 
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---

Just curious if this is a common occurrence? Maybe we should make a new
MODULE_DEVICE_TABLE macro that can declare the table, struct type, and
add in __used to the declaration like is done here? That way this gotcha
goes away without us having to remember that the table is used or not
used somewhere.

Anyway, I'll apply this patch to clk-next.


  reply	other threads:[~2018-10-18 20:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18 19:13 [PATCH] clk: s2mps11: Add used attribute to s2mps11_dt_match Nathan Chancellor
2018-10-18 20:29 ` Stephen Boyd [this message]
2018-10-18 20:42   ` Nathan Chancellor

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=153989459788.53599.2276628850158968119@swboyd.mtv.corp.google.com \
    --to=sboyd@kernel.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=krzk@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=sbkim73@samsung.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).