From patchwork Wed Oct 6 07:15:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 12538777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 730ADC433F5 for ; Wed, 6 Oct 2021 07:19:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3479D61100 for ; Wed, 6 Oct 2021 07:19:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3479D61100 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BfhoYi4whA+p2S2lgb8nOY8ek+YmQkKC5XGp+jn9HUw=; b=MRex5dV276mHFR Wa755/XSYuoeEps4C55DBg5jjw76tM6hHapOgJgptcArCK2N6a8ocfcVZbASYMrlfVOAS82giugWE erU3KXxkJTLqcOzCrWNLUJPtgaypLCgRKhXpQjbsYorhPv7wTx+Uh+bhtTlGVMKfhzwIow+u2kB4j D65lb7X+xQFzE032sZhFITNCAj5kArqSfdOcS9FcvdpUjetlxYHFE2ZhIm+//SR5yKuLbv7RKL2aQ FpUdZaksDiCVYdUrCnZCJmD7p05NSLETwvDqDVf45B3yygfRxHtU+2M9gkrnqrv1GIdvLCEiPlrXh CiIAX1jjmKIAUL8P2kKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mY1B2-00DAu3-Aj; Wed, 06 Oct 2021 07:17:20 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mY19l-00DAWz-UZ for linux-arm-kernel@lists.infradead.org; Wed, 06 Oct 2021 07:16:03 +0000 Received: by mail-lf1-x12e.google.com with SMTP id m3so6425412lfu.2 for ; Wed, 06 Oct 2021 00:16:01 -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 :mime-version:content-transfer-encoding; bh=G+uudF1elXgj2CYRAAhjhZzuZ2zqS9rHSGsbl2nlFFY=; b=RlM9lc7CB9JdOyTQ4MpXfKSPDtGKS7wFz07culpDMMYoAgsdu5TTGdBFAeBRwSyUCG LmRMkPZx4wKMMiZf5EDQvcgc3fLPj5mddxFnmakv9nn5aUpsMZNtxZaHemqAvkyWYWzt UWXjxQUZl7A0FVdws0zCpBxPtuHQOA5BhL4FHOXrqM9vWKK9lFpA6HqYwTHtwLlzAZD7 YCMDlm/XgTs6xmlJqFo3UJF567VMi5q7267KLROyK0Q/SFsToG8Rue7mDEhVnOYW89R5 ZIYb1RXmcao6GHNGHfXQHTt1HJC0hYLH2ME6DAWwk77ORxAKqzo/I2GrxuUI5qm5ujNk /61g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G+uudF1elXgj2CYRAAhjhZzuZ2zqS9rHSGsbl2nlFFY=; b=7pzV5shx+bAdxTJDeLix5+8QUp0NmprU+m5psniNx+RP2iOlBnVyOGCLAnAuPUS59w AaCyxj/XY4FOf8RnYJK3p4Al7XothD41vAAT3WmuEUcT/58CKk4Vf70pbRQoi2xXkq2u O5ne0TKFwOJSUnZUdKHhdyt5Cdryn3o9+KOEBqnZtKYof1EzCd1u/AD2kAJ7CvlvxH7j Hp4Sy7Ys/CYlwswpfFAZpN3UcGj0i72lgylTEzBRpz3vJzSFgkjMnAQ4ywcirO4qAWN+ vWoqic6V3lUGAAygCJLN6zq/6jhXTeaMaa17tJPD26RiR0PaYjSMOI5YfrqUbzzIFy4a vVbw== X-Gm-Message-State: AOAM533frQngxdRcJZMIyk7uLud66Wj2nwc6/tHyZESoHcrcCkHEnMja M8CQTflDwEH7yHgbDr5ME6a6vuTqA46zww== X-Google-Smtp-Source: ABdhPJwf2FRNpTOXAY89XLRF5kXnJJw701ler3rWnJUuAKx7wE4mqyW0rOll/wLKeBRqtPuTgFgqEA== X-Received: by 2002:a2e:a791:: with SMTP id c17mr26518748ljf.509.1633504560446; Wed, 06 Oct 2021 00:16:00 -0700 (PDT) Received: from jade.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id y7sm960376lfk.143.2021.10.06.00.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Oct 2021 00:16:00 -0700 (PDT) From: Jens Wiklander To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, op-tee@lists.trustedfirmware.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org Cc: Jerome Forissier , Etienne Carriere , Sumit Garg , Vincent Guittot , Rob Herring , Jonathan Corbet , Ard Biesheuvel , Marc Zyngier , Jens Wiklander Subject: [PATCH v6 4/6] tee: export teedev_open() and teedev_close_context() Date: Wed, 6 Oct 2021 09:15:44 +0200 Message-Id: <20211006071546.2540920-5-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211006071546.2540920-1-jens.wiklander@linaro.org> References: <20211006071546.2540920-1-jens.wiklander@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211006_001602_074603_53AC97E2 X-CRM114-Status: GOOD ( 15.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Exports the two functions teedev_open() and teedev_close_context() in order to make it easier to create a driver internal struct tee_context. Signed-off-by: Jens Wiklander Reviewed-by: Sumit Garg --- drivers/tee/tee_core.c | 6 ++++-- include/linux/tee_drv.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c index 85102d12d716..3fc426dad2df 100644 --- a/drivers/tee/tee_core.c +++ b/drivers/tee/tee_core.c @@ -43,7 +43,7 @@ static DEFINE_SPINLOCK(driver_lock); static struct class *tee_class; static dev_t tee_devt; -static struct tee_context *teedev_open(struct tee_device *teedev) +struct tee_context *teedev_open(struct tee_device *teedev) { int rc; struct tee_context *ctx; @@ -70,6 +70,7 @@ static struct tee_context *teedev_open(struct tee_device *teedev) return ERR_PTR(rc); } +EXPORT_SYMBOL_GPL(teedev_open); void teedev_ctx_get(struct tee_context *ctx) { @@ -96,13 +97,14 @@ void teedev_ctx_put(struct tee_context *ctx) kref_put(&ctx->refcount, teedev_ctx_release); } -static void teedev_close_context(struct tee_context *ctx) +void teedev_close_context(struct tee_context *ctx) { struct tee_device *teedev = ctx->teedev; teedev_ctx_put(ctx); tee_device_put(teedev); } +EXPORT_SYMBOL_GPL(teedev_close_context); static int tee_open(struct inode *inode, struct file *filp) { diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h index 3ebfea0781f1..26f42c4cd7a1 100644 --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -582,4 +582,18 @@ struct tee_client_driver { #define to_tee_client_driver(d) \ container_of(d, struct tee_client_driver, driver) +/** + * teedev_open() - Open a struct tee_device + * @teedev: Device to open + * + * @return a pointer to struct tee_context on success or an ERR_PTR on failure. + */ +struct tee_context *teedev_open(struct tee_device *teedev); + +/** + * teedev_close_context() - closes a struct tee_context + * @ctx: The struct tee_context to close + */ +void teedev_close_context(struct tee_context *ctx); + #endif /*__TEE_DRV_H*/