From patchwork Thu Apr 6 19:41:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 80429 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1273548vqo; Thu, 6 Apr 2023 13:08:55 -0700 (PDT) X-Google-Smtp-Source: AKy350YRo52UEjV3pPcYBXPNyWsDlvx++zYKH4y5gCuw4573aRRvvk7MlHtYj32fgVw2AK/2jMmR X-Received: by 2002:a05:6a20:b729:b0:da:4e05:768 with SMTP id fg41-20020a056a20b72900b000da4e050768mr582866pzb.38.1680811735215; Thu, 06 Apr 2023 13:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680811735; cv=none; d=google.com; s=arc-20160816; b=r3o/sb1PL9Wzb9BVy9oPLZzAnCkmU8+gm2uzQLlHbtw9WkfMtDmGrTU85Z+xdYN7TO UfSDycilR4Tl0Y6JlGUDFS3jZiqRt4gZPYBeL/R4sjWsuVrsiCnqaK4Yc7c7wYRRex1V M7/61T+n+suSwY76R8vjTAjA4RMtZEcb8Cz/ZUu3TYpzSlTqs4LtH9sCgmmx++P5ScrB uJ5oy80c7KXi8XHZvshmrndrUHoFY/RF1aGsDrQ5skXrCsBJyq8iUk2FlD/D+ZFK4cJO QjW2RPbXIV9QXl6V0sf9l9HUGKqY3eE2VLq7o2Yeo20PefcuTjkohNgaUuIJkYZI6I77 SnLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=icEeTUkukgMzfs5qelAig8rLR7lBbSi5G7d6Jn1tzIk=; b=CSsiK7M3MgKjQd9990MsHhDao4CZnlHYMINjAtu1oWjGnuVx8J+HqahN96BbH7iia+ Sndqo4eRJd9MOOvz6YsD0EQnz6U0UaKSGfjhs93NQPp5QnRwpd+NftwMS76EyZJDeSCq iflXcOyryu935tZKoIMCVFiaaq0KGmLzWmlTwr4R4tQPJmhQQGGxpZptC1im+1hILYAX isYmf7H9hbjLSte7978etZbJugHB27vYY9yDvskPI4flrsnkudot4bn2ua4lYf8wlh8c Gb6jJAo2iFZ496SXwPsL+fRJqhk9/tw9/Dwh49VnKQZRl9pnzWL/3bW47nhJmVy+nMA8 4rzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=aEHJyh2X; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d28-20020a630e1c000000b005138c1f1fcdsi1817313pgl.663.2023.04.06.13.08.42; Thu, 06 Apr 2023 13:08:55 -0700 (PDT) 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=@collabora.com header.s=mail header.b=aEHJyh2X; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237914AbjDFTmu (ORCPT + 99 others); Thu, 6 Apr 2023 15:42:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237881AbjDFTmf (ORCPT ); Thu, 6 Apr 2023 15:42:35 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6CA39747; Thu, 6 Apr 2023 12:42:24 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 5E70F66031CF; Thu, 6 Apr 2023 20:42:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680810143; bh=aW4fe1+DDo3cV0bZP+53AoiJSFgqHyfIP7z13IHIZi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aEHJyh2X1YhOg4vQKdBRIVPbQn8OBAJuEP3l1Iqrt6aX9fw7XYha1LnPXjg1Y3xMt zZwhhnDiZQM9phbDAtQEIEU4gvY3faGu6uR6zkhVn80soUn8dVf+Uy8uO45FRMAi5S VeOV/hTHD41F8ibJRNumKBIqbLICGj08djW58vqkLeiNWZ66lgVAfR/UbVBzZFL3vF tIRteF2by+S7azDg/t1pXjalQsWjA3dmNkan7AzL7p5Vp3Q34jyJvRTnL+X/f8ciUV oCz+P+4GhoF4TxalYYjoJV+EKEg0boZ9WEeZU1ikmM7ZQEGd0pSVnItkMhdRCAhGDr cDxqG7J21FlRA== From: Cristian Ciocaltea To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Bjorn Andersson , Joseph Chen , Ezequiel Garcia Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kernel@collabora.com Subject: [PATCH v3 7/8] regulator: fan53555: Use dev_err_probe Date: Thu, 6 Apr 2023 22:41:57 +0300 Message-Id: <20230406194158.963352-8-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230406194158.963352-1-cristian.ciocaltea@collabora.com> References: <20230406194158.963352-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1762458846105016188?= X-GMAIL-MSGID: =?utf-8?q?1762458846105016188?= Use dev_err_probe() instead of dev_err() in the probe function, which ensures the error code is always printed and, additionally, simplifies the code a bit. Signed-off-by: Cristian Ciocaltea --- drivers/regulator/fan53555.c | 47 ++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index 39c9c29f4ff6..acf14ba7aaa6 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c @@ -568,10 +568,9 @@ static int fan53555_regulator_probe(struct i2c_client *client) if (!pdata) pdata = fan53555_parse_dt(&client->dev, np, &di->desc); - if (!pdata || !pdata->regulator) { - dev_err(&client->dev, "Platform data not found!\n"); - return -ENODEV; - } + if (!pdata || !pdata->regulator) + return dev_err_probe(&client->dev, -ENODEV, + "Platform data not found!\n"); di->regulator = pdata->regulator; if (client->dev.of_node) { @@ -580,10 +579,9 @@ static int fan53555_regulator_probe(struct i2c_client *client) } else { /* if no ramp constraint set, get the pdata ramp_delay */ if (!di->regulator->constraints.ramp_delay) { - if (pdata->slew_rate >= ARRAY_SIZE(slew_rates)) { - dev_err(&client->dev, "Invalid slew_rate\n"); - return -EINVAL; - } + if (pdata->slew_rate >= ARRAY_SIZE(slew_rates)) + return dev_err_probe(&client->dev, -EINVAL, + "Invalid slew_rate\n"); di->regulator->constraints.ramp_delay = slew_rates[pdata->slew_rate]; @@ -593,34 +591,31 @@ static int fan53555_regulator_probe(struct i2c_client *client) } regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config); - if (IS_ERR(regmap)) { - dev_err(&client->dev, "Failed to allocate regmap!\n"); - return PTR_ERR(regmap); - } + if (IS_ERR(regmap)) + return dev_err_probe(&client->dev, PTR_ERR(regmap), + "Failed to allocate regmap!\n"); + di->dev = &client->dev; i2c_set_clientdata(client, di); /* Get chip ID */ ret = regmap_read(regmap, FAN53555_ID1, &val); - if (ret < 0) { - dev_err(&client->dev, "Failed to get chip ID!\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(&client->dev, ret, "Failed to get chip ID!\n"); + di->chip_id = val & DIE_ID; /* Get chip revision */ ret = regmap_read(regmap, FAN53555_ID2, &val); - if (ret < 0) { - dev_err(&client->dev, "Failed to get chip Rev!\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(&client->dev, ret, "Failed to get chip Rev!\n"); + di->chip_rev = val & DIE_REV; dev_info(&client->dev, "FAN53555 Option[%d] Rev[%d] Detected!\n", di->chip_id, di->chip_rev); /* Device init */ ret = fan53555_device_setup(di, pdata); - if (ret < 0) { - dev_err(&client->dev, "Failed to setup device!\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(&client->dev, ret, "Failed to setup device!\n"); + /* Register regulator */ config.dev = di->dev; config.init_data = di->regulator; @@ -630,9 +625,9 @@ static int fan53555_regulator_probe(struct i2c_client *client) ret = fan53555_regulator_register(di, &config); if (ret < 0) - dev_err(&client->dev, "Failed to register regulator!\n"); - return ret; + dev_err_probe(&client->dev, ret, "Failed to register regulator!\n"); + return ret; } static const struct i2c_device_id fan53555_id[] = {