mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	efi/dev-path-parser: Switch to use for_each_acpi_dev_match()
Switch to use for_each_acpi_dev_match() instead of home grown analogue. No functional change intended. Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
		
							parent
							
								
									55fc610c8c
								
							
						
					
					
						commit
						edbd1bc495
					
				
					 1 changed files with 17 additions and 30 deletions
				
			
		| 
						 | 
					@ -12,52 +12,39 @@
 | 
				
			||||||
#include <linux/efi.h>
 | 
					#include <linux/efi.h>
 | 
				
			||||||
#include <linux/pci.h>
 | 
					#include <linux/pci.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct acpi_hid_uid {
 | 
					 | 
				
			||||||
	struct acpi_device_id hid[2];
 | 
					 | 
				
			||||||
	char uid[11]; /* UINT_MAX + null byte */
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int __init match_acpi_dev(struct device *dev, const void *data)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct acpi_hid_uid hid_uid = *(const struct acpi_hid_uid *)data;
 | 
					 | 
				
			||||||
	struct acpi_device *adev = to_acpi_device(dev);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (acpi_match_device_ids(adev, hid_uid.hid))
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (adev->pnp.unique_id)
 | 
					 | 
				
			||||||
		return !strcmp(adev->pnp.unique_id, hid_uid.uid);
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		return !strcmp("0", hid_uid.uid);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static long __init parse_acpi_path(const struct efi_dev_path *node,
 | 
					static long __init parse_acpi_path(const struct efi_dev_path *node,
 | 
				
			||||||
				   struct device *parent, struct device **child)
 | 
									   struct device *parent, struct device **child)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct acpi_hid_uid hid_uid = {};
 | 
						char hid[ACPI_ID_LEN], uid[11]; /* UINT_MAX + null byte */
 | 
				
			||||||
 | 
						struct acpi_device *adev;
 | 
				
			||||||
	struct device *phys_dev;
 | 
						struct device *phys_dev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (node->header.length != 12)
 | 
						if (node->header.length != 12)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sprintf(hid_uid.hid[0].id, "%c%c%c%04X",
 | 
						sprintf(hid, "%c%c%c%04X",
 | 
				
			||||||
		'A' + ((node->acpi.hid >> 10) & 0x1f) - 1,
 | 
							'A' + ((node->acpi.hid >> 10) & 0x1f) - 1,
 | 
				
			||||||
		'A' + ((node->acpi.hid >>  5) & 0x1f) - 1,
 | 
							'A' + ((node->acpi.hid >>  5) & 0x1f) - 1,
 | 
				
			||||||
		'A' + ((node->acpi.hid >>  0) & 0x1f) - 1,
 | 
							'A' + ((node->acpi.hid >>  0) & 0x1f) - 1,
 | 
				
			||||||
			node->acpi.hid >> 16);
 | 
								node->acpi.hid >> 16);
 | 
				
			||||||
	sprintf(hid_uid.uid, "%u", node->acpi.uid);
 | 
						sprintf(uid, "%u", node->acpi.uid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*child = bus_find_device(&acpi_bus_type, NULL, &hid_uid,
 | 
						for_each_acpi_dev_match(adev, hid, NULL, -1) {
 | 
				
			||||||
				 match_acpi_dev);
 | 
							if (adev->pnp.unique_id && !strcmp(adev->pnp.unique_id, uid))
 | 
				
			||||||
	if (!*child)
 | 
								break;
 | 
				
			||||||
 | 
							if (!adev->pnp.unique_id && node->acpi.uid == 0)
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							acpi_dev_put(adev);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (!adev)
 | 
				
			||||||
		return -ENODEV;
 | 
							return -ENODEV;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	phys_dev = acpi_get_first_physical_node(to_acpi_device(*child));
 | 
						phys_dev = acpi_get_first_physical_node(adev);
 | 
				
			||||||
	if (phys_dev) {
 | 
						if (phys_dev) {
 | 
				
			||||||
		get_device(phys_dev);
 | 
							*child = get_device(phys_dev);
 | 
				
			||||||
		put_device(*child);
 | 
							acpi_dev_put(adev);
 | 
				
			||||||
		*child = phys_dev;
 | 
						} else
 | 
				
			||||||
	}
 | 
							*child = &adev->dev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue