Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp928208imm; Fri, 12 Oct 2018 08:55:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV62RwWwGq3RsbnP0wwBinWFZft+/y7nM7yBKJtYRMhoYx7AvH0T0QTmXZdi8usSvuphioj+s X-Received: by 2002:a62:7f8c:: with SMTP id a134-v6mr6545428pfd.257.1539359742057; Fri, 12 Oct 2018 08:55:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539359742; cv=none; d=google.com; s=arc-20160816; b=z5W085eI5PCz0ZG+BVAnaTZWqs7PbTrPRjyYb0VOeLcqa+OhMMVhFUcH6pYdduh4Rr p9TGxdgJ9r3AKOCqOL8y0LbP58J2e0qfzr84d9/8HsLvQ2b27cihKsbfgF7E/bbjP4AR Wc6loN7UiGpOzPFAhXCKIelujpL1KJKGwrXq64LelxoBkfarz/a3dpiXBDb+RF4/jpd0 SZHe54J9MD85RepGCjXhERqF+FkkcVJt/3skVBxzPjJYF3LdD5V/jmIZG3KsBDIhkqjE +/j5nBCNRFURyiqY2L7ZvocKZjeCzfN4RYJ7ihV3PxmjXG09boWrMTNCe2JutwOwj1oD Jrlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=LWPququgLQedysvFjpGLXmRRGXchcNwQRM0ixGjmZWs=; b=uNilZqbeC6CkiE0GAQ3wMKzEK9KgjagH8wYxJ6TZBixoFpreGReKn1OgbZM2CgaApW WEebdigSzDalw/2BPQcIHL89FRcUasTi/TKoaZqu4IBbyBLtgAaIOgMMuCb9nsmswvYG a7+3vD9UWEVM18du4krczvxj9tr512Tg6NPVhZV+Rpu/wbMUDmDyMEcL7UYY0EP7O/Xh EVtJmNLO+Q1jwtjZFqAwm+X5ag2XHjMK84uyYPoaQy3GWF4VfDnIZrFbNaj/0sNzPaJw wS9MbXlgkPOsthSJMnHnlkPjZffmO+VsmLBtqLC7fAXJzrr1a+umy+fIeQbS6ixjNTQu pdVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tohXJscs; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u4-v6si1506200pgi.554.2018.10.12.08.55.26; Fri, 12 Oct 2018 08:55:42 -0700 (PDT) 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=pass header.i=@gmail.com header.s=20161025 header.b=tohXJscs; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729196AbeJLX2K (ORCPT + 99 others); Fri, 12 Oct 2018 19:28:10 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37738 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728884AbeJLX2K (ORCPT ); Fri, 12 Oct 2018 19:28:10 -0400 Received: by mail-wr1-f66.google.com with SMTP id y11-v6so13961788wrd.4; Fri, 12 Oct 2018 08:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=LWPququgLQedysvFjpGLXmRRGXchcNwQRM0ixGjmZWs=; b=tohXJscsp+neT2UJsotVhkA9fEkTw7aX42y9wl+X+Zn/dPHKH7i/xRGDxAaU+vcR65 eAGIR8AbkVPgO9qWtVki4S1G0VU6zKfkGfh2azu+lMwQnxbF2RWT2H2gH7hgBVMdX22M WQDeaW0ZKbBUouICpVaA1WCSPq0p3UHHsRV1ouGsdqyEbVG/ozfV2aWMg++z08xxBU+y eXjEvAG2qfXyFtU2KiqER4gRzTIOa+eLoNP2V/FSKw7iNeyirMlWtFHiz+JzK6J3ax6h CfhK9SDfrA5GepI9jQdAy3946pumsjeMsVqGpon8kH3hfc1T8KPme06f8MJHrePQJICV ipOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=LWPququgLQedysvFjpGLXmRRGXchcNwQRM0ixGjmZWs=; b=TF9DEb8HR8Ch6duxXvI1/jbiWJRl6mGfWguMSrUvd4TEjvgDfoe7fLvFC6ArRQ3uZ/ aF2O9+xymb5mh/FlEsEOSAYhZTuiTP0LCoMAGCy3cwnOh7F0tApx5Q7ompO4/3rNEqPU 7z0QpCRd2/xWi0kk5sjBKuX5yhoYIJHAeH9fG7Z5xPZk+vGeENcEv4ORHGETq+MiyHEV bA1Eo1MhNLNo8h042EY/wex+mgxOKNhyalZUQnK3ROF304gfOdb7iIoP+RoXDdNJKVF6 Tvb+5nVcE6lCZgEKV3z/CY2LCOnFpwJw1WEpGVWKGjH+bwoP9kuh4LdqJZMDhxp+NuOd twqg== X-Gm-Message-State: ABuFfohHuL6bf5XczhmUfgnSgZNnrHCU2iDD3zQuT7UcAq8XJeizsZxv ukaqNPiWr2qfGHczACdguj8= X-Received: by 2002:adf:b593:: with SMTP id c19-v6mr6129951wre.223.1539359701706; Fri, 12 Oct 2018 08:55:01 -0700 (PDT) Received: from localhost (p2E5BEEEA.dip0.t-ipconnect.de. [46.91.238.234]) by smtp.gmail.com with ESMTPSA id m16-v6sm1660458wmd.35.2018.10.12.08.55.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Oct 2018 08:55:00 -0700 (PDT) Date: Fri, 12 Oct 2018 17:54:59 +0200 From: Thierry Reding To: =?utf-8?B?Vm9rw6HEjQ==?= Michal Cc: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , Rob Herring , Mark Rutland , "devicetree@vger.kernel.org" , "linux-pwm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Lukasz Majewski , Fabio Estevam , Lothar =?utf-8?Q?Wa=C3=9Fmann?= , "kernel@pengutronix.de" Subject: Re: =?utf-8?B?W1JDRsKgUEFUQ0gsdjIsMi8y?= =?utf-8?Q?=5D?= pwm: imx: Configure output to GPIO in disabled state Message-ID: <20181012155459.GG31561@ulmo> References: <1539163920-9442-3-git-send-email-michal.vokac@ysoft.com> <20181012085720.GA9451@taurus.defre.kleine-koenig.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Cgrdyab2wu3Akvjd" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Cgrdyab2wu3Akvjd Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 12, 2018 at 03:04:48PM +0000, Vok=C3=A1=C4=8D Michal wrote: > On 12.10.2018 10:57, Uwe Kleine-K=C3=B6nig wrote: > > On Wed, Oct 10, 2018 at 09:33:26AM +0000, Vok=C3=A1=C4=8D Michal wrote: [...] > >> +static int imx_pwm_init_pinctrl_info(struct imx_chip *imx_chip, > >> + struct platform_device *pdev) > >> +{ > >> + imx_chip->pinctrl =3D devm_pinctrl_get(&pdev->dev); > >> + if (!imx_chip->pinctrl || IS_ERR(imx_chip->pinctrl)) { > >> + dev_info(&pdev->dev, "can not get pinctrl\n"); > >> + return PTR_ERR(imx_chip->pinctrl); > >> + } > >> + > >> + imx_chip->pinctrl_pins_pwm =3D pinctrl_lookup_state(imx_chip->pinctr= l, > >> + "pwm"); > >> + imx_chip->pinctrl_pins_gpio =3D pinctrl_lookup_state(imx_chip->pinct= rl, > >> + "gpio"); > >> + imx_chip->pwm_gpiod =3D devm_gpiod_get_optional(&pdev->dev, "pwm", > >> + GPIOD_IN); > >> + > >> + if (PTR_ERR(imx_chip->pwm_gpiod) =3D=3D -EPROBE_DEFER) { > >=20 > > You must not use PTR_ERR on a value that might not contain an error > > pointer. >=20 > OK, thank you for valuable info. > So it seems like the I2C folks are in troubles as well: >=20 > https://elixir.bootlin.com/linux/latest/source/drivers/i2c/busses/i2c-im= x.c#L996 There's nothing inherently wrong with doing it like the above, just maybe slightly unusual. PTR_ERR() is really just casting from a pointer to an integer, so if the pointer happens to contain the value -EPROBE_DEFER, then the above will be true. If it contains a valid pointer, the above will be false, so it does exactly what you want. Perhaps a more idiomatic way to write this would be: if (IS_ERR(imx_chip->pwm_gpiod)) { if (PTR_ERR(imx_chip->pwm_gpiod) =3D=3D -EPROBE_DEFER) return -EPROBE_DEFER; } But that's not much clearer than what you have, so feel free to keep it that way. Thierry --Cgrdyab2wu3Akvjd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAlvAw88ACgkQ3SOs138+ s6GXsw//ZQtbpCz6HK0hGZvNAC+fn9QWEcg3hHDpDjDkDXJSvkbmcb0DicppwFE7 DRJcqK6M1bMI3JwZBUlrg2V3o3365DBXr+ojnTt7v1nKNhzG7+FIvL4ke6mxaiC9 NlpCqTZcD8rHxkRmT+fv5x38dIUOZJt85himbtGtO4F7uetHe5qrSRCxtbPjaeb/ Wv2lsGsaPtfTUTjO+XuoBnfpsmNrfm/iM2hJaw/YJgPk0u/roCvS2sIWcy2ldYUd loTNjQAvPMYmQNyraEs+6cfiz0NuukN2Z16KBppbInxtLmyWqUmDMdegVzOliAWd m0KGiSBykCkv0HeTEtvFcQwVYpvnY2NJATu06o3NvlsAabLK5O6ZEBUHu81DCo5w NWY85+kFu+99prTYD9zJGUOaGFAPHI6jTN3bIvKG2yL7vKugqkvlAdt8+7CnalRS 7+HP+3wP22ejckc36PbT0Uiit3IiNWb+E5tkZ/CgfT+V6bCSRnG6J/IGexi7QKbi RNIIBqrjaremE9vWtJ3jjwJIMTSwHndoOM56GoYyCNk2URoUkjuZWt47NmI78R7f /7KtZrxYH63wQOqdstOW6WMDRJefG5XHnpubPTXplNEYSaByTkeMJJwK/SBazcDS a2bnidG/OjnWqy8ayJkgsacoN32FNNJAf9s9PMAHLQwt/wyIFY4= =A30V -----END PGP SIGNATURE----- --Cgrdyab2wu3Akvjd--