Skip to content

Commit 514b82a

Browse files
pawelmollcmetcalf-tilera
authored andcommitted
char: tile-srom: Add real platform bus parent
Add a real platform bus device as a parent for the srom class devices, to prevent non-platform devices hanging from the bus root. Signed-off-by: Pawel Moll <pawel.moll@arm.com> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
1 parent 4cde4cc commit 514b82a

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎drivers/char/tile-srom.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ MODULE_LICENSE("GPL");
7676

7777
static int srom_devs; /* Number of SROM partitions */
7878
static struct cdev srom_cdev;
79+
static struct platform_device *srom_parent;
7980
static struct class *srom_class;
8081
static struct srom_dev *srom_devices;
8182

@@ -350,7 +351,7 @@ static int srom_setup_minor(struct srom_dev *srom, int index)
350351
SROM_PAGE_SIZE_OFF, sizeof(srom->page_size)) < 0)
351352
return -EIO;
352353

353-
dev = device_create(srom_class, &platform_bus,
354+
dev = device_create(srom_class, &srom_parent->dev,
354355
MKDEV(srom_major, index), srom, "%d", index);
355356
return PTR_ERR_OR_ZERO(dev);
356357
}
@@ -415,6 +416,13 @@ static int srom_init(void)
415416
if (result < 0)
416417
goto fail_chrdev;
417418

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+
418426
/* Create a sysfs class. */
419427
srom_class = class_create(THIS_MODULE, "srom");
420428
if (IS_ERR(srom_class)) {
@@ -438,6 +446,8 @@ static int srom_init(void)
438446
device_destroy(srom_class, MKDEV(srom_major, i));
439447
class_destroy(srom_class);
440448
fail_cdev:
449+
platform_device_unregister(srom_parent);
450+
fail_pdev:
441451
cdev_del(&srom_cdev);
442452
fail_chrdev:
443453
unregister_chrdev_region(dev, srom_devs);
@@ -454,6 +464,7 @@ static void srom_cleanup(void)
454464
device_destroy(srom_class, MKDEV(srom_major, i));
455465
class_destroy(srom_class);
456466
cdev_del(&srom_cdev);
467+
platform_device_unregister(srom_parent);
457468
unregister_chrdev_region(MKDEV(srom_major, 0), srom_devs);
458469
kfree(srom_devices);
459470
}

0 commit comments

Comments
 (0)