From patchwork Thu Apr 6 17:18:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 80365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1192085vqo; Thu, 6 Apr 2023 10:33:13 -0700 (PDT) X-Google-Smtp-Source: AKy350bSvrV03xpJOungePB4DsMNwW9k2k41+d9Xbs3L/o3GcuCi2RFLcJQmgoA814SUpktrsSra X-Received: by 2002:a62:6204:0:b0:625:d697:c386 with SMTP id w4-20020a626204000000b00625d697c386mr9162868pfb.22.1680802392821; Thu, 06 Apr 2023 10:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680802392; cv=none; d=google.com; s=arc-20160816; b=Us/7mHdYwMT+LJBLNYDKnF7kuTBNgtD3OxDQ3Zeby4f/z+o+2oWGGmVHZqR1ul5KWA dk/ht5iRCEJQvjsl43R6sTBnuEHCxL3l7LDyMh2/ewoPAjLP8bwF+s35nCswyGR5hzZT LQFR4PT4JXXJpk5ObBPZQm22lIkCT2kx6rrMpts0Rj7Qv2NTeOiDQ4iCWw3oy48pejhI E3oafX8chL4lgYYEvNFxMaz+7liVDs6YZfsCsuE/95UyktxkoY2CmPBM48tIdaVSVXE9 CzVXXtwJXt5trCXCTdeJzS5xjniRVnCYogXVOP/HeC0DtVu7JprWoJ+q4cRMThw/KL35 4SYw== 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=owMfJJPjS3qS4kf7elOgBC4wXKOfzDV9djsdHrs9gVB3PM0SYtdtgm98jUoFRXGYeg RROFHIBB2Kl0EafQBgtc/9lw453s4Zt1mQp2SwOaxVolRCspmKtgGkrFcSLzlUdIGlKJ V8GMKXSvitPZ9SohJHOv2MqLdUIOAfDRd5gbAycufcQlPzoS1dIZFMY61Phlg3bEFuHI 3BuDxjlMO59x2coX7MmFpScAoz0OZWKT9Cx4rTSY80EfdQee9sqAeSL25hVn5EXR8xla gxjwhB2rd1dMzebfDeB6GHzkCBeEzSFHZOTUEOma3xdsoMkNhVJO7rJCS2JbgZfnPCum 1t9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dgYIHtmW; 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 e26-20020a65689a000000b0050fa5891fc1si1712501pgt.551.2023.04.06.10.33.00; Thu, 06 Apr 2023 10:33:12 -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=dgYIHtmW; 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 S240005AbjDFRTI (ORCPT + 99 others); Thu, 6 Apr 2023 13:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239466AbjDFRSt (ORCPT ); Thu, 6 Apr 2023 13:18:49 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2045E9EE0; Thu, 6 Apr 2023 10:18:34 -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 6F06F66031DA; Thu, 6 Apr 2023 18:18:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680801512; bh=aW4fe1+DDo3cV0bZP+53AoiJSFgqHyfIP7z13IHIZi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dgYIHtmW20viYgzAuiHT2LtpL7/xhPrk9vZfBJ6ZPdokPx8xMx2lEgXqQ6Uy2/Rus UfUs7WwxyeGsmIMfSFIOQyiW2elF8SAiY24KIClzUYtMVhUZRkek5ygB0HRFyvVDV1 KCVDJbUGH9Hby0yvgHvK5WTYut9vfw/nee9HT+95o54kM2oufz7pPdFVr0gbPxqpXO Hlf9bZHlERlaBzTNGjnTxYmVm182bVqFZZssWwDbB2fmMO4mdIAK2p/GLnO5XgffFC MEKtFsRjLQjUAY/pvTb7sr7hrb5IoBFg+S+i7kacYnUf783tXiPbRqXdRJPeG556sN nRwEAFa8bWO6A== 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 v2 7/8] regulator: fan53555: Use dev_err_probe Date: Thu, 6 Apr 2023 20:18:05 +0300 Message-Id: <20230406171806.948290-8-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230406171806.948290-1-cristian.ciocaltea@collabora.com> References: <20230406171806.948290-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?1762449049822659938?= X-GMAIL-MSGID: =?utf-8?q?1762449049822659938?= 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[] = {