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