Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp405952rdb; Thu, 22 Feb 2024 07:23:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVKsnQPl1munY2dTwLAF8nvdg9dIxQ4OyD/VHeDduUO4M0g3Tjqc3HnxOMHZqq/qrbZWysxDl9ISXS89786UsWPCIu7N/4b3R/Og2+FCg== X-Google-Smtp-Source: AGHT+IGHGZYEJcunllrgPt/KQL02gdNZHe4sHqAg8AGoHXfl2TzxNT/v310qvn3WNiHbVR4oyWyQ X-Received: by 2002:a17:906:5f90:b0:a3e:526b:1bc2 with SMTP id a16-20020a1709065f9000b00a3e526b1bc2mr7616504eju.40.1708615403706; Thu, 22 Feb 2024 07:23:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708615403; cv=pass; d=google.com; s=arc-20160816; b=P8YzH9CmInqMHvLrzBNPZblvrLYk5e5Aqc1532yV6npF4ZVvesrURU1N6sIpArDOIP Rqgf/rgJiRZS9nXDaaBUaMmYqp8+Ksye++7RGvepKME9Gvu+IVquEwadnBkHTVEX/Zve tWlf92KmyplYJt6G217TmsXaKxrgllYpFVzgvoNmk2XX9kp7oSTXvY9A13QgUfNIKFs0 MVp7R4xZdf8GYqllw1MCMJg21HXxuAscm7ssMNZv8I0XTf3FW/n/wWo3kcWnFtYy5N+G wwHbiD+FhLeOUEWeO6hhbc8ePQynPPuT8+o8BRJSTGvK/4CkShGfVsGxTPkzpAyxL3+E MT5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :sender:dkim-signature; bh=18aJgkLrhUb7en6e+9IVDc7Sm8XASVYQ/8bIVIOkYlw=; fh=rO2AVMyQbe8Gy86WA7IxIvMXmD2UG65VV6YiGguxv/c=; b=hB3LD5iOLepqfmgnQykqqLHPmfON3aPvDFM0OLeXoy/rZfqguQVEK6UtJi/fdR3Bb0 KqFT9BILx5BCdAT47nw6MLaEHv3kIA+QU09NjWnpkS1/DjOHMiONIcxxYGTzf8wlOhwH Z413nRWY6QJJVAlaVQP/P8kTiPw5QPqIpbH49gey0c8Sejk62gReE/ACb1LcI41MW3QT NbVPBb2Z6WfgiqbvLpNMVKWr3tWBCG+ebPv/69ia5S80OwVUjPw+mrXqSVwklmxe2Yoj aTgRLULr1ceDaDc/FCbzlZMW3um5AiPxKwN8W+NCjRwnGG6EJrklGBMf/eXWM5PWtyj+ 0MXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=J9NSiHAY; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-crypto+bounces-2255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2255-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hr13-20020a1709073f8d00b00a3e5f4e8053si4638503ejc.674.2024.02.22.07.23.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 07:23:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=J9NSiHAY; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-crypto+bounces-2255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2255-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 412D21F260F4 for ; Thu, 22 Feb 2024 15:23:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 121E414D43A; Thu, 22 Feb 2024 15:23:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J9NSiHAY" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AA3B14C5AF; Thu, 22 Feb 2024 15:23:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708615395; cv=none; b=B3/dQym++IkhRaVYap6WAvNNx2D3A2sgIVb+FJ1ArFpQu6sYp8pt+dDwt+Q2+6cYBqeLBTX71U+6F9jfZOw2oUQgZZUnmXR9MGFnXTws1O6S63QhawbBdbSHgMuLG1sneus5ZbScQW8MdK2z4wPtroYzXJfWB8DNqs0P0YxYBZ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708615395; c=relaxed/simple; bh=+ZN8UG6yOE1/Kkd3lW/LjDTmZSDVEFOJ3z0ODzVRDng=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=D8kEG1FHYu+TyTn3BsWv7SWTu3dEyj7pVoSPE76dmqHRu6Me7HYYlAZjeboap6X26CEFMtOflpx7uvIB5N8bOSsSUU2C89wjAYNgobUsJIt1xxn6r3A0TM+IaoHMfrGiUqh4IzDyxVioPnpldrZwq1FdLIJNOe2fyeH0fk23Y1A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=J9NSiHAY; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6e45bd5014dso2192782b3a.1; Thu, 22 Feb 2024 07:23:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708615392; x=1709220192; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=18aJgkLrhUb7en6e+9IVDc7Sm8XASVYQ/8bIVIOkYlw=; b=J9NSiHAYWpjTK04Xn4Yq3CFxhJXY2TDEjpwNGVVGbc4ii28EFf19vT6quM+YNrzhIp LNvdxfEBpVuk3LyIYJIDq0cTH7PpYTsC/IqYMgMVKEOU07UiY1VEM0h7NHXrbpsqkM22 sXmvoJij4zaXQ7WscmlnJbaDBspHG8EbAtwj712xqC36wPOkPhp+9dz+yuRX3oHvuAT7 IYkfz8n/uviREwVnbkSPBy3aoZPhYxVFKC8vfDBdF8dF+fG/d+y0Yosj9saBxXoJdSMU TkjDhp39EsKTJYJXrbW0aRvrHlYlmZPqiQXZe7QsnUTM45M5kypr+N7l5oneTiHT1U9w gskQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708615392; x=1709220192; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=18aJgkLrhUb7en6e+9IVDc7Sm8XASVYQ/8bIVIOkYlw=; b=PTyKoDjQbRBZgAdkxKs3Dh/RH5t1ggI/8kC1Wxfy+m0bDv2VlpGrQrcf7QsE1sCcP9 A5xq+8YYLqgxQDR+hKvQv9QcViWDwE7t8vjPXUDKCS8Bvh/IvSX2ZNyl6mITshUT+CXy 2v83rkmsNjEnkOkdEyBZnHX6OjD2i6J9S4Zvw9cHK4u7BDIwyJsRR1C5ZidB23EENM49 K675wNJrYjF/VQtLPZ3x2O5GzFf94g8+EegVt89sRm25wFOP28O+Mq3wJbE9foMoNZ54 EZvOAMBTueEsv4g27p5YKv3ef4+ZGMaIsiOSZG48K/6fr3LNQRkpmXcZ+d3ciQ/Fs6zQ +WwQ== X-Forwarded-Encrypted: i=1; AJvYcCXMVEeD2H3AkzR+W2MMqxiDKFc+mcFGIl51uQI+BLCxZ3toOdEbTP9dCUgV0RLLZHQpnfe5lw79aFJkv3lffYqr2jJUF0hbZFKq0oOSQAcqYXKP+n6CzQKsoW7pDCOcqNP0RW5ELzRehrFM3y+Yqo0DeKamFzyIyyo76fKAFb6yu0SZ+ILDYZROVqwKzY+leLqBL4GoizwfkJPWdyiVXCZyuR/36Ok4ZQ6kj7a9PH5kZuqVbjd+fYSMkfn6iU+z X-Gm-Message-State: AOJu0YwCzoV9cbuJ9t0vuexRX1JRkhNz5W3rx91I8ufFGCGKqlmycEzK OLm+S6KD44dcgdg3h6Jj5lg/CUztlM5fuEBHX5y6Q+gcXuB/dS9R X-Received: by 2002:aa7:91d1:0:b0:6e0:4e7e:ef57 with SMTP id z17-20020aa791d1000000b006e04e7eef57mr19247160pfa.32.1708615392201; Thu, 22 Feb 2024 07:23:12 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b2-20020aa78ec2000000b006e4d2cbcac8sm998069pfr.94.2024.02.22.07.23.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Feb 2024 07:23:11 -0800 (PST) Sender: Guenter Roeck Message-ID: Date: Thu, 22 Feb 2024 07:23:08 -0800 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] devm-helpers: Add resource managed version of debugfs directory create function Content-Language: en-US To: =?UTF-8?Q?Marek_Beh=C3=BAn?= , linux-kernel@vger.kernel.org, Hans de Goede , Matti Vaittinen Cc: =?UTF-8?Q?Horia_Geant=C4=83?= , Pankaj Gupta , Gaurav Jain , Herbert Xu , "David S. Miller" , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Bamvor Jian Zhang , Linus Walleij , Bartosz Golaszewski , Douglas Anderson , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , James Seo , Jean Delvare , linux-crypto@vger.kernel.org, linux-cxl@vger.kernel.org, linux-gpio@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-hwmon@vger.kernel.org References: <20240222145838.12916-1-kabel@kernel.org> <20240222145838.12916-2-kabel@kernel.org> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ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4ZY/6C9tTcUv/KNAE5leyrD4IKbnV4PnbrVhjq861it/zRQW cFpWQszZyWRwNPWUUz7ejmm9lAwPbr8xWT4qMSA43VKQ7ZCeTQJ4TC8kjqtcbw41SjkjrcTG wF52zFO4bOWyovVAPncvV9eGA/vtnd3xEZXQiSt91kBSqK28yjxAqK/c3G6i7IX2rg6pzgqh hiH3/1qM2M/LSuqAv0Rwrt/k+pZXE+B4Ud42hwmMr0TfhNxG+X7YKvjKC+SjPjqp0CaztQ0H nsDLSLElVROxCd9m8CAUuHplgmR3seYCOrT4jriMFBtKNPtj2EE4DNV4s7k0Zy+6iRQ8G8ng QjsSqYJx8iAR8JRB7Gm2rQOMv8lSRdjva++GT0VLXtHULdlzg8VjDnFZ3lfz5PWEOeIMk7Rj trjv82EZtrhLuLjHRCaG50OOm0hwPSk1J64R8O3HjSLdertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: <20240222145838.12916-2-kabel@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2/22/24 06:58, Marek BehĂșn wrote: > 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 > drivers > drivers/cxl/mem.c > drivers/gpio/gpio-mockup.c > > Signed-off-by: Marek BehĂșn > --- > drivers/crypto/caam/ctrl.c | 16 +++------ > drivers/cxl/mem.c | 9 ++--- > 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 | 48 +++++++++++++++++++++++++++ > 8 files changed, 72 insertions(+), 71 deletions(-) > > diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c > index bdf367f3f679..ea3ed9a17f1a 100644 > --- a/drivers/crypto/caam/ctrl.c > +++ b/drivers/crypto/caam/ctrl.c > @@ -7,6 +7,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -604,11 +605,6 @@ static int init_clocks(struct device *dev, const struct caam_imx_data *data) > return devm_add_action_or_reset(dev, disable_clocks, ctrlpriv); > } > > -static void caam_remove_debugfs(void *root) > -{ > - debugfs_remove_recursive(root); > -} > - > #ifdef CONFIG_FSL_MC_BUS > static bool check_version(struct fsl_mc_version *mc_version, u32 major, > u32 minor, u32 revision) > @@ -1058,13 +1054,9 @@ static int caam_probe(struct platform_device *pdev) > ctrlpriv->era = caam_get_era(perfmon); > ctrlpriv->domain = iommu_get_domain_for_dev(dev); > > - dfs_root = debugfs_create_dir(dev_name(dev), NULL); > - if (IS_ENABLED(CONFIG_DEBUG_FS)) { > - ret = devm_add_action_or_reset(dev, caam_remove_debugfs, > - dfs_root); > - if (ret) > - return ret; > - } > + dfs_root = devm_debugfs_create_dir(dev, dev_name(dev), NULL); > + if (IS_ERR(dfs_root)) > + return PTR_ERR(dfs_root); > > caam_debugfs_init(ctrlpriv, perfmon, dfs_root); > > diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c > index c5c9d8e0d88d..4b38514887a4 100644 > --- a/drivers/cxl/mem.c > +++ b/drivers/cxl/mem.c > @@ -2,6 +2,7 @@ > /* Copyright(c) 2022 Intel Corporation. All rights reserved. */ > #include > #include > +#include > #include > #include > > @@ -30,11 +31,6 @@ static void enable_suspend(void *data) > cxl_mem_active_dec(); > } > > -static void remove_debugfs(void *dentry) > -{ > - debugfs_remove_recursive(dentry); > -} > - > static int cxl_mem_dpa_show(struct seq_file *file, void *data) > { > struct device *dev = file->private; > @@ -138,7 +134,8 @@ static int cxl_mem_probe(struct device *dev) > debugfs_create_file("clear_poison", 0200, dentry, cxlmd, > &cxl_poison_clear_fops); > > - rc = devm_add_action_or_reset(dev, remove_debugfs, dentry); > + rc = devm_add_action_or_reset(dev, devm_debugfs_dir_recursive_drop, > + dentry); > if (rc) > return rc; > > 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 > #include > #include > +#include > #include > #include > #include > @@ -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); > } > > static const struct of_device_id gpio_mockup_of_match[] = { > diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > index 62cc3893dca5..ad0ed2459394 100644 > --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c > +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -427,18 +428,12 @@ static int status_show(struct seq_file *s, void *data) > > DEFINE_SHOW_ATTRIBUTE(status); > > -static void ti_sn65dsi86_debugfs_remove(void *data) > -{ > - debugfs_remove_recursive(data); > -} > - > static void ti_sn65dsi86_debugfs_init(struct ti_sn65dsi86 *pdata) > { > struct device *dev = pdata->dev; > struct dentry *debugfs; > - int ret; > > - debugfs = debugfs_create_dir(dev_name(dev), NULL); > + debugfs = devm_debugfs_create_dir(dev, dev_name(dev), NULL); > > /* > * We might get an error back if debugfs wasn't enabled in the kernel > @@ -447,10 +442,6 @@ static void ti_sn65dsi86_debugfs_init(struct ti_sn65dsi86 *pdata) > if (IS_ERR_OR_NULL(debugfs)) > return; > > - ret = devm_add_action_or_reset(dev, ti_sn65dsi86_debugfs_remove, debugfs); > - if (ret) > - return; > - > debugfs_create_file("status", 0600, debugfs, pdata, &status_fops); > } > > diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c > index b5325d0e72b9..2a7c33763ce8 100644 > --- a/drivers/hwmon/hp-wmi-sensors.c > +++ b/drivers/hwmon/hp-wmi-sensors.c > @@ -23,6 +23,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -1304,12 +1305,6 @@ static int current_reading_show(struct seq_file *seqf, void *ignored) > } > DEFINE_SHOW_ATTRIBUTE(current_reading); > > -/* hp_wmi_devm_debugfs_remove - devm callback for debugfs cleanup */ > -static void hp_wmi_devm_debugfs_remove(void *res) > -{ > - debugfs_remove_recursive(res); > -} > - > /* hp_wmi_debugfs_init - create and populate debugfs directory tree */ > static void hp_wmi_debugfs_init(struct device *dev, struct hp_wmi_info *info, > struct hp_wmi_platform_events *pevents, > @@ -1320,21 +1315,15 @@ static void hp_wmi_debugfs_init(struct device *dev, struct hp_wmi_info *info, > struct dentry *debugfs; > struct dentry *entries; > struct dentry *dir; > - int err; > u8 i; > > /* dev_name() gives a not-very-friendly GUID for WMI devices. */ > scnprintf(buf, sizeof(buf), "hp-wmi-sensors-%u", dev->id); > > - debugfs = debugfs_create_dir(buf, NULL); > + debugfs = devm_debugfs_create_dir(dev, buf, NULL); > if (IS_ERR(debugfs)) > return; > > - err = devm_add_action_or_reset(dev, hp_wmi_devm_debugfs_remove, > - debugfs); > - if (err) > - return; > - > entries = debugfs_create_dir("sensor", debugfs); > > for (i = 0; i < icount; i++, info++) { > 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 > #include > #include > +#include > #include > #include > #include > @@ -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); > > 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; > } > > static umode_t pvt_is_visible(const void *data, enum hwmon_sensor_types type, > diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c > index 1363d9f89181..e0f956a21125 100644 > --- a/drivers/hwmon/pmbus/pmbus_core.c > +++ b/drivers/hwmon/pmbus/pmbus_core.c > @@ -7,6 +7,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -3336,13 +3337,6 @@ static const struct file_operations pmbus_debugfs_ops_mfr = { > .open = simple_open, > }; > > -static void pmbus_remove_debugfs(void *data) > -{ > - struct dentry *entry = data; > - > - debugfs_remove_recursive(entry); > -} > - > static int pmbus_init_debugfs(struct i2c_client *client, > struct pmbus_data *data) > { > @@ -3357,8 +3351,9 @@ static int pmbus_init_debugfs(struct i2c_client *client, > * Create the debugfs directory for this device. Use the hwmon device > * name to avoid conflicts (hwmon numbers are globally unique). > */ > - data->debugfs = debugfs_create_dir(dev_name(data->hwmon_dev), > - pmbus_debugfs_dir); > + data->debugfs = devm_debugfs_create_dir(data->dev, > + dev_name(data->hwmon_dev), > + pmbus_debugfs_dir); > if (IS_ERR_OR_NULL(data->debugfs)) { > data->debugfs = NULL; > return -ENODEV; > @@ -3542,8 +3537,7 @@ static int pmbus_init_debugfs(struct i2c_client *client, > } > } > > - return devm_add_action_or_reset(data->dev, > - pmbus_remove_debugfs, data->debugfs); > + return 0; > } > #else > static int pmbus_init_debugfs(struct i2c_client *client, > diff --git a/include/linux/devm-helpers.h b/include/linux/devm-helpers.h > index 70640fb96117..39d743175ec4 100644 > --- a/include/linux/devm-helpers.h > +++ b/include/linux/devm-helpers.h > @@ -23,6 +23,7 @@ > * already ran. > */ > > +#include > #include > #include > #include > @@ -108,4 +109,51 @@ static inline int devm_mutex_init(struct device *dev, struct mutex *lock) > return 0; > } > > +static inline void devm_debugfs_dir_recursive_drop(void *res) > +{ > + debugfs_remove_recursive(res); > +} > + > +/** > + * devm_debugfs_create_dir - Resource managed debugfs directory creation > + * @dev: Device which lifetime the directory is bound to > + * @name: a pointer to a string containing the name of the directory to > + * create > + * @parent: a pointer to the parent dentry for this file. This should be a > + * directory dentry if set. If this parameter is NULL, then the > + * directory will be created in the root of the debugfs filesystem. > + * > + * Create a debugfs directory which is automatically recursively removed when > + * the driver is detached. A few drivers create debugfs directories which they > + * want removed before driver is detached. > + * devm_debugfs_create_dir() can be used to omit the explicit > + * debugfs_remove_recursive() call when driver is detached. > + */ > +static inline struct dentry * > +devm_debugfs_create_dir(struct device *dev, const char *name, > + struct dentry *parent) > +{ > + struct dentry *dentry; > + > + dentry = debugfs_create_dir(name, parent); > + if (IS_ERR(dentry)) > + return dentry; > + > + /* > + * debugfs_remove_recursive() is an empty function if CONFIG_DEBUG_FS is > + * disabled. No need to register an action in that case. > + */ > + if (IS_ENABLED(CONFIG_DEBUG_FS)) { This conditional seems unnecessary since in that case debugfs_create_dir() would return -ENODEV, and the code below would never be executed to start with. Guenter > + int err; > + > + err = devm_add_action_or_reset(dev, > + devm_debugfs_dir_recursive_drop, > + dentry); > + if (err < 0) > + return ERR_PTR(err); > + } > + > + return dentry; > +} > + > #endif