Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp183339pxa; Wed, 26 Aug 2020 07:58:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQU6BKB5IC7j2g8cclDDK/VhPbfpz2CayaHR3b5YIvAt9w7QvlJCr0GvuIpnD0TOGG87pQ X-Received: by 2002:a17:906:d282:: with SMTP id ay2mr15467397ejb.265.1598453935520; Wed, 26 Aug 2020 07:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598453935; cv=none; d=google.com; s=arc-20160816; b=uSP7733Hh8C6b6tX/k/wniYrqR/k4TPgTEBip5LaxawWrgqAkKbYBaBiR/Ehv3Iety 5KkrwjiwMywEvB54mLrg7JYI0gqJ6fdq28QnBj2ZVqZ71nxKvIZGx1ohf4+UEDy0hgoE SM/USXQgurt5oMknvBpSA9a2+2j10gizEKnIJDZgHFX4SFSIFdoyNRbVfDaIoOklBySn WIDaNdDOaToBzZfpKAOYC8ZgCm9ac4/XIe27Pson8UpsFQ4bp7qqgvg1HJJwKKwRvH32 RPMwJJV47BGgYFkHc3mmXiXRHb+unW8tialmZP/NeVhg4aAQKqPPP+A52qLBJWygSRSo 766Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature; bh=WpJJYZar/9CF0hv1FpNeIFdOcp1kvTqPrnjI++Gs4cA=; b=nqP2qpRGTpETt7Wb9+Z+R+0xm7eFrfTJO17ziFtOQEc7Z7nfsx50XxkMhPBpBFvE2O rcXBm12EsroovogIVENkWuJYhy//eSj2WyDjgC7t/DZ0OwRgjo6ND1olOYuOz8PJUwPC ZBvM0/E081uW17Z/ul6yz6c/LHMqhgmA5sM1qCCONGbZovwJAkBURmPXxdrpjmEZhEdQ NhV5qbk2p0p5vZEZhdqVQ/DyHIy/jPXM0cVdkA7M+i5p4FGE5dJYxx84OEHcWby8pxRJ gkpy2z09ujM9nix4h1RhdYpviOwEG3enW7ZkVrImPcltf7NrzO6kklSGPPhFl3RliEYN 8ZaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P2tzGz1P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oi22si1712125ejb.415.2020.08.26.07.58.32; Wed, 26 Aug 2020 07:58:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P2tzGz1P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728219AbgHZOxS (ORCPT + 99 others); Wed, 26 Aug 2020 10:53:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:39434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727769AbgHZOwr (ORCPT ); Wed, 26 Aug 2020 10:52:47 -0400 Received: from localhost.localdomain (unknown [194.230.155.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CC7DF22B3F; Wed, 26 Aug 2020 14:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598453566; bh=Y7G4DkYRnj4ZC6IYiwugOSDmIVV0GnhDCg89XlxnjaM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=P2tzGz1PbCoU4kS+sLpzj1slIGGJOedVGNQUHWnnySa0173mP0PIvh/lMi9P1HJ/U rbC4oZik38HRxpeaCleLq+P7EY0GBgxMi6DXrZ4ey/6PsgisG3H+8/LRdoy0Z17RUK ES9Hj0kUVggFLJd/pQkCSs2w+CPSvnLOAo0jd6OQ= From: Krzysztof Kozlowski To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Peter Rosin , Kukjin Kim , Krzysztof Kozlowski , Michael Hennerich , Kevin Hilman , Neil Armstrong , Jerome Brunet , Martin Blumenstingl , Marek Vasut , Maxime Coquelin , Alexandre Torgue , Beniamin Bia , Tomasz Duszynski , Linus Walleij , Jonathan Bakker , Alexandru Ardelean , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH 08/16] iio: adc: stm32: Simplify with dev_err_probe() Date: Wed, 26 Aug 2020 16:51:45 +0200 Message-Id: <20200826145153.10444-8-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200826145153.10444-1-krzk@kernel.org> References: <20200826145153.10444-1-krzk@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value. Signed-off-by: Krzysztof Kozlowski --- drivers/iio/adc/stm32-adc-core.c | 62 ++++++++++++------------------- drivers/iio/adc/stm32-adc.c | 10 ++--- drivers/iio/adc/stm32-dfsdm-adc.c | 10 ++--- 3 files changed, 30 insertions(+), 52 deletions(-) diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c index 0e2068ec068b..184d5491c7ed 100644 --- a/drivers/iio/adc/stm32-adc-core.c +++ b/drivers/iio/adc/stm32-adc-core.c @@ -582,11 +582,9 @@ static int stm32_adc_core_switches_probe(struct device *dev, priv->syscfg = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); if (IS_ERR(priv->syscfg)) { ret = PTR_ERR(priv->syscfg); - if (ret != -ENODEV) { - if (ret != -EPROBE_DEFER) - dev_err(dev, "Can't probe syscfg: %d\n", ret); - return ret; - } + if (ret != -ENODEV) + return dev_err_probe(dev, ret, "Can't probe syscfg\n"); + priv->syscfg = NULL; } @@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev, priv->booster = devm_regulator_get_optional(dev, "booster"); if (IS_ERR(priv->booster)) { ret = PTR_ERR(priv->booster); - if (ret != -ENODEV) { - if (ret != -EPROBE_DEFER) - dev_err(dev, "can't get booster %d\n", - ret); - return ret; - } + if (ret != -ENODEV) + dev_err_probe(dev, ret, "can't get booster\n"); + priv->booster = NULL; } } @@ -612,11 +607,10 @@ static int stm32_adc_core_switches_probe(struct device *dev, priv->vdd = devm_regulator_get_optional(dev, "vdd"); if (IS_ERR(priv->vdd)) { ret = PTR_ERR(priv->vdd); - if (ret != -ENODEV) { - if (ret != -EPROBE_DEFER) - dev_err(dev, "can't get vdd %d\n", ret); - return ret; - } + if (ret != -ENODEV) + return dev_err_probe(dev, ret, + "can't get vdd\n"); + priv->vdd = NULL; } } @@ -669,40 +663,32 @@ static int stm32_adc_probe(struct platform_device *pdev) priv->common.phys_base = res->start; priv->vdda = devm_regulator_get(&pdev->dev, "vdda"); - if (IS_ERR(priv->vdda)) { - ret = PTR_ERR(priv->vdda); - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, "vdda get failed, %d\n", ret); - return ret; - } + if (IS_ERR(priv->vdda)) + return dev_err_probe(&pdev->dev, PTR_ERR(priv->vdda), + "vdda get failed\n"); priv->vref = devm_regulator_get(&pdev->dev, "vref"); - if (IS_ERR(priv->vref)) { - ret = PTR_ERR(priv->vref); - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, "vref get failed, %d\n", ret); - return ret; - } + if (IS_ERR(priv->vref)) + return dev_err_probe(&pdev->dev, PTR_ERR(priv->vref), + "vref get failed\n"); priv->aclk = devm_clk_get(&pdev->dev, "adc"); if (IS_ERR(priv->aclk)) { ret = PTR_ERR(priv->aclk); - if (ret != -ENOENT) { - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, "Can't get 'adc' clock\n"); - return ret; - } + if (ret != -ENOENT) + return dev_err_probe(&pdev->dev, ret, + "Can't get 'adc' clock\n"); + priv->aclk = NULL; } priv->bclk = devm_clk_get(&pdev->dev, "bus"); if (IS_ERR(priv->bclk)) { ret = PTR_ERR(priv->bclk); - if (ret != -ENOENT) { - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, "Can't get 'bus' clock\n"); - return ret; - } + if (ret != -ENOENT) + return dev_err_probe(&pdev->dev, ret, + "Can't get 'bus' clock\n"); + priv->bclk = NULL; } diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 3eb9ebe8372f..b3f31f147347 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1805,13 +1805,9 @@ static int stm32_adc_dma_request(struct device *dev, struct iio_dev *indio_dev) adc->dma_chan = dma_request_chan(dev, "rx"); if (IS_ERR(adc->dma_chan)) { ret = PTR_ERR(adc->dma_chan); - if (ret != -ENODEV) { - if (ret != -EPROBE_DEFER) - dev_err(dev, - "DMA channel request failed with %d\n", - ret); - return ret; - } + if (ret != -ENODEV) + return dev_err_probe(dev, ret, + "DMA channel request failed with\n"); /* DMA is optional: fall back to IRQ mode */ adc->dma_chan = NULL; diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 5e10fb4f3704..c7e0109315f8 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -1473,13 +1473,9 @@ static int stm32_dfsdm_adc_init(struct device *dev, struct iio_dev *indio_dev) /* Optionally request DMA */ ret = stm32_dfsdm_dma_request(dev, indio_dev); if (ret) { - if (ret != -ENODEV) { - if (ret != -EPROBE_DEFER) - dev_err(dev, - "DMA channel request failed with %d\n", - ret); - return ret; - } + if (ret != -ENODEV) + return dev_err_probe(dev, ret, + "DMA channel request failed with\n"); dev_dbg(dev, "No DMA support\n"); return 0; -- 2.17.1