From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A12F61E22F8; Fri, 6 Dec 2024 11:40:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733485247; cv=none; b=mSb3PzvUU3koVyUwkWqHnkl1vrRotZL8YmxThzhv7whjiBygP1SCNcn3plFhAEpYgMCT+a8Vic5Z2nFb3zZC6310iXlLSv0404gj7QNYmi4eHdVaCldzKlyijNEq+rGTkNWARnkWQdzf3AwDvogkggp5PhzgjAj2EMdv59nqtLs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733485247; c=relaxed/simple; bh=a5F2IsKDMl3Xo6j388UGnyU7LL1X131/hHGqQPu5ns4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Hfjwz1W8Yk5hlsAt9+Nq+Iep7eSSWMzFrGaMIblPWKHWIYnOCNAhVHIfINucdxdo46ogl5RPN9+eWpl1eXwe+ID4bU7/gWGGcwMmwp5K6wFc5a9QWmAQdOOaopa+ZD62k8S4utP6TwSOqvLS3Cupk6E981aWWVVO8dN61shDNnM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nVD5ExKh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nVD5ExKh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FF6DC4CED1; Fri, 6 Dec 2024 11:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733485247; bh=a5F2IsKDMl3Xo6j388UGnyU7LL1X131/hHGqQPu5ns4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nVD5ExKhhIM/8/ltOrTNlW0OSbomHuDK1iZoB7/CZ5kuaS2SVVHznX/0jS4rCpqAf Ij2KZ/2c+aptMyPK9nQjMmAhNOHotpRKrhivF+MClwppxnU2pVqML8CiIz+VZrCh6c OABdSdLm+mVFgxupIfJoq9lF4eyTfOKF0B/4nhNA= Date: Fri, 6 Dec 2024 12:40:43 +0100 From: Greg KH To: Jijie Shao Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, shenjian15@huawei.com, wangpeiyang1@huawei.com, liuyonglong@huawei.com, chenhao418@huawei.com, sudongming1@huawei.com, xujunsheng@huawei.com, shiyongbang@huawei.com, libaihan@huawei.com, jonathan.cameron@huawei.com, shameerali.kolothum.thodi@huawei.com, salil.mehta@huawei.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, hkelam@marvell.com Subject: Re: [PATCH V5 net-next 1/8] debugfs: Add debugfs_create_devm_dir() helper Message-ID: <2024120627-smudge-obsolete-efb6@gregkh> References: <20241206111629.3521865-1-shaojijie@huawei.com> <20241206111629.3521865-2-shaojijie@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241206111629.3521865-2-shaojijie@huawei.com> On Fri, Dec 06, 2024 at 07:16:22PM +0800, Jijie Shao wrote: > Add debugfs_create_devm_dir() helper > > Signed-off-by: Jijie Shao > --- > fs/debugfs/inode.c | 36 ++++++++++++++++++++++++++++++++++++ > include/linux/debugfs.h | 10 ++++++++++ > 2 files changed, 46 insertions(+) > > diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c > index 38a9c7eb97e6..f682c4952a27 100644 > --- a/fs/debugfs/inode.c > +++ b/fs/debugfs/inode.c > @@ -610,6 +610,42 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) > } > EXPORT_SYMBOL_GPL(debugfs_create_dir); > > +static void debugfs_remove_devm(void *dentry_rwa) > +{ > + struct dentry *dentry = dentry_rwa; > + > + debugfs_remove(dentry); > +} > + > +/** > + * debugfs_create_devm_dir - Managed debugfs_create_dir() > + * @dev: Device that owns the action > + * @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. > + * Managed debugfs_create_dir(). dentry will automatically be remove on > + * driver detach. > + */ > +struct dentry *debugfs_create_devm_dir(struct device *dev, const char *name, > + struct dentry *parent) > +{ > + struct dentry *dentry; > + int ret; > + > + dentry = debugfs_create_dir(name, parent); > + if (IS_ERR(dentry)) > + return dentry; > + > + ret = devm_add_action_or_reset(dev, debugfs_remove_devm, dentry); > + if (ret) > + ERR_PTR(ret); You don't clean up the directory you created if this failed? Why not? thanks, greg k-h