From patchwork Fri Feb 16 07:18:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 201977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp347759dyb; Thu, 15 Feb 2024 23:19:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX74tQoaaEo13Lr/3mlqvZpatWFgWRJDgVE1oPSzJGfmCFsfPEhW1Ur/5lEkDxsZcPIXIo0UzzRndyalkzjUkQkFj6HlQ== X-Google-Smtp-Source: AGHT+IHAN6rp9tSg2BJMy4ykYH4o2TpGsCpotwuPUMtFNSZF5HgYtBREyzeC0XdwfkJhj4jL99wO X-Received: by 2002:a17:906:8d0:b0:a3c:bfcd:bed2 with SMTP id o16-20020a17090608d000b00a3cbfcdbed2mr2736231eje.31.1708067942019; Thu, 15 Feb 2024 23:19:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708067942; cv=pass; d=google.com; s=arc-20160816; b=U/peG4sgV3LDu+tRu8CK1fwwZKAp+CsVxxFY1Vsyf3nLQ+MMfFkcQKpWTgQ5izX7+0 MNmxnlyarESaJRAh57frWZRm9CWvjT729JJzUhkZo1E1KmELOOXBN7JSN/7zIlGK0et1 s9LiSl7BEvPp6se+Uv1NssL0jc5wGj0GkfcJvagOHN4UjHhe9ma4H/SQ9HWgXZULlCMa tSTdxNz8kEFAwurUfv0Eu+A3zRMA/Q7Uak7xfd84pcLvc5uxrthzTAORZzpLiruCgBad 83lQKu7/+1cpShOe1WtR4pP6GUddBNcydiT6n6SAgd2wxGJuFe9yl69k3d3YW7s4nrOl aa7w== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68162-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l19-20020a1709065a9300b00a3c9c1befb6si1363692ejq.799.2024.02.15.23.19.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 23:19:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68162-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=pengutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-68162-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68162-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9B5991F2307B for ; Fri, 16 Feb 2024 07:19:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2177A168B1; Fri, 16 Feb 2024 07:18:50 +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_Kleine-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 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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791039050412657230 X-GMAIL-MSGID: 1791039050412657230 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(-) base-commit: d37e1e4c52bc60578969f391fb81f947c3e83118 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;