Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2024768rwb; Wed, 30 Nov 2022 00:59:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf7wAS3FfBVqCALkZMAUXkzQBEmMUp1INFN9RdD/ilZGqKO7ISI9CehD9DAEbJBQB8uS6nWA X-Received: by 2002:a17:90a:8c04:b0:219:5b3c:6983 with SMTP id a4-20020a17090a8c0400b002195b3c6983mr4349554pjo.131.1669798773536; Wed, 30 Nov 2022 00:59:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669798773; cv=none; d=google.com; s=arc-20160816; b=kjhL4PDEo4OEYqtMVCHZxNHsJX7sfnN+/c0FDZS+n2AalMPeU1/9oijlZVfHpV6Gmg EKKs1UnpXlj50YTsbSuuGlGNebesFYvd18G37NZuMefO/FpF+xNgd8EttISd7tpb3LKt W3XTGxWnoNGbP2xhoJ27nGjFJc3kLTWG6+Lrj1TYwBz6iazTigce9rwex//bMWSCPSRl eqWW9wNzm1tj/WbIGypjjkwQ076YUJDAq4SQrR/8R8KN3afFHZ5UILmcJy+WP53haJrD eWbWusBTt8lMD8sqOIt21hlUP4BCTb5WXAEX7FEIP9P9qU64Krea69JTPt4xfaCXsGLO QEFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=POXigpl8APO9IUP53K10fp0GXszPMpqd75en0jJlNCI=; b=qb86+vdDnZIcaJ7pTtf507y2UNCF3XCGY3wNSn1hAPDrk4J4c6hqnnNymBylAXJGIW oiryqg8kRi9ycHL4kfiawk7iVihcD48mw9rKp9th4cvVHLcKO940UOybTYtV7QU7pf30 dzzCLRfz+SwPtYLgiAgKPlOjHzdGCbxfsIJGvOq60xB9a360wd77m+lHPm2Y29WEKVDU 14f0DmfkgY6Mmm3705yDh7GwMIBueIpBI15rH7/fWjGQN1Kn3LYQvWLtqQEh1bdx3pPh R+mA1Ew68iL1FaFoIZpJpCyWuQF/YH7YPVjjCY4u/0J+5pcNWTqoj4nL4CxxHVtKSA8+ cWDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BKEb7vdq; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a056a00178500b00574a6ee885dsi1291466pfg.3.2022.11.30.00.59.23; Wed, 30 Nov 2022 00:59:33 -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=BKEb7vdq; 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 S235748AbiK3IiF (ORCPT + 85 others); Wed, 30 Nov 2022 03:38:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235717AbiK3Ih6 (ORCPT ); Wed, 30 Nov 2022 03:37:58 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65D901BEAB for ; Wed, 30 Nov 2022 00:37:53 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id mv18so15094570pjb.0 for ; Wed, 30 Nov 2022 00:37:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=POXigpl8APO9IUP53K10fp0GXszPMpqd75en0jJlNCI=; b=BKEb7vdqAI7Q9DB9QLXxAXPXGy0HSu3VCUUJO+kBh9DXhs9RShE0maxetIm2uaEfvF v/Eb5rGCEJus3URWVvtttM9RWHID8ZNd5d6DLcA+HZfUbgHKq4bDV1DVn2bJGXfqfE1H 9ZkBU8e4wJjq+/WUYHdVZhuc05qAzdeypWGQ6+qUuxIeQh6nXVJDbVk2LpAMF3hSh4LN 2ymjUXn0qPaLupxSJRLn2bp4jOrvuqzZ6uqnvZpZR4VLrmXCNSmmt6BeYSA31cc7J2PH ZQ4MwCEtAKowKrtwFq/jvfEH7nbHci7F92OxCTXaxnDmepS6pBBet6hnj5wvkHFVOyhi YTzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=POXigpl8APO9IUP53K10fp0GXszPMpqd75en0jJlNCI=; b=nk9lRTLCWAiTRm8HQvWNB7Te91lf+hbS9hOFH3lXMEU8VYSpomzTKir/WLpU6fPz+f Zbf8wjsQPk74DTah2F3CoE3kI0byEPOzblSXHyxcHJzLDfclsxJ6HmAPUbr9kbepBu9U ZBpESq42EgV0z2gwJgZJ/QQzLJaWBbhi+jQPwWPf/U82/phlr4/QdCuczk7zY0hTkgbw kjYxKphLEgE08tCe/D6WsShCa4IXPW6FurteEHVGo8ZLB6Gr9kWXbE85YnFxIfCRo4pn YUPN/PTmz8o5z4UvCNOkrUQuzIZG041hSOAX8GhAI7Az8Ix1vjXJFGHA2Bh14ug/TUE3 43QA== X-Gm-Message-State: ANoB5pmVaLJI0/0hXQVkkKQABJFkJBrdiGQmx1OzbX3McG66AyMgFFic nILxJIhDsk7mIWgoqmpB3u8= X-Received: by 2002:a17:90a:4605:b0:218:7dd7:ad4c with SMTP id w5-20020a17090a460500b002187dd7ad4cmr61548048pjg.224.1669797473202; Wed, 30 Nov 2022 00:37:53 -0800 (PST) Received: from localhost.localdomain ([2402:7500:486:4b30:18c:3eab:7c3:c142]) by smtp.gmail.com with ESMTPSA id c10-20020a056a00008a00b0057255b82bd1sm817583pfj.217.2022.11.30.00.37.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2022 00:37:52 -0800 (PST) From: cy_huang To: broonie@kernel.org Cc: lgirdwood@gmail.com, lee@kernel.org, matthias.bgg@gmail.com, yangyingliang@huawei.com, chiaen_wu@richtek.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, ChiYuan Huang Subject: [PATCH 2/2] regulator: mt6370: Switch to use dev_err_probe() helper Date: Wed, 30 Nov 2022 16:37:43 +0800 Message-Id: <1669797463-24887-2-git-send-email-u0084500@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1669797463-24887-1-git-send-email-u0084500@gmail.com> References: <1669797463-24887-1-git-send-email-u0084500@gmail.com> X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, 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 From: ChiYuan Huang Use dev_err_probe helper to simplify the probe function. Signed-off-by: ChiYuan Huang --- drivers/regulator/mt6370-regulator.c | 39 +++++++++++++----------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/regulator/mt6370-regulator.c b/drivers/regulator/mt6370-regulator.c index c2b589a..e090fbe 100644 --- a/drivers/regulator/mt6370-regulator.c +++ b/drivers/regulator/mt6370-regulator.c @@ -303,11 +303,9 @@ static int mt6370_regulator_irq_register(struct mt6370_priv *priv) ret = devm_request_threaded_irq(priv->dev, irq, NULL, mt6370_irqs[i].handler, 0, mt6370_irqs[i].name, rdev); - if (ret) { - dev_err(priv->dev, - "Failed to register (%d) interrupt\n", i); - return ret; - } + if (ret) + return dev_err_probe(priv->dev, ret, + "Failed to register (%d) interrupt\n", i); } return 0; @@ -329,20 +327,16 @@ static int mt6370_regualtor_register(struct mt6370_priv *priv) int i, ret; regulator_np = of_get_child_by_name(parent->of_node, "regulators"); - if (!regulator_np) { - dev_err(dev, "Could not find parent 'regulators' node\n"); - return -ENODEV; - } + if (!regulator_np) + return dev_err_probe(dev, -ENODEV, "Could not find parent 'regulators' node\n"); ret = of_regulator_match(dev, regulator_np, mt6370_regulator_match, ARRAY_SIZE(mt6370_regulator_match)); of_node_put(regulator_np); - if (ret < 0) { - dev_err(dev, "Error parsing regulator init data: %d\n", ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Error parsing regulator init data\n"); for (i = 0; i < MT6370_MAX_IDX; i++) { const struct regulator_desc *desc = mt6370_regulator_descs + i; @@ -355,17 +349,14 @@ static int mt6370_regualtor_register(struct mt6370_priv *priv) if (cfg.of_node && desc->of_parse_cb) { ret = desc->of_parse_cb(cfg.of_node, desc, &cfg); - if (ret) { - dev_err(dev, "Failed in of_parse_cb\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Failed in of_parse_cb\n"); } rdev = devm_regulator_register(dev, desc, &cfg); - if (IS_ERR(rdev)) { - dev_err(dev, "Failed to register (%d) regulator\n", i); - return PTR_ERR(rdev); - } + if (IS_ERR(rdev)) + return dev_err_probe(dev, PTR_ERR(rdev), + "Failed to register (%d) regulator\n", i); priv->rdev[i] = rdev; } @@ -385,10 +376,8 @@ static int mt6370_regulator_probe(struct platform_device *pdev) priv->dev = &pdev->dev; priv->regmap = dev_get_regmap(pdev->dev.parent, NULL); - if (!priv->regmap) { - dev_err(&pdev->dev, "Failed to init regmap\n"); - return -ENODEV; - } + if (!priv->regmap) + return dev_err_probe(&pdev->dev, -ENODEV, "Failed to init regmap\n"); ret = mt6370_regualtor_register(priv); if (ret) -- 2.7.4