From patchwork Thu May 25 11:13:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 98963 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp285790vqr; Thu, 25 May 2023 04:21:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6pRXKIagTjsHuk7BGlv+a+SXpUF3ysDOkDx+6fAfE3SDfSJoW3Cu5esG+3UV5OfpxLmo97 X-Received: by 2002:a17:902:e747:b0:1af:ccc9:ce65 with SMTP id p7-20020a170902e74700b001afccc9ce65mr1090566plf.28.1685013686756; Thu, 25 May 2023 04:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685013686; cv=none; d=google.com; s=arc-20160816; b=JMp+S4f1TZvofQSN6UJVxVLCVmzihM7bpn/kLpk/giirwJayQw+eMyvTc7ovsWQQW5 C4wHNzTcu2QMywV/dS9JZGYe0zSiylK/ztuhRtMDQKP42uDhqX0TojrIpuFXOe+5pSb9 pZqqOq5kmCshx3UZ65dKkBtKO3eeje9QoBjv30zrpZlv+L8U8sytTF+URsukbSGLD9Lg Z9c3BlqJc/jPUGXoa3DR5UD2nwtri30q+TBHT1CncQx4do6lBzpC+dvTF46VSWgY7byp hoI7OknbdUIKGanpJ7cifMU2ZYGhJXwdkQVewW9Q+SRUVPu1WTwUJXOOHRQZ3xVSIqU/ Q0tg== 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=niafEeVWJ/tLFt59XUcU3+Je7qDrJ5xE4omJ/URLlk0=; b=AQK2uiYbqSRfoYrvodGcQ35gMq5jn1E6mjt94A9Fyv7LV0ZlITI3QvIo7ACx+OLyAs YPuFrs03+AVHiqdAUWt4XvGgwBShkbRE2nC00N2VYw6kwE6uXNMful97rUGzmM2WqwOM YG3nCmU0sM6qxa6U2hTDtNQqGKuXH6535++5YaofbOhMJLzDhPwAPzapxjgb3pbgyqGi iGyxN7oiCQIrxNn6WGnKpAuyUFHS1Z0kLUpI9eaGS/uHokafbDG+n0ex1y6CBRBeyWTs eEMdqFSoIPZ4Zch0jG0fBtAVXyaaOOrlLCqxPjSLQIHsqdk9sYQd32q+a8S3uUL9s6J8 Y1SQ== 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 jj5-20020a170903048500b001ae4026d82bsi1262458plb.12.2023.05.25.04.21.13; Thu, 25 May 2023 04:21:26 -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 S235297AbjEYLOL (ORCPT + 99 others); Thu, 25 May 2023 07:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234503AbjEYLOF (ORCPT ); Thu, 25 May 2023 07:14:05 -0400 Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 638BF13A for ; Thu, 25 May 2023 04:14:03 -0700 (PDT) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed30:59b9:3473:f0ae:e2b7]) by michel.telenet-ops.be with bizsmtp id 0zE02A00P5NiV2706zE0Sd; Thu, 25 May 2023 13:14:00 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1q28ue-00349k-NM; Thu, 25 May 2023 13:14:00 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1q28uu-00DnlX-F9; Thu, 25 May 2023 13:14:00 +0200 From: Geert Uytterhoeven To: Liam Girdwood , Mark Brown , Osama Muhammad Cc: linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 2/2] regulator: core: Streamline debugfs operations Date: Thu, 25 May 2023 13:13:59 +0200 Message-Id: <2f8bb6e113359ddfab7b59e4d4274bd4c06d6d0a.1685013051.git.geert+renesas@glider.be> 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?1766864911346010346?= X-GMAIL-MSGID: =?utf-8?q?1766864911346010346?= 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 --- v3: - Rebase, v2: - Spin off error check fix into a separate patch, - Improve rationale. --- 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 c1bc4729301d5fed..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 (IS_ERR(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,