diff mbox

[libdrm,v2,2/2] etnaviv: add etna_bo_from_handle

Message ID 20170821105632.2458-2-p.zabel@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Philipp Zabel Aug. 21, 2017, 10:56 a.m. UTC
Although etnaviv_drmif.h declared etna_bo_from_handle from the start,
there was no implementation.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
v2: no changes since v1
---
 etnaviv/etnaviv_bo.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Daniel Stone Aug. 21, 2017, 11:35 a.m. UTC | #1
Hi Philipp,

On 21 August 2017 at 11:56, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> +struct etna_bo *
> +etna_bo_from_handle(struct etna_device *dev, uint32_t handle, uint32_t size)
> +{
> +       struct etna_bo *bo = NULL;

You can drop the NULL initialisation since it's always set by the
lookup_bo() call. But with that, both patches are:
Reviewed-by: Daniel Stone <daniels@collabora.com>

Cheers,
Daniel
diff mbox

Patch

diff --git a/etnaviv/etnaviv_bo.c b/etnaviv/etnaviv_bo.c
index 4fe877f1..75669572 100644
--- a/etnaviv/etnaviv_bo.c
+++ b/etnaviv/etnaviv_bo.c
@@ -135,6 +135,25 @@  struct etna_bo *etna_bo_new(struct etna_device *dev, uint32_t size,
 	return bo;
 }
 
+struct etna_bo *
+etna_bo_from_handle(struct etna_device *dev, uint32_t handle, uint32_t size)
+{
+	struct etna_bo *bo = NULL;
+
+	pthread_mutex_lock(&table_lock);
+
+	bo = lookup_bo(dev->handle_table, handle);
+	if (bo)
+		goto out_unlock;
+
+	bo = bo_from_handle(dev, size, handle, 0);
+
+out_unlock:
+	pthread_mutex_unlock(&table_lock);
+
+	return bo;
+}
+
 struct etna_bo *etna_bo_ref(struct etna_bo *bo)
 {
 	atomic_inc(&bo->refcnt);