Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp762624pxb; Wed, 29 Sep 2021 09:10:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+UI0/fxDXLMNCrHGFTsUL9ONcK2T3arkMABX+76oa96nNfsxfvbmmgYZLhLA4NJ2XIw2h X-Received: by 2002:a17:90a:4681:: with SMTP id z1mr763946pjf.113.1632931831376; Wed, 29 Sep 2021 09:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632931831; cv=none; d=google.com; s=arc-20160816; b=ytNSOJu4SD0LF/2JanHVP3W+iVaNNHX17nIGcpPAeWRgOLgd61yLQ8Hi44gcOZ4YgN C++Vh3Wciggb6Vb68FzxZ79FazOpNSmunJeoOyrVlVxCmdt510AgiRzT5HHDFSX2V3M8 yaxZN6AUWFyag4W1ji68HJDKKKTeAhaCfc7LAeXELM+//hKdskLfMfn048FtXUCq6tIt 9L2rscITJ7wifhb/2ktlN+w7uugaMTXoZdMSSn70dOEN4sa5lxlYIWApymPPaDycWkrY NggmqBPOGWVeE3CLeicJk8pOQgj+HnxOVspAYbJrZJsy+iCUKd0XTioLShL6jM/13sRE XmWw== 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:subject:cc:to:from:date; bh=edG4LLZBq7MprCM0ICa1lWNDo3o1p7bI0Zw9ruhECw4=; b=BfrRtnWp5Jf5+fWl47TLlULmdZKI4GGjSetNeYGvO91lPAiiuXaE8K/DbstFHp1n8v zZIQx1Da2Pl6UQkEmWdJ8hBhsOBi+YN3+VUjSUgudMexRXU8eAndVPQKV5ox2kUvIpqr CaVnUBezDnU7+nmmWM/qJmt1Cku+ytROTN0qDhksHLnzk2EXlj2065Itfq1kEHDWEGdX VLHSohPm9Fzf6KbsohCZhUgUUX6MEKJiVrumagesismVhJPk+ewfsJy0xK0kXq0eECwO uhVsjnXo1L2Aq52XX2+MA22f5JcStcZyvihUO9lcguyTDSDpBxL/2veoX2N74DQ7Ihm6 pupQ== ARC-Authentication-Results: i=1; mx.google.com; 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 oa1si2741384pjb.180.2021.09.29.09.10.16; Wed, 29 Sep 2021 09:10:31 -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; 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 S1345672AbhI2QHC (ORCPT + 99 others); Wed, 29 Sep 2021 12:07:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:53752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346039AbhI2QFv (ORCPT ); Wed, 29 Sep 2021 12:05:51 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D3C3A61407; Wed, 29 Sep 2021 16:04:08 +0000 (UTC) Date: Wed, 29 Sep 2021 17:08:02 +0100 From: Jonathan Cameron To: Cai Huoqing Cc: Kevin Tsai , Lars-Peter Clausen , Linus Walleij , , Subject: Re: [PATCH v2 3/4] iio: light: gp2ap002: Make use of the helper function dev_err_probe() Message-ID: <20210929170802.1ab77b3a@jic23-huawei> In-Reply-To: <20210928014156.1491-3-caihuoqing@baidu.com> References: <20210928014156.1491-1-caihuoqing@baidu.com> <20210928014156.1491-3-caihuoqing@baidu.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Sep 2021 09:41:54 +0800 Cai Huoqing wrote: > When possible use dev_err_probe help to properly deal with the > PROBE_DEFER error, the benefit is that DEFER issue will be logged > in the devices_deferred debugfs file. > Using dev_err_probe() can reduce code size, and the error value > gets printed. > > Signed-off-by: Cai Huoqing There is an explicit return of -EPROBE_DEFER in here that we should probably also handle. https://elixir.bootlin.com/linux/latest/source/drivers/iio/light/gp2ap002.c#L508 I guess simplest option is return dev_err_probe(dev, -EPROBE_DEFER, "no ADC, deferring\n"); > --- > drivers/iio/light/gp2ap002.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c > index f960be7d4001..724a3928ead1 100644 > --- a/drivers/iio/light/gp2ap002.c > +++ b/drivers/iio/light/gp2ap002.c > @@ -521,15 +521,14 @@ static int gp2ap002_probe(struct i2c_client *client, > } > > gp2ap002->vdd = devm_regulator_get(dev, "vdd"); > - if (IS_ERR(gp2ap002->vdd)) { > - dev_err(dev, "failed to get VDD regulator\n"); > - return PTR_ERR(gp2ap002->vdd); > - } > + if (IS_ERR(gp2ap002->vdd)) > + return dev_err_probe(dev, PTR_ERR(gp2ap002->vdd), > + "failed to get VDD regulator\n"); > + > gp2ap002->vio = devm_regulator_get(dev, "vio"); > - if (IS_ERR(gp2ap002->vio)) { > - dev_err(dev, "failed to get VIO regulator\n"); > - return PTR_ERR(gp2ap002->vio); > - } > + if (IS_ERR(gp2ap002->vio)) > + return dev_err_probe(dev, PTR_ERR(gp2ap002->vio), > + "failed to get VIO regulator\n"); > > /* Operating voltage 2.4V .. 3.6V according to datasheet */ > ret = regulator_set_voltage(gp2ap002->vdd, 2400000, 3600000);