From patchwork Thu Feb 6 17:38:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 862932 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0C527194C75; Thu, 6 Feb 2025 17:38:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738863517; cv=none; b=mryDvhlYtG41Yp7pDxVTkxHVWAUn01AIaCxBa8iDbtvthNTmUsksSoUqo1ke+0wMZgmsTKrjbre30MMg9yhhmHhuNoa9sWlTycjXPv0pL5ih/xxDE8v51lY8Z3GDZ2/IlUIPnPcg7cNmcS9i2zAIEmECMV8Lq8YMM1EL82Rhp/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738863517; c=relaxed/simple; bh=DeeEwrMxk15wFtTTk6UT9I61fCtbdBqCQIrXhHdA12w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IO0OCbPb3lPouAlrOyzvMq1hcvUFERp0K0xLA7n3AHiMDvJ35jxBmeY7/5z7B35LAuShndvWT8erIVT3k7PPBhabUyqfAGGVu6XMQkLS04RencDlp04qxlHZ6KpBjyN2jBuXDepWks/aQy8H4orKs7sTxV6ManfRa3KT33ot6Vw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hKboPcCy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hKboPcCy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D074BC4CEDD; Thu, 6 Feb 2025 17:38:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738863516; bh=DeeEwrMxk15wFtTTk6UT9I61fCtbdBqCQIrXhHdA12w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hKboPcCyGTiLHnX6A/gqVat18Uvi1yjrTmmcCPRio51nN4pbl9+zayUXKcIY4kHgm eFXNYxCJ63mTalqruoD+qm+n0GHyRatacCJ5KLVqTKnzGlEFQ/cp7LsuIefWAoRCy/ UoOX8VGmsA/ZfB7++3O6f6PbmOeIqKlIEE2JN9H4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Danilo Krummrich , Lyude Paul Cc: Greg Kroah-Hartman , Alexander Lobakin , Andy Shevchenko , Bjorn Helgaas , Jonathan Cameron , Liam Girdwood , Lukas Wunner , Mark Brown , =?utf-8?q?Ma=C3=ADra_Canal?= , Robin Murphy , Simona Vetter , Zijun Hu , linux-usb@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: [PATCH v3 2/8] regulator: dummy: convert to use the faux device interface Date: Thu, 6 Feb 2025 18:38:16 +0100 Message-ID: <2025020623-september-drained-9fd2@gregkh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <2025020620-skedaddle-olympics-1735@gregkh> References: <2025020620-skedaddle-olympics-1735@gregkh> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2848; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=DeeEwrMxk15wFtTTk6UT9I61fCtbdBqCQIrXhHdA12w=; b=owGbwMvMwCRo6H6F97bub03G02pJDOlLPvcvOx94ijHGeNm/gy4ZpzL4trM3WE14t26H10uFz 2ujzmvXdcSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEupMYFuy7K39Stf3OHc9V 398w/xYJ1vvw0JxhrvyNXYevCnn9SZj+YKbEKrbHoYbKNwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 The dummy regulator driver does not need to create a platform device, it only did so because it was simple to do. Change it over to use the faux bus instead as this is NOT a real platform device, and it makes the code even smaller than before. Reviewed-by: Mark Brown Reviewed-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- v3: - no change v2: - renamed vdev variable to fdev thanks to Mark drivers/regulator/dummy.c | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/drivers/regulator/dummy.c b/drivers/regulator/dummy.c index 5b9b9e4e762d..01cae1fc8009 100644 --- a/drivers/regulator/dummy.c +++ b/drivers/regulator/dummy.c @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -37,15 +37,15 @@ static const struct regulator_desc dummy_desc = { .ops = &dummy_ops, }; -static int dummy_regulator_probe(struct platform_device *pdev) +static int dummy_regulator_probe(struct faux_device *fdev) { struct regulator_config config = { }; int ret; - config.dev = &pdev->dev; + config.dev = &fdev->dev; config.init_data = &dummy_initdata; - dummy_regulator_rdev = devm_regulator_register(&pdev->dev, &dummy_desc, + dummy_regulator_rdev = devm_regulator_register(&fdev->dev, &dummy_desc, &config); if (IS_ERR(dummy_regulator_rdev)) { ret = PTR_ERR(dummy_regulator_rdev); @@ -56,36 +56,17 @@ static int dummy_regulator_probe(struct platform_device *pdev) return 0; } -static struct platform_driver dummy_regulator_driver = { - .probe = dummy_regulator_probe, - .driver = { - .name = "reg-dummy", - .probe_type = PROBE_PREFER_ASYNCHRONOUS, - }, +struct faux_device_ops dummy_regulator_driver = { + .probe = dummy_regulator_probe, }; -static struct platform_device *dummy_pdev; +static struct faux_device *dummy_fdev; void __init regulator_dummy_init(void) { - int ret; - - dummy_pdev = platform_device_alloc("reg-dummy", -1); - if (!dummy_pdev) { + dummy_fdev = faux_device_create("reg-dummy", &dummy_regulator_driver); + if (!dummy_fdev) { pr_err("Failed to allocate dummy regulator device\n"); return; } - - ret = platform_device_add(dummy_pdev); - if (ret != 0) { - pr_err("Failed to register dummy regulator device: %d\n", ret); - platform_device_put(dummy_pdev); - return; - } - - ret = platform_driver_register(&dummy_regulator_driver); - if (ret != 0) { - pr_err("Failed to register dummy regulator driver: %d\n", ret); - platform_device_unregister(dummy_pdev); - } } From patchwork Thu Feb 6 17:38:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 862931 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 00B4A18B495; Thu, 6 Feb 2025 17:38:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738863528; cv=none; b=NuHyc7Ml06wpDkS3LLnmkhEYNxpnqWb4ulymCr3aq8oz6bbV0U90xEksKGJ2L82AuSIlDgmSAXQTtvVMVsQhIx2iiumSuXbqJ65zdbyVaeOEcVbUUiRqRKiz+7f3z/xe3OQd5Q1MSrf+wPIBorMEN6oUHGXTRJL4uo93GcT95VE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738863528; c=relaxed/simple; bh=x/i7HqcmmGO7AfmigYoxB9WwFMZPo7dI4JfYsd4nJOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZiBYTsE05efSJ4zesfyKjr3eskPRc23DPQF7Em0/eecI4J0usYPe6UWfUi2CLf+U0rdma3Nib7dNUkYYjkqPlOJ03MjjfGJ7sYJR2jYVtNB7FhmrpImrg+hKocEQrSmJdruIxpgvJCrjau5DQXVCIvvnSjyPfc35qYjF7ShEuHU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kTpkIEi4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kTpkIEi4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5254AC4CEDD; Thu, 6 Feb 2025 17:38:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738863527; bh=x/i7HqcmmGO7AfmigYoxB9WwFMZPo7dI4JfYsd4nJOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kTpkIEi4ESqRssdn82hL9A+u83gR3e0r2SCNUpQf4KjZ0jtgSIdo0jRBoLScEA+Kv qjc0y26A7M65N5QjjW8QNzCC78rKHN0ao8kH5zfrJlTLl/gRYkWzNfMsA9aJsaUepA 9xcMeYSba7LywiTvl8pkjcOLysML11rgahxVBgqo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Danilo Krummrich , Lyude Paul Cc: Greg Kroah-Hartman , Alexander Lobakin , Andy Shevchenko , Bjorn Helgaas , Jonathan Cameron , Liam Girdwood , Lukas Wunner , Mark Brown , =?utf-8?q?Ma=C3=ADra_Canal?= , Robin Murphy , Simona Vetter , Zijun Hu , linux-usb@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: [PATCH v3 3/8] x86/microcode: move away from using a fake platform device Date: Thu, 6 Feb 2025 18:38:17 +0100 Message-ID: <2025020624-crinkle-refusal-eb28@gregkh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <2025020620-skedaddle-olympics-1735@gregkh> References: <2025020620-skedaddle-olympics-1735@gregkh> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2265; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=x/i7HqcmmGO7AfmigYoxB9WwFMZPo7dI4JfYsd4nJOA=; b=owGbwMvMwCRo6H6F97bub03G02pJDOlLPk/gkXHW0PWrPJZmLPf+fMW+K1P38a0+3xy8687f/ 8e/Bofod8SyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEjrcxzNN6aPplnVlFWp2Q g8st9s9f2C1OvGVYcNQzOMqQa8aPmnebj11TuM6y0tR6OwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Downloading firmware needs a device to hang off of, and so a platform device seemed like the simplest way to do this. Now that we have a faux device interface, use that instead as this "microcode device" is not anything resembling a platform device at all. Signed-off-by: Greg Kroah-Hartman --- v3: no change v2: new example patch in this series arch/x86/kernel/cpu/microcode/core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index b3658d11e7b6..f42e0d1b2baa 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -17,8 +17,8 @@ #define pr_fmt(fmt) "microcode: " fmt -#include #include +#include #include #include #include @@ -238,7 +238,7 @@ static void reload_early_microcode(unsigned int cpu) } /* fake device for request_firmware */ -static struct platform_device *microcode_pdev; +static struct faux_device *microcode_fdev; #ifdef CONFIG_MICROCODE_LATE_LOADING /* @@ -679,7 +679,7 @@ static int load_late_locked(void) if (!setup_cpus()) return -EBUSY; - switch (microcode_ops->request_microcode_fw(0, µcode_pdev->dev)) { + switch (microcode_ops->request_microcode_fw(0, µcode_fdev->dev)) { case UCODE_NEW: return load_late_stop_cpus(false); case UCODE_NEW_SAFE: @@ -828,9 +828,9 @@ static int __init microcode_init(void) if (early_data.new_rev) pr_info_once("Updated early from: 0x%08x\n", early_data.old_rev); - microcode_pdev = platform_device_register_simple("microcode", -1, NULL, 0); - if (IS_ERR(microcode_pdev)) - return PTR_ERR(microcode_pdev); + microcode_fdev = faux_device_create("microcode", NULL); + if (!microcode_fdev) + return -ENODEV; dev_root = bus_get_dev_root(&cpu_subsys); if (dev_root) { @@ -849,7 +849,7 @@ static int __init microcode_init(void) return 0; out_pdev: - platform_device_unregister(microcode_pdev); + faux_device_destroy(microcode_fdev); return error; } From patchwork Thu Feb 6 17:38:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 862930 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AA08D18C930; Thu, 6 Feb 2025 17:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738863535; cv=none; b=fwBUaOJSKNSxp1YzixRYNa5ap0bcux6eGQmx+eFx083ucKNrsI8jtHy3rH4LyziGCpNg+PC9sFyptsZ6t4WzRAH9paGWTQ0K1QwwEBheWTCVR+OZ8bXTE0rv4vaIYFJJMsNh1noDV1jGZFCINYOeJznDAVLaDdHq2aUJYYEXS1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738863535; c=relaxed/simple; bh=znFtKvPPaYztgKTaWjJ3kM2Hx0muydkEblyg0lJ2Hfc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JeWeucFLp/GPXpn7gORqZjpWgmEHa9GL0+Heq9cOKxi1tyxIQ8e/MQsQppzvsg0DpP8zM/tl1zOPtGcaLi6ttTMIxwmeMxWn2QIhtW2cHy40vIKUvpOAWtvkdC+xTSun/lXlTq4PXcKkxy7Pc5STHC8Nxm4/1GhjLBhk/cBHCdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dYcy4OGX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dYcy4OGX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CDE5C4CEE2; Thu, 6 Feb 2025 17:38:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738863534; bh=znFtKvPPaYztgKTaWjJ3kM2Hx0muydkEblyg0lJ2Hfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dYcy4OGXDPfFetlTFMy5Y1JemLitNDUcqt1nut090U6V1FtFhp7B2pZL4gcGM4pJS H9FC4J6Jyt1/jtZ3qKq9k60dCrng3xwR/MCa4yNV2NVv1ueMunk0wppNFjbzzsUuin QtzviK1Khzhav1mylel9LgoFgCIGg/WvMJ9XuRT4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Danilo Krummrich , Lyude Paul Cc: Greg Kroah-Hartman , Alexander Lobakin , Andy Shevchenko , Bjorn Helgaas , Jonathan Cameron , Liam Girdwood , Lukas Wunner , Mark Brown , =?utf-8?q?Ma=C3=ADra_Canal?= , Robin Murphy , Simona Vetter , Zijun Hu , linux-usb@vger.kernel.org, rust-for-linux@vger.kernel.org, Mark Gross , Arnd Bergmann Subject: [PATCH v3 5/8] tlclk: convert to use faux_device Date: Thu, 6 Feb 2025 18:38:19 +0100 Message-ID: <2025020624-catlike-delay-fbf5@gregkh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <2025020620-skedaddle-olympics-1735@gregkh> References: <2025020620-skedaddle-olympics-1735@gregkh> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3031; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=znFtKvPPaYztgKTaWjJ3kM2Hx0muydkEblyg0lJ2Hfc=; b=owGbwMvMwCRo6H6F97bub03G02pJDOlLPk90mZZVMi/b5+z3fVc/8ia9stt65c2Fd4zfY7zmz Y5ocLFa0RHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQAT2cTCMN8pv3J1vPWzr+o5 laanN70o1inl9GRY0BZV+mbj2Yxzpuu3JJj31lRH7p6VDgA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 The tlclk driver does not need to create a platform device, it only did so because it was simple to do that in order to get a place in sysfs to hang some device-specific attributes. Change it over to use the faux device instead as this is NOT a real platform device, and it makes the code even smaller than before. Cc: Mark Gross Cc: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- v3: new patch in the series. For an example of the api working, does not have to be merged at this time, but I can take it if the maintainers give an ack. drivers/char/tlclk.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c index 377bebf6c925..97f64de61bdd 100644 --- a/drivers/char/tlclk.c +++ b/drivers/char/tlclk.c @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include /* inb/outb */ #include @@ -742,7 +742,7 @@ static ssize_t store_reset (struct device *d, static DEVICE_ATTR(reset, (S_IWUSR|S_IWGRP), NULL, store_reset); -static struct attribute *tlclk_sysfs_entries[] = { +static struct attribute *tlclk_attrs[] = { &dev_attr_current_ref.attr, &dev_attr_telclock_version.attr, &dev_attr_alarms.attr, @@ -766,13 +766,9 @@ static struct attribute *tlclk_sysfs_entries[] = { &dev_attr_reset.attr, NULL }; +ATTRIBUTE_GROUPS(tlclk); -static const struct attribute_group tlclk_attribute_group = { - .name = NULL, /* put in device directory */ - .attrs = tlclk_sysfs_entries, -}; - -static struct platform_device *tlclk_device; +static struct faux_device *tlclk_device; static int __init tlclk_init(void) { @@ -817,24 +813,13 @@ static int __init tlclk_init(void) goto out3; } - tlclk_device = platform_device_register_simple("telco_clock", - -1, NULL, 0); - if (IS_ERR(tlclk_device)) { - printk(KERN_ERR "tlclk: platform_device_register failed.\n"); - ret = PTR_ERR(tlclk_device); + tlclk_device = faux_device_create_with_groups("telco_clock", NULL, tlclk_groups); + if (!tlclk_device) { + ret = -ENODEV; goto out4; } - ret = sysfs_create_group(&tlclk_device->dev.kobj, - &tlclk_attribute_group); - if (ret) { - printk(KERN_ERR "tlclk: failed to create sysfs device attributes.\n"); - goto out5; - } - return 0; -out5: - platform_device_unregister(tlclk_device); out4: misc_deregister(&tlclk_miscdev); out3: @@ -848,8 +833,7 @@ static int __init tlclk_init(void) static void __exit tlclk_cleanup(void) { - sysfs_remove_group(&tlclk_device->dev.kobj, &tlclk_attribute_group); - platform_device_unregister(tlclk_device); + faux_device_destroy(tlclk_device); misc_deregister(&tlclk_miscdev); unregister_chrdev(tlclk_major, "telco_clock"); From patchwork Thu Feb 6 17:38:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 862929 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 234EE18D634; Thu, 6 Feb 2025 17:39:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738863541; cv=none; b=GUU+gjGToNAdbdZKutYy43gQiET3VWnR8K9naOHkNfaMSpuqYpMrb5OIcm7/M6iqijvoJXDBfNUzRD9EFtdVChXA+zkctLAyaTxMryWcEauC3ZBD8x18nmWNp4vSc53swIwT3Ll4u4COU+kTgf4MEULa/hwR7naHOVs4cQ14EW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738863541; c=relaxed/simple; bh=9QmCo1G84X1vZbeBiTVfBzjgYCxTZDPjtxuxsMu2KD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XPSGUMA0ERM1wbbB/6ZgAxIlwHxvWVmT9DWijqrKUv7CQhbAVLkR6yCCAprPhST4Lw0CSagYg1GSotgjLpQ1zMiYSu/isdS5XYmLQxmX+RQLuDfeb5nYY05jMd0ptI3gu3wdaj+wuiW+hLdyCp2Uoy0e7gk5fixjuCcQdE56wJY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=U2pXIE9o; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="U2pXIE9o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02394C4CEDD; Thu, 6 Feb 2025 17:39:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738863540; bh=9QmCo1G84X1vZbeBiTVfBzjgYCxTZDPjtxuxsMu2KD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2pXIE9oYKSZSzS5aaEd/FrlO1piuNQ12EdRp2nLxkSfXYYoMPnUA0MnzpkVwpC5W HDOYAxT45o3lCipdn+Bt+l92ZJQiw1wJbkralZvdyMEkrIqsbDCLLO4CuXIfb8EPkG qPZlMq1//KgyQA9DW40vAOJ8pj3piZ9qelJhhiyw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Danilo Krummrich , Lyude Paul Cc: Greg Kroah-Hartman , Alexander Lobakin , Andy Shevchenko , Bjorn Helgaas , Jonathan Cameron , Liam Girdwood , Lukas Wunner , Mark Brown , =?utf-8?q?Ma=C3=ADra_Canal?= , Robin Murphy , Simona Vetter , Zijun Hu , linux-usb@vger.kernel.org, rust-for-linux@vger.kernel.org, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org Subject: [PATCH v3 7/8] drm/vgem/vgem_drv convert to use faux_device Date: Thu, 6 Feb 2025 18:38:21 +0100 Message-ID: <2025020625-corsage-undertow-765c@gregkh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <2025020620-skedaddle-olympics-1735@gregkh> References: <2025020620-skedaddle-olympics-1735@gregkh> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3368; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=9QmCo1G84X1vZbeBiTVfBzjgYCxTZDPjtxuxsMu2KD4=; b=owGbwMvMwCRo6H6F97bub03G02pJDOlLPk98x72R9cfd6DMMHcfYKmapLrV4WJPa0BrQ1iGR1 P1457ykjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZiIznmG+bl38pqrPLkvv5qz 0faUpLjaZ4cXcxgW9Hx/lp9jJXFtx6zQFKNdbGl+zn9nAwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 The vgem driver does not need to create a platform device, as there is no real platform resources associated it, it only did so because it was simple to do that in order to get a device to use for resource management of drm resources. Change the driver to use the faux device instead as this is NOT a real platform device. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Simona Vetter Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman --- v3: new patch in the series. For an example of the api working, does not have to be merged at this time, but I can take it if the maintainers give an ack. drivers/gpu/drm/vgem/vgem_drv.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c index 2752ab4f1c97..2a50c0b76fac 100644 --- a/drivers/gpu/drm/vgem/vgem_drv.c +++ b/drivers/gpu/drm/vgem/vgem_drv.c @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include @@ -52,7 +52,7 @@ static struct vgem_device { struct drm_device drm; - struct platform_device *platform; + struct faux_device *faux_dev; } *vgem_device; static int vgem_open(struct drm_device *dev, struct drm_file *file) @@ -127,27 +127,27 @@ static const struct drm_driver vgem_driver = { static int __init vgem_init(void) { int ret; - struct platform_device *pdev; + struct faux_device *fdev; - pdev = platform_device_register_simple("vgem", -1, NULL, 0); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); + fdev = faux_device_create("vgem", NULL); + if (!fdev) + return -ENODEV; - if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) { + if (!devres_open_group(&fdev->dev, NULL, GFP_KERNEL)) { ret = -ENOMEM; goto out_unregister; } - dma_coerce_mask_and_coherent(&pdev->dev, + dma_coerce_mask_and_coherent(&fdev->dev, DMA_BIT_MASK(64)); - vgem_device = devm_drm_dev_alloc(&pdev->dev, &vgem_driver, + vgem_device = devm_drm_dev_alloc(&fdev->dev, &vgem_driver, struct vgem_device, drm); if (IS_ERR(vgem_device)) { ret = PTR_ERR(vgem_device); goto out_devres; } - vgem_device->platform = pdev; + vgem_device->faux_dev = fdev; /* Final step: expose the device/driver to userspace */ ret = drm_dev_register(&vgem_device->drm, 0); @@ -157,19 +157,19 @@ static int __init vgem_init(void) return 0; out_devres: - devres_release_group(&pdev->dev, NULL); + devres_release_group(&fdev->dev, NULL); out_unregister: - platform_device_unregister(pdev); + faux_device_destroy(fdev); return ret; } static void __exit vgem_exit(void) { - struct platform_device *pdev = vgem_device->platform; + struct faux_device *fdev = vgem_device->faux_dev; drm_dev_unregister(&vgem_device->drm); - devres_release_group(&pdev->dev, NULL); - platform_device_unregister(pdev); + devres_release_group(&fdev->dev, NULL); + faux_device_destroy(fdev); } module_init(vgem_init);