From: Jarkko Nikula <jarkko.nikula@linux.intel.com>
To: linux-acpi@vger.kernel.org
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Jarkko Nikula <jarkko.nikula@linux.intel.com>
Subject: [PATCH] ACPI / scan: Fix enumeration for special SPI and I2C devices
Date: Thu, 15 Jun 2017 15:40:49 +0300 [thread overview]
Message-ID: <20170615124049.19787-1-jarkko.nikula@linux.intel.com> (raw)
Commit f406270bf73d ("ACPI / scan: Set the visited flag for all
enumerated devices") caused that two group of special SPI or I2C
devices do not enumerate. SPI and I2C devices are expected to be
enumerated by the SPI and I2C subsystems but change caused that
acpi_bus_attach() marks those devices with acpi_device_set_enumerated().
First group of devices are matched using Device Tree compatible property
with special _HID "PRP0001". Those devices have matched scan handler,
acpi_scan_attach_handler() retuns 1 and acpi_bus_attach() marks them
with acpi_device_set_enumerated().
Second group of devices without valid _HID such as "LNXVIDEO" have
device->pnp.type.platform_id set to zero and change again marks them
with acpi_device_set_enumerated().
Fix this by checking is the device SPI or I2C device and let the code go
through the device_attach() and acpi_default_enumeration() path for all
SPI and I2C devices.
Fixes: f406270bf73d ("ACPI / scan: Set the visited flag for all enumerated devices")
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
This should go to linux-stable v4.9+ but it doesn't apply due the commit
f5beabfe6179 ("ACPI / scan: Apply default enumeration to devices with
ACPI drivers"). Should both be queued or have another version from this
for linux-stable?
---
drivers/acpi/scan.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 3a10d7573477..38b9a319b0c4 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1745,20 +1745,27 @@ static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
return -1;
}
-static void acpi_default_enumeration(struct acpi_device *device)
+static bool acpi_is_spi_i2c_slave(struct acpi_device *device)
{
struct list_head resource_list;
bool is_spi_i2c_slave = false;
- /*
- * Do not enumerate SPI/I2C slaves as they will be enumerated by their
- * respective parents.
- */
INIT_LIST_HEAD(&resource_list);
acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
&is_spi_i2c_slave);
acpi_dev_free_resource_list(&resource_list);
- if (!is_spi_i2c_slave) {
+
+ return is_spi_i2c_slave;
+}
+
+static void acpi_default_enumeration(struct acpi_device *device,
+ bool spi_i2c_slave)
+{
+ /*
+ * Do not enumerate SPI/I2C slaves as they will be enumerated by their
+ * respective parents.
+ */
+ if (!spi_i2c_slave) {
acpi_create_platform_device(device, NULL);
acpi_device_set_enumerated(device);
} else {
@@ -1780,7 +1787,7 @@ static int acpi_generic_device_attach(struct acpi_device *adev,
* below can be unconditional.
*/
if (adev->data.of_compatible)
- acpi_default_enumeration(adev);
+ acpi_default_enumeration(adev, acpi_is_spi_i2c_slave(adev));
return 1;
}
@@ -1823,6 +1830,7 @@ static void acpi_bus_attach(struct acpi_device *device)
{
struct acpi_device *child;
acpi_handle ejd;
+ bool spi_i2c_slave;
int ret;
if (ACPI_SUCCESS(acpi_bus_get_ejd(device->handle, &ejd)))
@@ -1853,8 +1861,9 @@ static void acpi_bus_attach(struct acpi_device *device)
if (ret < 0)
return;
+ spi_i2c_slave = acpi_is_spi_i2c_slave(device);
device->flags.match_driver = true;
- if (ret > 0) {
+ if (ret > 0 && !spi_i2c_slave) {
acpi_device_set_enumerated(device);
goto ok;
}
@@ -1863,10 +1872,10 @@ static void acpi_bus_attach(struct acpi_device *device)
if (ret < 0)
return;
- if (device->pnp.type.platform_id)
- acpi_default_enumeration(device);
- else
+ if (!device->pnp.type.platform_id && !spi_i2c_slave)
acpi_device_set_enumerated(device);
+ else
+ acpi_default_enumeration(device, spi_i2c_slave);
ok:
list_for_each_entry(child, &device->children, node)
--
2.11.0
next reply other threads:[~2017-06-15 12:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-15 12:40 Jarkko Nikula [this message]
2017-06-18 11:07 ` [PATCH] ACPI / scan: Fix enumeration for special SPI and I2C devices Mika Westerberg
2017-06-19 10:14 ` Jarkko Nikula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170615124049.19787-1-jarkko.nikula@linux.intel.com \
--to=jarkko.nikula@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).