From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] of: Make const the device node pointers in of_clk_get and of_node_put
Date: Sun, 9 Nov 2014 18:50:19 +0000 [thread overview]
Message-ID: <20141109185019.GU4042@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <375a82230accf26dfbbb74e6f928243ea8e38b50.1415557680.git.moinejf@free.fr>
On Sat, Nov 08, 2014 at 07:33:22PM +0100, Jean-Francois Moine wrote:
> Some device nodes are sometimes referenced by const pointers.
>
> This patch avoids to cast these pointers when calling the functions
> of_clk_get() and of_node_put().
NAK. Firstly, of_node_put contains a kref, which is /definitely/ not
a const item when kobject_put() is called on it. Inside the kobject
is a kref, which kobject_put() will call kref_put() on. kref_put()
in turn will internally call atomic_sub_and_test() on a value embedded
within the kref struct.
Ergo, of_node_put() modifies the struct device_node contents. Therefore,
of_node_put() definitely not treating the data pointed to as read-only,
and therefore it is completely inappropriate for it to be marked "const".
What this then means is that it fundamentally undermines the idea of
storing the pointer to a device_node as a const pointer, as the device
node must always be modified when you're done with it (because it's a
ref-counted structure.) So, having it const in your code is a bug.
What this also means is that every other place that you've added const
below is also very dubious.
--
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2014-11-09 18:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-09 18:28 [PATCH 0/2] of: Fix some 'const' problems Jean-Francois Moine
2014-11-08 18:33 ` [PATCH 1/2] of: Make const the device node pointers in of_clk_get and of_node_put Jean-Francois Moine
2014-11-09 18:50 ` Russell King - ARM Linux [this message]
2014-11-09 19:28 ` Jean-Francois Moine
2014-11-09 11:38 ` [PATCH 2/2] ASoC: Remove useless casts Jean-Francois Moine
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=20141109185019.GU4042@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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).