1 // SPDX-License-Identifier: GPL-2.0
3 * Linux kernel module helpers.
7 #include <linux/module.h>
8 #include <linux/slab.h>
9 #include <linux/string.h>
11 ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
20 /* %p eats all alphanum characters, so %c must be used here */
21 csize = snprintf(str, len, "of:N%pOFn%c%s", np, 'T',
22 of_node_get_device_type(np));
28 of_property_for_each_string(np, "compatible", p, compat) {
29 csize = strlen(compat) + 1;
34 csize = snprintf(str, len, "C%s", compat);
47 int of_request_module(const struct device_node *np)
56 size = of_modalias(np, NULL, 0);
60 /* Reserve an additional byte for the trailing '\0' */
63 str = kmalloc(size, GFP_KERNEL);
67 of_modalias(np, str, size);
69 ret = request_module(str);
74 EXPORT_SYMBOL_GPL(of_request_module);