Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp375506imu; Fri, 11 Jan 2019 01:55:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN7cwIk0l2kWSOfU5+lwAzKhFJMDdFmBqaVYj7tPHtxI8ptxEqbR8nH6M+hBa8fNDtfvbdX3 X-Received: by 2002:a62:15d5:: with SMTP id 204mr14042283pfv.103.1547200515872; Fri, 11 Jan 2019 01:55:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547200515; cv=none; d=google.com; s=arc-20160816; b=mYddRC7ca7e9XHNUKekJKgdcm+XAINXCnszZuJOO5SqUtqo8LaUMb/J7/mOhJ0ZWwt teXnhp5+yoVhTf3V1aArURyskCg8eFQ8hIhQDD7MzO4EfoQfi00srem4jT/2a17C2yJD tv4+b6UvanCFetzK7rrOoOU99CMRvPPaYjXp5pH91GodqCNPFUKcl42fD39lcx3D8iVZ LU/gdBR8UesTrWuSaVzVNkNtkIBPwxkRrCEILJLCc8PonbFK1WwDVI7inFu6BAdknffW jbgYFjZ34rtaSIq/SctbkxM9Z34jwQdWUzgRs/zC2CGG/huLXLHkMuBNYwG97CXgmHwn YUzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6TXYG0bRygv37lt/cmIuFfZcnUSM355T9n2ZJXUOXPE=; b=E3u87KldPpRdcCnmGpnwKDTVJ5UWJD4m0HaNrAw7nohxDgJncRU5Lxcrqqas8lvy8c NkZCqD4eML9DaEaIh0dQDL4oM5bwWvVIHMdAoVak+5jF9hluOiAWZUkSjzlj9x2NaJe+ pZY1QE8yU53MjVHqA57q6eXhxW9FB/TwLaUV7gW4THvDags3ezQLLhobmwD4abtmslaj MNUPzqO9hoTnq9S5PAS8vj4LxWaiQ/65WpjNO/7MymN3X2N8jlEaaw+SaRj6WVKhD5kQ sM7o/yi56VwblbJA+iDQj4MEA+BfrzO5jXSoAfl9xgciLDDFOX89BIofJQh3j65CmDSs jpTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=auggXh3e; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si72680263pgj.34.2019.01.11.01.55.00; Fri, 11 Jan 2019 01:55:15 -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; dkim=pass header.i=@linaro.org header.s=google header.b=auggXh3e; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730832AbfAKJwD (ORCPT + 99 others); Fri, 11 Jan 2019 04:52:03 -0500 Received: from mail-vs1-f68.google.com ([209.85.217.68]:39024 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbfAKJwD (ORCPT ); Fri, 11 Jan 2019 04:52:03 -0500 Received: by mail-vs1-f68.google.com with SMTP id h78so8848543vsi.6 for ; Fri, 11 Jan 2019 01:52:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6TXYG0bRygv37lt/cmIuFfZcnUSM355T9n2ZJXUOXPE=; b=auggXh3eSLNCvw2+OMx6WOeqof/9eRBvDRe3sNrVnKSytLC0n6jddw1GRRW8kAJCfQ L1Ci0N/vlIQYbtnCKmcNG5j3YLRFH2ImiXEaRx5OfQIM0yezxdHi/J52vsbCNtAuMB9b eZVb5nz9KMlhsBXCglVo/6kBsUM2tESEqqyzk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6TXYG0bRygv37lt/cmIuFfZcnUSM355T9n2ZJXUOXPE=; b=nsjy+x4WuNfeZhakCTYtqAA6X6xVuaVdeKN/gA7GhONCle/O7EQwBV+tm42h+jz4y3 CrSi/qYLzyZLMOCT4lTeZ1hxpK1iK25JnvAXgeKdZwPNpZh2azFwlIoUoQlhh08tfMNE nMIfizGS0X+aTV8rDYweWlTuDKefbTgbkdb2Dgks/obY9p6/6jT5qSHzGuLF1iDs3HCZ brxIpZy0bWK2S6x4YaIkDm+eDqoH8a6V6cg6cke8iOHx71cm6sQqVAnd76DnLaDdnnj4 9UOS42JgdhZCWZ8eMtUpd8mpekPygBorn0vCGgRly3vu7kWK1rlLboBwSByI0iPpXShM TIag== X-Gm-Message-State: AJcUukcDMZQlUceKYWvuu8IhcEsIBVbHyn7JtDhaZZww0dCaJkLAESBp 5Ndj1EXowdvc94RSieWUfQKk4LaV9tKMLFRv2Gww1Q== X-Received: by 2002:a67:2045:: with SMTP id g66mr5711533vsg.180.1547200321471; Fri, 11 Jan 2019 01:52:01 -0800 (PST) MIME-Version: 1.0 References: <1547123097-16431-1-git-send-email-sumit.garg@linaro.org> <1547123097-16431-3-git-send-email-sumit.garg@linaro.org> <20190110141856.p3evqyf34py74gkg@holly.lan> <20190111093902.hfxb67txjhhlegzu@holly.lan> In-Reply-To: <20190111093902.hfxb67txjhhlegzu@holly.lan> From: Sumit Garg Date: Fri, 11 Jan 2019 15:21:50 +0530 Message-ID: Subject: Re: [PATCH v2 2/4] tee: optee: add TEE bus device enumeration support To: Daniel Thompson Cc: linux-arm-kernel@lists.infradead.org, "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , linux-kernel@vger.kernel.org, Jens Wiklander , mpm@selenic.com, Herbert Xu , Rob Herring , Mark Rutland , Arnd Bergmann , Greg Kroah-Hartman , Ard Biesheuvel , Bhupesh Sharma , tee-dev@lists.linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 11 Jan 2019 at 15:09, Daniel Thompson wrote: > > On Fri, Jan 11, 2019 at 12:52:19PM +0530, Sumit Garg wrote: > > On Thu, 10 Jan 2019 at 19:49, Daniel Thompson > > wrote: > > > > +static int get_devices(struct tee_context *ctx, u32 session, > > > > + struct tee_shm *device_uuid, u32 *shm_size) > > > > > > Missing const on device_uuid? > > > > > > > I don't think we should have a const for device_uuid here as this is > > shared memory struct pointer which is dynamically allocated and used > > to fetch device UUIDs. > > Agree. Perhaps device_uuid is misnamed though (part of the reason I > misread this is that it is singular so I though it was a single UUID > travelling into the TZ). > Will rename it to device_shm instead. > > > > + rc = get_devices(ctx, sess_arg.session, device_shm, &shm_size); > > > > + if (rc < 0) > > > > + goto out_shm; > > > > + > > > > + device_uuid = tee_shm_get_va(device_shm, 0); > > > > + if (IS_ERR(device_uuid)) { > > > > + pr_err("tee_shm_get_va failed\n"); > > > > + rc = PTR_ERR(device_uuid); > > > > + goto out_shm; > > > > + } > > > > + > > > > + while (idx < shm_size / sizeof(uuid_t)) { > > > > > > This is a very uncommon way to write a for loop ;-). > > > > > > > Ok, will add "num_devices" variable. > > num_devices might add readability but that is not what I meant. > > The most idiomatic way to write somthing that loops for every valid index > value is: > > for (i=0; i < limit; i++) > > You wrote it like this: > > int idx=0; > > /* lots of code between initializer and first use */ > > while (idx < limit) { > /* more code */ > idx++; > } > > Sure, they are equivalent but the idiomatic form is easier to read. > Oh okay, will use "for" loop instead. -Sumit > > Daniel.