Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5031666ybv; Mon, 17 Feb 2020 10:47:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwjPcDZR7g7SgsPwFLljAtN/k/NDwLOKjVrsQFxR4HYwJOnIRxIlNiKg1q5hY+FRkp3vUfU X-Received: by 2002:a9d:6c58:: with SMTP id g24mr13832732otq.229.1581965232323; Mon, 17 Feb 2020 10:47:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581965232; cv=none; d=google.com; s=arc-20160816; b=lsdCdy+Rg4pjELEwMCaBW9yD3j7emaRqiPAMpSmm4PA4EMrxTEhGGO2vRhVSNnRkD2 xc7h+Gi7oNwJczD6Kul+MfUyTdVQdUMG/kpzAl2lnEwdSwG1VyIYNvozl9mwL9Cr2cQr Dk/Uy/R2sYdg1bZ52ancaRVv1O5BqIgfWOoBbXOi1kVW1VSoLTjxfx9U/ZV5qjfP94zP GhEMupcTnchArONJOEmNRKIn01X0zGZ9ohBvxljtPMFAPcHwigHOmxKpF9FPVZs4Hz9c ABZ5j1vpEP8gY7ZIeGduOfrFnY0L9PuoQlvgjaT5UB5aG5rtdm35JRjbPwIxgEkoa4+8 1KFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=FrQjJ8ihAd6vGkITrjAOakArT8nZi8aEb7RBIaL49hI=; b=pBBUA5f+AQew1gKB+mjmOQNNvBWgGzRtUxsqimTaKt5/m9Ut8xss7F4WDatNhmCe5m +hhXb7xQStA8/5UrsTKT0KEK/dJY/iSoM6w4XFq4OXMLp9+hfHdb+mcd78N0RrQTamgZ 9zDtOtAl1tbrCjUpWEaNzkFWO97m/zJ/Iy8v7QwdGfrXb1+zwiojfY+A6++3zMoyRZQI YAz+JjSV2Q1WqL4UpOXFy//8ZQ77J6IYUm+5jL8raKLX7YPGplkQp9rMnPbmKYEEDV7f GGP5mI8AcPeG5NzJ0cATdtHf6Zydfb/dijvbi2GeNSOZgAHS4E26EaLHvCwHCBf7y4gZ 0uvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@goldelico.com header.s=strato-dkim-0002 header.b="C/RUgW+l"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si7172328oih.186.2020.02.17.10.46.50; Mon, 17 Feb 2020 10:47:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@goldelico.com header.s=strato-dkim-0002 header.b="C/RUgW+l"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729479AbgBQSia (ORCPT + 99 others); Mon, 17 Feb 2020 13:38:30 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.23]:32424 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727601AbgBQSia (ORCPT ); Mon, 17 Feb 2020 13:38:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1581964705; s=strato-dkim-0002; d=goldelico.com; h=To:References:Message-Id:Cc:Date:In-Reply-To:From:Subject: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=FrQjJ8ihAd6vGkITrjAOakArT8nZi8aEb7RBIaL49hI=; b=C/RUgW+liIXAfAfCIm529v+jKked3nuE7PD3NF9M3TwOog2K4kdi5L7lty+eBiXoTJ LAM9zW31gWz6eQzZigYDA+z6P63yjLqBy12HuujvSC1qogMWy9zmRT/VW66eeGJlEMYW siR+NN108eqDrdHBLkWozSRDt4Bzjibgyw0SEgB1EYKufU0Re/vQDDtKB4yUbODSCPc5 XIRDK7jpxIs6Gn64BosL5lWMMvz9GLR0XqZnXXb9tBi3JH8qYJOuqJvewYdTr6osVRjP bRSgyUj5qL7vmhFCE7SK+T/TLLjLsePc2LacG55X4Mhmjw1FtfCre84S9NxmMLIU5fHp Id3Q== X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMgPgp8VKxflSZ1P34KBj5Qpw97WFDVCaXA0OXQ==" X-RZG-CLASS-ID: mo00 Received: from imac.fritz.box by smtp.strato.de (RZmta 46.1.12 DYNA|AUTH) with ESMTPSA id U06217w1HIcGPAL (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Mon, 17 Feb 2020 19:38:16 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: [PATCH v3] extcon: palmas: hide error messages if gpio returns -EPROBE_DEFER From: "H. Nikolaus Schaller" In-Reply-To: <20200217182906.GA140676@lenoch> Date: Mon, 17 Feb 2020 19:38:16 +0100 Cc: MyungJoo Ham , Chanwoo Choi , linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org, kernel@pyra-handheld.com, linux-omap@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <012228CC-2B49-4AAE-B574-92E44621F0D6@goldelico.com> References: <20200217182906.GA140676@lenoch> To: Ladislav Michl X-Mailer: Apple Mail (2.3124) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > Am 17.02.2020 um 19:29 schrieb Ladislav Michl : >=20 > On Mon, Feb 17, 2020 at 02:58:14PM +0100, H. Nikolaus Schaller wrote: >>=20 >>> Am 17.02.2020 um 14:38 schrieb H. Nikolaus Schaller = : >>>=20 >>> If the gpios are probed after this driver (e.g. if they >>> come from an i2c expander) there is no need to print an >>> error message. >>>=20 >>> Signed-off-by: H. Nikolaus Schaller >>> --- >>> drivers/extcon/extcon-palmas.c | 8 ++++++-- >>> 1 file changed, 6 insertions(+), 2 deletions(-) >>>=20 >>> diff --git a/drivers/extcon/extcon-palmas.c = b/drivers/extcon/extcon-palmas.c >>> index edc5016f46f1..cea58d0cb457 100644 >>> --- a/drivers/extcon/extcon-palmas.c >>> +++ b/drivers/extcon/extcon-palmas.c >>> @@ -205,14 +205,18 @@ static int palmas_usb_probe(struct = platform_device *pdev) >>>=20 >>> palmas_usb->id_gpiod =3D devm_gpiod_get_optional(&pdev->dev, = "id", >>> GPIOD_IN); >>> - if (IS_ERR(palmas_usb->id_gpiod)) { >>> + if (PTR_ERR(palmas_usb->id_gpiod) =3D=3D -EPROBE_DEFER) { >>> + return -EPROBE_DEFER; >>> + } else if (IS_ERR(palmas_usb->id_gpiod)) { >>=20 >> Hm. >>=20 >> While looking again at that: why do we need the "{" and "} else "? >>=20 >> It should be sufficient to have >>=20 >>> palmas_usb->id_gpiod =3D devm_gpiod_get_optional(&pdev->dev, = "id", >>> GPIOD_IN); >>> + if (PTR_ERR(palmas_usb->id_gpiod) =3D=3D -EPROBE_DEFER) >>> + return -EPROBE_DEFER; >>> if (IS_ERR(palmas_usb->id_gpiod)) { >>=20 >> What do you think is better coding style here? >=20 > How about something like this? (just an idea with some work left for = you ;-)) >=20 > --- a/drivers/extcon/extcon-palmas.c > +++ b/drivers/extcon/extcon-palmas.c > @@ -206,8 +206,10 @@ static int palmas_usb_probe(struct = platform_device *pdev) > palmas_usb->id_gpiod =3D devm_gpiod_get_optional(&pdev->dev, = "id", > GPIOD_IN); > if (IS_ERR(palmas_usb->id_gpiod)) { > - dev_err(&pdev->dev, "failed to get id gpio\n"); > - return PTR_ERR(palmas_usb->id_gpiod); > + status =3D PTR_ERR(palmas_usb->id_gpiod); > + if (status !=3D -EPROBE_DEFER) > + dev_err(&pdev->dev, "failed to get id gpio: = %d\n", status); > + return status; > } Well, what would be the improvement? It needs an additional variable and makes the change more complex. The main suggestion by Chanwoo Choi was to move the check for = EPROBE_DEFER outside of the IS_ERR() because checking this first and then for = EPROBE_DEFER is not necessary. If acceptable I'd prefer my last proposal. It just adds 2 LOC before and without touching the existing if (IS_ERR(...)). If the compiler is clever it can cache palmas_usb->id_gpiod in a = register which serves the same purpose as the status variable. >=20 > palmas_usb->vbus_gpiod =3D devm_gpiod_get_optional(&pdev->dev, = "vbus", BR and thanks, Nikolaus=