diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 5db9b0202d03..76178ecaa9f9 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -777,6 +777,34 @@ static int ion_init_sysfs(void) return 0; } +#ifdef CONFIG_DEBUG_FS +static int ion_heaps_show(struct seq_file *s, void *unused) +{ + struct ion_device *dev = internal_dev; + struct ion_heap *heap; + + down_read(&dev->lock); + seq_printf(s, "%s\t%s\t%s\n", "id", "type", "name"); + plist_for_each_entry(heap, &dev->heaps, node) { + seq_printf(s, "%u\t%u\t%s\n", heap->id, heap->type, heap->name); + } + up_read(&dev->lock); + return 0; +} + +static int ion_heaps_open(struct inode *inode, struct file *file) +{ + return single_open(file, ion_heaps_show, NULL); +} + +static const struct file_operations ion_heaps_operations = { + .open = ion_heaps_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; +#endif + static int ion_device_create(void) { struct ion_device *idev; @@ -803,6 +831,10 @@ static int ion_device_create(void) } idev->debug_root = debugfs_create_dir("ion", NULL); +#ifdef CONFIG_DEBUG_FS + debugfs_create_file("heaps", 0444, idev->debug_root, NULL, + &ion_heaps_operations); +#endif idev->buffers = RB_ROOT; mutex_init(&idev->buffer_lock); init_rwsem(&idev->lock);