From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: "Marek Behún" <kabel@kernel.org>
Cc: Jonathan.Cameron@huawei.com, Laurent.pinchart@ideasonboard.com,
airlied@gmail.com, andrzej.hajda@intel.com, arm@kernel.org,
arnd@arndb.de, bamv2005@gmail.com, brgl@bgdev.pl,
daniel@ffwll.ch, davem@davemloft.net, dianders@chromium.org,
dri-devel@lists.freedesktop.org, eajames@linux.ibm.com,
gaurav.jain@nxp.com, gregory.clement@bootlin.com,
hdegoede@redhat.com, herbert@gondor.apana.org.au,
horia.geanta@nxp.com, james.clark@arm.com, james@equiv.tech,
jdelvare@suse.com, jernej.skrabec@gmail.com, jonas@kwiboo.se,
linus.walleij@linaro.org, linux-crypto@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org, linux@roeck-us.net,
maarten.lankhorst@linux.intel.com, mazziesaccount@gmail.com,
mripard@kernel.org, naresh.solanki@9elements.com,
neil.armstrong@linaro.org, pankaj.gupta@nxp.com,
patrick.rudolph@9elements.com, rfoss@kernel.org, soc@kernel.org,
tzimmermann@suse.de
Subject: Re: [PATCH v5 08/11] devm-helpers: Add resource managed version of debugfs directory create function
Date: Sat, 23 Mar 2024 22:10:40 +0100 [thread overview]
Message-ID: <f7c64a5a-2abc-4b7e-95db-7ca57b5427c0@wanadoo.fr> (raw)
In-Reply-To: <20240323164359.21642-9-kabel__6885.49310886941$1711212291$gmane$org@kernel.org>
Le 23/03/2024 à 17:43, Marek Behún a écrit :
> A few drivers register a devm action to remove a debugfs directory,
> implementing a one-liner function that calls debufs_remove_recursive().
> Help drivers avoid this repeated implementations by adding managed
> version of debugfs directory create function.
>
> Use the new function devm_debugfs_create_dir() in the following
> drivers:
> drivers/crypto/caam/ctrl.c
> drivers/gpu/drm/bridge/ti-sn65dsi86.c
> drivers/hwmon/hp-wmi-sensors.c
> drivers/hwmon/mr75203.c
> drivers/hwmon/pmbus/pmbus_core.c
>
> Also use the action function devm_debugfs_dir_recursive_drop() in
> driver
> drivers/gpio/gpio-mockup.c
>
> As per Dan Williams' request [1], do not touch the driver
> drivers/cxl/mem.c
>
> [1] https://lore.kernel.org/linux-gpio/65d7918b358a5_1ee3129432@dwillia2-mobl3.amr.corp.intel.com.notmuch/
>
> Signed-off-by: Marek Behún <kabel@kernel.org>
> ---
> drivers/crypto/caam/ctrl.c | 16 +++--------
> drivers/gpio/gpio-mockup.c | 11 ++------
> drivers/gpu/drm/bridge/ti-sn65dsi86.c | 13 ++-------
> drivers/hwmon/hp-wmi-sensors.c | 15 ++--------
> drivers/hwmon/mr75203.c | 15 ++++------
> drivers/hwmon/pmbus/pmbus_core.c | 16 ++++-------
> include/linux/devm-helpers.h | 40 +++++++++++++++++++++++++++
> 7 files changed, 61 insertions(+), 65 deletions(-)
...
> diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
> index 455eecf6380e..adbe0fe09490 100644
> --- a/drivers/gpio/gpio-mockup.c
> +++ b/drivers/gpio/gpio-mockup.c
> @@ -12,6 +12,7 @@
> #include <linux/cleanup.h>
> #include <linux/debugfs.h>
> #include <linux/device.h>
> +#include <linux/devm-helpers.h>
> #include <linux/gpio/driver.h>
> #include <linux/interrupt.h>
> #include <linux/irq.h>
> @@ -390,13 +391,6 @@ static void gpio_mockup_debugfs_setup(struct device *dev,
> }
> }
>
> -static void gpio_mockup_debugfs_cleanup(void *data)
> -{
> - struct gpio_mockup_chip *chip = data;
> -
> - debugfs_remove_recursive(chip->dbg_dir);
> -}
> -
> static void gpio_mockup_dispose_mappings(void *data)
> {
> struct gpio_mockup_chip *chip = data;
> @@ -480,7 +474,8 @@ static int gpio_mockup_probe(struct platform_device *pdev)
>
> gpio_mockup_debugfs_setup(dev, chip);
>
> - return devm_add_action_or_reset(dev, gpio_mockup_debugfs_cleanup, chip);
> + return devm_add_action_or_reset(dev, devm_debugfs_dir_recursive_drop,
> + chip->dbg_dir);
This look strange. Shouldn't the debugfs_create_dir() call in
gpio_mockup_debugfs_setup() be changed, instead?
(I've not look in the previous version if something was said about it,
so apologies if already discussed)
> }
>
> static const struct of_device_id gpio_mockup_of_match[] = {
...
> diff --git a/drivers/hwmon/mr75203.c b/drivers/hwmon/mr75203.c
> index 50a8b9c3f94d..50f348fca108 100644
> --- a/drivers/hwmon/mr75203.c
> +++ b/drivers/hwmon/mr75203.c
> @@ -10,6 +10,7 @@
> #include <linux/bits.h>
> #include <linux/clk.h>
> #include <linux/debugfs.h>
> +#include <linux/devm-helpers.h>
> #include <linux/hwmon.h>
> #include <linux/kstrtox.h>
> #include <linux/module.h>
> @@ -216,17 +217,11 @@ static const struct file_operations pvt_ts_coeff_j_fops = {
> .llseek = default_llseek,
> };
>
> -static void devm_pvt_ts_dbgfs_remove(void *data)
> -{
> - struct pvt_device *pvt = (struct pvt_device *)data;
> -
> - debugfs_remove_recursive(pvt->dbgfs_dir);
> - pvt->dbgfs_dir = NULL;
> -}
> -
> static int pvt_ts_dbgfs_create(struct pvt_device *pvt, struct device *dev)
> {
> - pvt->dbgfs_dir = debugfs_create_dir(dev_name(dev), NULL);
> + pvt->dbgfs_dir = devm_debugfs_create_dir(dev, dev_name(dev), NULL);
> + if (IS_ERR(pvt->dbgfs_dir))
> + return PTR_ERR(pvt->dbgfs_dir);
Not sure if the test and error handling should be added here.
*If I'm correct*, functions related to debugfs already handle this case
and just do nothing. And failure in debugfs related code is not
considered as something that need to be reported and abort a probe function.
Maybe the same other (already existing) tests in this patch should be
removed as well, in a separated patch.
just my 2c
CJ
>
> debugfs_create_u32("ts_coeff_h", 0644, pvt->dbgfs_dir,
> &pvt->ts_coeff.h);
> @@ -237,7 +232,7 @@ static int pvt_ts_dbgfs_create(struct pvt_device *pvt, struct device *dev)
> debugfs_create_file("ts_coeff_j", 0644, pvt->dbgfs_dir, pvt,
> &pvt_ts_coeff_j_fops);
>
> - return devm_add_action_or_reset(dev, devm_pvt_ts_dbgfs_remove, pvt);
> + return 0;
> }
...
next prev parent reply other threads:[~2024-03-23 21:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-23 16:43 [PATCH v5 00/11] Turris Omnia MCU driver Marek Behún
2024-03-23 16:43 ` [PATCH v5 02/11] platform: cznic: Add preliminary support for Turris Omnia MCU Marek Behún
2024-03-24 11:01 ` Andy Shevchenko
2024-03-24 15:04 ` Marek Behún
2024-03-24 15:30 ` Andy Shevchenko
2024-03-25 10:39 ` Marek Behún
2024-04-02 16:41 ` Marek Behún
2024-03-23 16:43 ` [PATCH v5 03/11] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs Marek Behún
2024-03-25 9:10 ` Matti Vaittinen
2024-03-25 9:53 ` Marek Behún
2024-03-25 10:25 ` Matti Vaittinen
2024-04-02 9:59 ` Dan Carpenter
2024-03-23 16:43 ` [PATCH v5 08/11] devm-helpers: Add resource managed version of debugfs directory create function Marek Behún
2024-03-23 17:21 ` Guenter Roeck
[not found] ` <20240323164359.21642-9-kabel__6885.49310886941$1711212291$gmane$org@kernel.org>
2024-03-23 21:10 ` Christophe JAILLET [this message]
2024-03-23 21:25 ` Marek Behún
2024-03-24 9:21 ` Christophe JAILLET
2024-03-24 15:08 ` Marek Behún
2024-03-25 11:05 ` Dan Carpenter
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=f7c64a5a-2abc-4b7e-95db-7ca57b5427c0@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=Jonathan.Cameron@huawei.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=arm@kernel.org \
--cc=arnd@arndb.de \
--cc=bamv2005@gmail.com \
--cc=brgl@bgdev.pl \
--cc=daniel@ffwll.ch \
--cc=davem@davemloft.net \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=eajames@linux.ibm.com \
--cc=gaurav.jain@nxp.com \
--cc=gregory.clement@bootlin.com \
--cc=hdegoede@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=horia.geanta@nxp.com \
--cc=james.clark@arm.com \
--cc=james@equiv.tech \
--cc=jdelvare@suse.com \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=kabel@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mazziesaccount@gmail.com \
--cc=mripard@kernel.org \
--cc=naresh.solanki@9elements.com \
--cc=neil.armstrong@linaro.org \
--cc=pankaj.gupta@nxp.com \
--cc=patrick.rudolph@9elements.com \
--cc=rfoss@kernel.org \
--cc=soc@kernel.org \
--cc=tzimmermann@suse.de \
/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).