Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752011AbdDDCiN (ORCPT ); Mon, 3 Apr 2017 22:38:13 -0400 Received: from mout.gmx.net ([212.227.17.20]:58632 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751406AbdDDCiL (ORCPT ); Mon, 3 Apr 2017 22:38:11 -0400 Date: Tue, 4 Apr 2017 04:38:07 +0200 From: Jonathan =?utf-8?Q?Neusch=C3=A4fer?= To: Bjorn Andersson Cc: Jonathan Neusch?fer , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Andy Gross , David Brown , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] soc: qcom: smsm: Handle probe deferral Message-ID: <20170404023807.4ivn4pt4zv2bq4di@latitude> References: <20170315114357.14446-1-j.neuschaefer@gmx.net> <20170328061829.GI70446@Bjorns-MacBook-Pro-2.local> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fosh7oenpj3g2ctl" Content-Disposition: inline In-Reply-To: <20170328061829.GI70446@Bjorns-MacBook-Pro-2.local> User-Agent: NeoMutt/20170113 (1.7.2) X-Provags-ID: V03:K0:r4Pvf/zNHMz8mU8n0+7cFpFYCAmwyrJ5/4snso/8ZpqqeTvyyd7 f/Zhl681ayEEuaE50RT5p6+OUDMn6YBfk7tHCXbTnWdLP8Q6qrHcmWgRYitLdaTThgTavr6 gFf8lOYMi3XFsKKv8b/nGhHIoo0f0Bn/lXB6Cvo2jc2wb0z2ZNsDN3hPoyVI6bhBfynbyOr LaDX8Nnhag13Fbm6PKqRg== X-UI-Out-Filterresults: notjunk:1;V01:K0:X86VhvwJNak=:FB3GfwL2Cr2ZEA0B4IM9Tg QkI2wP/okddpqB1cDGL2ebD8qK1ratcCFnfPkhW640rS6t3YehqJKaJof2Ch1MZZZWwCcvO6Q MbP9Bi1o0DYd9j18Q0UcDvms5rgKato69zMQi6YeD5n5BoKLaHIIAPZuOqyO/nZpX+141WOj+ KV/dh8NVZaw7HvHtmOjY18aiWciJplKtMIfAFn8pqrpmI17wJa4vQQR7Y3WlFkEtC0rvGSSxu 35rQSE0jAHr0g1NlhvwEMqOFnBzLP54Nk8ftyl9Y3FFNUEPJo8SedSe1Q6RW8vZz/tC35He7u kPKUPr2PeCmZlEyTP3D61caXZ7U0wPw2ymYpge9hnvnpMX2bLBUlvUolw7YQOdxi2UYuuAkhv JcRDm1AIbdSa5HSDt7Hd80edsyWqoHirKO0oLQykI/xV++dcW7BYmPiZjTQkKqUcJ14/itdUX hb8l1thT9SqFDpFuxuHfH2YbAjHxcQ09afE0eOZINYyXaMuIHEltn4wCWLMmHkH9IrFkhwg/K OQUSnjwnldbCfVlGJv5uW8mDC9tTJMyhOZb73BUnHjoQkl4t66gJsgZbDdN9S/LEVRcdmdyb4 9SogY92WB6hUk/p46Du83Sugvm8efS1h0LSqwqXIVreQoGZw1GrTFQtfK8i7qsudREP6yiyts B9SbyqdqI+cN591HJF/83TzwvcSbDsI5ads5AZFmYMya/RdLl8CFyu4QnV897djklXjyV9F6y v/ZSELbeSTR4Koy8XKK+gXOGU/KCDL2+aP3R4y9+Ba1IAHDlxVTo/3wZjF8= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3673 Lines: 99 --fosh7oenpj3g2ctl Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 27, 2017 at 11:18:29PM -0700, Bjorn Andersson wrote: > On Wed 15 Mar 04:43 PDT 2017, Jonathan Neusch?fer wrote: [...] > > info =3D qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_SMSM_SIZE_INFO, &size= ); > > - if (PTR_ERR(info) =3D=3D -ENOENT || size !=3D sizeof(*info)) { > > + if (PTR_ERR(info) =3D=3D -EPROBE_DEFER) { > > + return PTR_ERR(info); > > + } else if (PTR_ERR(info) =3D=3D -ENOENT || size !=3D sizeof(*info)) { >=20 > The following elseif was supposed to take care of this case, but I > clearly screwed this up. >=20 > Rather than adding a special case for EPROBE_DEFER before the two checks > and then fix up the original expression to make errors fall back to the > original else, I think you should rearrange the conditionals. >=20 > Probably better to write it like this instead: >=20 > if (IS_ERR(info) && PTR_ERR(info) !=3D -ENOENT) { > if (PTR_ERR(info) !=3D -EPROBE_DEFER) > dev_err(smsm->dev, "unable to retrieve smsm size = info\n"); > return PTR_ERR(info); > } else if (IS_ERR(info) || size !=3D sizeof(*info)) { > dev_warn(smsm->dev, "no smsm size info, using defaults\n"= ); > smsm->num_entries =3D SMSM_DEFAULT_NUM_ENTRIES; > smsm->num_hosts =3D SMSM_DEFAULT_NUM_HOSTS; > return 0; > } Indeed, this looks better. And it also obsoletes my patch 2/2, which is nice. > > dev_warn(smsm->dev, "no smsm size info, using defaults\n"); > > smsm->num_entries =3D SMSM_DEFAULT_NUM_ENTRIES; > > smsm->num_hosts =3D SMSM_DEFAULT_NUM_HOSTS; > > @@ -515,7 +517,9 @@ static int qcom_smsm_probe(struct platform_device *= pdev) > > /* Acquire the main SMSM state vector */ > > ret =3D qcom_smem_alloc(QCOM_SMEM_HOST_ANY, SMEM_SMSM_SHARED_STATE, > > smsm->num_entries * sizeof(u32)); > > - if (ret < 0 && ret !=3D -EEXIST) { > > + if (ret =3D=3D -EPROBE_DEFER) { > > + return ret; > > + } else if (ret < 0 && ret !=3D -EEXIST) { >=20 > The idiomatic way to write this is: >=20 > if (ret < 0 && ret !=3D -EEXIST) { > if (ret !=3D -EPROBE_DEFER) > dev_err(); > return ret; > } >=20 > However, for us to reach this point in smsm_probe() the above > qcom_smem_get() must have returned successfully, i.e. we have SMEM in > place so there's no need to handle this case specifically. I came to the same conclusion but wasn't sure. I'll drop this part from my patch. I'll send a v2 of this series, although after applying your suggestions, I can't claim much originality anymore. Thanks for the review, Jonathan Neusch=C3=A4fer --fosh7oenpj3g2ctl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJY4wcHAAoJEAgwRJqO81/bzZgP/1AVrnoMpmeTj9r17941CZoC yy9al+zbVOt8mqGN7pIc+n6yOyyRDtL9/hozAUHe0gqTbgnzOt26cS8NbMxZieeJ zYG8JMxl/iXAnw5Jnk+XGQ37q66P927FYzpv41JYO0TLnlnA/xvNy7tjhDpm2qgI sANQ7xocNzoZvDwOGJRs8jegFCZGahkjaAXQqhNE26bX8pJLnBEpcxue7or2iCGU +zVk1Dkh1w3sN06cyJj1zYAb9/cmUux53JGIwuT9uh7jQDD1jGreFCpblIkLG13O LQzLX18odEBEwfC+EpNOHKzpZ7O+wL9x3Z5J+W2Y/ljqWpiCgG5gHrn8uhCMAEUV Oh8Tz+zXul6YL2AsVzWZ2Bfk2QG+o3JWqJVHQnZC64BAuYOhjtrUWgum0fgeybcc OCa5wT4bEqfcIsSYLXSU5cjbdQGRFqomylLWkYg4yGD76E04tNgMwpuvz74WLvFf 4VCI05/H6Bhthbbtq8TZc1Li3pGOAHKOXzYYrNlSBlJd5uOqMOcEAlBvzjtn/XR5 2P4a1LZ8qtXkG5aKDfC3CTbk773wHFmJDQK84S14fNNHkQ0FDqmHVLYaRw44lPzs 3/agpuN6soUWYa58H12rM3Q4cRzKkFPG+YRV3tZrXtcecp7/SLW6yxsSo1mVs6Rn ONPGuMvpxND0LPciGmaZ =yESW -----END PGP SIGNATURE----- --fosh7oenpj3g2ctl--