Add a real platform bus device as a parent for the srom class devices, to prevent non-platform devices hanging from the bus root.
Showing the changes to drivers/char (1 of 1 file). Show all
Unified · Split
| @@ -76,6 +76,7 @@ MODULE_LICENSE("GPL"); · 75 unmodified lines | ||
| 76 | 76 | |
| 77 | 77 | static int srom_devs; /* Number of SROM partitions */ |
| 78 | 78 | static struct cdev srom_cdev; |
| 79 | +static struct platform_device *srom_parent; | |
| 79 | 80 | static struct class *srom_class; |
| 80 | 81 | static struct srom_dev *srom_devices; |
| 81 | 82 | |
| @@ -350,7 +351,7 @@ static int srom_setup_minor(struct srom_dev *srom, int index) · 268 unmodified lines | ||
| 350 | 351 | SROM_PAGE_SIZE_OFF, sizeof(srom->page_size)) < 0) |
| 351 | 352 | return -EIO; |
| 352 | 353 | |
| 353 | − dev = device_create(srom_class, &platform_bus, | |
| 354 | + dev = device_create(srom_class, &srom_parent->dev, | |
| 354 | 355 | MKDEV(srom_major, index), srom, "%d", index); |
| 355 | 356 | return PTR_ERR_OR_ZERO(dev); |
| 356 | 357 | } |
| @@ -415,6 +416,13 @@ static int srom_init(void) · 58 unmodified lines | ||
| 415 | 416 | if (result < 0) |
| 416 | 417 | goto fail_chrdev; |
| 417 | 418 | |
| 419 | + /* Create a parent device */ | |
| 420 | + srom_parent = platform_device_register_simple("srom", -1, NULL, 0); | |
| 421 | + if (IS_ERR(srom_parent)) { | |
| 422 | + result = PTR_ERR(srom_parent); | |
| 423 | + goto fail_pdev; | |
| 424 | + } | |
| 425 | + | |
| 418 | 426 | /* Create a sysfs class. */ |
| 419 | 427 | srom_class = class_create(THIS_MODULE, "srom"); |
| 420 | 428 | if (IS_ERR(srom_class)) { |
| @@ -438,6 +446,8 @@ fail_class: · 17 unmodified lines | ||
| 438 | 446 | device_destroy(srom_class, MKDEV(srom_major, i)); |
| 439 | 447 | class_destroy(srom_class); |
| 440 | 448 | fail_cdev: |
| 449 | + platform_device_unregister(srom_parent); | |
| 450 | +fail_pdev: | |
| 441 | 451 | cdev_del(&srom_cdev); |
| 442 | 452 | fail_chrdev: |
| 443 | 453 | unregister_chrdev_region(dev, srom_devs); |
| @@ -454,6 +464,7 @@ static void srom_cleanup(void) · 10 unmodified lines | ||
| 454 | 464 | device_destroy(srom_class, MKDEV(srom_major, i)); |
| 455 | 465 | class_destroy(srom_class); |
| 456 | 466 | cdev_del(&srom_cdev); |
| 467 | + platform_device_unregister(srom_parent); | |
| 457 | 468 | unregister_chrdev_region(MKDEV(srom_major, 0), srom_devs); |
| 458 | 469 | kfree(srom_devices); |
| 459 | 470 | } |