Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of/fdt: create common debugfs

Both powerpc and microblaze have the same FDT blob in debugfs feature.
Move this to common location and remove the powerpc and microblaze
implementations. This feature could become more useful when FDT
overlay support is added.

This changes the path of the blob from "$arch/flat-device-tree" to
"device-tree/flat-device-tree".

Signed-off-by: Rob Herring <robh@kernel.org>
Tested-by: Michal Simek <michal.simek@xilinx.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
Tested-by: Grant Likely <grant.likely@linaro.org>
Tested-by: Stephen Chivers <schivers@csc.com>

+24 -52
-31
arch/microblaze/kernel/prom.c
··· 114 114 115 115 pr_debug(" <- early_init_devtree()\n"); 116 116 } 117 - 118 - /******* 119 - * 120 - * New implementation of the OF "find" APIs, return a refcounted 121 - * object, call of_node_put() when done. The device tree and list 122 - * are protected by a rw_lock. 123 - * 124 - * Note that property management will need some locking as well, 125 - * this isn't dealt with yet. 126 - * 127 - *******/ 128 - 129 - #if defined(CONFIG_DEBUG_FS) && defined(DEBUG) 130 - static struct debugfs_blob_wrapper flat_dt_blob; 131 - 132 - static int __init export_flat_device_tree(void) 133 - { 134 - struct dentry *d; 135 - 136 - flat_dt_blob.data = initial_boot_params; 137 - flat_dt_blob.size = initial_boot_params->totalsize; 138 - 139 - d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR, 140 - of_debugfs_root, &flat_dt_blob); 141 - if (!d) 142 - return 1; 143 - 144 - return 0; 145 - } 146 - device_initcall(export_flat_device_tree); 147 - #endif
-21
arch/powerpc/kernel/prom.c
··· 29 29 #include <linux/bitops.h> 30 30 #include <linux/export.h> 31 31 #include <linux/kexec.h> 32 - #include <linux/debugfs.h> 33 32 #include <linux/irq.h> 34 33 #include <linux/memblock.h> 35 34 #include <linux/of.h> ··· 923 924 { 924 925 return (int)phys_id == get_hard_smp_processor_id(cpu); 925 926 } 926 - 927 - #if defined(CONFIG_DEBUG_FS) && defined(DEBUG) 928 - static struct debugfs_blob_wrapper flat_dt_blob; 929 - 930 - static int __init export_flat_device_tree(void) 931 - { 932 - struct dentry *d; 933 - 934 - flat_dt_blob.data = initial_boot_params; 935 - flat_dt_blob.size = be32_to_cpu(initial_boot_params->totalsize); 936 - 937 - d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR, 938 - powerpc_debugfs_root, &flat_dt_blob); 939 - if (!d) 940 - return 1; 941 - 942 - return 0; 943 - } 944 - __initcall(export_flat_device_tree); 945 - #endif
+24
drivers/of/fdt.c
··· 20 20 #include <linux/errno.h> 21 21 #include <linux/slab.h> 22 22 #include <linux/libfdt.h> 23 + #include <linux/debugfs.h> 23 24 24 25 #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ 25 26 #include <asm/page.h> ··· 916 915 } 917 916 unflatten_device_tree(); 918 917 } 918 + 919 + #if defined(CONFIG_DEBUG_FS) && defined(DEBUG) 920 + static struct debugfs_blob_wrapper flat_dt_blob; 921 + 922 + static int __init of_flat_dt_debugfs_export_fdt(void) 923 + { 924 + struct dentry *d = debugfs_create_dir("device-tree", NULL); 925 + 926 + if (!d) 927 + return -ENOENT; 928 + 929 + flat_dt_blob.data = initial_boot_params; 930 + flat_dt_blob.size = fdt_totalsize(initial_boot_params); 931 + 932 + d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR, 933 + d, &flat_dt_blob); 934 + if (!d) 935 + return -ENOENT; 936 + 937 + return 0; 938 + } 939 + module_init(of_flat_dt_debugfs_export_fdt); 940 + #endif 919 941 920 942 #endif /* CONFIG_OF_EARLY_FLATTREE */