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

of/fdt: Fix ‘of_fdt_match’ defined but not used compiler warning

When CONFIG_OF_EARLY_FLATTREE is disabled, there is a compiler
warning,

drivers/of/fdt.c:129:19: warning: ‘of_fdt_match’ defined but not used [-Wunused-function]
static int __init of_fdt_match(const void *blob, unsigned long node,

Since the only caller of of_fdt_match() is of_flat_dt_match(),
let's move the body of of_fdt_match() into of_flat_dt_match()
and eliminate of_fdt_match().

Meanwhile, move of_fdt_is_compatible() under CONFIG_OF_EARLY_FLATTREE,
as all callers are over there.

Fixes: 9b4d2b635bd0 ("of/fdt: Remove dead code and mark functions with __init")
Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Rob Herring <robh@kernel.org>

authored by

Kefeng Wang and committed by
Rob Herring
5d9c4e95 2554fcb8

+45 -54
+45 -54
drivers/of/fdt.c
··· 78 78 } 79 79 } 80 80 81 - /** 82 - * of_fdt_is_compatible - Return true if given node from the given blob has 83 - * compat in its compatible list 84 - * @blob: A device tree blob 85 - * @node: node to test 86 - * @compat: compatible string to compare with compatible list. 87 - * 88 - * On match, returns a non-zero value with smaller values returned for more 89 - * specific compatible values. 90 - */ 91 - static int of_fdt_is_compatible(const void *blob, 92 - unsigned long node, const char *compat) 93 - { 94 - const char *cp; 95 - int cplen; 96 - unsigned long l, score = 0; 97 - 98 - cp = fdt_getprop(blob, node, "compatible", &cplen); 99 - if (cp == NULL) 100 - return 0; 101 - while (cplen > 0) { 102 - score++; 103 - if (of_compat_cmp(cp, compat, strlen(compat)) == 0) 104 - return score; 105 - l = strlen(cp) + 1; 106 - cp += l; 107 - cplen -= l; 108 - } 109 - 110 - return 0; 111 - } 112 - 113 81 static bool of_fdt_device_is_available(const void *blob, unsigned long node) 114 82 { 115 83 const char *status = fdt_getprop(blob, node, "status", NULL); ··· 89 121 return true; 90 122 91 123 return false; 92 - } 93 - 94 - /** 95 - * of_fdt_match - Return true if node matches a list of compatible values 96 - */ 97 - static int __init of_fdt_match(const void *blob, unsigned long node, 98 - const char *const *compat) 99 - { 100 - unsigned int tmp, score = 0; 101 - 102 - if (!compat) 103 - return 0; 104 - 105 - while (*compat) { 106 - tmp = of_fdt_is_compatible(blob, node, *compat); 107 - if (tmp && (score == 0 || (tmp < score))) 108 - score = tmp; 109 - compat++; 110 - } 111 - 112 - return score; 113 124 } 114 125 115 126 static void *unflatten_dt_alloc(void **mem, unsigned long size, ··· 712 765 } 713 766 714 767 /** 768 + * of_fdt_is_compatible - Return true if given node from the given blob has 769 + * compat in its compatible list 770 + * @blob: A device tree blob 771 + * @node: node to test 772 + * @compat: compatible string to compare with compatible list. 773 + * 774 + * On match, returns a non-zero value with smaller values returned for more 775 + * specific compatible values. 776 + */ 777 + static int of_fdt_is_compatible(const void *blob, 778 + unsigned long node, const char *compat) 779 + { 780 + const char *cp; 781 + int cplen; 782 + unsigned long l, score = 0; 783 + 784 + cp = fdt_getprop(blob, node, "compatible", &cplen); 785 + if (cp == NULL) 786 + return 0; 787 + while (cplen > 0) { 788 + score++; 789 + if (of_compat_cmp(cp, compat, strlen(compat)) == 0) 790 + return score; 791 + l = strlen(cp) + 1; 792 + cp += l; 793 + cplen -= l; 794 + } 795 + 796 + return 0; 797 + } 798 + 799 + /** 715 800 * of_flat_dt_is_compatible - Return true if given node has compat in compatible list 716 801 * @node: node to test 717 802 * @compat: compatible string to compare with compatible list. ··· 758 779 */ 759 780 static int __init of_flat_dt_match(unsigned long node, const char *const *compat) 760 781 { 761 - return of_fdt_match(initial_boot_params, node, compat); 782 + unsigned int tmp, score = 0; 783 + 784 + if (!compat) 785 + return 0; 786 + 787 + while (*compat) { 788 + tmp = of_fdt_is_compatible(initial_boot_params, node, *compat); 789 + if (tmp && (score == 0 || (tmp < score))) 790 + score = tmp; 791 + compat++; 792 + } 793 + 794 + return score; 762 795 } 763 796 764 797 /**