public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
To: Krzysztof Kozlowski <krzk@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
	Kukjin Kim <kgene@kernel.org>,
	Javier Martinez Canillas <javier@osg.samsung.com>,
	Matt Mackall <mpm@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
	linux-crypto@vger.kernel.org, Olof Johansson <olof@lixom.net>,
	Arnd Bergmann <arnd@arndb.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH 1/3] crypto: hw_random - Add new Exynos RNG driver
Date: Fri, 24 Mar 2017 17:45:41 +0100	[thread overview]
Message-ID: <87677624.EBdhaJY1KM@amdc3058> (raw)
In-Reply-To: <20170324161934.kc6g36nazr3y32kp@kozik-lap>

On Friday, March 24, 2017 07:19:34 PM Krzysztof Kozlowski wrote:
> On Fri, Mar 24, 2017 at 05:11:25PM +0100, Bartlomiej Zolnierkiewicz wrote:
> > On Friday, March 24, 2017 06:46:00 PM Krzysztof Kozlowski wrote:
> > > I really do not like global or file-scope variables. I do not like
> > > drivers using them. Actually I hate them.
> > > 
> > > From time to time I encounter a driver which was designed with that
> > > approach - static fields and hidden assumption that there will be only
> > > one instance. Usually that assumption is really hidden...
> > > 
> > > ... and then it happens that I want to use two instances which of course
> > > fails.
> > > 
> > > This code serves as a clear documentation for this assumption - only one
> > > instance is allowed. You can look at it as a self-documenting
> > > requirement.
> > 
> > For me it looks as needless case of defensive programming and when
> > I see the code like this it always raises questions about the real
> > intentions of the code. I find it puzzling and not helpful.
> 
> I do not understand what might be puzzling about check for static
> file-scope value. It is of course subjective, but for me that looks
> pretty self-explanatory.

The check should never happen given that ->probe will not happen twice.

However it seems that this is possible now with DT platform devices and
incorrect DTB.

> > > And I think the probe might be called twice, for example in case of
> > > mistake in DTB.
> > 
> > Even if this is possible resource allocation code in the driver will
> > take take care of handling it just fine,
> 
> Indeed, the devm_ioremap_resource() solves the case. I can drop the
> check then.

Looking on this a bit more it seems that devm_ioremap_resource() will
not cover all mistakes (using compatible by mistake in some other DTB
node).

Leave the check, I take my objection back.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

  reply	other threads:[~2017-03-24 16:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 14:24 [PATCH 0/3] crypto: hw_random - Add new Exynos RNG driver Krzysztof Kozlowski
2017-03-24 14:24 ` [PATCH 1/3] " Krzysztof Kozlowski
2017-03-24 14:37   ` Stephan Müller
2017-03-24 14:43     ` Krzysztof Kozlowski
2017-03-24 14:46       ` Stephan Müller
2017-03-24 14:51         ` Krzysztof Kozlowski
2017-03-24 14:55           ` Stephan Müller
2017-03-24 14:58             ` Krzysztof Kozlowski
2017-03-24 15:26   ` Bartlomiej Zolnierkiewicz
2017-03-24 15:46     ` Krzysztof Kozlowski
2017-03-24 16:11       ` Bartlomiej Zolnierkiewicz
2017-03-24 16:19         ` Krzysztof Kozlowski
2017-03-24 16:45           ` Bartlomiej Zolnierkiewicz [this message]
2017-03-24 17:01             ` Krzysztof Kozlowski
2017-03-24 14:24 ` [PATCH 2/3] ARM: exynos_defconfig: Enable Exynos RNG and user-space crypto API Krzysztof Kozlowski
2017-03-24 14:24 ` [PATCH 3/3] ARM: multi_v7_defconfig: " Krzysztof Kozlowski

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=87677624.EBdhaJY1KM@amdc3058 \
    --to=b.zolnierkie@samsung.com \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=javier@osg.samsung.com \
    --cc=kgene@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mpm@selenic.com \
    --cc=olof@lixom.net \
    /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