From: Chunyan Zhang <zhang.lyra@gmail.com>
To: Rob Herring <robh+dt@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>,
DTML <devicetree@vger.kernel.org>,
Chunyan Zhang <chunyan.zhang@unisoc.com>,
LKML <linux-kernel@vger.kernel.org>,
Orson Zhai <orsonzhai@gmail.com>
Subject: Re: [PATCH] of: fix of_address_to_resource and of_iomap undefined
Date: Mon, 6 Sep 2021 12:36:57 +0800 [thread overview]
Message-ID: <CAAfSe-vpmqSH9mzecn8w4qsD_zg7SFKkJy=bwVZxdwyVqd73kw@mail.gmail.com> (raw)
In-Reply-To: <CAL_JsqJrXPEEJrPnhZKhrddBw3LHwoKEJ3-eoMOsRtGt6k8i7w@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3515 bytes --]
On Sat, 4 Sept 2021 at 04:23, Rob Herring <robh+dt@kernel.org> wrote:
>
> On Thu, Sep 2, 2021 at 4:27 AM Chunyan Zhang <zhang.lyra@gmail.com> wrote:
> >
> > From: Chunyan Zhang <chunyan.zhang@unisoc.com>
> >
> > If CONFIG_OF is selected, but CONFIG_OF_ADDRESS is not, when compiling
> > files (sunch as timer_of.c) in which the function of_iomap() is invoked,
> > compiler would report 'undefined reference to of_iomap', the same case
> > is for of_address_to_resource().
>
> What arch and config are you building?
sparc, and the config is attached.
>
> > This patch also makes sure that of_iomap() and of_address_to_resource()
> > are declared for sparc so that sparc can have its specific
> > implementations in arch/sparc/kernel/of_device_common.c, even if
> > including include/linux/of_address.h in it.
> >
> > Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
> > ---
> > include/linux/of_address.h | 33 +++++++++++++++++----------------
> > 1 file changed, 17 insertions(+), 16 deletions(-)
> >
> > diff --git a/include/linux/of_address.h b/include/linux/of_address.h
> > index 45598dbec269..02a719d58466 100644
> > --- a/include/linux/of_address.h
> > +++ b/include/linux/of_address.h
> > @@ -80,6 +80,23 @@ static inline u64 of_translate_address(struct device_node *np,
> > return OF_BAD_ADDR;
> > }
> >
> > +#ifdef CONFIG_SPARC
> > +extern int of_address_to_resource(struct device_node *dev, int index,
> > + struct resource *r);
> > +void __iomem *of_iomap(struct device_node *device, int index);
>
> This is now in the !CONFIG_OF_ADDRESS section. So for
> CONFIG_OF_ADDRESS, we'd never have a function declaration.
Not sure I got your point.
There are these two function declarations both in
arch/sparc/kernel/of_device_common.c (CONFIG_SPARC &&
!CONFIG_OF_ADDRESS) and drivers/of/address.c (!CONFIG_SPARC &&
CONFIG_OF_ADDRESS).
> This change does not look right at all to me.
>
> > +#else
> > +static inline int of_address_to_resource(struct device_node *dev, int index,
> > + struct resource *r)
> > +{
> > + return -EINVAL;
> > +}
> > +
> > +static inline void __iomem *of_iomap(struct device_node *device, int index)
> > +{
> > + return NULL;
> > +}
> > +#endif
Now, I'm also not sure if this change is right, I learned in another
patch recently that Linus prefers to avoid the extra code like this.
https://lkml.org/lkml/2021/7/2/511
> > +
> > static inline const __be32 *__of_get_address(struct device_node *dev, int index, int bar_no,
> > u64 *size, unsigned int *flags)
> > {
> > @@ -124,22 +141,6 @@ static inline bool of_dma_is_coherent(struct device_node *np)
> > }
> > #endif /* CONFIG_OF_ADDRESS */
> >
> > -#ifdef CONFIG_OF
> > -extern int of_address_to_resource(struct device_node *dev, int index,
> > - struct resource *r);
> > -void __iomem *of_iomap(struct device_node *node, int index);
> > -#else
> > -static inline int of_address_to_resource(struct device_node *dev, int index,
> > - struct resource *r)
> > -{
> > - return -EINVAL;
> > -}
> > -
> > -static inline void __iomem *of_iomap(struct device_node *device, int index)
> > -{
> > - return NULL;
> > -}
> > -#endif
> > #define of_range_parser_init of_pci_range_parser_init
> >
> > static inline const __be32 *of_get_address(struct device_node *dev, int index,
> > --
> > 2.25.1
> >
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 11286 bytes --]
prev parent reply other threads:[~2021-09-06 4:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-02 9:27 [PATCH] of: fix of_address_to_resource and of_iomap undefined Chunyan Zhang
2021-09-03 20:22 ` Rob Herring
2021-09-06 4:36 ` Chunyan Zhang [this message]
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='CAAfSe-vpmqSH9mzecn8w4qsD_zg7SFKkJy=bwVZxdwyVqd73kw@mail.gmail.com' \
--to=zhang.lyra@gmail.com \
--cc=chunyan.zhang@unisoc.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=orsonzhai@gmail.com \
--cc=robh+dt@kernel.org \
/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).