Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp937180rdb; Thu, 15 Feb 2024 23:18:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWYneA1I6CAo6sB/bk+fP+52x2j51uaLIML4KynKVIq0Ym97el+DhWE7NRnPzivyMVLtaFF0Jx+iWTpCF3hW8UnTog64V40fjl30GjPpQ== X-Google-Smtp-Source: AGHT+IGoFv3o9ecbihiKNUZ3g45tWitSoF3W2/2m80kcVsz6wzmBTev2EtGOQTMyLHBOhpfkFVaY X-Received: by 2002:a81:6cc1:0:b0:607:d048:bd23 with SMTP id h184-20020a816cc1000000b00607d048bd23mr4104794ywc.20.1708067934656; Thu, 15 Feb 2024 23:18:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708067934; cv=pass; d=google.com; s=arc-20160816; b=VLrSBfGk+I2JshEiZ8juRnPLH18srjUsGHLxy9v1evK2htjn1+xJt+V4lJkc5VqSAl QfAlLX0dEbthGSCyLDqOnXaN46e4c1spoTffBLW7GCoDCf/+k0CgQb7eWTsg6L2UAyf4 1Jxs6opzp4E/pdSxaaTWPhEZIHKJUSCocWzmu/dgytSL1S6MAH49JWcAkeHgJlzAscOV QeI0dAVNs6qIqj76BRntk8nktBI8K1CpTwELVTsgwdTXid+hM5cjnA+zWHmToug+FOuR Ny4whznGEAiaFsRlVDJ7RfCUx3MRxL/bk6eEqUhVeFdEw/iuGaqv0bLh1m/0x/OKYUpN f2bA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=Zcu2j9A9tTi5/JsiI3wlTgtWT7XEjE2R0ieV6H9NsN4=; fh=SV7jp/N4w5H/WguTuPXZpem2ktA8CMnlzZDNo6r9whw=; b=OWHFuJTOX0n5zgX/VgCxJIkua7DQzNLGfRAfcJt+F9opD0gUIomex1MjcvE9wRXvoV nhm63uevGU2gzMh2kwa8QnwvwALL9c4fZ6MyUsFuqRrFXX/OFfF95mO7neZgOel3CPK+ dX8zi7V1sh9fiB+B45PqWZeK8eIV2j3kB8e7MrbH2O6KtVSoL6UMgcV23L718xIOVBaj fR9FiCT+8py0y8a7TJtZVK5xaj0kpi5If44C2n7wrZUffTQhJAtBQWp0BmYivPGten62 GoVqGIEx7tYSW37mRE9uWgAWJ4Hc93dqutMfJUwpk43H4tbCaFmbIc3x16qwYE1qjvAN JL7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-68162-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68162-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j22-20020ac874d6000000b0042c644c36a9si3146761qtr.52.2024.02.15.23.18.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 23:18:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68162-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-68162-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68162-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6C5C71C22679 for ; Fri, 16 Feb 2024 07:18:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 231FE14F62; Fri, 16 Feb 2024 07:18:49 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ECCC2F44 for ; Fri, 16 Feb 2024 07:18:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708067928; cv=none; b=D5v5Y/OSumXChn5gTZZg+0LFjVGR9wq64++MOy+qyEeGMinuvYDxyb32Gll67imWqRn5XKqjfIPOse9FW5S+KGsrC4YFWBNC/Uj205sOBZbTPaZnp1SEPMH7r/bOcT1uIHRO56lZro3TXm0d4ln1SYhwkjum014/LmmJ/ajRpEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708067928; c=relaxed/simple; bh=5YYd1mc9oE4gQ6nfD69b18mEEMCG2oT720uDPviPQGk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=K32jw17CSqz+u2gjOlnx4Jwf0wr3qdYvaXMK64k9kQW9KxwA6ZITRhKAMy5B0Yg5Jh0wu8c7Ejs7OYfrcdeKdNo128VqOEsTEKfR8ds4i4uZy1JPkv24ELoK3k1W0kSYkkieYpXMljxJE2MSyr6SHhBp4xp5YzDSHH3JKUKmpB0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rasUc-00020h-0H; Fri, 16 Feb 2024 08:18:42 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rasUb-001244-2w; Fri, 16 Feb 2024 08:18:41 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1rasUb-005pqX-01; Fri, 16 Feb 2024 08:18:41 +0100 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH] regulator: pwm-regulator: Use dev_err_probe() for error paths in .probe() Date: Fri, 16 Feb 2024 08:18:30 +0100 Message-ID: <20240216071829.1513748-2-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=3378; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=5YYd1mc9oE4gQ6nfD69b18mEEMCG2oT720uDPviPQGk=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBlzwxGyClUmA1tGdWbOOkZJ5+vxLG7c/5ZA3CfU b/KKog8kgCJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZc8MRgAKCRCPgPtYfRL+ TgV2B/9xLhveg3237uG5nURdadNydHctCiCuZ9fxi+jMDEK3Oue+rcxZcc8Szd/qvkrUNZJAivU 6ZvNBvup9Z0xHY1vk2+7HuUJQ+1/4scf8dDO9v+RMvwcECH15viq88pzHK3+PVs2rvn+RkIjG7C 5FvQTRiq52bbBiUSwP/uipgpLvljCLSNIEev5QDrA3LKfSKQ1UZkuevp7ReMeSGsNctlMPf8P8q e14fXn6or2l3mrUfgMn0C8DJAVfOayiWzgeJDIRP9dXGpvaY96X1LiqdMtzaIfvv1bZCOvNG6NE bVQy71HdiJm7x8+vT1iluzYUaw6I4PDiARCPB+RSQlPUxvsC X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org One error path already used the dev_err_probe() helper. Make use of it in the other error paths, too, for consistent output. This results in a more compact source code and symbolic output of the error code. Signed-off-by: Uwe Kleine-König --- drivers/regulator/pwm-regulator.c | 40 +++++++++++++------------------ 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index 60cfcd741c2a..7434b6b22d32 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -271,11 +271,10 @@ static int pwm_regulator_init_table(struct platform_device *pdev, of_find_property(np, "voltage-table", &length); if ((length < sizeof(*duty_cycle_table)) || - (length % sizeof(*duty_cycle_table))) { - dev_err(&pdev->dev, "voltage-table length(%d) is invalid\n", - length); - return -EINVAL; - } + (length % sizeof(*duty_cycle_table))) + return dev_err_probe(&pdev->dev, -EINVAL, + "voltage-table length(%d) is invalid\n", + length); duty_cycle_table = devm_kzalloc(&pdev->dev, length, GFP_KERNEL); if (!duty_cycle_table) @@ -284,10 +283,9 @@ static int pwm_regulator_init_table(struct platform_device *pdev, ret = of_property_read_u32_array(np, "voltage-table", (u32 *)duty_cycle_table, length / sizeof(u32)); - if (ret) { - dev_err(&pdev->dev, "Failed to read voltage-table: %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, + "Failed to read voltage-table\n"); drvdata->state = -ENOTRECOVERABLE; drvdata->duty_cycle_table = duty_cycle_table; @@ -359,10 +357,9 @@ static int pwm_regulator_probe(struct platform_device *pdev) enum gpiod_flags gpio_flags; int ret; - if (!np) { - dev_err(&pdev->dev, "Device Tree node missing\n"); - return -EINVAL; - } + if (!np) + return dev_err_probe(&pdev->dev, -EINVAL, + "Device Tree node missing\n"); drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) @@ -400,8 +397,7 @@ static int pwm_regulator_probe(struct platform_device *pdev) gpio_flags); if (IS_ERR(drvdata->enb_gpio)) { ret = PTR_ERR(drvdata->enb_gpio); - dev_err(&pdev->dev, "Failed to get enable GPIO: %d\n", ret); - return ret; + return dev_err_probe(&pdev->dev, ret, "Failed to get enable GPIO\n"); } ret = pwm_adjust_config(drvdata->pwm); @@ -409,19 +405,17 @@ static int pwm_regulator_probe(struct platform_device *pdev) return ret; ret = pwm_regulator_init_boot_on(pdev, drvdata, init_data); - if (ret) { - dev_err(&pdev->dev, "Failed to apply boot_on settings: %d\n", - ret); - return ret; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, + "Failed to apply boot_on settings\n"); regulator = devm_regulator_register(&pdev->dev, &drvdata->desc, &config); if (IS_ERR(regulator)) { ret = PTR_ERR(regulator); - dev_err(&pdev->dev, "Failed to register regulator %s: %d\n", - drvdata->desc.name, ret); - return ret; + return dev_err_probe(&pdev->dev, ret, + "Failed to register regulator %s\n", + drvdata->desc.name); } return 0; base-commit: d37e1e4c52bc60578969f391fb81f947c3e83118 -- 2.43.0