diff mbox series

[RFC,3/4] platform/x86: i2c-multi-instantiate: Pass ACPI fwnode to instantiated I2C-clients

Message ID 20201105080014.45410-4-hdegoede@redhat.com
State New
Headers show
Series platform/x86: i2c-multi-instantiate: Pass ACPI fwnode to instantiated i2c-clients | expand

Commit Message

Hans de Goede Nov. 5, 2020, 8 a.m. UTC
The ACPI fwnode may contain additional info which is useful for the
I2C-driver. E.g. some accelerometer ACPI fwnode's contain an ACPI method
providing rotation/mount matrix info.

Pass the ACPI-fwnode to the instantiated I2C-clients by setting
i2c_board_info.fwnode, so that the I2C-drivers can access this info.

Now that we set i2c_board_info.irq to -ENOENT if there is no IRQ,
avoiding the I2C-core assigning the first IRQ described in the ACPI
resources to the client, this is safe to do.

Setting the fwnode also influences acpi_device_[uevent_]modalias and
acpi_dev_pm_attach, but these both call acpi_device_is_first_physical_node
and are a no-op if this returns false.

The first physical node for the ACPI fwnode is actually the ACPI core
instantiated platform-device to which the I2C-multi-instantiate driver
binds, so acpi_device_is_first_physical_node always returns false for
the instantiated I2C-clients and thus we can safely pass the fwnode.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/i2c-multi-instantiate.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andy Shevchenko Nov. 5, 2020, 10:31 a.m. UTC | #1
On Thu, Nov 5, 2020 at 10:00 AM Hans de Goede <hdegoede@redhat.com> wrote:
>
> The ACPI fwnode may contain additional info which is useful for the
> I2C-driver. E.g. some accelerometer ACPI fwnode's contain an ACPI method
> providing rotation/mount matrix info.
>
> Pass the ACPI-fwnode to the instantiated I2C-clients by setting
> i2c_board_info.fwnode, so that the I2C-drivers can access this info.
>
> Now that we set i2c_board_info.irq to -ENOENT if there is no IRQ,
> avoiding the I2C-core assigning the first IRQ described in the ACPI
> resources to the client, this is safe to do.
>
> Setting the fwnode also influences acpi_device_[uevent_]modalias and
> acpi_dev_pm_attach, but these both call acpi_device_is_first_physical_node
> and are a no-op if this returns false.

Perhaps add () to the mentioned function calls.

> The first physical node for the ACPI fwnode is actually the ACPI core
> instantiated platform-device to which the I2C-multi-instantiate driver
> binds, so acpi_device_is_first_physical_node always returns false for
> the instantiated I2C-clients and thus we can safely pass the fwnode.

Ditto.

> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/platform/x86/i2c-multi-instantiate.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
> index cb4688bdd6b6..cbccfcbed44c 100644
> --- a/drivers/platform/x86/i2c-multi-instantiate.c
> +++ b/drivers/platform/x86/i2c-multi-instantiate.c
> @@ -93,6 +93,7 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
>                 snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev),
>                          inst_data[i].type, i);
>                 board_info.dev_name = name;
> +               board_info.fwnode = dev->fwnode;
>                 switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) {
>                 case IRQ_RESOURCE_GPIO:
>                         ret = acpi_dev_gpio_irq_get(adev, inst_data[i].irq_idx);
> --
> 2.28.0
>
diff mbox series

Patch

diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index cb4688bdd6b6..cbccfcbed44c 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -93,6 +93,7 @@  static int i2c_multi_inst_probe(struct platform_device *pdev)
 		snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev),
 			 inst_data[i].type, i);
 		board_info.dev_name = name;
+		board_info.fwnode = dev->fwnode;
 		switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) {
 		case IRQ_RESOURCE_GPIO:
 			ret = acpi_dev_gpio_irq_get(adev, inst_data[i].irq_idx);