From patchwork Tue Feb 4 11:09:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13958911 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 6597A20969D; Tue, 4 Feb 2025 11:09: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=1738667377; cv=none; b=oswkgzjmKoNCuPI6gReF8m0glgK+yWESXI4hR6r4/qWTrtvUVWJbAWOUG/nQV/UuTveWJD0shZyfj2nfr0kVeAXdt7jpvbGrzZ4+Rv+EFFvSgHE26qvBds7TTeOImhT8VBEL4sVlYh7iU8MGXLtKTryO28mu2MKGxOoedpnFEBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738667377; c=relaxed/simple; bh=M9fF2yZwbhd2NgZD12wwwug3mQYv6nfiLMXhmY+0PZM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ohc2GhBXcv9WRd0QUb4aenYQH3tsapn0AVwJdm+OLTLPWynhLdoTK4ZCXsdwQr/9LYFGtXsk8BHzdaJfh7hUKKwORWnw9XUDoYnyP4HBBLXi9X9OQPnp7XvwItZDU3RI5nzVYY+XAm8nC+JcuXXnfRCEsnRoSGUlnm1CEW75Vjo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jQGewVxX; 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="jQGewVxX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CA3EC4CEDF; Tue, 4 Feb 2025 11:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738667376; bh=M9fF2yZwbhd2NgZD12wwwug3mQYv6nfiLMXhmY+0PZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jQGewVxXP5zGIq9J4mWul5stjA+03hkSDPUfXtSbFQhhTob7G0YvSfAOk7gHkdgWO vZ5TIYJSBnMUh8W78n7TaBXfGXxvNEPpKJ4jHTDNkyUfbWj5Kvwc1Y/GfOeRd1rTxV 871Nraww1cItAEf86WF6WzYfscfnf4diz8nD5k/o= 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 v2 1/5] driver core: add a faux bus for use when a simple device/bus is needed Date: Tue, 4 Feb 2025 12:09:13 +0100 Message-ID: <2025020424-retrain-recharger-407c@gregkh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <2025020421-poster-moisture-534b@gregkh> References: <2025020421-poster-moisture-534b@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=9456; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=M9fF2yZwbhd2NgZD12wwwug3mQYv6nfiLMXhmY+0PZM=; b=owGbwMvMwCRo6H6F97bub03G02pJDOkLv6ZEOAp9z+1lPl69Y3lznNPtvMlbP36wm1xlYlWTH s6ol7ewI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACYixc6woKOtImWf2sqlzRYH G69X7a9SXRobwbBg2X+2F4n7v7AumTF5bbV9hi/bJ6VoAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Many drivers abuse the platform driver/bus system as it provides a simple way to create and bind a device to a driver-specific set of probe/release functions. Instead of doing that, and wasting all of the memory associated with a platform device, here is a "faux" bus that can be used instead. Signed-off-by: Greg Kroah-Hartman Reviewed-by: Danilo Krummrich Reviewed-by: Jonathan Cameron Reviewed-by: Lyude Paul --- v2: - renamed bus and root device to just "faux" thanks to Thomas - removed the one-driver-per-device and now just have one driver entirely thanks to Danilo - kerneldoc fixups and additions and string handling bounds checks hanks to Andy - coding style fix thanks to Jonathan - tested that the destroy path actually works drivers/base/Makefile | 2 +- drivers/base/base.h | 1 + drivers/base/faux.c | 196 ++++++++++++++++++++++++++++++++++++ drivers/base/init.c | 1 + include/linux/device/faux.h | 31 ++++++ 5 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 drivers/base/faux.c create mode 100644 include/linux/device/faux.h diff --git a/drivers/base/Makefile b/drivers/base/Makefile index 7fb21768ca36..8074a10183dc 100644 --- a/drivers/base/Makefile +++ b/drivers/base/Makefile @@ -6,7 +6,7 @@ obj-y := component.o core.o bus.o dd.o syscore.o \ cpu.o firmware.o init.o map.o devres.o \ attribute_container.o transport_class.o \ topology.o container.o property.o cacheinfo.o \ - swnode.o + swnode.o faux.o obj-$(CONFIG_AUXILIARY_BUS) += auxiliary.o obj-$(CONFIG_DEVTMPFS) += devtmpfs.o obj-y += power/ diff --git a/drivers/base/base.h b/drivers/base/base.h index 8cf04a557bdb..0042e4774b0c 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -137,6 +137,7 @@ int hypervisor_init(void); static inline int hypervisor_init(void) { return 0; } #endif int platform_bus_init(void); +int faux_bus_init(void); void cpu_dev_init(void); void container_dev_init(void); #ifdef CONFIG_AUXILIARY_BUS diff --git a/drivers/base/faux.c b/drivers/base/faux.c new file mode 100644 index 000000000000..9b28643afc45 --- /dev/null +++ b/drivers/base/faux.c @@ -0,0 +1,196 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2025 Greg Kroah-Hartman + * Copyright (c) 2025 The Linux Foundation + * + * A "simple" faux bus that allows devices to be created and added + * automatically to it. This is to be used whenever you need to create a + * device that is not associated with any "real" system resources, and do + * not want to have to deal with a bus/driver binding logic. It is + * intended to be very simple, with only a create and a destroy function + * available. + */ +#include +#include +#include +#include +#include +#include +#include "base.h" + +#define MAX_NAME_SIZE 256 /* Max size of a faux_device name */ + +/* + * Internal wrapper structure so we can hold the memory + * for the driver and the name string of the faux device. + */ +struct faux_object { + struct faux_device faux_dev; + const struct faux_driver_ops *faux_ops; + char name[]; +}; +#define to_faux_object(dev) container_of_const(dev, struct faux_object, faux_dev.dev) + +static struct device faux_bus_root = { + .init_name = "faux", +}; + +static int faux_match(struct device *dev, const struct device_driver *drv) +{ + /* Match always succeeds, we only have one driver */ + return 1; +} + +static int faux_probe(struct device *dev) +{ + struct faux_object *faux_obj = to_faux_object(dev); + struct faux_device *faux_dev = &faux_obj->faux_dev; + const struct faux_driver_ops *faux_ops = faux_obj->faux_ops; + int ret = 0; + + if (faux_ops && faux_ops->probe) + ret = faux_ops->probe(faux_dev); + + return ret; +} + +static void faux_remove(struct device *dev) +{ + struct faux_object *faux_obj = to_faux_object(dev); + struct faux_device *faux_dev = &faux_obj->faux_dev; + const struct faux_driver_ops *faux_ops = faux_obj->faux_ops; + + if (faux_ops && faux_ops->remove) + faux_ops->remove(faux_dev); +} + +static const struct bus_type faux_bus_type = { + .name = "faux", + .match = faux_match, + .probe = faux_probe, + .remove = faux_remove, +}; + +static struct device_driver faux_driver = { + .name = "faux_driver", + .bus = &faux_bus_type, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, +}; + +static void faux_device_release(struct device *dev) +{ + struct faux_object *faux_obj = to_faux_object(dev); + + kfree(faux_obj); +} + +/** + * faux_device_create - create and register a faux device and driver + * @name: name of the device and driver we are adding + * @faux_ops: struct faux_driver_ops that the new device will call back into, can be NULL + * + * Create a new faux device and driver, both with the same name, and + * register them in the driver core properly. The probe() callback of + * @faux_ops will be called with the new device that is created for the + * caller to do something with. + * + * Note, when this function is called, the functions specified in struct + * faux_ops will be called before the function returns, so be prepared for + * everything to be properly initialized before that point in time. + * + * Return: + * * NULL if an error happened with creating the device + * * pointer to a valid struct faux_device that is registered with sysfs + */ +struct faux_device *faux_device_create(const char *name, struct faux_driver_ops *faux_ops) +{ + struct device *dev; + struct faux_object *faux_obj; + struct faux_device *faux_dev; + int name_size; + int ret; + + name_size = strlen(name); + if (name_size > MAX_NAME_SIZE) + return NULL; + + faux_obj = kzalloc(sizeof(*faux_obj) + name_size + 1, GFP_KERNEL); + if (!faux_obj) + return NULL; + + /* Save off the name of the object into local memory */ + memcpy(faux_obj->name, name, name_size); + + /* Save off the callbacks so we can use them in the future */ + faux_obj->faux_ops = faux_ops; + + /* Initialize the device portion and register it with the driver core */ + faux_dev = &faux_obj->faux_dev; + dev = &faux_dev->dev; + + device_initialize(dev); + dev->release = faux_device_release; + dev->parent = &faux_bus_root; + dev->bus = &faux_bus_type; + dev_set_name(dev, "%s", name); + + ret = device_add(dev); + if (ret) { + pr_err("%s: device_add for %s faux device failed with %d\n", + __func__, name, ret); + put_device(dev); + return NULL; + } + + return faux_dev; +} +EXPORT_SYMBOL_GPL(faux_device_create); + +/** + * faux_device_destroy - destroy a faux device + * @faux_dev: faux device to destroy + * + * Unregister and free all memory associated with a faux device that was + * previously created with a call to faux_device_create(). + */ +void faux_device_destroy(struct faux_device *faux_dev) +{ + struct device *dev = &faux_dev->dev; + + if (IS_ERR_OR_NULL(faux_dev)) + return; + + device_del(dev); + + /* The final put_device() will clean up the driver we created for this device. */ + put_device(dev); +} +EXPORT_SYMBOL_GPL(faux_device_destroy); + +int __init faux_bus_init(void) +{ + int ret; + + ret = device_register(&faux_bus_root); + if (ret) { + put_device(&faux_bus_root); + return ret; + } + + ret = bus_register(&faux_bus_type); + if (ret) + goto error_bus; + + ret = driver_register(&faux_driver); + if (ret) + goto error_driver; + + return ret; + +error_driver: + bus_unregister(&faux_bus_type); + +error_bus: + device_unregister(&faux_bus_root); + return ret; +} diff --git a/drivers/base/init.c b/drivers/base/init.c index c4954835128c..9d2b06d65dfc 100644 --- a/drivers/base/init.c +++ b/drivers/base/init.c @@ -32,6 +32,7 @@ void __init driver_init(void) /* These are also core pieces, but must come after the * core core pieces. */ + faux_bus_init(); of_core_init(); platform_bus_init(); auxiliary_bus_init(); diff --git a/include/linux/device/faux.h b/include/linux/device/faux.h new file mode 100644 index 000000000000..2c8ae5bd7ae8 --- /dev/null +++ b/include/linux/device/faux.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2025 Greg Kroah-Hartman + * Copyright (c) 2025 The Linux Foundation + * + * A "simple" faux bus that allows devices to be created and added + * automatically to it. This is to be used whenever you need to create a + * device that is not associated with any "real" system resources, and do + * not want to have to deal with a bus/driver binding logic. It is + * intended to be very simple, with only a create and a destroy function + * available. + */ +#ifndef _FAUX_DEVICE_H_ +#define _FAUX_DEVICE_H_ + +#include + +struct faux_device { + struct device dev; +}; +#define to_faux_device(x) container_of_const((x), struct faux_device, dev) + +struct faux_driver_ops { + int (*probe)(struct faux_device *faux_dev); + void (*remove)(struct faux_device *faux_dev); +}; + +struct faux_device *faux_device_create(const char *name, struct faux_driver_ops *faux_ops); +void faux_device_destroy(struct faux_device *faux_dev); + +#endif /* _FAUX_DEVICE_H_ */ From patchwork Tue Feb 4 11:09:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13958913 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 B313B20C00E; Tue, 4 Feb 2025 11:09:45 +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=1738667386; cv=none; b=NuQZIWLTXsBZ8x3dyhhq/yTaAdIPTCYii5R2ilOYm6gYAGYdDD4By73ZolxZPaNpL6qPL2m8AjxwSxKuW+xUSZkGFxFvP+NmUewpqhB0eKR7yodku6ccRNZwP9ozAGvNj8il2R2FTXF464njM/CQpU69uPao6bvFJVe3JRdaiv4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738667386; c=relaxed/simple; bh=2oLZPp+3xuQLLYWTD0IeW4wqB4YveRahPZ5fYZybOIM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XVspDVY5fHL/cG6EVZwbZ1WQQEq4/VFry4oW4O0YCgUBTGxKu5ZrRJ9ZXNniIsrmJd2J045KPqKfzXDQt7DJqEkoVMkE/bjJlZKUQBw4FfNediYC3bKwWRia51+nSiZ21uM2tqVjlj1KrztMZ14DiCMjOHvGgH30CrYAF5cnoZw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sX6cxsEG; 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="sX6cxsEG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74D25C4CEDF; Tue, 4 Feb 2025 11:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738667385; bh=2oLZPp+3xuQLLYWTD0IeW4wqB4YveRahPZ5fYZybOIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sX6cxsEGDxun7fzpRPcmC0dCNoCQAR2NCKCYzQl6DU8MFZWQdPYs98V0xYjCgUwBR WiqF/4rm2dggRqFWF5p5Zb204LxvjJTyKC4b5R7bkf3TAw7eb5ant6SE/T90PbhQZV Umul3AcZCu9UbVyImabPcMiBsS4nGxmFPCe1xTwI= 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 v2 2/5] regulator: dummy: convert to use the faux bus Date: Tue, 4 Feb 2025 12:09:14 +0100 Message-ID: <2025020424-shuffle-facedown-973f@gregkh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <2025020421-poster-moisture-534b@gregkh> References: <2025020421-poster-moisture-534b@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=2727; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=2oLZPp+3xuQLLYWTD0IeW4wqB4YveRahPZ5fYZybOIM=; b=owGbwMvMwCRo6H6F97bub03G02pJDOkLv6a8tjzI1pXwe6V4068H/Fv9/4VEe3WGOxRs6Ht2a ncj2wPujlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZiIuRDDfP83AVV5ix7cnMVt H/Xdrqw5MCpRm2F+7cxbU48o2Vz/Gxak8375u9uHTFwbAQ== 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. Signed-off-by: Greg Kroah-Hartman Reviewed-by: Mark Brown Reviewed-by: Jonathan Cameron --- 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..4dfff27d5b03 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_driver_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 Tue Feb 4 11:09:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13958914 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 D0A6E20A5F1; Tue, 4 Feb 2025 11:09:49 +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=1738667389; cv=none; b=Rpnft9FTj5GJWf6fsPgXgVrxktBVXfd/BQS+71F6H7/PmwVBbY0jQNkAMzebxbIUNjtg3nMvlNcLglpaWR9YLqMllBWGOxzi//aHZtUi0N9w6JHcZJDx0Vd8/I9ZCrRLXDjvavxxAyDwrTmP4sADpsdVCvO/breA+U2KBjxqkjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738667389; c=relaxed/simple; bh=BUDXKiFk/9VT3QXVDcyMfviA4AmGJkFmSYcFfg6fQDg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HoIv4OXoKfDaOM/xxw95nZ8a0KmMrDg8asiTYnijDwLN5X5fj5fo7P89SKjwdClvvFQizZdPww6w9NeGWFZh+W9GXaSHpUZDzs1UIStYYi6fyQKyggcMRDE4vSHGKbqKjWC+9b8HiKP9CvEgaqJQyBMg6AnHWnMA9vbgM6FM/CI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HvdhsEwa; 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="HvdhsEwa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B4F2C4CEDF; Tue, 4 Feb 2025 11:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738667389; bh=BUDXKiFk/9VT3QXVDcyMfviA4AmGJkFmSYcFfg6fQDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HvdhsEwajw6HdjQcvlPREsrFcafz47DEDkaqlkXrq4vnnEn1rdrwe/KAkkgvZ0k2U TNxwZr6N0fSX6p9NwdLwJnOmZ+LapwNukGZKstN8R5ENFz2IqpOLSOB0wyaeuQWMtH eCGVt5T1dhUGtLq5HNkISLra0ZTioNP2/ajaomsw= 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 v2 3/5] USB: phy: convert usb_phy_generic logic to use a faux device Date: Tue, 4 Feb 2025 12:09:15 +0100 Message-ID: <2025020424-overstock-scheming-6a30@gregkh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <2025020421-poster-moisture-534b@gregkh> References: <2025020421-poster-moisture-534b@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=5681; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=BUDXKiFk/9VT3QXVDcyMfviA4AmGJkFmSYcFfg6fQDg=; b=owGbwMvMwCRo6H6F97bub03G02pJDOkLv6buy4yMOXKGKdHQdfaU4LIPxSdufO9Z5tnZyXDr0 /y91R/6OmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiC54yzPfy91lcHp0Z+mf9 vgPLVhzYkZgk8IRhwZYgF92HH7cK3jkUqhyXzGITfvzOEQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 The usb_phy_generic code was creating a "fake" platform device to pass around in different places. Instead of doing that, use the faux bus instead as that is what is really wanted here. Site note, this fixes a bug in the mpfs driver where the incorrect pointer was being passed to usb_phy_generic_unregister(), odd that no one ever hit this in the past. Signed-off-by: Greg Kroah-Hartman --- v2: no change drivers/usb/chipidea/ci_hdrc_pci.c | 2 +- drivers/usb/dwc2/pci.c | 4 ++-- drivers/usb/musb/mediatek.c | 4 ++-- drivers/usb/musb/mpfs.c | 4 ++-- drivers/usb/musb/tusb6010.c | 2 +- drivers/usb/phy/phy-generic.c | 9 ++++----- include/linux/usb/usb_phy_generic.h | 9 +++++---- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c b/drivers/usb/chipidea/ci_hdrc_pci.c index d63479e1ad10..63511ea30d6e 100644 --- a/drivers/usb/chipidea/ci_hdrc_pci.c +++ b/drivers/usb/chipidea/ci_hdrc_pci.c @@ -20,7 +20,7 @@ struct ci_hdrc_pci { struct platform_device *ci; - struct platform_device *phy; + struct faux_device *phy; }; /****************************************************************************** diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c index f3a1e4232a31..8cb50620aa55 100644 --- a/drivers/usb/dwc2/pci.c +++ b/drivers/usb/dwc2/pci.c @@ -30,7 +30,7 @@ static const char dwc2_driver_name[] = "dwc2-pci"; struct dwc2_pci_glue { struct platform_device *dwc2; - struct platform_device *phy; + struct faux_device *phy; }; /** @@ -53,7 +53,7 @@ static int dwc2_pci_probe(struct pci_dev *pci, { struct resource res[2]; struct platform_device *dwc2; - struct platform_device *phy; + struct faux_device *phy; int ret; struct device *dev = &pci->dev; struct dwc2_pci_glue *glue; diff --git a/drivers/usb/musb/mediatek.c b/drivers/usb/musb/mediatek.c index aa988d74b58d..995bab88506a 100644 --- a/drivers/usb/musb/mediatek.c +++ b/drivers/usb/musb/mediatek.c @@ -43,7 +43,7 @@ struct mtk_glue { struct device *dev; struct musb *musb; struct platform_device *musb_pdev; - struct platform_device *usb_phy; + struct faux_device *usb_phy; struct phy *phy; struct usb_phy *xceiv; enum phy_mode phy_mode; @@ -507,7 +507,7 @@ static int mtk_musb_probe(struct platform_device *pdev) static void mtk_musb_remove(struct platform_device *pdev) { struct mtk_glue *glue = platform_get_drvdata(pdev); - struct platform_device *usb_phy = glue->usb_phy; + struct faux_device *usb_phy = glue->usb_phy; platform_device_unregister(glue->musb_pdev); usb_phy_generic_unregister(usb_phy); diff --git a/drivers/usb/musb/mpfs.c b/drivers/usb/musb/mpfs.c index 7edc8429b274..ef20794aee12 100644 --- a/drivers/usb/musb/mpfs.c +++ b/drivers/usb/musb/mpfs.c @@ -25,7 +25,7 @@ struct mpfs_glue { struct device *dev; struct platform_device *musb; - struct platform_device *phy; + struct faux_device *phy; struct clk *clk; }; @@ -356,7 +356,7 @@ static void mpfs_remove(struct platform_device *pdev) clk_disable_unprepare(glue->clk); platform_device_unregister(glue->musb); - usb_phy_generic_unregister(pdev); + usb_phy_generic_unregister(glue->phy); } #ifdef CONFIG_OF diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 90b760a95e4e..92609f9d20ff 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -32,7 +32,7 @@ struct tusb6010_glue { struct device *dev; struct platform_device *musb; - struct platform_device *phy; + struct faux_device *phy; struct gpio_desc *enable; struct gpio_desc *intpin; }; diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index 6c3ececf9137..a6cece75d0f8 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c @@ -30,16 +30,15 @@ (IRQF_SHARED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | \ IRQF_ONESHOT) -struct platform_device *usb_phy_generic_register(void) +struct faux_device *usb_phy_generic_register(void) { - return platform_device_register_simple("usb_phy_generic", - PLATFORM_DEVID_AUTO, NULL, 0); + return faux_device_create("usb_phy_generic", NULL); } EXPORT_SYMBOL_GPL(usb_phy_generic_register); -void usb_phy_generic_unregister(struct platform_device *pdev) +void usb_phy_generic_unregister(struct faux_device *fdev) { - platform_device_unregister(pdev); + faux_device_destroy(fdev); } EXPORT_SYMBOL_GPL(usb_phy_generic_unregister); diff --git a/include/linux/usb/usb_phy_generic.h b/include/linux/usb/usb_phy_generic.h index cd9e70a552a0..856db2bacc07 100644 --- a/include/linux/usb/usb_phy_generic.h +++ b/include/linux/usb/usb_phy_generic.h @@ -3,18 +3,19 @@ #define __LINUX_USB_NOP_XCEIV_H #include +#include #if IS_ENABLED(CONFIG_NOP_USB_XCEIV) /* sometimes transceivers are accessed only through e.g. ULPI */ -extern struct platform_device *usb_phy_generic_register(void); -extern void usb_phy_generic_unregister(struct platform_device *); +struct faux_device *usb_phy_generic_register(void); +void usb_phy_generic_unregister(struct faux_device *); #else -static inline struct platform_device *usb_phy_generic_register(void) +static inline struct faux_device *usb_phy_generic_register(void) { return NULL; } -static inline void usb_phy_generic_unregister(struct platform_device *pdev) +static inline void usb_phy_generic_unregister(struct faux_device *fdev) { } #endif From patchwork Tue Feb 4 11:09:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13958915 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 EA71620D514; Tue, 4 Feb 2025 11:09:52 +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=1738667393; cv=none; b=u2P1+Iil5xgiZJ81AAPaDnjMuTPHdRgZxCeApYyVvHButM8qrebLRSJsI0Gi8GU/MSf3U1VXkgiCzmlk49jABHTG0q0JO0IKPat7wVnt3gsl2oEfyOi74V/+qEr2HWeAruWsloFYw+Jcz7It+kXeJGedcAIgnRw7HGiRxEBOYN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738667393; c=relaxed/simple; bh=LdW0uVQlr+ae304Zc3rLEEKoqyXxDQFCwoGTQbR2z/Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=liTE13hySbb58TbkftpFRN8U5+fQ+0Ev7qVT9W47L1xfkAa3CFm9zrhikf3Z2+ofUO6OgKbiqEqPw1QLE5vkYoldOY+xCzIuqlqfSEVzcvD8VA+54g5QM0SVmRENG3GJ2mHEcriwkz65PyYuGYEyzFZ8WmEXSotQ+6QFGTS2jBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CmMUIrIP; 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="CmMUIrIP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C835AC4CEE2; Tue, 4 Feb 2025 11:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738667392; bh=LdW0uVQlr+ae304Zc3rLEEKoqyXxDQFCwoGTQbR2z/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CmMUIrIPH1RbtuN6Kd0eHH7037I/7f/31Zbg4YZmbd3APqSUpMia0i9zQa3Uzd92Y dlU1bLN04TZPjyYHH93exJjPYdGMNPeni1jw6wzuKx4P5Hncu0yhA8dGPfgH6dBYzm DVTRm5w9JAkIkTdauMLeMGnkUjvOkW00YJp7r33g= 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 v2 4/5] x86/microcode: move away from using a fake platform device Date: Tue, 4 Feb 2025 12:09:16 +0100 Message-ID: <2025020425-try-clicker-2267@gregkh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <2025020421-poster-moisture-534b@gregkh> References: <2025020421-poster-moisture-534b@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=2253; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=LdW0uVQlr+ae304Zc3rLEEKoqyXxDQFCwoGTQbR2z/Y=; b=owGbwMvMwCRo6H6F97bub03G02pJDOkLv6b+41bedtA0K3rpbp+Zeo4v5nw/+D72v3feZ7ufW e2sK/fc64hlYRBkYpAVU2T5so3n6P6KQ4pehranYeawMoEMYeDiFICJRKUyzOE9uIq/sF7X5XUK w8UiNVMxhRvv6hkWzN8pnR14piOx4GHrn/xV9l28XP8NAQ== 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 --- 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 Tue Feb 4 11:09:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13958916 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 F41D620DD64; Tue, 4 Feb 2025 11:09:55 +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=1738667396; cv=none; b=c36goRrvyGXOFxls13KCf5mODA0f91J0V0YK15UtgKwLkg5wyMF4ZV+JI1mp+/M1GI+9Aj71O/CqYiBPJQniyOrTiKYFhBBDlj+iyCgE6YuwmgK8IIMdJnvJvpiOW0llOxjZS9DCdTLiHHLHLvEO9+HtsIgqcyAiuHD+zLKghEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738667396; c=relaxed/simple; bh=ntgkV69b2fyGJypAfUMTQ4pQJEyhemVKS7tW1bGczT0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gR7Dekz/uT4/ahfu9TOCzaXPKK3lZjBlcR7QRXxMUPFqHoUbCBpmmDqOMwWvFphXcdaCAvSHN8fBuRdv6Vfj/XU/zsjgftJ4oagcao8vxEPGdQn9EvSGy+YnDabq32kNaX6+y//lfT+O8psbH1wplvqa33HGw2lZD7Nngesea0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=m5OpiXnJ; 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="m5OpiXnJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6BD0C4CEE4; Tue, 4 Feb 2025 11:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738667395; bh=ntgkV69b2fyGJypAfUMTQ4pQJEyhemVKS7tW1bGczT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m5OpiXnJL/VJ7CuaMpqzR1NQBzX6td9VU/aPCBR7oSkz6XW9uknmvfpyLyTsMTdRz 6qYahXaiBgKY0NDtUPaw5KAX5Ec5l+HzNy1n7a2EkEAKIFsk5eTA+HdNRhgeJ3+VVB OYqQ5CpQQrmCMsVgy/571Gmx0gHW4y+hhEzY2Zew= 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 v2 5/5] wifi: cfg80211: move away from using a fake platform device Date: Tue, 4 Feb 2025 12:09:17 +0100 Message-ID: <2025020425-esquire-tucking-7521@gregkh> X-Mailer: git-send-email 2.48.1 In-Reply-To: <2025020421-poster-moisture-534b@gregkh> References: <2025020421-poster-moisture-534b@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=4009; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=ntgkV69b2fyGJypAfUMTQ4pQJEyhemVKS7tW1bGczT0=; b=owGbwMvMwCRo6H6F97bub03G02pJDOkLv6buK9h3oSJQduHZKc+Yck6ZbHR/xC1Y/u5H+PZ3/ z45+rxT7ohlYRBkYpAVU2T5so3n6P6KQ4pehranYeawMoEMYeDiFICJbPBgmMNxcvnN43x/N+2e K+fqFxBwYuPX06wMc6Usl2yeHdLgK7642eT1U32fZAn+aQA= 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 "regulatory device" is not anything resembling a platform device at all. Signed-off-by: Greg Kroah-Hartman --- v2: new example patch in this series net/wireless/reg.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 2dd0533e7660..e7a7179eb14d 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include @@ -105,7 +105,7 @@ static struct regulatory_request __rcu *last_request = (void __force __rcu *)&core_request_world; /* To trigger userspace events and load firmware */ -static struct platform_device *reg_pdev; +static struct faux_device *reg_fdev; /* * Central wireless core regulatory domains, we only need two, @@ -582,7 +582,7 @@ static int call_crda(const char *alpha2) else pr_debug("Calling CRDA to update world regulatory domain\n"); - ret = kobject_uevent_env(®_pdev->dev.kobj, KOBJ_CHANGE, env); + ret = kobject_uevent_env(®_fdev->dev.kobj, KOBJ_CHANGE, env); if (ret) return ret; @@ -778,7 +778,7 @@ static bool regdb_has_valid_signature(const u8 *data, unsigned int size) const struct firmware *sig; bool result; - if (request_firmware(&sig, "regulatory.db.p7s", ®_pdev->dev)) + if (request_firmware(&sig, "regulatory.db.p7s", ®_fdev->dev)) return false; result = verify_pkcs7_signature(data, size, sig->data, sig->size, @@ -1060,7 +1060,7 @@ static int query_regdb_file(const char *alpha2) return -ENOMEM; err = request_firmware_nowait(THIS_MODULE, true, "regulatory.db", - ®_pdev->dev, GFP_KERNEL, + ®_fdev->dev, GFP_KERNEL, (void *)alpha2, regdb_fw_cb); if (err) kfree(alpha2); @@ -1076,7 +1076,7 @@ int reg_reload_regdb(void) const struct ieee80211_regdomain *current_regdomain; struct regulatory_request *request; - err = request_firmware(&fw, "regulatory.db", ®_pdev->dev); + err = request_firmware(&fw, "regulatory.db", ®_fdev->dev); if (err) return err; @@ -4297,12 +4297,12 @@ static int __init regulatory_init_db(void) * in that case, don't try to do any further work here as * it's doomed to lead to crashes. */ - if (IS_ERR_OR_NULL(reg_pdev)) + if (!reg_fdev) return -EINVAL; err = load_builtin_regdb_keys(); if (err) { - platform_device_unregister(reg_pdev); + faux_device_destroy(reg_fdev); return err; } @@ -4310,7 +4310,7 @@ static int __init regulatory_init_db(void) err = regulatory_hint_core(cfg80211_world_regdom->alpha2); if (err) { if (err == -ENOMEM) { - platform_device_unregister(reg_pdev); + faux_device_destroy(reg_fdev); return err; } /* @@ -4339,9 +4339,9 @@ late_initcall(regulatory_init_db); int __init regulatory_init(void) { - reg_pdev = platform_device_register_simple("regulatory", 0, NULL, 0); - if (IS_ERR(reg_pdev)) - return PTR_ERR(reg_pdev); + reg_fdev = faux_device_create("regulatory", NULL); + if (!reg_fdev) + return -ENODEV; rcu_assign_pointer(cfg80211_regdomain, cfg80211_world_regdom); @@ -4369,9 +4369,9 @@ void regulatory_exit(void) reset_regdomains(true, NULL); rtnl_unlock(); - dev_set_uevent_suppress(®_pdev->dev, true); + dev_set_uevent_suppress(®_fdev->dev, true); - platform_device_unregister(reg_pdev); + faux_device_destroy(reg_fdev); list_for_each_entry_safe(reg_beacon, btmp, ®_pending_beacons, list) { list_del(®_beacon->list);