hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/firmware/efi/dev-path-parser.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * dev-path-parser.c - EFI Device Path parser
34 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de>
....@@ -5,14 +6,6 @@
56 * This program is free software; you can redistribute it and/or modify
67 * it under the terms of the GNU General Public License (version 2) as
78 * published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
13
- *
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/>.
169 */
1710
1811 #include <linux/acpi.h>
....@@ -24,9 +17,9 @@
2417 char uid[11]; /* UINT_MAX + null byte */
2518 };
2619
27
-static int __init match_acpi_dev(struct device *dev, void *data)
20
+static int __init match_acpi_dev(struct device *dev, const void *data)
2821 {
29
- struct acpi_hid_uid hid_uid = *(struct acpi_hid_uid *)data;
22
+ struct acpi_hid_uid hid_uid = *(const struct acpi_hid_uid *)data;
3023 struct acpi_device *adev = to_acpi_device(dev);
3124
3225 if (acpi_match_device_ids(adev, hid_uid.hid))
....@@ -38,13 +31,13 @@
3831 return !strcmp("0", hid_uid.uid);
3932 }
4033
41
-static long __init parse_acpi_path(struct efi_dev_path *node,
34
+static long __init parse_acpi_path(const struct efi_dev_path *node,
4235 struct device *parent, struct device **child)
4336 {
4437 struct acpi_hid_uid hid_uid = {};
4538 struct device *phys_dev;
4639
47
- if (node->length != 12)
40
+ if (node->header.length != 12)
4841 return -EINVAL;
4942
5043 sprintf(hid_uid.hid[0].id, "%c%c%c%04X",
....@@ -76,12 +69,12 @@
7669 return dev_is_pci(dev) && to_pci_dev(dev)->devfn == devfn;
7770 }
7871
79
-static long __init parse_pci_path(struct efi_dev_path *node,
72
+static long __init parse_pci_path(const struct efi_dev_path *node,
8073 struct device *parent, struct device **child)
8174 {
8275 unsigned int devfn;
8376
84
- if (node->length != 6)
77
+ if (node->header.length != 6)
8578 return -EINVAL;
8679 if (!parent)
8780 return -EINVAL;
....@@ -112,19 +105,19 @@
112105 * search for a device.
113106 */
114107
115
-static long __init parse_end_path(struct efi_dev_path *node,
108
+static long __init parse_end_path(const struct efi_dev_path *node,
116109 struct device *parent, struct device **child)
117110 {
118
- if (node->length != 4)
111
+ if (node->header.length != 4)
119112 return -EINVAL;
120
- if (node->sub_type != EFI_DEV_END_INSTANCE &&
121
- node->sub_type != EFI_DEV_END_ENTIRE)
113
+ if (node->header.sub_type != EFI_DEV_END_INSTANCE &&
114
+ node->header.sub_type != EFI_DEV_END_ENTIRE)
122115 return -EINVAL;
123116 if (!parent)
124117 return -ENODEV;
125118
126119 *child = get_device(parent);
127
- return node->sub_type;
120
+ return node->header.sub_type;
128121 }
129122
130123 /**
....@@ -163,7 +156,7 @@
163156 * %ERR_PTR(-EINVAL) if a node is malformed or exceeds @len,
164157 * %ERR_PTR(-ENOTSUPP) if support for a node type is not yet implemented.
165158 */
166
-struct device * __init efi_get_device_by_path(struct efi_dev_path **node,
159
+struct device * __init efi_get_device_by_path(const struct efi_dev_path **node,
167160 size_t *len)
168161 {
169162 struct device *parent = NULL, *child;
....@@ -173,16 +166,16 @@
173166 return NULL;
174167
175168 while (!ret) {
176
- if (*len < 4 || *len < (*node)->length)
169
+ if (*len < 4 || *len < (*node)->header.length)
177170 ret = -EINVAL;
178
- else if ((*node)->type == EFI_DEV_ACPI &&
179
- (*node)->sub_type == EFI_DEV_BASIC_ACPI)
171
+ else if ((*node)->header.type == EFI_DEV_ACPI &&
172
+ (*node)->header.sub_type == EFI_DEV_BASIC_ACPI)
180173 ret = parse_acpi_path(*node, parent, &child);
181
- else if ((*node)->type == EFI_DEV_HW &&
182
- (*node)->sub_type == EFI_DEV_PCI)
174
+ else if ((*node)->header.type == EFI_DEV_HW &&
175
+ (*node)->header.sub_type == EFI_DEV_PCI)
183176 ret = parse_pci_path(*node, parent, &child);
184
- else if (((*node)->type == EFI_DEV_END_PATH ||
185
- (*node)->type == EFI_DEV_END_PATH2))
177
+ else if (((*node)->header.type == EFI_DEV_END_PATH ||
178
+ (*node)->header.type == EFI_DEV_END_PATH2))
186179 ret = parse_end_path(*node, parent, &child);
187180 else
188181 ret = -ENOTSUPP;
....@@ -192,8 +185,8 @@
192185 return ERR_PTR(ret);
193186
194187 parent = child;
195
- *node = (void *)*node + (*node)->length;
196
- *len -= (*node)->length;
188
+ *node = (void *)*node + (*node)->header.length;
189
+ *len -= (*node)->header.length;
197190 }
198191
199192 if (ret == EFI_DEV_END_ENTIRE)