linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Serge Semin" <fancer.lancer@gmail.com>
Cc: "Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Alexey Malahov" <Alexey.Malahov@baikalelectronics.ru>,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] mips: cm: Convert __mips_cm_l2sync_phys_base() to weak function
Date: Mon, 26 Feb 2024 13:04:33 +0100	[thread overview]
Message-ID: <cc9e02b3-57df-4a7d-bd21-2d574bf4b878@app.fastmail.com> (raw)
In-Reply-To: <y2lxeu5uvj7ezlv7kf6lox5e5xprmvrhqmf3gvzjsatlrrlub7@mvqzoyq5mnvd>

On Mon, Feb 26, 2024, at 12:27, Serge Semin wrote:
> On Mon, Feb 26, 2024 at 12:04:06PM +0100, Arnd Bergmann wrote:
>> On Mon, Feb 26, 2024, at 11:54, Serge Semin wrote:
s to.
>> 
>> Since the resolution of the alias is all done at link time
>> anyway, could you just convert these to an #ifdef check
>> that documents exactly when each of the versions is used?
>
> Not sure I've completely understood what you meant. Do you suggest to
> add a mips_cm_l2sync_phys_base macro which would be defined if a
> "strong" version of the method is defined (and surround the
> underscored function by it)?
>
> Please note after this patch is applied no aliases will
> be left, but only a single weakly defined method:
> mips_cm_l2sync_phys_base()
> This is what we agreed to do with Thomas:
> https://lore.kernel.org/linux-mips/pf6cvzper4g5364nqhd4wd2pmlkyygoymobeqduulpslcjhyy6@kf66z7chjbl3
> Thus there will be no need in the macro you suggest since the
> weak-version of the method will be discarded by the linker as it will
> have been replaced with the "strong" one. 

I meant that instead of having both a weak and an optional strong
version that get linked together, always define exactly one of the
two, such as:

#ifndef CONFIG_MIPS_CM_xxx
static phys_addr_t mips_cm_l2sync_phys_base(void)
{
       /* current implementation ... */
}
#endif

where CONFIG_MIPS_CM_xxx is the Kconfig symbol that decides
whether the file with the strong version is built or not.

This way you always get exactly one of the two versions
of the function built, the local version can be inlined
if the compiler thinks that is better, and the #ifdef
documents exactly whether the function is used or not
for a given configuration, rather than a reader having
to track down how many other definitions exist and whether
a config includes them.

       Arnd

  reply	other threads:[~2024-02-26 12:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 10:54 [PATCH v2 0/2] MIPS: Fix missing proto and passing arg warnings Serge Semin
2024-02-26 10:54 ` [PATCH v2 1/2] mips: cm: Convert __mips_cm_l2sync_phys_base() to weak function Serge Semin
2024-02-26 11:04   ` Arnd Bergmann
2024-02-26 11:27     ` Serge Semin
2024-02-26 12:04       ` Arnd Bergmann [this message]
2024-02-26 12:20         ` Serge Semin
2024-02-26 12:29           ` Arnd Bergmann
2024-02-26 13:11             ` Serge Semin
2024-03-11 13:07               ` Thomas Bogendoerfer
2024-02-26 10:54 ` [PATCH v2 2/2] mips: cm: Convert __mips_cm_phys_base() " Serge Semin
2024-03-11 13:05 ` [PATCH v2 0/2] MIPS: Fix missing proto and passing arg warnings Thomas Bogendoerfer

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=cc9e02b3-57df-4a7d-bd21-2d574bf4b878@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=Alexey.Malahov@baikalelectronics.ru \
    --cc=akpm@linux-foundation.org \
    --cc=fancer.lancer@gmail.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /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).