Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * apple-properties.c - EFI device properties on Macs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Properties are stored either as:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * u8 arrays which can be retrieved with device_property_read_u8_array() or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * booleans which can be queried with device_property_present().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define pr_fmt(fmt) "apple-properties: " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/memblock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/efi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/platform_data/x86/apple.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/property.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/ucs2_string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) static bool dump_properties __initdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static int __init dump_properties_enable(char *arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	dump_properties = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) __setup("dump_apple_properties", dump_properties_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) struct dev_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	u32 prop_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	struct efi_dev_path path[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	 * followed by key/value pairs, each key and value preceded by u32 len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	 * len includes itself, value may be empty (in which case its len is 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) struct properties_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	u32 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	u32 dev_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	struct dev_header dev_header[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static void __init unmarshal_key_value_pairs(struct dev_header *dev_header,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 					     struct device *dev, const void *ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 					     struct property_entry entry[])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	for (i = 0; i < dev_header->prop_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		int remaining = dev_header->len - (ptr - (void *)dev_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		u32 key_len, val_len, entry_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		const u8 *entry_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		char *key;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		if (sizeof(key_len) > remaining)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		key_len = *(typeof(key_len) *)ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		if (key_len + sizeof(val_len) > remaining ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		    key_len < sizeof(key_len) + sizeof(efi_char16_t) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		    *(efi_char16_t *)(ptr + sizeof(key_len)) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			dev_err(dev, "invalid property name len at %#zx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 				ptr - (void *)dev_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		val_len = *(typeof(val_len) *)(ptr + key_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		if (key_len + val_len > remaining ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		    val_len < sizeof(val_len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			dev_err(dev, "invalid property val len at %#zx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 				ptr - (void *)dev_header + key_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		/* 4 bytes to accommodate UTF-8 code points + null byte */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		key = kzalloc((key_len - sizeof(key_len)) * 4 + 1, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		if (!key) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			dev_err(dev, "cannot allocate property name\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		ucs2_as_utf8(key, ptr + sizeof(key_len),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			     key_len - sizeof(key_len));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		entry_data = ptr + key_len + sizeof(val_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		entry_len = val_len - sizeof(val_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		if (entry_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			entry[i] = PROPERTY_ENTRY_U8_ARRAY_LEN(key, entry_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 							       entry_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			entry[i] = PROPERTY_ENTRY_BOOL(key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		if (dump_properties) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			dev_info(dev, "property: %s\n", key);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			print_hex_dump(KERN_INFO, pr_fmt(), DUMP_PREFIX_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 				16, 1, entry_data, entry_len, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		ptr += key_len + val_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	if (i != dev_header->prop_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		dev_err(dev, "got %d device properties, expected %u\n", i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			dev_header->prop_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		print_hex_dump(KERN_ERR, pr_fmt(), DUMP_PREFIX_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			16, 1, dev_header, dev_header->len, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	dev_info(dev, "assigning %d device properties\n", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static int __init unmarshal_devices(struct properties_header *properties)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	size_t offset = offsetof(struct properties_header, dev_header[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	while (offset + sizeof(struct dev_header) < properties->len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		struct dev_header *dev_header = (void *)properties + offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		struct property_entry *entry = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		const struct efi_dev_path *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		size_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		if (offset + dev_header->len > properties->len ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		    dev_header->len <= sizeof(*dev_header)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			pr_err("invalid len in dev_header at %#zx\n", offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		ptr = dev_header->path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		len = dev_header->len - sizeof(*dev_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		dev = efi_get_device_by_path(&ptr, &len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		if (IS_ERR(dev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			pr_err("device path parse error %ld at %#zx:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 			       PTR_ERR(dev), (void *)ptr - (void *)dev_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 			print_hex_dump(KERN_ERR, pr_fmt(), DUMP_PREFIX_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			       16, 1, dev_header, dev_header->len, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			dev = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 			goto skip_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		entry = kcalloc(dev_header->prop_count + 1, sizeof(*entry),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 				GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		if (!entry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			dev_err(dev, "cannot allocate properties\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 			goto skip_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		unmarshal_key_value_pairs(dev_header, dev, ptr, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		if (!entry[0].name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 			goto skip_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		ret = device_add_properties(dev, entry); /* makes deep copy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 			dev_err(dev, "error %d assigning properties\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		for (i = 0; entry[i].name; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			kfree(entry[i].name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) skip_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		kfree(entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		put_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		offset += dev_header->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static int __init map_properties(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	struct properties_header *properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	struct setup_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	u32 data_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	u64 pa_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	if (!x86_apple_machine)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	pa_data = boot_params.hdr.setup_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	while (pa_data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		data = memremap(pa_data, sizeof(*data), MEMREMAP_WB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		if (!data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			pr_err("cannot map setup_data header\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		if (data->type != SETUP_APPLE_PROPERTIES) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			pa_data = data->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 			memunmap(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		data_len = data->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		memunmap(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		data = memremap(pa_data, sizeof(*data) + data_len, MEMREMAP_WB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		if (!data) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 			pr_err("cannot map setup_data payload\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		properties = (struct properties_header *)data->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		if (properties->version != 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 			pr_err("unsupported version:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			print_hex_dump(KERN_ERR, pr_fmt(), DUMP_PREFIX_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			       16, 1, properties, data_len, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			ret = -ENOTSUPP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		} else if (properties->len != data_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 			pr_err("length mismatch, expected %u\n", data_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			print_hex_dump(KERN_ERR, pr_fmt(), DUMP_PREFIX_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			       16, 1, properties, data_len, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			ret = unmarshal_devices(properties);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		 * Can only free the setup_data payload but not its header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		 * to avoid breaking the chain of ->next pointers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		data->len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		memunmap(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		memblock_free_late(pa_data + sizeof(*data), data_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) fs_initcall(map_properties);