aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorPawel Moll <pawel.moll@arm.com>2014-08-08 11:32:58 -0400
committerChris Metcalf <cmetcalf@tilera.com>2014-10-02 10:19:34 -0400
commit514b82a52b7aaa413ab8f0e7db93a5ccd0540d09 (patch)
tree6244d14105f7a1a2833bb53c33e91e59c0a5a97f /drivers/char
parent4cde4cc87a19cfe7351e3d0fd87d8a49271781f6 (diff)
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>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/tile-srom.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c
index bd377472dcfb..02e76ac6d282 100644
--- a/drivers/char/tile-srom.c
+++ b/drivers/char/tile-srom.c
@@ -76,6 +76,7 @@ MODULE_LICENSE("GPL");
76 76
77static int srom_devs; /* Number of SROM partitions */ 77static int srom_devs; /* Number of SROM partitions */
78static struct cdev srom_cdev; 78static struct cdev srom_cdev;
79static struct platform_device *srom_parent;
79static struct class *srom_class; 80static struct class *srom_class;
80static struct srom_dev *srom_devices; 81static struct srom_dev *srom_devices;
81 82
@@ -350,7 +351,7 @@ static int srom_setup_minor(struct srom_dev *srom, int index)
350 SROM_PAGE_SIZE_OFF, sizeof(srom->page_size)) < 0) 351 SROM_PAGE_SIZE_OFF, sizeof(srom->page_size)) < 0)
351 return -EIO; 352 return -EIO;
352 353
353 dev = device_create(srom_class, &platform_bus, 354 dev = device_create(srom_class, &srom_parent->dev,
354 MKDEV(srom_major, index), srom, "%d", index); 355 MKDEV(srom_major, index), srom, "%d", index);
355 return PTR_ERR_OR_ZERO(dev); 356 return PTR_ERR_OR_ZERO(dev);
356} 357}
@@ -415,6 +416,13 @@ static int srom_init(void)
415 if (result < 0) 416 if (result < 0)
416 goto fail_chrdev; 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 /* Create a sysfs class. */ 426 /* Create a sysfs class. */
419 srom_class = class_create(THIS_MODULE, "srom"); 427 srom_class = class_create(THIS_MODULE, "srom");
420 if (IS_ERR(srom_class)) { 428 if (IS_ERR(srom_class)) {
@@ -438,6 +446,8 @@ fail_class:
438 device_destroy(srom_class, MKDEV(srom_major, i)); 446 device_destroy(srom_class, MKDEV(srom_major, i));
439 class_destroy(srom_class); 447 class_destroy(srom_class);
440fail_cdev: 448fail_cdev:
449 platform_device_unregister(srom_parent);
450fail_pdev:
441 cdev_del(&srom_cdev); 451 cdev_del(&srom_cdev);
442fail_chrdev: 452fail_chrdev:
443 unregister_chrdev_region(dev, srom_devs); 453 unregister_chrdev_region(dev, srom_devs);
@@ -454,6 +464,7 @@ static void srom_cleanup(void)
454 device_destroy(srom_class, MKDEV(srom_major, i)); 464 device_destroy(srom_class, MKDEV(srom_major, i));
455 class_destroy(srom_class); 465 class_destroy(srom_class);
456 cdev_del(&srom_cdev); 466 cdev_del(&srom_cdev);
467 platform_device_unregister(srom_parent);
457 unregister_chrdev_region(MKDEV(srom_major, 0), srom_devs); 468 unregister_chrdev_region(MKDEV(srom_major, 0), srom_devs);
458 kfree(srom_devices); 469 kfree(srom_devices);
459} 470}