scan.c (c3b5d3cea508d2c8ff493ef18c45a9cc58fb7015) scan.c (ee89209402e0b9a733169901063afdf0ae7909db)
1/*
2 * scan.c - support for transforming the ACPI namespace into individual objects
3 */
4
5#include <linux/module.h>
6#include <linux/init.h>
7#include <linux/slab.h>
8#include <linux/kernel.h>

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

130static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
131 int size)
132{
133 int len;
134 int count;
135 struct acpi_hardware_id *id;
136
137 /*
1/*
2 * scan.c - support for transforming the ACPI namespace into individual objects
3 */
4
5#include <linux/module.h>
6#include <linux/init.h>
7#include <linux/slab.h>
8#include <linux/kernel.h>

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

130static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
131 int size)
132{
133 int len;
134 int count;
135 struct acpi_hardware_id *id;
136
137 /*
138 * Since we skip PRP0001 from the modalias below, 0 should be returned
139 * if PRP0001 is the only ACPI/PNP ID in the device's list.
138 * Since we skip ACPI_DT_NAMESPACE_HID from the modalias below, 0 should
139 * be returned if ACPI_DT_NAMESPACE_HID is the only ACPI/PNP ID in the
140 * device's list.
140 */
141 count = 0;
142 list_for_each_entry(id, &acpi_dev->pnp.ids, list)
141 */
142 count = 0;
143 list_for_each_entry(id, &acpi_dev->pnp.ids, list)
143 if (strcmp(id->id, "PRP0001"))
144 if (strcmp(id->id, ACPI_DT_NAMESPACE_HID))
144 count++;
145
146 if (!count)
147 return 0;
148
149 len = snprintf(modalias, size, "acpi:");
150 if (len <= 0)
151 return len;
152
153 size -= len;
154
155 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
145 count++;
146
147 if (!count)
148 return 0;
149
150 len = snprintf(modalias, size, "acpi:");
151 if (len <= 0)
152 return len;
153
154 size -= len;
155
156 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
156 if (!strcmp(id->id, "PRP0001"))
157 if (!strcmp(id->id, ACPI_DT_NAMESPACE_HID))
157 continue;
158
159 count = snprintf(&modalias[len], size, "%s:", id->id);
160 if (count < 0)
161 return -EINVAL;
162
163 if (count >= size)
164 return -ENOMEM;

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

172
173/**
174 * create_of_modalias - Creates DT compatible string for modalias and uevent
175 * @acpi_dev: ACPI device object.
176 * @modalias: Buffer to print into.
177 * @size: Size of the buffer.
178 *
179 * Expose DT compatible modalias as of:NnameTCcompatible. This function should
158 continue;
159
160 count = snprintf(&modalias[len], size, "%s:", id->id);
161 if (count < 0)
162 return -EINVAL;
163
164 if (count >= size)
165 return -ENOMEM;

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

173
174/**
175 * create_of_modalias - Creates DT compatible string for modalias and uevent
176 * @acpi_dev: ACPI device object.
177 * @modalias: Buffer to print into.
178 * @size: Size of the buffer.
179 *
180 * Expose DT compatible modalias as of:NnameTCcompatible. This function should
180 * only be called for devices having PRP0001 in their list of ACPI/PNP IDs.
181 * only be called for devices having ACPI_DT_NAMESPACE_HID in their list of
182 * ACPI/PNP IDs.
181 */
182static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
183 int size)
184{
185 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
186 const union acpi_object *of_compatible, *obj;
187 int len, count;
188 int i, nval;

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

975 ACPI Bus operations
976 -------------------------------------------------------------------------- */
977
978/**
979 * acpi_of_match_device - Match device object using the "compatible" property.
980 * @adev: ACPI device object to match.
981 * @of_match_table: List of device IDs to match against.
982 *
183 */
184static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
185 int size)
186{
187 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
188 const union acpi_object *of_compatible, *obj;
189 int len, count;
190 int i, nval;

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

977 ACPI Bus operations
978 -------------------------------------------------------------------------- */
979
980/**
981 * acpi_of_match_device - Match device object using the "compatible" property.
982 * @adev: ACPI device object to match.
983 * @of_match_table: List of device IDs to match against.
984 *
983 * If @dev has an ACPI companion which has the special PRP0001 device ID in its
984 * list of identifiers and a _DSD object with the "compatible" property, use
985 * that property to match against the given list of identifiers.
985 * If @dev has an ACPI companion which has ACPI_DT_NAMESPACE_HID in its list of
986 * identifiers and a _DSD object with the "compatible" property, use that
987 * property to match against the given list of identifiers.
986 */
987static bool acpi_of_match_device(struct acpi_device *adev,
988 const struct of_device_id *of_match_table)
989{
990 const union acpi_object *of_compatible, *obj;
991 int i, nval;
992
993 if (!adev)

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

1033
1034 list_for_each_entry(hwid, &device->pnp.ids, list) {
1035 /* First, check the ACPI/PNP IDs provided by the caller. */
1036 for (id = ids; id->id[0]; id++)
1037 if (!strcmp((char *) id->id, hwid->id))
1038 return id;
1039
1040 /*
988 */
989static bool acpi_of_match_device(struct acpi_device *adev,
990 const struct of_device_id *of_match_table)
991{
992 const union acpi_object *of_compatible, *obj;
993 int i, nval;
994
995 if (!adev)

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

1035
1036 list_for_each_entry(hwid, &device->pnp.ids, list) {
1037 /* First, check the ACPI/PNP IDs provided by the caller. */
1038 for (id = ids; id->id[0]; id++)
1039 if (!strcmp((char *) id->id, hwid->id))
1040 return id;
1041
1042 /*
1041 * Next, check the special "PRP0001" ID and try to match the
1043 * Next, check ACPI_DT_NAMESPACE_HID and try to match the
1042 * "compatible" property if found.
1043 *
1044 * The id returned by the below is not valid, but the only
1045 * caller passing non-NULL of_ids here is only interested in
1046 * whether or not the return value is NULL.
1047 */
1044 * "compatible" property if found.
1045 *
1046 * The id returned by the below is not valid, but the only
1047 * caller passing non-NULL of_ids here is only interested in
1048 * whether or not the return value is NULL.
1049 */
1048 if (!strcmp("PRP0001", hwid->id)
1050 if (!strcmp(ACPI_DT_NAMESPACE_HID, hwid->id)
1049 && acpi_of_match_device(device, of_ids))
1050 return id;
1051 }
1052 return NULL;
1053}
1054
1055/**
1056 * acpi_match_device - Match a struct device against a given list of ACPI IDs

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

2400 acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
2401 &is_spi_i2c_slave);
2402 acpi_dev_free_resource_list(&resource_list);
2403 if (!is_spi_i2c_slave)
2404 acpi_create_platform_device(device);
2405}
2406
2407static const struct acpi_device_id generic_device_ids[] = {
1051 && acpi_of_match_device(device, of_ids))
1052 return id;
1053 }
1054 return NULL;
1055}
1056
1057/**
1058 * acpi_match_device - Match a struct device against a given list of ACPI IDs

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

2402 acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
2403 &is_spi_i2c_slave);
2404 acpi_dev_free_resource_list(&resource_list);
2405 if (!is_spi_i2c_slave)
2406 acpi_create_platform_device(device);
2407}
2408
2409static const struct acpi_device_id generic_device_ids[] = {
2408 {"PRP0001", },
2410 {ACPI_DT_NAMESPACE_HID, },
2409 {"", },
2410};
2411
2412static int acpi_generic_device_attach(struct acpi_device *adev,
2413 const struct acpi_device_id *not_used)
2414{
2415 /*
2411 {"", },
2412};
2413
2414static int acpi_generic_device_attach(struct acpi_device *adev,
2415 const struct acpi_device_id *not_used)
2416{
2417 /*
2416 * Since PRP0001 is the only ID handled here, the test below can be
2417 * unconditional.
2418 * Since ACPI_DT_NAMESPACE_HID is the only ID handled here, the test
2419 * below can be unconditional.
2418 */
2419 if (adev->data.of_compatible)
2420 acpi_default_enumeration(adev);
2421
2422 return 1;
2423}
2424
2425static struct acpi_scan_handler generic_device_handler = {

--- 263 unchanged lines hidden ---
2420 */
2421 if (adev->data.of_compatible)
2422 acpi_default_enumeration(adev);
2423
2424 return 1;
2425}
2426
2427static struct acpi_scan_handler generic_device_handler = {

--- 263 unchanged lines hidden ---