mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
06f054b1fe
DT Bindings: - Convert samsung,exynos5-dp, atmel,lcdc, aspeed,ast2400-wdt bindings to schemas - Add bindings for Allwinner H616 NMI controller, Renesas r8a779g0 irqc, Renesas R-Car V4M TMU and CMT timers, Freescale S32G3 linflexuart, and Mediatek MT7988 XHCI - Add 'reg' constraints on DSI and SPI display panels - More dropping of unnecessary quotes in schemas - Use full paths rather than relative paths in schema $refs - Drop redundant storing of phandle for reserved memory DT Core: - Use scope based cleanups for kfree() and of_node_put() - Track interrupt-map and power-supplies for fw_devlink - Add buffer overflow check in of_modalias() - Add and use __of_prop_free() helper for freeing struct property -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEktVUI4SxYhzZyEuo+vtdtY28YcMFAmZGQGQACgkQ+vtdtY28 YcNUcg/7BqmWMNSPCqExiR/Vj9jGjpbZlXH5I8w2vvSpcDbeWgAAXxSLnPJvdM3n tqDFec+4ieHAqerd0T3DAjauK1EIsC/+DiBO1JIgb6yhLkTcr+X5MYH7U5/WmQe/ +3baDokNXhqWQnas8YMNFzJqTJNFkUijS2QgwiL4Ypz2e64mctPjoSQKOtkQA8iZ jfh/r2w0wIeous00Kf07REC6oL5Svzrx2Cg9geiFVIk9Puyk6esr/H1a4jyLbAvc F3znSY21x5vqMGX3F0z8Mp5/aYpuvGkrXkzbOv8+OEP0ipJCwHA0BuK7pYe6narj Ys0SygCrEC2VoWv2PypEN7xSj4/9TVt5gIWK9Lxf/fJLeuTVDr+9qhv4WvuYyDdG kI09PlkG5bovpLAZi/YqulcRGEOPuJIQ+GST9Rf+0fFuAeCbxQmhq7BWmaSedUm2 lt0F5NofGTuTXAEMrwlu7FrfPZrVXLFczpsvG8dunR1iGYJm5QvIaJoqnFoQjUa6 1Vi4cK7VNRGhOYx/3uBzF8lB+CN5MqKyMUCc4hcR4f4Ut4/uPg4HjgxJUWo9aY76 VyryxNEV0K9idUMmW+dGEtbmXWc8ukbz2OOAPlKYobbmIOQpQZcMIizq7ilanZmZ DNRhcqvoAwb7+zGaJ1DWFy/14/09JNBuC+mZUNjvxzb3fhcvjqE= =tslW -----END PGP SIGNATURE----- Merge tag 'devicetree-for-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull devicetree updates from Rob Herring: "DT Bindings: - Convert samsung,exynos5-dp, atmel,lcdc, aspeed,ast2400-wdt bindings to schemas - Add bindings for Allwinner H616 NMI controller, Renesas r8a779g0 irqc, Renesas R-Car V4M TMU and CMT timers, Freescale S32G3 linflexuart, and Mediatek MT7988 XHCI - Add 'reg' constraints on DSI and SPI display panels - More dropping of unnecessary quotes in schemas - Use full paths rather than relative paths in schema $refs - Drop redundant storing of phandle for reserved memory DT Core: - Use scope based cleanups for kfree() and of_node_put() - Track interrupt-map and power-supplies for fw_devlink - Add buffer overflow check in of_modalias() - Add and use __of_prop_free() helper for freeing struct property" * tag 'devicetree-for-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (25 commits) of: property: Add fw_devlink support for interrupt-map property dt-bindings: display: panel: constrain 'reg' in DSI panels dt-bindings: display: panel: constrain 'reg' in SPI panels dt-bindings: display: samsung,ams495qa01: add missing SPI properties ref dt-bindings: Use full path to other schemas dt-bindings: PCI: qcom,pcie-sm8350: Drop redundant 'oneOf' sub-schema of: module: add buffer overflow check in of_modalias() dt-bindings: PCI: microchip: increase number of items in ranges property dt-bindings: Drop unnecessary quotes on keys dt-bindings: interrupt-controller: mediatek,mt6577-sysirq: Drop unnecessary quotes of: property: Use scope based cleanup on port_node of: reserved_mem: Remove the use of phandle from the reserved_mem APIs of: property: fw_devlink: Add support for "power-supplies" binding dt-bindings: watchdog: aspeed,ast2400-wdt: Convert to DT schema dt-bindings: irq: sun7i-nmi: Add binding for the H616 NMI controller dt-bindings: interrupt-controller: renesas,irqc: Add r8a779g0 support dt-bindings: timer: renesas,tmu: Add R-Car V4M support dt-bindings: timer: renesas,cmt: Add R-Car V4M support of: Use scope based of_node_put() cleanups of: Use scope based kfree() cleanups ...
84 lines
1.6 KiB
C
84 lines
1.6 KiB
C
// 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;
|
|
|
|
/*
|
|
* Prevent a kernel oops in vsnprintf() -- it only allows passing a
|
|
* NULL ptr when the length is also 0. Also filter out the negative
|
|
* lengths...
|
|
*/
|
|
if ((len > 0 && !str) || len < 0)
|
|
return -EINVAL;
|
|
|
|
/* 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;
|
|
if (csize >= len)
|
|
csize = len > 0 ? len - 1 : 0;
|
|
len -= csize;
|
|
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);
|