From patchwork Wed Nov 23 12:00:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 24933 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2753192wrr; Wed, 23 Nov 2022 04:22:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf5JDVc1Oj3vhkGQDq83hQ/tslEEmQuwBgV8MiiGKF9Fk/dGGK+ptu8MhAF/aveqOkGCVPu6 X-Received: by 2002:a17:90b:2705:b0:218:78ae:bdaa with SMTP id px5-20020a17090b270500b0021878aebdaamr29454690pjb.162.1669206143004; Wed, 23 Nov 2022 04:22:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206142; cv=none; d=google.com; s=arc-20160816; b=fk1lPdEp53Vxi27zXW3HpxR9yfSr8/9VupoZdNVQwMTpwP/vaPESwv715WFyNX2cL9 S8fErzvbGRR6xmbcmtskw0jWTgLCoLv+MqFmxgDFLDYkbZGne7p1OQOFyAoHNSOWlmvh 7RDyXeQnplgaHwmm6jhBVH+0RuiQFuZWU34TT09AtKvnp3WyhNCsgAN5b1DRS4QHnv0q KCSfknWBlPsWYWP/0sL0EkvG0kE1IXbUYFWa4zGMf14ErpibTsZYCh5tH/C1Et5sCl7T BcewnPZ5pZ31V4k0qgld2pfCRLbmSRh1ekxMeGI7673/uuRlfCGLJWWy5YLg3a3qGsbE qfWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zS55Mqs8mGnHpdp7oRDU+t6pDD2XkxqurchuAVXqwyM=; b=EAfS7idA+vsFlhAuYVpuvWL56VmHKFMl9fZNXvtduUwS94fq8fkxUgZ3RwyHo+CnYN xPiXWd9XJiWRT+QjpJGuz2U1Cy+af3EMIqsh/pe2xOqukRjUmbH8oEOJv6IvT7d6JIUJ YYod0TLPfSQRipjrZal3LAFyjOl5UPp/XtaSnLfVdoM15qRBXotGd94iwae9KcwRs/NN G06rsyEm4/jmpzK+2Xtv8aW+bm+2J7WLohPVlzwJaEk9EWKgOhYK9UKDsTQNfZdbF4NO XsDwUW3cl5bGSS61rdN5GcDUtQyaPdfUqzqU/GhILfgMGiI3aO1r2SEk7oFEYM+q2ZlW +hVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Vor3x6XM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k3-20020aa79d03000000b0056cac533dfdsi14702889pfp.261.2022.11.23.04.22.09; Wed, 23 Nov 2022 04:22:22 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Vor3x6XM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236909AbiKWMAU (ORCPT + 99 others); Wed, 23 Nov 2022 07:00:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237133AbiKWMAN (ORCPT ); Wed, 23 Nov 2022 07:00:13 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB8372528B for ; Wed, 23 Nov 2022 04:00:11 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id a29so27781402lfj.9 for ; Wed, 23 Nov 2022 04:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=zS55Mqs8mGnHpdp7oRDU+t6pDD2XkxqurchuAVXqwyM=; b=Vor3x6XMUSIngVDCU+LDA/CBbyvunZChKH+78No/VCFCtR84rCTens51rsgt90xQdj cCkaLBlZ+h6hhKJYemzUkvrTADIPxvysoofOiEalkxu5Hqiq1PNZBtRXwsFC1DZishnc 85UKpEiAgNfPoS3E565T1cOdukD7S6FqSWTCrgBgPZ/NJA6uK3kwwMgAsrMrT9WDTDCS HXLjuMRfaxIPXWmRg9WfFssnEOCdWpKycMjD5YBSjlA4C8upblWCK0PaFSidOOb9mpfE Lx/Rs6aVjzxwKPDNPZOaJ0C02ZK1dQWBcABKeKDRUvQYjuxijBeImM2tthMfVcI/FpX7 99Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zS55Mqs8mGnHpdp7oRDU+t6pDD2XkxqurchuAVXqwyM=; b=asgzZY8+V050s3yrzP8SELvPakQV6ZmHxei7RNDRO9IYLXXoipisXT8UvN91BnqiDp Abu2gG93ryzuhxhBeGUAWKo5lxYvrviL6Eq5T/W2Qho3d7shdiZVIyDI0/pJfkDeTUz3 THTVc8KNqh44S/BeaTd0cnYhWoFF12z/IOdHnpRqdyk/6IcsluPe0MpEhsowCAnrtNqy KQLzMdP8dhFMLMuvFoM1UsKx7Uo1OjlRkvocJ2nxDZuWSfKF37f5M1bwHaem56R6z1IE Q16xBJSh/VZ9D0F6e9YOcCriyU2Z/Aldld+q/rfF60Pz+ywZzwbYY+7Bgc70zHop+Q44 MlVA== X-Gm-Message-State: ANoB5pkiK6TZbqb/yg0He9ZyZeN+oUFVP8BTOUpn0Fo337isG9oAY7XE LQtFVWUjoF6sWHh845FfzRE= X-Received: by 2002:a19:501c:0:b0:4b1:82c6:295b with SMTP id e28-20020a19501c000000b004b182c6295bmr8751542lfb.67.1669204810012; Wed, 23 Nov 2022 04:00:10 -0800 (PST) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id p1-20020a2eb101000000b0027709706194sm2209527ljl.49.2022.11.23.04.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 04:00:09 -0800 (PST) Date: Wed, 23 Nov 2022 14:00:05 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Matti Vaittinen , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] regulator: bd718x7: Drop unnecessary info print Message-ID: <33fd99abf2451999938fef4ba6cf7b3f19e9b992.1669203610.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1750289500807220246?= X-GMAIL-MSGID: =?utf-8?q?1750289500807220246?= A device-tree node name was printed when bd718x7 driver's feedback-loop feature was developed. This print was accidentally left in driver. The info-level print just pollutes the log. Drop unnecessary pr_info() Fixes: d2ad981151b3 ("regulator: bd718x7: Support external connection to scale voltages") Signed-off-by: Matti Vaittinen --- drivers/regulator/bd718x7-regulator.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c index 00efb18a836c..d161b0026f33 100644 --- a/drivers/regulator/bd718x7-regulator.c +++ b/drivers/regulator/bd718x7-regulator.c @@ -1576,8 +1576,6 @@ static int setup_feedback_loop(struct device *dev, struct device_node *np, if (!of_node_name_eq(np, desc->of_match)) continue; - pr_info("Looking at node '%s'\n", desc->of_match); - /* The feedback loop connection does not make sense for LDOs */ if (desc->id >= BD718XX_LDO1) return -EINVAL; From patchwork Wed Nov 23 12:00:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 24930 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2751068wrr; Wed, 23 Nov 2022 04:17:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5s+YLAip1ggPcW3UWGOYdjwAzUlVTQZjTDWYi9FOh7zkv44hf+c7oNxfC984xyxOUEy6BR X-Received: by 2002:a05:6402:1156:b0:467:374e:5f9b with SMTP id g22-20020a056402115600b00467374e5f9bmr8412877edw.283.1669205857266; Wed, 23 Nov 2022 04:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669205857; cv=none; d=google.com; s=arc-20160816; b=h5K+DI27+iZ09lSeRSVXKdZ0br+1sVnAwAqLq1GyE4lIMZJ+w5xvowSXvJkuCfnWzU 6gkIQefY8u4Hn+p0IpmgnGhk7inFksefgtbtN5AOQDWEDYOCfSAuBv41Ueh6tOY2B9kh shosbdMOp9gzDjQEabMgHREra2xW3x+CKE9V9hEsgUWZPsQZyxYnPkUa/HazccQoK/8z ftLnXXPu8F1qIPaLw8UL4rqiDEX7Kdkohbl6/3TMRUR2HR3rWsUIl/OVEjWXNa0m3CRz RclgsN9cfg/t7e5el6QwFI2JmS3urOKoK3cwC0G99M4MhtJ6OBoTtmtUFVrHsD2gGTFV pj0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=x5p4E1mI/PEqffjz8f8OBqeFrGyZRJUVUJmG4+2QrCs=; b=ghrJjOWk/HZ7Gk/zhI2Biz118xyi56yOVk5DvmOpoFRgkZIUB0zZ3YjaXuNjDSBerP pGZuv8FQPC+68bu/jM2J4mlOVaqZHpRpgI+x1ywMdjgsjel0wNX/gS1vJ57q5FEMpgv2 EaFtg1F49q+rZNpZfK++hdsgg2zw0u2A5zugINI7JF/Tb5yGy+pY5vyMGbpRxLTJZFZ2 XNktoxrPy4gV+HrvmUJq75pBJxnkzsmCK4DslXFZ8Q+3i/5Ch63TDl9/141ByZopTVla hTSvxTQBwRnrr5KQp47g6Ch++h3F7Kedqx1xODq3GBSQmIcWrUTpEudjsfkRYaZWvwZ8 lSnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jycwFKbX; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id em8-20020a056402364800b00461d9b36740si13560002edb.240.2022.11.23.04.17.12; Wed, 23 Nov 2022 04:17:37 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jycwFKbX; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237083AbiKWMAc (ORCPT + 99 others); Wed, 23 Nov 2022 07:00:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236982AbiKWMAa (ORCPT ); Wed, 23 Nov 2022 07:00:30 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE87A7651 for ; Wed, 23 Nov 2022 04:00:27 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id r12so27883321lfp.1 for ; Wed, 23 Nov 2022 04:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=x5p4E1mI/PEqffjz8f8OBqeFrGyZRJUVUJmG4+2QrCs=; b=jycwFKbXMlZHgNRBW8WkRiTlZgPFeIVvaxQAfGZ77WVlLnzg6fqwEwUkshRSp/1sEr 2kxb8Uw8xAnQ+rXrXSBpw07NrlYZiNEG0RO7DHwZK+bpX5JOL/Vnml8/UfIqleJMjOzg xD+IS9wKm+8JUx/MqGnfqAa2d9JgO9kaJafjxEFzuW1pIuz8syhr98hagafP6/gCOLCq LrNyFz+/L+ke8h0eqecdo1uUigr6qA1qEcves9XU99qT5XmWaKItuTJ4XvKJV2xvOG8u pKXT6NzjYySfqCVkvnEF2cYQseWQlfvlWMQ3conHtYBE09428AUHOQ99XJHmUUEiFXj2 CFkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=x5p4E1mI/PEqffjz8f8OBqeFrGyZRJUVUJmG4+2QrCs=; b=YLrvuUUEDRSgLAs51OB/do0sRXNRJ2i6et0dwlRYH6LZs0C5xLKJ7BerQYJ8UgLp9+ Drm27SZUQ5pgkrnc2VUsNkRxvCcAa3y8PqbmfQpwQonmz6ycsx59qTA+gRSxcCyPcDGr eSa1gmDJiWaCbpyY1Ns5VHmk/XlHZEOPqYseIZKACh89KP5jH8FGkozWTNxT1Bhi7KeV u+vecBQJZHXc3VCFbPga+cgeLijKhgxkf/ZO4dvbKwh1HhjirtyFT0Dk+v86CE2Q1Qt2 n0tOsxG59ZAeJzh/xkH5FBq1IjW3Cx2/rBNx2otUsHPIHFGxUdf2DBcR5gEuA9a1VGDf SRNw== X-Gm-Message-State: ANoB5plABJCQdew3wy4UK6KRYjGIQX3vplPCfISCuEjQWoMQP/TeEnrE 4KLzFX2WzfF7k/vmMR429D/aLpcEkyI= X-Received: by 2002:a05:6512:3c83:b0:4a2:3a78:106d with SMTP id h3-20020a0565123c8300b004a23a78106dmr9000513lfv.419.1669204826033; Wed, 23 Nov 2022 04:00:26 -0800 (PST) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id q21-20020a056512211500b004aa3d587c84sm2881410lfr.200.2022.11.23.04.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 04:00:25 -0800 (PST) Date: Wed, 23 Nov 2022 14:00:21 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Matti Vaittinen , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] regulator: bd71815: bd71828: bd9576: Use dev_err_probe() Message-ID: <0b644da4a8f58558ffe474d2593f85c46de2f965.1669203610.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1750289200926912188?= X-GMAIL-MSGID: =?utf-8?q?1750289200926912188?= The dev_err_probe() has (at least) following benefits over dev_err() when printing an error print for a failed function call at a device driver probe: - Omit error level print if error is 'EPRBE_DEFER' - Standardized print format for returned error - return the error value allowing shortening calls like: if (ret) { dev_err(...); return ret; } to if (ret) return dev_err_probe(...); Convert the ROHM BD71828, ROHM BD71815 and ROHM BD9576 regulator drivers to use the dev_err_probe() when returned error is not hard-coded constant. Signed-off-by: Matti Vaittinen --- drivers/regulator/bd71815-regulator.c | 10 ++--- drivers/regulator/bd71828-regulator.c | 21 +++++------ drivers/regulator/bd9576-regulator.c | 54 +++++++++++++-------------- 3 files changed, 38 insertions(+), 47 deletions(-) diff --git a/drivers/regulator/bd71815-regulator.c b/drivers/regulator/bd71815-regulator.c index c2b8b8be7824..8b55046eded8 100644 --- a/drivers/regulator/bd71815-regulator.c +++ b/drivers/regulator/bd71815-regulator.c @@ -602,12 +602,10 @@ static int bd7181x_probe(struct platform_device *pdev) config.ena_gpiod = NULL; rdev = devm_regulator_register(&pdev->dev, desc, &config); - if (IS_ERR(rdev)) { - dev_err(&pdev->dev, - "failed to register %s regulator\n", - desc->name); - return PTR_ERR(rdev); - } + if (IS_ERR(rdev)) + return dev_err_probe(&pdev->dev, PTR_ERR(rdev), + "failed to register %s regulator\n", + desc->name); } return 0; } diff --git a/drivers/regulator/bd71828-regulator.c b/drivers/regulator/bd71828-regulator.c index a4f09a5a30ca..ad728f4f2241 100644 --- a/drivers/regulator/bd71828-regulator.c +++ b/drivers/regulator/bd71828-regulator.c @@ -750,23 +750,20 @@ static int bd71828_probe(struct platform_device *pdev) rd = &bd71828_rdata[i]; rdev = devm_regulator_register(&pdev->dev, &rd->desc, &config); - if (IS_ERR(rdev)) { - dev_err(&pdev->dev, - "failed to register %s regulator\n", - rd->desc.name); - return PTR_ERR(rdev); - } + if (IS_ERR(rdev)) + return dev_err_probe(&pdev->dev, PTR_ERR(rdev), + "failed to register %s regulator\n", + rd->desc.name); + for (j = 0; j < rd->reg_init_amnt; j++) { ret = regmap_update_bits(config.regmap, rd->reg_inits[j].reg, rd->reg_inits[j].mask, rd->reg_inits[j].val); - if (ret) { - dev_err(&pdev->dev, - "regulator %s init failed\n", - rd->desc.name); - return ret; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, + "regulator %s init failed\n", + rd->desc.name); } } return 0; diff --git a/drivers/regulator/bd9576-regulator.c b/drivers/regulator/bd9576-regulator.c index 393c8693b327..02c70768652b 100644 --- a/drivers/regulator/bd9576-regulator.c +++ b/drivers/regulator/bd9576-regulator.c @@ -953,30 +953,28 @@ static int bd957x_probe(struct platform_device *pdev) dev_fwnode(pdev->dev.parent), "rohm,vout1-en", GPIOD_OUT_LOW, "vout1-en"); - if (!IS_ERR(en)) { - /* VOUT1_OPS gpio ctrl */ - /* - * Regulator core prioritizes the ena_gpio over - * enable/disable/is_enabled callbacks so no need to - * clear them. We can still use same ops - */ + + /* VOUT1_OPS gpio ctrl */ + /* + * Regulator core prioritizes the ena_gpio over + * enable/disable/is_enabled callbacks so no need to clear them + * even if GPIO is used. So, we can still use same ops. + * + * In theory it is possible someone wants to set vout1-en LOW + * during OTP loading and set VOUT1 to be controlled by GPIO - + * but control the GPIO from some where else than this driver. + * For that to work we should unset the is_enabled callback + * here. + * + * I believe such case where rohm,vout1-en-low is set and + * vout1-en-gpios is not is likely to be a misconfiguration. + * So let's just err out for now. + */ + if (!IS_ERR(en)) config.ena_gpiod = en; - } else { - /* - * In theory it is possible someone wants to set - * vout1-en LOW during OTP loading and set VOUT1 to be - * controlled by GPIO - but control the GPIO from some - * where else than this driver. For that to work we - * should unset the is_enabled callback here. - * - * I believe such case where rohm,vout1-en-low is set - * and vout1-en-gpios is not is likely to be a - * misconfiguration. So let's just err out for now. - */ - dev_err(&pdev->dev, - "Failed to get VOUT1 control GPIO\n"); - return PTR_ERR(en); - } + else + return dev_err_probe(&pdev->dev, PTR_ERR(en), + "Failed to get VOUT1 control GPIO\n"); } /* @@ -1037,12 +1035,10 @@ static int bd957x_probe(struct platform_device *pdev) r->rdev = devm_regulator_register(&pdev->dev, desc, &config); - if (IS_ERR(r->rdev)) { - dev_err(&pdev->dev, - "failed to register %s regulator\n", - desc->name); - return PTR_ERR(r->rdev); - } + if (IS_ERR(r->rdev)) + return dev_err_probe(&pdev->dev, PTR_ERR(r->rdev), + "failed to register %s regulator\n", + desc->name); /* * Clear the VOUT1 GPIO setting - rest of the regulators do not * support GPIO control From patchwork Wed Nov 23 12:00:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 24934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2753299wrr; Wed, 23 Nov 2022 04:22:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5m4IMNZt75qRweraSB6NhBXiHltv8sW91lwCCkOku2mS/TGP7JVUUARb/e+/CayhjfszjY X-Received: by 2002:a17:902:7d94:b0:187:4920:3a7e with SMTP id a20-20020a1709027d9400b0018749203a7emr11344533plm.171.1669206160354; Wed, 23 Nov 2022 04:22:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669206160; cv=none; d=google.com; s=arc-20160816; b=tKOkUSPEBq1odZzaiiEpgn1vEIPpi3qxpSwAofAXroiWjO/7858mbC+JdjGywV4CW+ 5ulC9foUDoQ609Xyfgk6F2HPpHLmLLjwyZznJsLi4OeNukQz9IiDRguoYjIG07CZCR7Q cjRRpylBPlxQtRg+spvwYNpccstYSDYTjjGIC1b2IsDTQxBv0P7xgg/ZNgn1Z4N9RLlz 2v85QesW70uFTXRNyAW8vs14Mzf9rL9woACcR1lr8fbd5tjTX8YPZv3Qd8wU8PPPMmbC 6jW2b4kgap0gWdnH9QcVLEcWNiJSFOY5pruj9Lej4iJ3RzZ7T2vO21ph2L6FFT9ouEP/ XIvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hcR8ovYNo2My0WUKcVnNmYC5cYpEMC0rr3gdSJ74NfU=; b=BKbD3qrVnQR+sk2s4hqXVpWfHaHVVRXHrbNphZZCZn9swWLBF729WswNwNhSEH+O+z YxeshwHzuw/DZ/CEzBNO+XSV9cwdnETnDkmJzy/qNuWavy/9l4yjIfEFyd+uSIPbHumL FSR3Sa3G/t/JFivQrIGF0HvTwCB8ritj1HPgsR9Fk8wwbD2Id2a+pWY0wqRWwvZ6oRIE lVGUctmlihgVqy6LC8o/N346HJ/wCMhpWabWQT27W97ODk4klpks3pY2sfi8FXLyUedl Yu8DP5YXABjH4fsa+cAaoGPzM1fY8BWMAQr3NRz+Ih+Q2VlRpwNw6olwgijPC3EVa+NV Kv9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZrlPHAS+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a170902e94900b00186881688f9si16313702pll.276.2022.11.23.04.22.26; Wed, 23 Nov 2022 04:22:40 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZrlPHAS+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237125AbiKWMAs (ORCPT + 99 others); Wed, 23 Nov 2022 07:00:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237133AbiKWMAp (ORCPT ); Wed, 23 Nov 2022 07:00:45 -0500 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36249624A for ; Wed, 23 Nov 2022 04:00:44 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id s8so27820396lfc.8 for ; Wed, 23 Nov 2022 04:00:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hcR8ovYNo2My0WUKcVnNmYC5cYpEMC0rr3gdSJ74NfU=; b=ZrlPHAS+WGiK3Lav2tjX9E3L3EQhNwAGul34uyaC6bhMi4CQY5elSYO++LxtQ+rIG7 pynaS8fphG+u0aowuVnGAGSO308yaigyNIPmgo2h9itDgHFQKi03T7NGZl+96WAr7+k1 OKf6GBFSb/8U0NObV+mVI5sikProfgzcwhqJoiErqM490fCODGRBD2biWQLeX63LAIT6 9gHBFjNOMOc5CaeR8dEZKz+2i9v0z5qpZpEep3MVS+ZoeSAmAo3SN1wnPVS6uKXFPs71 fqYOZt/GYlz08sOgbf1t2FvLTMExnQPPTa0b6TK1jk+wTPp1uNOznGI4Yk9le4LNWiDs vwWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hcR8ovYNo2My0WUKcVnNmYC5cYpEMC0rr3gdSJ74NfU=; b=TLCDroC83hHX9dRrRPu09a9hfEkH9w2YnfqNWGW9hvrYBybRbbpMXNCqiTNDSHuWIp Yq0iD/5phcZk3sK7dSjteKQ6EKSEABaPCF6gee1WC11ESBKlES9pikfRcP5nbJ3y2gYU hIXDPY2qRDzLvyYSFG5r+FZz/DyszAYEEyKm+fsGBQmGnJK/093HwVmRRah4DtYcMD41 1EseJA3FLGnJ4127NDJjHBraPoVvFe5Jkss1QwesU3PotorYvnk5G/nHsP//4HHtvdgy 2zatYOsvjp+EH4nl4l5MmX1BgiiAEa6bkarVIwUqY9CsPHuP6XpusE/CtiplWcvroJdt kshg== X-Gm-Message-State: ANoB5pl4U1IWzBbCfTUPPSNspUxYc7EXIUS36MZcdIxj/SRL1wzbLUPq jPLhO4c/UCW3SGPKdy0wJEEBOODMDM4= X-Received: by 2002:a05:6512:68b:b0:4a8:d2b7:ed5c with SMTP id t11-20020a056512068b00b004a8d2b7ed5cmr10789411lfe.434.1669204842474; Wed, 23 Nov 2022 04:00:42 -0800 (PST) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id o7-20020ac25e27000000b004b48c977d8dsm2892067lfg.125.2022.11.23.04.00.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 04:00:41 -0800 (PST) Date: Wed, 23 Nov 2022 14:00:38 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Matti Vaittinen , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] regulator: bd718x7: Use dev_err_probe() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1750289518588613295?= X-GMAIL-MSGID: =?utf-8?q?1750289518588613295?= The dev_err_probe() has (at least) following benefits over dev_err() when printing an error print for a failed function call at a device driver probe: - Omit error level print if error is 'EPRBE_DEFER' - Standardized print format for returned error - return the error value allowing shortening calls like: if (ret) { dev_err(...); return ret; } to if (ret) return dev_err_probe(...); Convert the ROHM BD718x7 regulator driver to use the dev_err_probe() when returned error is not hard-coded constant. NOTE: This commit also changes the error handling path to return immediately from a spot where the error is spotted instead of using a single point of exit. Signed-off-by: Matti Vaittinen --- For many years I have preferred a single point of exit in a function when managing it does not require any big tricks. In my experience a single point of exit makes resource-leaking and lock releasing much less error prone. Eg, consider mistakes like: ... mutex_lock(&mtx) ... if (err) return err; ... mutex_unlock(&mtx); return 0; Vs. ... mutex_lock(&mtx) ... if (err) goto err_out; ... err_out: mutex_unlock(&mtx); return err; I still think a single point of exit is often a good idea. However, I am slowly adapting to thought that the single point of exit does not really play a big role in bd718x7 regulator probe and using dev_err_probe() allows us to avoid the extra {} after condition... So, maybe it indeed is a time for me to ditch the goto here. Please, let me know if you think othervice :) --- drivers/regulator/bd718x7-regulator.c | 51 ++++++++++----------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c index d161b0026f33..894fab0d53d0 100644 --- a/drivers/regulator/bd718x7-regulator.c +++ b/drivers/regulator/bd718x7-regulator.c @@ -1706,20 +1706,17 @@ static int bd718xx_probe(struct platform_device *pdev) break; default: dev_err(&pdev->dev, "Unsupported chip type\n"); - err = -EINVAL; - goto err; + return -EINVAL; } /* Register LOCK release */ err = regmap_update_bits(regmap, BD718XX_REG_REGLOCK, (REGLOCK_PWRSEQ | REGLOCK_VREG), 0); - if (err) { - dev_err(&pdev->dev, "Failed to unlock PMIC (%d)\n", err); - goto err; - } else { - dev_dbg(&pdev->dev, "Unlocked lock register 0x%x\n", - BD718XX_REG_REGLOCK); - } + if (err) + return dev_err_probe(&pdev->dev, err, "Failed to unlock PMIC\n"); + + dev_dbg(&pdev->dev, "Unlocked lock register 0x%x\n", + BD718XX_REG_REGLOCK); use_snvs = of_property_read_bool(pdev->dev.parent->of_node, "rohm,reset-snvs-powered"); @@ -1736,13 +1733,11 @@ static int bd718xx_probe(struct platform_device *pdev) BD718XX_WDOG_POWEROFF_MASK | BD718XX_KEY_L_POWEROFF_MASK, BD718XX_POWOFF_TO_RDY); - if (err) { - dev_err(&pdev->dev, "Failed to change reset target\n"); - goto err; - } else { - dev_dbg(&pdev->dev, - "Changed all resets from SVNS to READY\n"); - } + if (err) + return dev_err_probe(&pdev->dev, err, + "Failed to change reset target\n"); + + dev_dbg(&pdev->dev, "Changed all resets from SVNS to READY\n"); } config.dev = pdev->dev.parent; @@ -1778,13 +1773,10 @@ static int bd718xx_probe(struct platform_device *pdev) desc->ops = swops[i]; rdev = devm_regulator_register(&pdev->dev, desc, &config); - if (IS_ERR(rdev)) { - dev_err(&pdev->dev, - "failed to register %s regulator\n", - desc->name); - err = PTR_ERR(rdev); - goto err; - } + if (IS_ERR(rdev)) + return dev_err_probe(&pdev->dev, PTR_ERR(rdev), + "failed to register %s regulator\n", + desc->name); /* * Regulator register gets the regulator constraints and @@ -1807,28 +1799,23 @@ static int bd718xx_probe(struct platform_device *pdev) !rdev->constraints->boot_on)) { err = regmap_update_bits(regmap, r->init.reg, r->init.mask, r->init.val); - if (err) { - dev_err(&pdev->dev, + if (err) + return dev_err_probe(&pdev->dev, err, "Failed to take control for (%s)\n", desc->name); - goto err; - } } for (j = 0; j < r->additional_init_amnt; j++) { err = regmap_update_bits(regmap, r->additional_inits[j].reg, r->additional_inits[j].mask, r->additional_inits[j].val); - if (err) { - dev_err(&pdev->dev, + if (err) + return dev_err_probe(&pdev->dev, err, "Buck (%s) initialization failed\n", desc->name); - goto err; - } } } -err: return err; }