Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17321438ybl; Thu, 2 Jan 2020 03:13:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwihA1HBJxw5LngU12ZLbQ1uEHqUa3svDlNtpGcbgbNFspAoN0fr6S9Yp5H6dWa/k4yawnx X-Received: by 2002:a05:6830:1248:: with SMTP id s8mr90679138otp.202.1577963607452; Thu, 02 Jan 2020 03:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577963607; cv=none; d=google.com; s=arc-20160816; b=N61JC5EhojwcGDG8DwS1Ie4hzQD2WM9td7xxH5h1PgrPVU9jdenfIa1TBS4Fzt47Xb b7Sel2iHqg2+CRPT5LjJphozkCZf6b+qG48ckDL8HMsTRZ55wyBS/UV8D85HekTSUc/e bqrvYanv+tE+W6+yWZQmlsS1zp6DBnTKlq7uA7p8xOAKvDTZzi+sUvt9vFGQwnZ9Yccr qMjPCDbvzZl3sRTh4KtVhMviN0RfVf7oNJb84SOVR4GiAA+Gugk2qBrJxBYO36jNYFdj 5rDY+wOIE4OC+R3BlQJw6TcE948gQybJbcCDpcqeF9dSoV8WLyfBD0w6zxDIuGxIcHgb MrzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:user-agent:date :message-id:subject:autocrypt:openpgp:from:references:cc:to; bh=HaQRDvSYq+HtxksoRkRYSFFIwl9YZH3wEkPPUGTvvIU=; b=IGoA/bjxmdX+4W9L1dD7V8yATWvuqB3zn7VnNlo7JIIqPglIf9Q+qRtUQ1jZAvvyzt uSMC7YTxae+lXzP367J8qloqx4OT4O7v8Wudms9p3+f6jhc2FFi8aK4paAK4rx6RPjTZ i6+IhsCVVV91BAWnt4Je+72DLV3HESrT+wp4oUUlSlA6pWxYMzZFZfapOCnTbRaQ+Akr vmSBPbo7pF2DIB7rQsWwL4mDB17407OlWX74CqlA+5plvFI+9JkiTUlnyfAdK1PUgEYK SffIFT2LlEgVWi23k0Q7QccxKbcdig5wB0F6lpGd3CDChmHYREq0xOFhGvTeryAntVnv znKA== ARC-Authentication-Results: i=1; mx.google.com; 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 e73si28206546oib.145.2020.01.02.03.13.15; Thu, 02 Jan 2020 03:13:27 -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; 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 S1728167AbgABLMF (ORCPT + 99 others); Thu, 2 Jan 2020 06:12:05 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:44207 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728115AbgABLMF (ORCPT ); Thu, 2 Jan 2020 06:12:05 -0500 Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1imyOX-0006zL-2Q; Thu, 02 Jan 2020 12:12:01 +0100 Received: from [IPv6:2a03:f580:87bc:d400:c097:3b50:f886:b2e] (unknown [IPv6:2a03:f580:87bc:d400:c097:3b50:f886:b2e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mkl@blackshift.org", Issuer "StartCom Class 1 Client CA" (not verified)) (Authenticated sender: mkl@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id C1C5549A0B9; Thu, 2 Jan 2020 11:11:59 +0000 (UTC) To: Dan Murphy Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org References: <20191210163204.28225-1-dmurphy@ti.com> From: Marc Kleine-Budde Openpgp: preference=signencrypt Autocrypt: addr=mkl@pengutronix.de; prefer-encrypt=mutual; keydata= mQINBFFVq30BEACtnSvtXHoeHJxG6nRULcvlkW6RuNwHKmrqoksispp43X8+nwqIFYgb8UaX zu8T6kZP2wEIpM9RjEL3jdBjZNCsjSS6x1qzpc2+2ivjdiJsqeaagIgvy2JWy7vUa4/PyGfx QyUeXOxdj59DvLwAx8I6hOgeHx2X/ntKAMUxwawYfPZpP3gwTNKc27dJWSomOLgp+gbmOmgc 6U5KwhAxPTEb3CsT5RicsC+uQQFumdl5I6XS+pbeXZndXwnj5t84M+HEj7RN6bUfV2WZO/AB Xt5+qFkC/AVUcj/dcHvZwQJlGeZxoi4veCoOT2MYqfR0ax1MmN+LVRvKm29oSyD4Ts/97cbs XsZDRxnEG3z/7Winiv0ZanclA7v7CQwrzsbpCv+oj+zokGuKasofzKdpywkjAfSE1zTyF+8K nxBAmzwEqeQ3iKqBc3AcCseqSPX53mPqmwvNVS2GqBpnOfY7Mxr1AEmxdEcRYbhG6Xdn+ACq Dq0Db3A++3PhMSaOu125uIAIwMXRJIzCXYSqXo8NIeo9tobk0C/9w3fUfMTrBDtSviLHqlp8 eQEP8+TDSmRP/CwmFHv36jd+XGmBHzW5I7qw0OORRwNFYBeEuiOIgxAfjjbLGHh9SRwEqXAL kw+WVTwh0MN1k7I9/CDVlGvc3yIKS0sA+wudYiselXzgLuP5cQARAQABtCZNYXJjIEtsZWlu ZS1CdWRkZSA8bWtsQHBlbmd1dHJvbml4LmRlPokCVAQTAQoAPgIbAwIeAQIXgAULCQgHAwUV Cgk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kjDtP4lWKAn4tUcdcwMOT5d0I3q WATP4wFI8QktNBqF3VY47HFwF9PtNuOZIqeAquKezywUc5KqKdqEWCPx9pfLxBAh3GW2Zfjp lP6A5upKs2ktDZOC2HZXP4IJ1GTk8hnfS4ade8s9FNcwu9m3JlxcGKLPq5DnIbPVQI1UUR4F QyAqTtIdSpeFYbvH8D7pO4lxLSz2ZyBMk+aKKs6GL5MqEci8OcFW Subject: Re: [PATCH v2] can: tcan4x5x: Turn on the power before parsing the config Message-ID: <32ea95b2-25fe-8c26-cc90-9f9264e0d8f5@pengutronix.de> Date: Thu, 2 Jan 2020 12:11:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191210163204.28225-1-dmurphy@ti.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Di8rHTXB2rcggZJiDjV7RER7SlJVMpnFs" X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Di8rHTXB2rcggZJiDjV7RER7SlJVMpnFs Content-Type: multipart/mixed; boundary="q6xRA7IIHSCP9XlJg1YgufvurNBMMGnOB"; protected-headers="v1" From: Marc Kleine-Budde To: Dan Murphy Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Message-ID: <32ea95b2-25fe-8c26-cc90-9f9264e0d8f5@pengutronix.de> Subject: Re: [PATCH v2] can: tcan4x5x: Turn on the power before parsing the config References: <20191210163204.28225-1-dmurphy@ti.com> In-Reply-To: <20191210163204.28225-1-dmurphy@ti.com> --q6xRA7IIHSCP9XlJg1YgufvurNBMMGnOB Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable On 12/10/19 5:32 PM, Dan Murphy wrote: > The parse config function now performs action on the device either > reading or writing and a reset. If the regulator is managed it needs > to be turned on. So turn on the regulator if available if the parsing > fails then turn off the regulator. >=20 > Fixes: a5235f3c7c23 ("can: tcan45x: Make wake-up GPIO an optional GPIO"= ) > Signed-off-by: Dan Murphy > --- >=20 > v2 - Added error handling and moved regulator_get to probe >=20 > drivers/net/can/m_can/tcan4x5x.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) >=20 > diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/t= can4x5x.c > index 4e1789ea2bc3..ddf7db498241 100644 > --- a/drivers/net/can/m_can/tcan4x5x.c > +++ b/drivers/net/can/m_can/tcan4x5x.c > @@ -374,11 +374,6 @@ static int tcan4x5x_parse_config(struct m_can_clas= sdev *cdev) > if (IS_ERR(tcan4x5x->device_state_gpio)) > tcan4x5x->device_state_gpio =3D NULL; > =20 > - tcan4x5x->power =3D devm_regulator_get_optional(cdev->dev, > - "vsup"); > - if (PTR_ERR(tcan4x5x->power) =3D=3D -EPROBE_DEFER) > - return -EPROBE_DEFER; > - > return 0; > } > =20 > @@ -412,6 +407,12 @@ static int tcan4x5x_can_probe(struct spi_device *s= pi) > if (!priv) > return -ENOMEM; > =20 > + priv->power =3D devm_regulator_get_optional(&spi->dev, "vsup"); > + if (PTR_ERR(priv->power) =3D=3D -EPROBE_DEFER) > + return -EPROBE_DEFER; > + else > + priv->power =3D NULL; > + BTW: you are leaking the netdev allocated with m_can_class_allocate_dev()= =2E In order to fix this: - introduce a m_can_class_free_dev() function that calls the free_candev(). - fix error path in tcan4x5x_can_probe() and m_can_plat_probe() by adding the missing m_can_class_free_dev() - remove the free_candev() from the error path in m_can_class_register() it makes no sense that this function free a ressource it has not allocated - remove the free_candev() from m_can_class_unregister() it makes no sense that this function free a ressource it has not allocated - add needed m_can_class_free_dev() to tcan4x5x_can_remove() and m_can_plat_remove() Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | --q6xRA7IIHSCP9XlJg1YgufvurNBMMGnOB-- --Di8rHTXB2rcggZJiDjV7RER7SlJVMpnFs Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEmvEkXzgOfc881GuFWsYho5HknSAFAl4Nz/gACgkQWsYho5Hk nSCpKwf/ZHsmy0A40kM8GPLEqFNrKr1+0fshcdbJnyiDzKvAPXuix0GsWQ3vDCaJ WhfJLCKsUlNYokayw1MCv1jRj20QfkjXLeVnf8ygr8uU+BSgFCk76+8ZUpi0iqOh 6329aYUA6W0+aJ57D9wr1SfcmOMF9CWIXTpfX7fKLbjpa0S3FTwIgubYDeX1t3hT XA82dejocKG8pTzWnPEjZqTqKQ2MKFzphdwRB2Skvfmoe9Ke3IS98h/BKw6ciosz dAJ5RBidNUao6NFVqj4IBJSlBFYtuPj9TAn7p0uNXxCUNYa5Mnfqc4MFIgGxkEKx rrsHl3tnEfSNRr0+J5kt+ltf9ZbFaw== =/g3H -----END PGP SIGNATURE----- --Di8rHTXB2rcggZJiDjV7RER7SlJVMpnFs--