Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3186737rdb; Tue, 6 Feb 2024 09:29:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYf6xCLlhKm1AP2viroNn5lVHe7ljaA/ZQ86LUUi/3sT5TBMPlsc3nxcmMT/5J9O4skgQi X-Received: by 2002:a05:6830:1d81:b0:6e0:e90a:4b7 with SMTP id y1-20020a0568301d8100b006e0e90a04b7mr3243798oti.28.1707240592647; Tue, 06 Feb 2024 09:29:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240592; cv=pass; d=google.com; s=arc-20160816; b=ACKAkww/HqPLoOoACiEHhhKs33QYTs4QfxpT046bnJYwc50A9wAKB27XtFd0pROD34 GCk6GMpgLuJIwyJt4fUMn5LGtJxJqN4gm92duVPkQ7P4A9jJBv5/uYMYItOzr7AWVPd3 M3rzDi0NnGXFrmWS2vFKTyF62Hq7XsIg3rfR5M6PEPVopcy9uTrudKeSBNkNWLJSJVkv 4clEY0JNd9VuGH6kt+WcDKFmPRczF0Ysva05Rv4XkxNAbJvME9/o5GG16+kkTR4J18Tm 33ynjTyX41CdK65ABtO7TZMyTNIAIU8KjF806A1pNnMEEeGiQcYNHNlUdqWXuXBuOUqR rmfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jmVPFCNKCEoxyfP5fWPRoMeSPbEbmBVNboqHaLmwopU=; fh=5A/L0T7ZkVaU5oGff+B+X7UXlznZg2jiOWR906mzhLg=; b=LL086uE4lmdOcP89fS4FtrxlyQn+2U+auiLJiCj1bfEpEiMhlvcioNlT1BUKQUniHm LgKrsKeNp92MdZJ9K4TEbyHEa9sdgtipCmTeOauMFo2wZO/B7EtjS98seGKulBQ34ZzU uX2r+g/1UKw8LM4pSQ5iwHUjM3peGHCnv2em4LzUFqw85dadXjVHNNg22fxSGnJkl+Gs MtTwjND70yF74dr6gG9SlItuKox3QCRbifSr70tjrU9ErU6zTzzG2CAMiu48N+AUWbA8 4bX9f3Qi6DMNrbeJMiP6PIlbaAGvFsvNWTC7b0hj01766aDqS6er5SQ4kH/q6V6gwdVY 7Dmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bj9f6nPN; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-55377-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55377-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCVrlSyUUk7x+D2oI7Si24FJneZQ/Jbc6ZU2pVwUF3ISw2eZTFJeZzCyBtIKSux9mtTe629Arnw7MbiUVyyum9WVneFI4jIsf/fn4TUH0Q== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d2-20020a05622a100200b0042bffb591d9si2775728qte.94.2024.02.06.09.29.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:29:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55377-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bj9f6nPN; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-55377-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55377-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 641581C2389E for ; Tue, 6 Feb 2024 17:29:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25F97168BA; Tue, 6 Feb 2024 17:28:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="bj9f6nPN" Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA14914A81 for ; Tue, 6 Feb 2024 17:28:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240519; cv=none; b=Jt7es5nZUmGM2Fk52ClYRvhr5rFCy1olBEofL5q3fQfXVNAiqWwj5pgxgvezE/zOjtvLWXrwCCGtpbIzy1WmrA2dIgYlerxeqpt6qCs1cSa+N8rAicHp7S5w0qEvnUa7Es29VuU0Te6LUy2phdfj6v8105M23vmNGgs0exyeXdA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240519; c=relaxed/simple; bh=ckxXDAMdL+HGgVVf2k5qWXyty13TiKMKkVY5UlvzvTM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SbbDI1Im5ikABZxPsTP1rZBWlSrdy8rCBoCZZzjme9RrpYahXZCfBcdKGz8a0M5MlBcH7Of/kdtL9vemlomlCOeKsU9bAQDLwJo7IR1VsLfeAM1fgVcH0APwGlRHmcA3iJUfZCzScqG2SE2gq6kYHP+oLYrL+NSEpRuJynHTr50= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=bj9f6nPN; arc=none smtp.client-ip=95.215.58.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707240516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jmVPFCNKCEoxyfP5fWPRoMeSPbEbmBVNboqHaLmwopU=; b=bj9f6nPNUnvNreGxSEJL4GRanUU7epVcP9jtGuoNULXnMXPcYRC8wNMLn1F/9NdkMVaYxx rsABrTZTT8ee69ohJDd7pIwPlD9xmEuQnkNVKaOW4GFfph5FtQCL9dcx2Rc6ilrBkL+lc7 W6tnQifptQj4MMRWcdDpGe/xKyH8moI= From: Sui Jingfeng To: Lucas Stach Cc: Russell King , Christian Gmeiner , David Airlie , Daniel Vetter , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [etnaviv-next v13 6/7] drm/etnaviv: Update the implement of etnaviv_create_platform_device() Date: Wed, 7 Feb 2024 01:27:58 +0800 Message-Id: <20240206172759.421737-7-sui.jingfeng@linux.dev> In-Reply-To: <20240206172759.421737-1-sui.jingfeng@linux.dev> References: <20240206172759.421737-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Because we need this function to create virtial child. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 33 +++++++++++++++++++++++---- drivers/gpu/drm/etnaviv/etnaviv_drv.h | 9 ++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index d5a5fcc30341..5f65f2dead44 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -670,16 +670,36 @@ static struct platform_driver etnaviv_platform_driver = { }, }; -static int etnaviv_create_platform_device(const char *name, - struct platform_device **ppdev) +int etnaviv_create_platform_device(struct device *parent, + const char *name, int id, + struct resource *pres, + void *data, + struct platform_device **ppdev) { struct platform_device *pdev; int ret; - pdev = platform_device_alloc(name, PLATFORM_DEVID_NONE); + pdev = platform_device_alloc(name, id); if (!pdev) return -ENOMEM; + pdev->dev.parent = parent; + + if (pres) { + ret = platform_device_add_resources(pdev, pres, 1); + if (ret) { + platform_device_put(pdev); + return ret; + } + } + + if (data) { + void *pdata = kmalloc(sizeof(void *), GFP_KERNEL); + + *(void **)pdata = data; + pdev->dev.platform_data = pdata; + } + ret = platform_device_add(pdev); if (ret) { platform_device_put(pdev); @@ -691,7 +711,7 @@ static int etnaviv_create_platform_device(const char *name, return 0; } -static void etnaviv_destroy_platform_device(struct platform_device **ppdev) +void etnaviv_destroy_platform_device(struct platform_device **ppdev) { struct platform_device *pdev = *ppdev; @@ -728,7 +748,10 @@ static int __init etnaviv_init(void) if (np) { of_node_put(np); - ret = etnaviv_create_platform_device("etnaviv", &etnaviv_drm); + ret = etnaviv_create_platform_device(NULL, "etnaviv", + PLATFORM_DEVID_NONE, + NULL, NULL, + &etnaviv_drm); if (ret) goto unregister_platform_driver; } diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_drv.h index 9c05f503747a..bd8ac64dbaf3 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +98,14 @@ bool etnaviv_cmd_validate_one(struct etnaviv_gpu *gpu, u32 *stream, unsigned int size, struct drm_etnaviv_gem_submit_reloc *relocs, unsigned int reloc_size); +int etnaviv_create_platform_device(struct device *parent, + const char *name, int id, + struct resource *pres, + void *data, + struct platform_device **ppdev); + +void etnaviv_destroy_platform_device(struct platform_device **ppdev); + #ifdef CONFIG_DEBUG_FS void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv, struct seq_file *m); -- 2.34.1