linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 03/12] nvmem: mtk-efuse: fix different address space warnings of sparse
Date: Fri, 20 Oct 2017 16:49:11 +0200	[thread overview]
Message-ID: <20171020144911.GC8965@kroah.com> (raw)
In-Reply-To: <CAK7LNAR_64jmOmjAYUVrrjz2WQ8RQnm-dg8CHVgQhYxcMYzOKg@mail.gmail.com>

On Fri, Oct 20, 2017 at 10:55:04PM +0900, Masahiro Yamada wrote:
> 2017-10-20 22:34 GMT+09:00 Greg KH <gregkh@linuxfoundation.org>:
> > On Mon, Oct 09, 2017 at 03:26:32PM +0200, srinivas.kandagatla@linaro.org wrote:
> >> From: Masahiro Yamada <yamada.masahiro@socionext.com>
> >>
> >> Fix the following sparse warnings:
> >>
> >> drivers/nvmem/mtk-efuse.c:24:30: warning: incorrect type in initializer (different address spaces)
> >> drivers/nvmem/mtk-efuse.c:24:30:    expected void [noderef] <asn:2>*base
> >> drivers/nvmem/mtk-efuse.c:24:30:    got void *context
> >> drivers/nvmem/mtk-efuse.c:37:30: warning: incorrect type in initializer (different address spaces)
> >> drivers/nvmem/mtk-efuse.c:37:30:    expected void [noderef] <asn:2>*base
> >> drivers/nvmem/mtk-efuse.c:37:30:    got void *context
> >> drivers/nvmem/mtk-efuse.c:69:23: warning: incorrect type in assignment (different address spaces)
> >> drivers/nvmem/mtk-efuse.c:69:23:    expected void *priv
> >> drivers/nvmem/mtk-efuse.c:69:23:    got void [noderef] <asn:2>*[assigned] base
> >>
> >> The type of nvmem_config->priv is (void *), so sparse complains
> >> about assignment of the base address with (void __iomem *) type.
> >>
> >> Even if we cast it out, sparse still warns:
> >> warning: cast removes address space of expression
> >>
> >> Of course, we can shut up the sparse by marking __force, but a more
> >> correct way is to put the base address into driver private data.
> >
> > Ick, no, really?
> >
> > That's horrid.  Do the __force cast as that is what you are really doing
> > here, and it is good to see the bad use of it (hint, perhaps the api
> > needs to be fixed up so you do not have to do that???)
> 
> 
> Other drivers take private data from the "void *context".
> 
> In this driver, the priv just happens to have one member.
> What's the matter?
> 
> 
> 
> 
> >> diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
> >> index fa7a0f66b37e..c4058b598703 100644
> >> --- a/drivers/nvmem/mtk-efuse.c
> >> +++ b/drivers/nvmem/mtk-efuse.c
> >> @@ -18,15 +18,19 @@
> >>  #include <linux/nvmem-provider.h>
> >>  #include <linux/platform_device.h>
> >>
> >> +struct mtk_efuse_priv {
> >> +     void __iomem *base;
> >> +};
> >> +
> >>  static int mtk_reg_read(void *context,
> >
> >
> > Make the read call take a __iomem *, not a random void *.  That should
> > solve this issue, right?
> >
> 
> NACK.
> 
> See drivers/nvmem/imx-iim.c
> 
> The ->reg_read hook needs more private data than __iomem *.

Ok, that makes a bit more sense, but it still feels a bit of a hack,
don't you agree?

thanks,

greg k-h

  reply	other threads:[~2017-10-20 14:49 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-09 13:26 [PATCH 00/12] nvmem: patches set-1 for v4.15 srinivas.kandagatla
2017-10-09 13:26 ` [PATCH 01/12] nvmem: imx-iim: use stack for nvmem_config instead of malloc'ing it srinivas.kandagatla
2017-10-20 13:32   ` Greg KH
2017-10-20 13:47     ` Masahiro Yamada
2017-10-20 13:54       ` Greg KH
2017-10-20 14:26         ` Masahiro Yamada
2017-10-20 14:47           ` Greg KH
2017-10-20 16:18             ` Masahiro Yamada
2017-10-20 16:26               ` Greg KH
2017-10-30 15:55                 ` Masahiro Yamada
2017-10-09 13:26 ` [PATCH 02/12] nvmem: mtk-efuse: " srinivas.kandagatla
2017-10-20 13:34   ` Greg KH
2017-10-20 13:47     ` Masahiro Yamada
2017-10-20 13:54       ` Greg KH
2017-10-20 13:59         ` Masahiro Yamada
2017-10-20 14:48           ` Greg KH
2017-10-09 13:26 ` [PATCH 03/12] nvmem: mtk-efuse: fix different address space warnings of sparse srinivas.kandagatla
2017-10-20 13:34   ` Greg KH
2017-10-20 13:55     ` Masahiro Yamada
2017-10-20 14:49       ` Greg KH [this message]
2017-10-20 16:08         ` Masahiro Yamada
2017-10-09 13:26 ` [PATCH 04/12] nvmem: qfprom: " srinivas.kandagatla
2017-10-20 13:34   ` Greg KH
2017-10-09 13:26 ` [PATCH 05/12] nvmem: set nvmem->owner to nvmem->dev->driver->owner if unset srinivas.kandagatla
2017-10-20 13:38   ` Greg KH
2017-10-20 13:44     ` Srinivas Kandagatla
2017-10-20 13:52       ` Greg KH
2017-10-09 13:26 ` [PATCH 06/12] nvmem: sunxi-sid: add support for A64/H5's SID controller srinivas.kandagatla
2017-10-20 13:36   ` Greg KH
2017-10-09 13:26 ` [PATCH 07/12] dt-bindings: nvmem: add description for UniPhier eFuse srinivas.kandagatla
2017-10-20 13:36   ` Greg KH
2017-10-09 13:26 ` [PATCH 08/12] nvmem: uniphier: add UniPhier eFuse driver srinivas.kandagatla
2017-10-20 13:37   ` Greg KH
2017-10-09 13:26 ` [PATCH 09/12] nvmem: rockchip: add support for RK3368 srinivas.kandagatla
2017-10-09 13:26 ` [PATCH 10/12] dt-bindings: nvmem: Describe the Amlogic Meson6/Meson8/Meson8b efuse srinivas.kandagatla
2017-10-12 20:52   ` Martin Blumenstingl
2017-10-09 13:26 ` [PATCH 11/12] nvmem: meson-efuse: indicate that this driver is only for Meson GX SoCs srinivas.kandagatla
2017-10-12 20:51   ` Martin Blumenstingl
2017-10-09 13:26 ` [PATCH 12/12] nvmem: add a driver for the Amlogic Meson6/Meson8/Meson8b SoCs srinivas.kandagatla

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=20171020144911.GC8965@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=yamada.masahiro@socionext.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).