Skip to content

Commit cd5545a

Browse files
committed
Merge tag 'acpi-4.12-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI fix from Rafael Wysocki: "This fixes the ACPI-based enumeration of some I2C and SPI devices broken in 4.11. Specifics: - I2C and SPI devices are expected to be enumerated by the I2C and SPI subsystems, respectively, but due to a change made during the 4.11 cycle, in some cases the ACPI core marks them as already enumerated which causes the I2C and SPI subsystems to overlook them, so fix that (Jarkko Nikula)" * tag 'acpi-4.12-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI / scan: Fix enumeration for special SPI and I2C devices
2 parents ba6cbdb + e4330d8 commit cd5545a

File tree

2 files changed

+39
-31
lines changed

2 files changed

+39
-31
lines changed

drivers/acpi/scan.c

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,37 @@ static void acpi_init_coherency(struct acpi_device *adev)
14281428
adev->flags.coherent_dma = cca;
14291429
}
14301430

1431+
static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
1432+
{
1433+
bool *is_spi_i2c_slave_p = data;
1434+
1435+
if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
1436+
return 1;
1437+
1438+
/*
1439+
* devices that are connected to UART still need to be enumerated to
1440+
* platform bus
1441+
*/
1442+
if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
1443+
*is_spi_i2c_slave_p = true;
1444+
1445+
/* no need to do more checking */
1446+
return -1;
1447+
}
1448+
1449+
static bool acpi_is_spi_i2c_slave(struct acpi_device *device)
1450+
{
1451+
struct list_head resource_list;
1452+
bool is_spi_i2c_slave = false;
1453+
1454+
INIT_LIST_HEAD(&resource_list);
1455+
acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
1456+
&is_spi_i2c_slave);
1457+
acpi_dev_free_resource_list(&resource_list);
1458+
1459+
return is_spi_i2c_slave;
1460+
}
1461+
14311462
void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
14321463
int type, unsigned long long sta)
14331464
{
@@ -1443,6 +1474,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
14431474
acpi_bus_get_flags(device);
14441475
device->flags.match_driver = false;
14451476
device->flags.initialized = true;
1477+
device->flags.spi_i2c_slave = acpi_is_spi_i2c_slave(device);
14461478
acpi_device_clear_enumerated(device);
14471479
device_initialize(&device->dev);
14481480
dev_set_uevent_suppress(&device->dev, true);
@@ -1727,38 +1759,13 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
17271759
return AE_OK;
17281760
}
17291761

1730-
static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
1731-
{
1732-
bool *is_spi_i2c_slave_p = data;
1733-
1734-
if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
1735-
return 1;
1736-
1737-
/*
1738-
* devices that are connected to UART still need to be enumerated to
1739-
* platform bus
1740-
*/
1741-
if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
1742-
*is_spi_i2c_slave_p = true;
1743-
1744-
/* no need to do more checking */
1745-
return -1;
1746-
}
1747-
17481762
static void acpi_default_enumeration(struct acpi_device *device)
17491763
{
1750-
struct list_head resource_list;
1751-
bool is_spi_i2c_slave = false;
1752-
17531764
/*
17541765
* Do not enumerate SPI/I2C slaves as they will be enumerated by their
17551766
* respective parents.
17561767
*/
1757-
INIT_LIST_HEAD(&resource_list);
1758-
acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
1759-
&is_spi_i2c_slave);
1760-
acpi_dev_free_resource_list(&resource_list);
1761-
if (!is_spi_i2c_slave) {
1768+
if (!device->flags.spi_i2c_slave) {
17621769
acpi_create_platform_device(device, NULL);
17631770
acpi_device_set_enumerated(device);
17641771
} else {
@@ -1854,7 +1861,7 @@ static void acpi_bus_attach(struct acpi_device *device)
18541861
return;
18551862

18561863
device->flags.match_driver = true;
1857-
if (ret > 0) {
1864+
if (ret > 0 && !device->flags.spi_i2c_slave) {
18581865
acpi_device_set_enumerated(device);
18591866
goto ok;
18601867
}
@@ -1863,10 +1870,10 @@ static void acpi_bus_attach(struct acpi_device *device)
18631870
if (ret < 0)
18641871
return;
18651872

1866-
if (device->pnp.type.platform_id)
1867-
acpi_default_enumeration(device);
1868-
else
1873+
if (!device->pnp.type.platform_id && !device->flags.spi_i2c_slave)
18691874
acpi_device_set_enumerated(device);
1875+
else
1876+
acpi_default_enumeration(device);
18701877

18711878
ok:
18721879
list_for_each_entry(child, &device->children, node)

include/acpi/acpi_bus.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ struct acpi_device_flags {
210210
u32 of_compatible_ok:1;
211211
u32 coherent_dma:1;
212212
u32 cca_seen:1;
213-
u32 reserved:20;
213+
u32 spi_i2c_slave:1;
214+
u32 reserved:19;
214215
};
215216

216217
/* File System */

0 commit comments

Comments
 (0)