History

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.

Pawel Moll committed 12 years ago

Commit 514b82a1 parent 4cde4cc1 file · +12 −1Browse files

Unified · Split

drivers/char/tile-srom.c+12−1
@@ -76,6 +76,7 @@ MODULE_LICENSE("GPL"); · 75 unmodified lines
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) · 268 unmodified lines
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) · 58 unmodified lines
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 @@ fail_class: · 17 unmodified lines
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) · 10 unmodified lines
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 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t