From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan =?utf-8?Q?Neusch=C3=A4fer?= Subject: Re: [PATCH 1/2] soc: qcom: smsm: Handle probe deferral Date: Tue, 4 Apr 2017 04:38:07 +0200 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" Return-path: 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 Content-Disposition: inline In-Reply-To: <20170328061829.GI70446@Bjorns-MacBook-Pro-2.local> Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org 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 --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--