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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'devicetree-fixes-for-5.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux

Pull devicetree fixes from Rob Herring:

- Fix fw_devlink failure with ".*,nr-gpios" properties

- Doc link reference fixes from Mauro

- Fixes for unaligned FDT handling found on OpenRisc. First, avoid
crash with better error handling when unflattening an unaligned FDT.
Second, fix memory allocations for FDTs to ensure alignment.

* tag 'devicetree-fixes-for-5.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux:
of: property: fw_devlink: do not link ".*,nr-gpios"
dt-bindings:iio:adc: update motorola,cpcap-adc.yaml reference
dt-bindings: fix references for iio-bindings.txt
dt-bindings: don't use ../dir for doc references
of: unittest: overlay: ensure proper alignment of copied FDT
of: properly check for error returned by fdt_get_name()

+88 -43
+1 -1
Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
··· 32 32 - "#thermal-sensor-cells" Used to expose itself to thermal fw. 33 33 34 34 Read more about iio bindings at 35 - Documentation/devicetree/bindings/iio/iio-bindings.txt 35 + https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/ 36 36 37 37 Example: 38 38 ncp15wb473@0 {
+3 -2
Documentation/devicetree/bindings/iio/adc/ingenic,adc.yaml
··· 14 14 Industrial I/O subsystem bindings for ADC controller found in 15 15 Ingenic JZ47xx SoCs. 16 16 17 - ADC clients must use the format described in iio-bindings.txt, giving 18 - a phandle and IIO specifier pair ("io-channels") to the ADC controller. 17 + ADC clients must use the format described in 18 + https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml, 19 + giving a phandle and IIO specifier pair ("io-channels") to the ADC controller. 19 20 20 21 properties: 21 22 compatible:
+3 -1
Documentation/devicetree/bindings/input/adc-joystick.yaml
··· 24 24 description: > 25 25 List of phandle and IIO specifier pairs. 26 26 Each pair defines one ADC channel to which a joystick axis is connected. 27 - See Documentation/devicetree/bindings/iio/iio-bindings.txt for details. 27 + See 28 + https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml 29 + for details. 28 30 29 31 '#address-cells': 30 32 const: 1
+4 -1
Documentation/devicetree/bindings/input/touchscreen/resistive-adc-touch.txt
··· 5 5 - compatible: must be "resistive-adc-touch" 6 6 The device must be connected to an ADC device that provides channels for 7 7 position measurement and optional pressure. 8 - Refer to ../iio/iio-bindings.txt for details 8 + Refer to 9 + https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml 10 + for details 11 + 9 12 - iio-channels: must have at least two channels connected to an ADC device. 10 13 These should correspond to the channels exposed by the ADC device and should 11 14 have the right index as the ADC device registers them. These channels
+3 -1
Documentation/devicetree/bindings/mfd/ab8500.txt
··· 72 72 pwm|regulator|rtc|sysctrl|usb]"; 73 73 74 74 A few child devices require ADC channels from the GPADC node. Those follow the 75 - standard bindings from iio/iio-bindings.txt and iio/adc/adc.txt 75 + standard bindings from 76 + https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml 77 + and Documentation/devicetree/bindings/iio/adc/adc.yaml 76 78 77 79 abx500-temp : io-channels "aux1" and "aux2" for measuring external 78 80 temperatures.
+8 -8
Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
··· 16 16 The sub-functions of CPCAP get their own node with their own compatible values, 17 17 which are described in the following files: 18 18 19 - - ../power/supply/cpcap-battery.txt 20 - - ../power/supply/cpcap-charger.txt 21 - - ../regulator/cpcap-regulator.txt 22 - - ../phy/phy-cpcap-usb.txt 23 - - ../input/cpcap-pwrbutton.txt 24 - - ../rtc/cpcap-rtc.txt 25 - - ../leds/leds-cpcap.txt 26 - - ../iio/adc/cpcap-adc.txt 19 + - Documentation/devicetree/bindings/power/supply/cpcap-battery.txt 20 + - Documentation/devicetree/bindings/power/supply/cpcap-charger.txt 21 + - Documentation/devicetree/bindings/regulator/cpcap-regulator.txt 22 + - Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt 23 + - Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt 24 + - Documentation/devicetree/bindings/rtc/cpcap-rtc.txt 25 + - Documentation/devicetree/bindings/leds/leds-cpcap.txt 26 + - Documentation/devicetree/bindings/iio/adc/motorola,cpcap-adc.yaml 27 27 28 28 The only exception is the audio codec. Instead of a compatible value its 29 29 node must be named "audio-codec".
+23 -13
drivers/of/fdt.c
··· 205 205 *pprev = NULL; 206 206 } 207 207 208 - static bool populate_node(const void *blob, 208 + static int populate_node(const void *blob, 209 209 int offset, 210 210 void **mem, 211 211 struct device_node *dad, ··· 214 214 { 215 215 struct device_node *np; 216 216 const char *pathp; 217 - unsigned int l, allocl; 217 + int len; 218 218 219 - pathp = fdt_get_name(blob, offset, &l); 219 + pathp = fdt_get_name(blob, offset, &len); 220 220 if (!pathp) { 221 221 *pnp = NULL; 222 - return false; 222 + return len; 223 223 } 224 224 225 - allocl = ++l; 225 + len++; 226 226 227 - np = unflatten_dt_alloc(mem, sizeof(struct device_node) + allocl, 227 + np = unflatten_dt_alloc(mem, sizeof(struct device_node) + len, 228 228 __alignof__(struct device_node)); 229 229 if (!dryrun) { 230 230 char *fn; 231 231 of_node_init(np); 232 232 np->full_name = fn = ((char *)np) + sizeof(*np); 233 233 234 - memcpy(fn, pathp, l); 234 + memcpy(fn, pathp, len); 235 235 236 236 if (dad != NULL) { 237 237 np->parent = dad; ··· 295 295 struct device_node *nps[FDT_MAX_DEPTH]; 296 296 void *base = mem; 297 297 bool dryrun = !base; 298 + int ret; 298 299 299 300 if (nodepp) 300 301 *nodepp = NULL; ··· 323 322 !of_fdt_device_is_available(blob, offset)) 324 323 continue; 325 324 326 - if (!populate_node(blob, offset, &mem, nps[depth], 327 - &nps[depth+1], dryrun)) 328 - return mem - base; 325 + ret = populate_node(blob, offset, &mem, nps[depth], 326 + &nps[depth+1], dryrun); 327 + if (ret < 0) 328 + return ret; 329 329 330 330 if (!dryrun && nodepp && !*nodepp) 331 331 *nodepp = nps[depth+1]; ··· 374 372 { 375 373 int size; 376 374 void *mem; 375 + int ret; 376 + 377 + if (mynodes) 378 + *mynodes = NULL; 377 379 378 380 pr_debug(" -> unflatten_device_tree()\n"); 379 381 ··· 398 392 399 393 /* First pass, scan for size */ 400 394 size = unflatten_dt_nodes(blob, NULL, dad, NULL); 401 - if (size < 0) 395 + if (size <= 0) 402 396 return NULL; 403 397 404 398 size = ALIGN(size, 4); ··· 416 410 pr_debug(" unflattening %p...\n", mem); 417 411 418 412 /* Second pass, do actual unflattening */ 419 - unflatten_dt_nodes(blob, mem, dad, mynodes); 413 + ret = unflatten_dt_nodes(blob, mem, dad, mynodes); 414 + 420 415 if (be32_to_cpup(mem + size) != 0xdeadbeef) 421 416 pr_warn("End of tree marker overwritten: %08x\n", 422 417 be32_to_cpup(mem + size)); 423 418 424 - if (detached && mynodes) { 419 + if (ret <= 0) 420 + return NULL; 421 + 422 + if (detached && mynodes && *mynodes) { 425 423 of_node_set_flag(*mynodes, OF_DETACHED); 426 424 pr_debug("unflattened tree is detached\n"); 427 425 }
+2
drivers/of/of_private.h
··· 8 8 * Copyright (C) 1996-2005 Paul Mackerras. 9 9 */ 10 10 11 + #define FDT_ALIGN_SIZE 8 12 + 11 13 /** 12 14 * struct alias_prop - Alias property in 'aliases' node 13 15 * @link: List node to link the structure in aliases_lookup list
+15 -9
drivers/of/overlay.c
··· 57 57 * struct overlay_changeset 58 58 * @id: changeset identifier 59 59 * @ovcs_list: list on which we are located 60 - * @fdt: FDT that was unflattened to create @overlay_tree 60 + * @fdt: base of memory allocated to hold aligned FDT that was unflattened to create @overlay_tree 61 61 * @overlay_tree: expanded device tree that contains the fragment nodes 62 62 * @count: count of fragment structures 63 63 * @fragments: fragment nodes in the overlay expanded device tree ··· 719 719 /** 720 720 * init_overlay_changeset() - initialize overlay changeset from overlay tree 721 721 * @ovcs: Overlay changeset to build 722 - * @fdt: the FDT that was unflattened to create @tree 723 - * @tree: Contains all the overlay fragments and overlay fixup nodes 722 + * @fdt: base of memory allocated to hold aligned FDT that was unflattened to create @tree 723 + * @tree: Contains the overlay fragments and overlay fixup nodes 724 724 * 725 725 * Initialize @ovcs. Populate @ovcs->fragments with node information from 726 726 * the top level of @tree. The relevant top level nodes are the fragment ··· 873 873 * internal documentation 874 874 * 875 875 * of_overlay_apply() - Create and apply an overlay changeset 876 - * @fdt: the FDT that was unflattened to create @tree 876 + * @fdt: base of memory allocated to hold the aligned FDT 877 877 * @tree: Expanded overlay device tree 878 878 * @ovcs_id: Pointer to overlay changeset id 879 879 * ··· 953 953 /* 954 954 * after overlay_notify(), ovcs->overlay_tree related pointers may have 955 955 * leaked to drivers, so can not kfree() tree, aka ovcs->overlay_tree; 956 - * and can not free fdt, aka ovcs->fdt 956 + * and can not free memory containing aligned fdt. The aligned fdt 957 + * is contained within the memory at ovcs->fdt, possibly at an offset 958 + * from ovcs->fdt. 957 959 */ 958 960 ret = overlay_notify(ovcs, OF_OVERLAY_PRE_APPLY); 959 961 if (ret) { ··· 1016 1014 int of_overlay_fdt_apply(const void *overlay_fdt, u32 overlay_fdt_size, 1017 1015 int *ovcs_id) 1018 1016 { 1019 - const void *new_fdt; 1017 + void *new_fdt; 1018 + void *new_fdt_align; 1020 1019 int ret; 1021 1020 u32 size; 1022 - struct device_node *overlay_root; 1021 + struct device_node *overlay_root = NULL; 1023 1022 1024 1023 *ovcs_id = 0; 1025 1024 ret = 0; ··· 1039 1036 * Must create permanent copy of FDT because of_fdt_unflatten_tree() 1040 1037 * will create pointers to the passed in FDT in the unflattened tree. 1041 1038 */ 1042 - new_fdt = kmemdup(overlay_fdt, size, GFP_KERNEL); 1039 + new_fdt = kmalloc(size + FDT_ALIGN_SIZE, GFP_KERNEL); 1043 1040 if (!new_fdt) 1044 1041 return -ENOMEM; 1045 1042 1046 - of_fdt_unflatten_tree(new_fdt, NULL, &overlay_root); 1043 + new_fdt_align = PTR_ALIGN(new_fdt, FDT_ALIGN_SIZE); 1044 + memcpy(new_fdt_align, overlay_fdt, size); 1045 + 1046 + of_fdt_unflatten_tree(new_fdt_align, NULL, &overlay_root); 1047 1047 if (!overlay_root) { 1048 1048 pr_err("unable to unflatten overlay_fdt\n"); 1049 1049 ret = -EINVAL;
+10 -1
drivers/of/property.c
··· 1262 1262 DEFINE_SIMPLE_PROP(pinctrl8, "pinctrl-8", NULL) 1263 1263 DEFINE_SUFFIX_PROP(regulators, "-supply", NULL) 1264 1264 DEFINE_SUFFIX_PROP(gpio, "-gpio", "#gpio-cells") 1265 - DEFINE_SUFFIX_PROP(gpios, "-gpios", "#gpio-cells") 1265 + 1266 + static struct device_node *parse_gpios(struct device_node *np, 1267 + const char *prop_name, int index) 1268 + { 1269 + if (!strcmp_suffix(prop_name, ",nr-gpios")) 1270 + return NULL; 1271 + 1272 + return parse_suffix_prop_cells(np, prop_name, index, "-gpios", 1273 + "#gpio-cells"); 1274 + } 1266 1275 1267 1276 static struct device_node *parse_iommu_maps(struct device_node *np, 1268 1277 const char *prop_name, int index)
+16 -6
drivers/of/unittest.c
··· 22 22 #include <linux/slab.h> 23 23 #include <linux/device.h> 24 24 #include <linux/platform_device.h> 25 + #include <linux/kernel.h> 25 26 26 27 #include <linux/i2c.h> 27 28 #include <linux/i2c-mux.h> ··· 1409 1408 static int __init unittest_data_add(void) 1410 1409 { 1411 1410 void *unittest_data; 1412 - struct device_node *unittest_data_node, *np; 1411 + void *unittest_data_align; 1412 + struct device_node *unittest_data_node = NULL, *np; 1413 1413 /* 1414 1414 * __dtb_testcases_begin[] and __dtb_testcases_end[] are magically 1415 1415 * created by cmd_dt_S_dtb in scripts/Makefile.lib ··· 1419 1417 extern uint8_t __dtb_testcases_end[]; 1420 1418 const int size = __dtb_testcases_end - __dtb_testcases_begin; 1421 1419 int rc; 1420 + void *ret; 1422 1421 1423 1422 if (!size) { 1424 - pr_warn("%s: No testcase data to attach; not running tests\n", 1425 - __func__); 1423 + pr_warn("%s: testcases is empty\n", __func__); 1426 1424 return -ENODATA; 1427 1425 } 1428 1426 1429 1427 /* creating copy */ 1430 - unittest_data = kmemdup(__dtb_testcases_begin, size, GFP_KERNEL); 1428 + unittest_data = kmalloc(size + FDT_ALIGN_SIZE, GFP_KERNEL); 1431 1429 if (!unittest_data) 1432 1430 return -ENOMEM; 1433 1431 1434 - of_fdt_unflatten_tree(unittest_data, NULL, &unittest_data_node); 1432 + unittest_data_align = PTR_ALIGN(unittest_data, FDT_ALIGN_SIZE); 1433 + memcpy(unittest_data_align, __dtb_testcases_begin, size); 1434 + 1435 + ret = of_fdt_unflatten_tree(unittest_data_align, NULL, &unittest_data_node); 1436 + if (!ret) { 1437 + pr_warn("%s: unflatten testcases tree failed\n", __func__); 1438 + kfree(unittest_data); 1439 + return -ENODATA; 1440 + } 1435 1441 if (!unittest_data_node) { 1436 - pr_warn("%s: No tree to attach; not running tests\n", __func__); 1442 + pr_warn("%s: testcases tree is empty\n", __func__); 1437 1443 kfree(unittest_data); 1438 1444 return -ENODATA; 1439 1445 }