Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/x86: dell-pc: Transition to faux device

Use a faux device parent for registering the platform_profile instead of
a "fake" platform device.

The faux bus is a minimalistic, single driver bus designed for this
purpose.

Signed-off-by: Kurt Borja <kuurtb@gmail.com>
Link: https://lore.kernel.org/r/20250411-dell-faux-v1-3-ea1f1c929b7e@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Kurt Borja and committed by
Ilpo Järvinen
99fb11d1 48e21e02

+13 -33
+13 -33
drivers/platform/x86/dell/dell-pc.c
··· 13 13 #include <linux/bitfield.h> 14 14 #include <linux/bitops.h> 15 15 #include <linux/bits.h> 16 + #include <linux/device/faux.h> 16 17 #include <linux/dmi.h> 17 18 #include <linux/err.h> 18 19 #include <linux/init.h> 19 20 #include <linux/kernel.h> 20 21 #include <linux/module.h> 21 22 #include <linux/platform_profile.h> 22 - #include <linux/platform_device.h> 23 23 #include <linux/slab.h> 24 24 25 25 #include "dell-smbios.h" 26 26 27 - static struct platform_device *platform_device; 27 + static struct faux_device *dell_pc_fdev; 28 28 static int supported_modes; 29 29 30 30 static const struct dmi_system_id dell_device_table[] __initconst = { ··· 246 246 .profile_set = thermal_platform_profile_set, 247 247 }; 248 248 249 - static int thermal_init(void) 249 + static int dell_pc_faux_probe(struct faux_device *fdev) 250 250 { 251 251 struct device *ppdev; 252 252 int ret; ··· 258 258 if (ret < 0) 259 259 return ret; 260 260 261 - platform_device = platform_device_register_simple("dell-pc", PLATFORM_DEVID_NONE, NULL, 0); 262 - if (IS_ERR(platform_device)) 263 - return PTR_ERR(platform_device); 261 + ppdev = devm_platform_profile_register(&fdev->dev, "dell-pc", NULL, 262 + &dell_pc_platform_profile_ops); 264 263 265 - ppdev = devm_platform_profile_register(&platform_device->dev, "dell-pc", 266 - NULL, &dell_pc_platform_profile_ops); 267 - if (IS_ERR(ppdev)) { 268 - ret = PTR_ERR(ppdev); 269 - goto cleanup_platform_device; 270 - } 271 - 272 - return 0; 273 - 274 - cleanup_platform_device: 275 - platform_device_unregister(platform_device); 276 - 277 - return ret; 264 + return PTR_ERR_OR_ZERO(ppdev); 278 265 } 279 266 280 - static void thermal_cleanup(void) 281 - { 282 - platform_device_unregister(platform_device); 283 - } 267 + static const struct faux_device_ops dell_pc_faux_ops = { 268 + .probe = dell_pc_faux_probe, 269 + }; 284 270 285 271 static int __init dell_init(void) 286 272 { 287 - int ret; 288 - 289 273 if (!dmi_check_system(dell_device_table)) 290 274 return -ENODEV; 291 275 292 - ret = thermal_init(); 293 - if (ret) 294 - goto fail_thermal; 276 + dell_pc_fdev = faux_device_create("dell-pc", NULL, &dell_pc_faux_ops); 277 + if (!dell_pc_fdev) 278 + return -ENODEV; 295 279 296 280 return 0; 297 - 298 - fail_thermal: 299 - thermal_cleanup(); 300 - return ret; 301 281 } 302 282 303 283 static void __exit dell_exit(void) 304 284 { 305 - thermal_cleanup(); 285 + faux_device_destroy(dell_pc_fdev); 306 286 } 307 287 308 288 module_init(dell_init);