From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Hans de Goede <hdegoede@redhat.com>,
Chen-Yu Tsai <wens@csie.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev,
linux-rpi-kernel@lists.infradead.org,
Javier Carrasco <javier.carrasco.cruz@gmail.com>
Subject: [PATCH 00/10] input: automate of_node_put() calls for device_node
Date: Thu, 10 Oct 2024 23:25:50 +0200 [thread overview]
Message-ID: <20241010-input_automate_of_node_put-v1-0-ebc62138fbf8@gmail.com> (raw)
This series removes the explicit calls to 'of_node_put()' from the input
subsystem, either by switching from 'for_each_child_of_node()' to its
scoped variant 'for_each_child_of_node_scoped()', or by adding the
cleanup attribute to the device_node by means of the '__free()' macro.
This series simplifies the code in some cases, and it makes it in
general more robust, as it will avoid memory leaks if early returns are
added without the required call to 'of_node_put()', which is a rather
common issue.
The following drivers unconditionally release the device node after
using it:
- misc/twl4030-vibra.c ('of_node_put()' under an if, but only if the
node received a valid value).
- misc/sparcspkr.c
- serio/i8042-sparcio.h
- touchscreen/raspberrypi-ts.c
- touchscreen/ts4800-ts.c
The usage of the cleanup faciliy for these drivers offers no real gain
at the moment, but as soon as an error path is added to them, things can
go wrong, as it has happened multiple times with such nodes. I intended
to remove this error-prone pattern from the subsystem, so it is not
"borrowed" by new users. But if someone has strong feelings about the
automatic cleanup for those drives, I will not complain if they are left
as they are (at least until a new buggy error path is introduced ;)).
The approach for the variable declaration is the one that has been
followed in previous clean ups: as near as possible to its usage,
instead of at the top. I have no strong feelings about that either, but
I would prefer it that way for consistency and to have a common pattern
for future additions.
A single call to 'of_node_put()' has been left behind in rmi4/rmi_bus.c,
as it is used to release a node passed as a parameter, which would make
the use of the cleanup attribute too cumbersome for no real gain. It is
called unconditionally, and it will probably not be used as a common
pattern for new users of a device_node.
There has been some previous work from Dmitry to use the cleanup
facilities for 'fwnode_handle' and mutexes[1][2], which this series
aims to complement for 'device_node'.
Link: https://lore.kernel.org/linux-input/20240904044244.1042174-1-dmitry.torokhov@gmail.com/ [1]
Link: https://lore.kernel.org/linux-input/20240825051627.2848495-1-dmitry.torokhov@gmail.com/ [2]
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
Javier Carrasco (10):
Input: cap11xx - switch to for_each_child_of_node_scoped
Input: mtk-pmic-keys - switch to for_each_child_of_node_scoped
Input: sun4i-lradc-keys - switch to for_each_child_of_node_scoped
Input: twl6040-vibra - use cleanup facility for device_node
Input: twl4030-vibra - use cleanup facility for device_node
Input: sparcspkr - use cleanup facility for device_node
Input: 88pm860x - use cleanup facility for device_node
Input: i8042 - use cleanup facility for device_node
Input: raspberrypi-ts - use cleanup facility for device_node
Input: ts4800-ts - use cleanup facility for device_node
drivers/input/keyboard/cap11xx.c | 12 ++++--------
drivers/input/keyboard/mtk-pmic-keys.c | 17 +++++------------
drivers/input/keyboard/sun4i-lradc-keys.c | 7 ++-----
drivers/input/misc/sparcspkr.c | 4 +---
drivers/input/misc/twl4030-vibra.c | 11 +++--------
drivers/input/misc/twl6040-vibra.c | 8 ++------
drivers/input/serio/i8042-sparcio.h | 6 +-----
drivers/input/touchscreen/88pm860x-ts.c | 20 +++++++-------------
drivers/input/touchscreen/raspberrypi-ts.c | 4 +---
drivers/input/touchscreen/ts4800-ts.c | 5 ++---
10 files changed, 28 insertions(+), 66 deletions(-)
---
base-commit: 515ef92b4939fa51f9f1ee278618e2d419b0b8b0
change-id: 20241009-input_automate_of_node_put-1bae9f5c02d9
Best regards,
--
Javier Carrasco <javier.carrasco.cruz@gmail.com>
next reply other threads:[~2024-10-10 21:25 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 21:25 Javier Carrasco [this message]
2024-10-10 21:25 ` [PATCH 01/10] Input: cap11xx - switch to for_each_child_of_node_scoped Javier Carrasco
2024-10-20 3:59 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 02/10] Input: mtk-pmic-keys " Javier Carrasco
2024-10-20 4:00 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 03/10] Input: sun4i-lradc-keys " Javier Carrasco
2024-10-11 10:36 ` Andre Przywara
2024-10-20 4:02 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 04/10] Input: twl6040-vibra - use cleanup facility for device_node Javier Carrasco
2024-10-20 4:09 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 05/10] Input: twl4030-vibra " Javier Carrasco
2024-10-20 4:09 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 06/10] Input: sparcspkr " Javier Carrasco
2024-10-10 21:43 ` Al Viro
2024-10-10 22:01 ` Javier Carrasco
2024-10-10 22:09 ` Javier Carrasco
2024-10-10 22:22 ` Al Viro
2024-10-10 22:28 ` Javier Carrasco
2024-10-10 21:25 ` [PATCH 07/10] Input: 88pm860x " Javier Carrasco
2024-10-20 4:19 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 08/10] Input: i8042 " Javier Carrasco
2024-10-20 4:19 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 09/10] Input: raspberrypi-ts " Javier Carrasco
2024-10-20 4:20 ` Dmitry Torokhov
2024-10-10 21:26 ` [PATCH 10/10] Input: ts4800-ts " Javier Carrasco
2024-10-20 4:20 ` Dmitry Torokhov
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=20241010-input_automate_of_node_put-v1-0-ebc62138fbf8@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dmitry.torokhov@gmail.com \
--cc=florian.fainelli@broadcom.com \
--cc=hdegoede@redhat.com \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=matthias.bgg@gmail.com \
--cc=samuel@sholland.org \
--cc=wens@csie.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).