Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1490701ybg; Thu, 4 Jun 2020 11:02:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXczMBsYQHC2pibCkW4A68VB7WlIYumOctrH/1f/MOKELSlQSQmjM0vy0/m++06OPQ7ovk X-Received: by 2002:a05:6402:7d4:: with SMTP id u20mr5362973edy.30.1591293721270; Thu, 04 Jun 2020 11:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591293721; cv=none; d=google.com; s=arc-20160816; b=C/Bn8K9oUbKfhXCVFSU5tbqr2RJ9mvYqOYW8xnVqu7i1P889AlMmILPr5ovaPMdT5g 6kRWVLx8+PPThjX4cAdrQoTep6kg7qqN51Z/oICBjoLzzdK2D+JxQu/p+f3KtUA4oq7Q h3ewPKot5bBijqDxHDHFecKOJcZrjAvFlU4g7D4tjE4AP7O2ggv62+ZtbldxU9fxLZ0c oy/SHL+lsHLQ1PskG1jHP+nE/MgSaSUVA6vsGR30fq5DTQW8FDaEscD8K/I6jks/Xz0L EgZvptj/scGD/laYQB0/eGxaZO9TuE0cTdx7j3gxLpdsfEVaEWz7KMLPKAGJUbzkuJXd dRNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=y1Q9f/owSvUftqSD1Hv4bVUGbDrPIGyfax6gzi32kpI=; b=FS7ARZXWlss8uFIU9W8Ip+6khkooK/16X/eJECZNDxq6kCXU9h0vrqwgGu/K/e6Drs 5M8Zp4RA+5Y6jprZiHw621mHOGuS8VvVY1EQn6Aqm7PlPjGcL23T97HLPizqF1pfwH5P VflMgCZbqIsNHS4Pth9MysKJ6+IE+ncL4dHTJXS+Qa/s75aKAT2zjB9znYIgm2E2hPMk HDlgvY53d6w5tUmlFS42IhR+eyuQfQ+xCHzBh7H8iu4DdfbSMVvzVo3xTwOUPwz92JXA XIsl2tC2Ojb5uK9fLPHsHxrMLSP1AjdMIXKsLV7eaJy4p5QOy6C2q4gDsVpQZA7oYf2l /rzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z4UfZa+l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id cb1si2044197ejb.42.2020.06.04.11.01.37; Thu, 04 Jun 2020 11:02:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z4UfZa+l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730434AbgFDR7F (ORCPT + 99 others); Thu, 4 Jun 2020 13:59:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730385AbgFDR67 (ORCPT ); Thu, 4 Jun 2020 13:58:59 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C7A6C08C5C2 for ; Thu, 4 Jun 2020 10:58:59 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id h188so4157978lfd.7 for ; Thu, 04 Jun 2020 10:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y1Q9f/owSvUftqSD1Hv4bVUGbDrPIGyfax6gzi32kpI=; b=z4UfZa+lMLv9ShPYyfh+GzumSq3gGE6u750clZOuQxq+iIssvL53B15ckxMDWbgilT Y97NO2inkyooaFl1RiKXYZPZfxYD8JeuP4lWbC6+prNZCPutbHdXuHMJpmlSDSS9L3Ld KFdTxuAMWY5A+D25hrJgRYNgpzikvi7ybP1j01lLvfUG/C56nYtin72DfPI1WHKJyoU+ FkaU3ZYqOaDOJLwOIds3gYBJcDJ7b8tSCjT3fgJrOkTXXVmwiKovflV+ylKlM9fiqOgF rCV1SDmSSsSTYbJg05hNbA3Zc98hKNB1FqSpFR8uHqLOu08tFXaK6WISHRVTQxb34LBI A0zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y1Q9f/owSvUftqSD1Hv4bVUGbDrPIGyfax6gzi32kpI=; b=ajycV5p0VsdPNL47K8kxU0+z/Uo5kpHQD2TWhZLegmHShM5Y2YysjotW1sbZnE+fVR JJzArgZpF5JPFd8hEgJ2fKghnKqQs/d4xaajF3pi33Mx6qLeSa6pcH3JrqDhmZYgLrlo f1FNMhLRmUI0784rht96nvmy1t31HRHaTPu1aJ8ivZ1t8vQgGrGmtHQ3+SYnc1D08HaM KyMyHdug5GPUNmEm0ekXE+R0GPusDSUeeOwFIfiyn5YomOMfrBG1Ud6AP6G9wjWZGS/l geS4F5cK4I5C1klNiHHi52gvL5ZS9Q/VMRfKOdrYEe72LX1mlo3L+MzoRdBJ2khRMKg2 IKZw== X-Gm-Message-State: AOAM533uRRV+j8gBXFxqR4uIdg9+TIm4attDHY4O0S/NpKaxSYYQcmSp Wis3IloR8cxohYb1+Br0J71pZKJUKdM= X-Received: by 2002:ac2:490f:: with SMTP id n15mr3155675lfi.39.1591293537372; Thu, 04 Jun 2020 10:58:57 -0700 (PDT) Received: from localhost.localdomain ([176.59.41.83]) by smtp.gmail.com with ESMTPSA id y17sm72404lfa.77.2020.06.04.10.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 10:58:56 -0700 (PDT) From: Maxim Uvarov To: linux-kernel@vger.kernel.org, tee-dev@lists.linaro.org Cc: peterhuewe@gmx.de, jarkko.sakkinen@linux.intel.com, jgg@ziepe.ca, gregkh@linuxfoundation.org, jens.wiklander@linaro.org, linux-integrity@vger.kernel.org, arnd@linaro.org, sumit.garg@linaro.org, Maxim Uvarov Subject: [PATCHv8 1/3] optee: use uuid for sysfs driver entry Date: Thu, 4 Jun 2020 20:58:49 +0300 Message-Id: <20200604175851.758-2-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200604175851.758-1-maxim.uvarov@linaro.org> References: <20200604175851.758-1-maxim.uvarov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the evolving use-cases for TEE bus, now it's required to support multi-stage enumeration process. But using a simple index doesn't suffice this requirement and instead leads to duplicate sysfs entries. So instead switch to use more informative device UUID for sysfs entry like: /sys/bus/tee/devices/optee-ta- Signed-off-by: Maxim Uvarov Reviewed-by: Sumit Garg --- Documentation/ABI/testing/sysfs-bus-optee-devices | 8 ++++++++ MAINTAINERS | 1 + drivers/tee/optee/device.c | 9 ++++++--- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-optee-devices diff --git a/Documentation/ABI/testing/sysfs-bus-optee-devices b/Documentation/ABI/testing/sysfs-bus-optee-devices new file mode 100644 index 000000000000..0ae04ae5374a --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-optee-devices @@ -0,0 +1,8 @@ +What: /sys/bus/tee/devices/optee-ta-/ +Date: May 2020 +KernelVersion 5.7 +Contact: tee-dev@lists.linaro.org +Description: + OP-TEE bus provides reference to registered drivers under this directory. The + matches Trusted Application (TA) driver and corresponding TA in secure OS. Drivers + are free to create needed API under optee-ta- directory. diff --git a/MAINTAINERS b/MAINTAINERS index ecc0749810b0..6717afef2de3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12516,6 +12516,7 @@ OP-TEE DRIVER M: Jens Wiklander L: tee-dev@lists.linaro.org S: Maintained +F: Documentation/ABI/testing/sysfs-bus-optee-devices F: drivers/tee/optee/ OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c index e3a148521ec1..23d264c8146e 100644 --- a/drivers/tee/optee/device.c +++ b/drivers/tee/optee/device.c @@ -65,7 +65,7 @@ static int get_devices(struct tee_context *ctx, u32 session, return 0; } -static int optee_register_device(const uuid_t *device_uuid, u32 device_id) +static int optee_register_device(const uuid_t *device_uuid) { struct tee_client_device *optee_device = NULL; int rc; @@ -75,7 +75,10 @@ static int optee_register_device(const uuid_t *device_uuid, u32 device_id) return -ENOMEM; optee_device->dev.bus = &tee_bus_type; - dev_set_name(&optee_device->dev, "optee-clnt%u", device_id); + if (dev_set_name(&optee_device->dev, "optee-ta-%pUl", device_uuid)) { + kfree(optee_device); + return -ENOMEM; + } uuid_copy(&optee_device->id.uuid, device_uuid); rc = device_register(&optee_device->dev); @@ -144,7 +147,7 @@ int optee_enumerate_devices(void) num_devices = shm_size / sizeof(uuid_t); for (idx = 0; idx < num_devices; idx++) { - rc = optee_register_device(&device_uuid[idx], idx); + rc = optee_register_device(&device_uuid[idx]); if (rc) goto out_shm; } -- 2.17.1