From patchwork Tue May 23 15:03:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 98049 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp2210033rwl; Tue, 23 May 2023 08:27:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7gohISL2AVLM2BtRmRfv5OeCxKNMvuoa4ENcOageWy04XWtwPByhP42QD7v3p9QrAAC3ne X-Received: by 2002:a17:90a:cb92:b0:253:727d:aa5e with SMTP id a18-20020a17090acb9200b00253727daa5emr15499375pju.8.1684855673475; Tue, 23 May 2023 08:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684855673; cv=none; d=google.com; s=arc-20160816; b=UmVnde2EzJDAZ6CMaEFd+hHYzSknCD3oUcm1scvabA6W6gxG715e8QDTm8aFoAjV7o /YDIDjwWOCiN54FtjV1cTHkEdMmpVCF1WO00knZf7gGlMSybREyZqHXasgXxTCh2C5tC uXeCPrzs+1eiCQv3WMSxy7NzB/4kgbHLXs4bUYK2lzhfrgPRMlGMVaNytoFVGschMvrt BMciMJmsgBLbeLffjnoqx3Rati7aOayw76HTdVe8J82OJLvQ2sGdCPjEegMoVDUK/ib2 wP8UCBDXF0VjKNRgboV36r7GYFsG4v15T8Y6r642dBtdeuPo2Xj+GvudzS54Biq+cqOr rUng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ketX1JHvWJ8iWVstsZOlpVtHlmvff/G8PEZrKTqtIM8=; b=Pn/Z8GPkeQDtFfugQPLVy8rayq898duaSeu8UaFjZdN11m8a/PRUMRxVuDiGtZl1Lf oIns2AgWBDDxBwQquWTPxcXr8RrwaUJ+sQJsL5xsIFOmYHWo20T9FAmTOTI7rtvC7ViF XYkkfMyEdRxE4ZBJpJpc/ZOo+9L+E5JTTEAO2wBS4ZKKEG8NGZzH7m0LU2meA2lMbxzd dW4CX9/2G5CTH5XxBk3rMK3tKk7pCCGyDwrS3SaNBuBJvZFZje03817T161eBQu9v3Rp JUb/oeOhYUdKA+vOOoup71AjhqrGL8qw03hJj0lIo1laKb5+iMQDQvtLgrRd74G4gOZk aJ1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a17090ab90c00b002528c249b09si6398307pjr.97.2023.05.23.08.27.38; Tue, 23 May 2023 08:27:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237460AbjEWPMu (ORCPT + 99 others); Tue, 23 May 2023 11:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236851AbjEWPMo (ORCPT ); Tue, 23 May 2023 11:12:44 -0400 X-Greylist: delayed 445 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 23 May 2023 08:12:39 PDT Received: from riemann.telenet-ops.be (riemann.telenet-ops.be [IPv6:2a02:1800:110:4::f00:10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3CDD126 for ; Tue, 23 May 2023 08:12:39 -0700 (PDT) Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by riemann.telenet-ops.be (Postfix) with ESMTPS id 4QQd0K01dtz4x7JT for ; Tue, 23 May 2023 17:05:05 +0200 (CEST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed30:b0ac:7afd:272:4cff]) by michel.telenet-ops.be with bizsmtp id 0F442A0010Jkz7G06F44Lr; Tue, 23 May 2023 17:04:04 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1q1TYD-002svD-FI; Tue, 23 May 2023 17:04:04 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1q1TYR-00CkB7-SM; Tue, 23 May 2023 17:04:03 +0200 From: Geert Uytterhoeven To: Liam Girdwood , Mark Brown , Osama Muhammad Cc: linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] regulator: core: Streamline debugfs operations Date: Tue, 23 May 2023 17:03:58 +0200 Message-Id: <587f259fb8634daa268595f60fa52c3c4d9bbec2.1684854090.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766698660884940372?= X-GMAIL-MSGID: =?utf-8?q?1766699222743545143?= If CONFIG_DEBUG_FS is not set: regulator: Failed to create debugfs directory ... regulator-dummy: Failed to create debugfs directory As per the comments for debugfs_create_dir(), errors returned by this function should be expected, and ignored: * If debugfs is not enabled in the kernel, the value -%ENODEV will be * returned. * * NOTE: it's expected that most callers should _ignore_ the errors returned * by this function. Other debugfs functions handle the fact that the "dentry" * passed to them could be an error and they don't crash in that case. * Drivers should generally work fine even if debugfs fails to init anyway. Afhere to the debugfs spirit, and streamline all operations by: 1. Demoting the importance of the printed error messages to debug level, like is already done in create_regulator(), 2. Further ignoring any returned errors. Fix the error check on the return value of debugfs_create_dir() in create_regulator(), which was missed before. Fixes: 2bf1c45be3b8f3a3 ("regulator: Fix error checking for debugfs_create_dir") Signed-off-by: Geert Uytterhoeven --- drivers/regulator/core.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 698ab7f5004bf6b7..d8e1caaf207e108f 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1911,19 +1911,17 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, if (err != -EEXIST) regulator->debugfs = debugfs_create_dir(supply_name, rdev->debugfs); - if (!regulator->debugfs) { + if (IS_ERR(regulator->debugfs)) rdev_dbg(rdev, "Failed to create debugfs directory\n"); - } else { - debugfs_create_u32("uA_load", 0444, regulator->debugfs, - ®ulator->uA_load); - debugfs_create_u32("min_uV", 0444, regulator->debugfs, - ®ulator->voltage[PM_SUSPEND_ON].min_uV); - debugfs_create_u32("max_uV", 0444, regulator->debugfs, - ®ulator->voltage[PM_SUSPEND_ON].max_uV); - debugfs_create_file("constraint_flags", 0444, - regulator->debugfs, regulator, - &constraint_flags_fops); - } + + debugfs_create_u32("uA_load", 0444, regulator->debugfs, + ®ulator->uA_load); + debugfs_create_u32("min_uV", 0444, regulator->debugfs, + ®ulator->voltage[PM_SUSPEND_ON].min_uV); + debugfs_create_u32("max_uV", 0444, regulator->debugfs, + ®ulator->voltage[PM_SUSPEND_ON].max_uV); + debugfs_create_file("constraint_flags", 0444, regulator->debugfs, + regulator, &constraint_flags_fops); /* * Check now if the regulator is an always on regulator - if @@ -5256,10 +5254,8 @@ static void rdev_init_debugfs(struct regulator_dev *rdev) } rdev->debugfs = debugfs_create_dir(rname, debugfs_root); - if (IS_ERR(rdev->debugfs)) { - rdev_warn(rdev, "Failed to create debugfs directory\n"); - return; - } + if (IS_ERR(rdev->debugfs)) + rdev_dbg(rdev, "Failed to create debugfs directory\n"); debugfs_create_u32("use_count", 0444, rdev->debugfs, &rdev->use_count); @@ -6179,7 +6175,7 @@ static int __init regulator_init(void) debugfs_root = debugfs_create_dir("regulator", NULL); if (IS_ERR(debugfs_root)) - pr_warn("regulator: Failed to create debugfs directory\n"); + pr_debug("regulator: Failed to create debugfs directory\n"); #ifdef CONFIG_DEBUG_FS debugfs_create_file("supply_map", 0444, debugfs_root, NULL,