From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bjorn Andersson Subject: Re: [PATCH v2 3/5] soc: qcom: smem: Support global partition Date: Wed, 4 Oct 2017 21:15:23 -0700 Message-ID: <20171005041523.GX1165@minitux> References: <1505424302-29147-1-git-send-email-clew@codeaurora.org> <1505424302-29147-4-git-send-email-clew@codeaurora.org> <20170915183334.GQ2016@tuxbook> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mail-pf0-f179.google.com ([209.85.192.179]:46197 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750761AbdJEEP1 (ORCPT ); Thu, 5 Oct 2017 00:15:27 -0400 Received: by mail-pf0-f179.google.com with SMTP id r68so7353732pfj.3 for ; Wed, 04 Oct 2017 21:15:27 -0700 (PDT) Content-Disposition: inline In-Reply-To: Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org To: Chris Lew Cc: andy.gross@linaro.org, david.brown@linaro.org, aneela@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org On Fri 15 Sep 14:02 PDT 2017, Chris Lew wrote: > > > On 9/15/2017 11:33 AM, Bjorn Andersson wrote: > > On Thu 14 Sep 14:25 PDT 2017, Chris Lew wrote: > > > > [..] > > > +static struct smem_ptable *qcom_smem_get_ptable(struct qcom_smem *smem) > > > { > > > - struct smem_partition_header *header; > > > - struct smem_ptable_entry *entry; > > > struct smem_ptable *ptable; > > > - unsigned remote_host; > > > - u32 version, host0, host1; > > > - int i; > > > + u32 version; > > > ptable = smem->regions[0].virt_base + smem->regions[0].size - SZ_4K; > > > if (memcmp(ptable->magic, SMEM_PTABLE_MAGIC, sizeof(ptable->magic))) > > > - return 0; > > > + return NULL; > > > version = le32_to_cpu(ptable->version); > > > if (version != 1) { > > > dev_err(smem->dev, > > > "Unsupported partition header version %d\n", version); > > > + return ERR_PTR(-EINVAL); > > > > In the calling places NULL and -EINVAL are both treated as -EINVAL, so I > > think it's better to just return NULL here as well as check for !ptable > > in callers. > > > > Regards, > > Bjorn > > > > qcom_smem_enumerate_partitions allowed the partition table to be optional > before. I want to keep that behavior for V11 where smem might only have the > global heap. The probe will continue with a NULL/0 return from > qcom_get_ptable/qcom_smem_enumerate_partitions. > You're right, I missed that detail. Which allows me to argue that I do not feel that testing with IS_ERR_OR_NULL() to let a 0 pass through to the caller is not obvious. I think it's better if you replace the NULL with ERR_PTR(-ENOENT), which you test and forward in both callers and then for the one caller where partitions are optional you check if ret < 0 && ret != -ENOENT. (Alternatively you check for NULL in enumerate_partitions() and return 0 with a nice comment saying that everything is okay) Regards, Bjorn