apple-properties.c (6e98503dba64e721ba839e75dca036266ec0140f) apple-properties.c (44612d7e0c379001460b37a29721128715bdcb02)
1/*
2 * apple-properties.c - EFI device properties on Macs
3 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License (version 2) as
7 * published by the Free Software Foundation.
8 *

--- 5 unchanged lines hidden (view full) ---

14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18#define pr_fmt(fmt) "apple-properties: " fmt
19
20#include <linux/bootmem.h>
21#include <linux/efi.h>
1/*
2 * apple-properties.c - EFI device properties on Macs
3 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License (version 2) as
7 * published by the Free Software Foundation.
8 *

--- 5 unchanged lines hidden (view full) ---

14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18#define pr_fmt(fmt) "apple-properties: " fmt
19
20#include <linux/bootmem.h>
21#include <linux/efi.h>
22#include <linux/io.h>
22#include <linux/platform_data/x86/apple.h>
23#include <linux/property.h>
24#include <linux/slab.h>
25#include <linux/ucs2_string.h>
26#include <asm/setup.h>
27
28static bool dump_properties __initdata;
29

--- 154 unchanged lines hidden (view full) ---

184 u64 pa_data;
185 int ret;
186
187 if (!x86_apple_machine)
188 return 0;
189
190 pa_data = boot_params.hdr.setup_data;
191 while (pa_data) {
23#include <linux/platform_data/x86/apple.h>
24#include <linux/property.h>
25#include <linux/slab.h>
26#include <linux/ucs2_string.h>
27#include <asm/setup.h>
28
29static bool dump_properties __initdata;
30

--- 154 unchanged lines hidden (view full) ---

185 u64 pa_data;
186 int ret;
187
188 if (!x86_apple_machine)
189 return 0;
190
191 pa_data = boot_params.hdr.setup_data;
192 while (pa_data) {
192 data = ioremap(pa_data, sizeof(*data));
193 data = memremap(pa_data, sizeof(*data), MEMREMAP_WB);
193 if (!data) {
194 pr_err("cannot map setup_data header\n");
195 return -ENOMEM;
196 }
197
198 if (data->type != SETUP_APPLE_PROPERTIES) {
199 pa_data = data->next;
194 if (!data) {
195 pr_err("cannot map setup_data header\n");
196 return -ENOMEM;
197 }
198
199 if (data->type != SETUP_APPLE_PROPERTIES) {
200 pa_data = data->next;
200 iounmap(data);
201 memunmap(data);
201 continue;
202 }
203
204 data_len = data->len;
202 continue;
203 }
204
205 data_len = data->len;
205 iounmap(data);
206 memunmap(data);
206
207
207 data = ioremap(pa_data, sizeof(*data) + data_len);
208 data = memremap(pa_data, sizeof(*data) + data_len, MEMREMAP_WB);
208 if (!data) {
209 pr_err("cannot map setup_data payload\n");
210 return -ENOMEM;
211 }
212
213 properties = (struct properties_header *)data->data;
214 if (properties->version != 1) {
215 pr_err("unsupported version:\n");

--- 8 unchanged lines hidden (view full) ---

224 } else
225 ret = unmarshal_devices(properties);
226
227 /*
228 * Can only free the setup_data payload but not its header
229 * to avoid breaking the chain of ->next pointers.
230 */
231 data->len = 0;
209 if (!data) {
210 pr_err("cannot map setup_data payload\n");
211 return -ENOMEM;
212 }
213
214 properties = (struct properties_header *)data->data;
215 if (properties->version != 1) {
216 pr_err("unsupported version:\n");

--- 8 unchanged lines hidden (view full) ---

225 } else
226 ret = unmarshal_devices(properties);
227
228 /*
229 * Can only free the setup_data payload but not its header
230 * to avoid breaking the chain of ->next pointers.
231 */
232 data->len = 0;
232 iounmap(data);
233 memunmap(data);
233 free_bootmem_late(pa_data + sizeof(*data), data_len);
234
235 return ret;
236 }
237 return 0;
238}
239
240fs_initcall(map_properties);
234 free_bootmem_late(pa_data + sizeof(*data), data_len);
235
236 return ret;
237 }
238 return 0;
239}
240
241fs_initcall(map_properties);