From patchwork Wed May 24 12:22:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 98465 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2811773vqo; Wed, 24 May 2023 05:34:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7G4NuXKtaFH1VxwiGu/3XoLKDOAto4QQAvTmebvgHzf+RXa/a6HXBU9YaoFw9cxIyTeGvQ X-Received: by 2002:a05:6a20:3d0e:b0:10b:96be:ca35 with SMTP id y14-20020a056a203d0e00b0010b96beca35mr10988005pzi.28.1684931644098; Wed, 24 May 2023 05:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684931644; cv=none; d=google.com; s=arc-20160816; b=xBH6jAkqCbqgO4shUuNNSSa6vsnokduL3jaU7kqLnmTzoPvEwtW+MbVF8sANjxIl3v H04EbBvish40FHyV0HhDCfjixo6lPSomo6znW6lkQwwkPNbK65QTBiYAYB7DrB0nwBSt YRe5c1YVs1x3WEkwU7nkb8RuvXs84L9B6RvY82HOqoNqtmGBV5OJaRVImoWtixRGv3rA aGMOtJvL0mnLQin3Z9OIg1jbeVRn3UnUA49Z6dK/U02SgzA5IeYul2u8n85VBCUzJ7Q7 l+T6PC5bQIz0JoL7EMK6HRhEcpbhX9BkJX134ZTa7leFqN/qAi5nuMzGgj+2fCr0B1ee ljRQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PCizjfO687RH0Ch+ggLJGGH34Zydf++kdVhgZ0USbvg=; b=RvtVTJ3ko4Z1mbfw8YCBZM4bshYcitXAIObFMQSPdqNVxlV/tBcwwxqJ96SopTnm7Q tZv/seooq288iFPiKMmqynqjNLJoD+IIDLL0JoIQSr1RErxF573vUIevqdsgFQ8Dxt/X jzdObI6h4x2KIkGqdvrJqdrDBl9IR9JTvuBjI3c4OUDG3gG0h8khhRjzkc4ZNCvSVCLp r8F8G7jxYNeu225RHbp0rfkgtmL+ZgbxuSy4bWGcmrqX9falsCGxW/rR6nN3y3eIlthL RF58BLQu6iFK2eq16dNkb0jQhIghyqjRjrC1TeFoF+ShpDPGd9UMj9NjU9my6HZ6fo4+ K27Q== 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 e5-20020a636905000000b005132342a587si684038pgc.610.2023.05.24.05.33.50; Wed, 24 May 2023 05:34:04 -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 S232199AbjEXMWf (ORCPT + 99 others); Wed, 24 May 2023 08:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbjEXMW0 (ORCPT ); Wed, 24 May 2023 08:22:26 -0400 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6213F9E for ; Wed, 24 May 2023 05:22:22 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed30:59b9:3473:f0ae:e2b7]) by laurent.telenet-ops.be with bizsmtp id 0cNL2A00C5NiV2701cNLTe; Wed, 24 May 2023 14:22:20 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1q1nVF-002xw9-Aj; Wed, 24 May 2023 14:22:20 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1q1nVU-00DPCA-C7; Wed, 24 May 2023 14:22:20 +0200 From: Geert Uytterhoeven To: Liam Girdwood , Mark Brown , Osama Muhammad Cc: linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 1/2] regulator: core: Fix more error checking for debugfs_create_dir() Date: Wed, 24 May 2023 14:22:17 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1766778883587325569?= X-GMAIL-MSGID: =?utf-8?q?1766778883587325569?= In case of failure, debugfs_create_dir() does not return NULL, but an error pointer. Most incorrect error checks were fixed, but the one in create_regulator() was forgotten. Fix the remaining error check. Fixes: 2bf1c45be3b8f3a3 ("regulator: Fix error checking for debugfs_create_dir") Signed-off-by: Geert Uytterhoeven --- v2: - Split off from "regulator: core: Streamline debugfs operations". --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 698ab7f5004bf6b7..ad8baf65f63e369b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1911,7 +1911,7 @@ 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, From patchwork Wed May 24 12:22:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 98464 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2811686vqo; Wed, 24 May 2023 05:33:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70YReZtGUzryZiVV4ZX+0uDjlsphfxthB77MZhWKBqhIw23jnpY01cQnNk/CybmLaYO8uG X-Received: by 2002:a17:902:c153:b0:1ac:988e:2624 with SMTP id 19-20020a170902c15300b001ac988e2624mr18563147plj.37.1684931634867; Wed, 24 May 2023 05:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684931634; cv=none; d=google.com; s=arc-20160816; b=H1ZeqZfyTKQ/B4zILNp/3FB7fniMTGF+FF2b5539n208C3MfVral16ui8BAcwFJtno xLDOmjyQnAPLY6pcqdXH+i9NZ0Nu/zx4HeWmlQHRpY3+JXXAS88rVIrGgAGIK1AzdYE0 X6X3aIVQWT5/P0o3NL/hA0FRgXRDKzpqiea5cJQcOSWz2d9GNRpj+zDAOt1opuojg9ch VX66+tbEdN0PTyL9p7K1SQMswVnzOzx/k8KD6G1rOq2N3kE4JKhG7LpN5F4Xskf7LEFJ hfaFJUO567RznUvgkPW0OdGSb8zFnepOsJ57A1Iu15dh2yCry7CD56BZFDENJWUkC1bo 47Gg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=EcY95NLsBmt20gzmtvmcLeBW5nKrMn+U835ZIRS4SKU=; b=Bo+1ICegxmOfw3sx0cDWCU1VqzkG/JyJZmi3C+WT8CKmDUUqeGYB/stfwvPWiUBjYj w4ADCJ9FJoskyyEHz7Y7JoZPlWpPB2LB4a7wOvBcw882LzVM2p22wnuaAHOWwRIeVfDl ELjyQiNcJOCU71wKGaj9IpCH6h6HAdYRjz4jOoA5iJIKqDFsXe5SxObJgfi+Gy/7KHu8 /BtBUfgn+NQSMF/O28sr/aHMk++RSGvkhq1jVGLB0Ri4Y+uFO1gQ7QsEIKOWYh6UsG8U qqHeSMl4nLALotDmVmyHhUFSorpC73K4f9snMYu2q66L5VpbGHniBdg0WyDPycWpwvgj om5g== 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 e8-20020a170902744800b001a966042af8si7971125plt.341.2023.05.24.05.33.42; Wed, 24 May 2023 05:33:54 -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 S232790AbjEXMWa (ORCPT + 99 others); Wed, 24 May 2023 08:22:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbjEXMWZ (ORCPT ); Wed, 24 May 2023 08:22:25 -0400 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E56199 for ; Wed, 24 May 2023 05:22:22 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed30:59b9:3473:f0ae:e2b7]) by laurent.telenet-ops.be with bizsmtp id 0cNL2A00D5NiV2701cNLTf; Wed, 24 May 2023 14:22:20 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1q1nVF-002xwB-BN; Wed, 24 May 2023 14:22:20 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1q1nVU-00DPCD-Ci; Wed, 24 May 2023 14:22:20 +0200 From: Geert Uytterhoeven To: Liam Girdwood , Mark Brown , Osama Muhammad Cc: linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 2/2] regulator: core: Streamline debugfs operations Date: Wed, 24 May 2023 14:22:18 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1766778874266370176?= X-GMAIL-MSGID: =?utf-8?q?1766778874266370176?= 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. Adhere 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, as by design, all debugfs functions are no-ops when passed an error pointer. Fixes: 2bf1c45be3b8f3a3 ("regulator: Fix error checking for debugfs_create_dir") Signed-off-by: Geert Uytterhoeven --- v2: - Spin off error check fix into a separate patch, - Improve rationale. --- drivers/regulator/core.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ad8baf65f63e369b..d8e1caaf207e108f 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1913,17 +1913,15 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, regulator->debugfs = debugfs_create_dir(supply_name, rdev->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,