Contributors: 11
Author |
Tokens |
Token Proportion |
Commits |
Commit Proportion |
Stephen Boyd |
80 |
27.97% |
1 |
5.26% |
Stephen Rothwell |
77 |
26.92% |
3 |
15.79% |
Rob Herring |
54 |
18.88% |
4 |
21.05% |
Miquel Raynal |
32 |
11.19% |
4 |
21.05% |
Sylvain Munaut |
17 |
5.94% |
1 |
5.26% |
Björn Andersson |
11 |
3.85% |
1 |
5.26% |
Shawn Guo |
6 |
2.10% |
1 |
5.26% |
Grant C. Likely |
5 |
1.75% |
1 |
5.26% |
Robin Murphy |
2 |
0.70% |
1 |
5.26% |
Greg Kroah-Hartman |
1 |
0.35% |
1 |
5.26% |
Stepan Moskovchenko |
1 |
0.35% |
1 |
5.26% |
Total |
286 |
|
19 |
|
// SPDX-License-Identifier: GPL-2.0
/*
* Linux kernel module helpers.
*/
#include <linux/of.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/string.h>
ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
{
const char *compat;
char *c;
struct property *p;
ssize_t csize;
ssize_t tsize;
/* Name & Type */
/* %p eats all alphanum characters, so %c must be used here */
csize = snprintf(str, len, "of:N%pOFn%c%s", np, 'T',
of_node_get_device_type(np));
tsize = csize;
len -= csize;
if (str)
str += csize;
of_property_for_each_string(np, "compatible", p, compat) {
csize = strlen(compat) + 1;
tsize += csize;
if (csize > len)
continue;
csize = snprintf(str, len, "C%s", compat);
for (c = str; c; ) {
c = strchr(c, ' ');
if (c)
*c++ = '_';
}
len -= csize;
str += csize;
}
return tsize;
}
int of_request_module(const struct device_node *np)
{
char *str;
ssize_t size;
int ret;
if (!np)
return -ENODEV;
size = of_modalias(np, NULL, 0);
if (size < 0)
return size;
/* Reserve an additional byte for the trailing '\0' */
size++;
str = kmalloc(size, GFP_KERNEL);
if (!str)
return -ENOMEM;
of_modalias(np, str, size);
str[size - 1] = '\0';
ret = request_module(str);
kfree(str);
return ret;
}
EXPORT_SYMBOL_GPL(of_request_module);