diff options
| -rw-r--r-- | drivers/acpi/scan.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 99f97ac64aa4..b4d5549265ed 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
| @@ -194,7 +194,8 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias, | |||
| 194 | * | 194 | * |
| 195 | * Check if the given device has an ACPI companion and if that companion has | 195 | * Check if the given device has an ACPI companion and if that companion has |
| 196 | * a valid list of PNP IDs, and if the device is the first (primary) physical | 196 | * a valid list of PNP IDs, and if the device is the first (primary) physical |
| 197 | * device associated with it. | 197 | * device associated with it. Return the companion pointer if that's the case |
| 198 | * or NULL otherwise. | ||
| 198 | * | 199 | * |
| 199 | * If multiple physical devices are attached to a single ACPI companion, we need | 200 | * If multiple physical devices are attached to a single ACPI companion, we need |
| 200 | * to be careful. The usage scenario for this kind of relationship is that all | 201 | * to be careful. The usage scenario for this kind of relationship is that all |
| @@ -208,31 +209,31 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias, | |||
| 208 | * resources available from it but they will be matched normally using functions | 209 | * resources available from it but they will be matched normally using functions |
| 209 | * provided by their bus types (and analogously for their modalias). | 210 | * provided by their bus types (and analogously for their modalias). |
| 210 | */ | 211 | */ |
| 211 | static bool acpi_companion_match(const struct device *dev) | 212 | static struct acpi_device *acpi_companion_match(const struct device *dev) |
| 212 | { | 213 | { |
| 213 | struct acpi_device *adev; | 214 | struct acpi_device *adev; |
| 214 | bool ret; | ||
| 215 | 215 | ||
| 216 | adev = ACPI_COMPANION(dev); | 216 | adev = ACPI_COMPANION(dev); |
| 217 | if (!adev) | 217 | if (!adev) |
| 218 | return false; | 218 | return NULL; |
| 219 | 219 | ||
| 220 | if (list_empty(&adev->pnp.ids)) | 220 | if (list_empty(&adev->pnp.ids)) |
| 221 | return false; | 221 | return NULL; |
| 222 | 222 | ||
| 223 | mutex_lock(&adev->physical_node_lock); | 223 | mutex_lock(&adev->physical_node_lock); |
| 224 | if (list_empty(&adev->physical_node_list)) { | 224 | if (list_empty(&adev->physical_node_list)) { |
| 225 | ret = false; | 225 | adev = NULL; |
| 226 | } else { | 226 | } else { |
| 227 | const struct acpi_device_physical_node *node; | 227 | const struct acpi_device_physical_node *node; |
| 228 | 228 | ||
| 229 | node = list_first_entry(&adev->physical_node_list, | 229 | node = list_first_entry(&adev->physical_node_list, |
| 230 | struct acpi_device_physical_node, node); | 230 | struct acpi_device_physical_node, node); |
| 231 | ret = node->dev == dev; | 231 | if (node->dev != dev) |
| 232 | adev = NULL; | ||
| 232 | } | 233 | } |
| 233 | mutex_unlock(&adev->physical_node_lock); | 234 | mutex_unlock(&adev->physical_node_lock); |
| 234 | 235 | ||
| 235 | return ret; | 236 | return adev; |
| 236 | } | 237 | } |
| 237 | 238 | ||
| 238 | /* | 239 | /* |
| @@ -904,7 +905,7 @@ static const struct acpi_device_id *__acpi_match_device( | |||
| 904 | * If the device is not present, it is unnecessary to load device | 905 | * If the device is not present, it is unnecessary to load device |
| 905 | * driver for it. | 906 | * driver for it. |
| 906 | */ | 907 | */ |
| 907 | if (!device->status.present) | 908 | if (!device || !device->status.present) |
| 908 | return NULL; | 909 | return NULL; |
| 909 | 910 | ||
| 910 | for (id = ids; id->id[0]; id++) | 911 | for (id = ids; id->id[0]; id++) |
| @@ -929,16 +930,7 @@ static const struct acpi_device_id *__acpi_match_device( | |||
| 929 | const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, | 930 | const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, |
| 930 | const struct device *dev) | 931 | const struct device *dev) |
| 931 | { | 932 | { |
| 932 | struct acpi_device *adev; | 933 | return __acpi_match_device(acpi_companion_match(dev), ids); |
| 933 | acpi_handle handle = ACPI_HANDLE(dev); | ||
| 934 | |||
| 935 | if (!ids || !handle || acpi_bus_get_device(handle, &adev)) | ||
| 936 | return NULL; | ||
| 937 | |||
| 938 | if (!acpi_companion_match(dev)) | ||
| 939 | return NULL; | ||
| 940 | |||
| 941 | return __acpi_match_device(adev, ids); | ||
| 942 | } | 934 | } |
| 943 | EXPORT_SYMBOL_GPL(acpi_match_device); | 935 | EXPORT_SYMBOL_GPL(acpi_match_device); |
| 944 | 936 | ||
