All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike
@ 2018-11-28 11:45 Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 01/15] platform/x86: intel_cht_int33fe: Remove duplicate NULL check Andy Shevchenko
                   ` (17 more replies)
  0 siblings, 18 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

Currently i2c-multi-instantiate driver does not support the case
of INT3515 USB PD device, where:

- Interrupt() is used instead of GpioInt()
- All slaves may be the same from IP point of view
- There can be variadic amount of slaves

This series is addressing all above.

Note, series has been smoke tested (Heikki would do BAT or more)
on Intel Coffee Lake system.

The idea is to push this either through PDx86 tree (needs Rafael's ACKs) or ACPI.
In any case it needs tags from Heikki, Hans, Mika, Wolfram and Jonathan.

Testing and comments are warmly welcome.

In v5:
- unmess with patches 3 and 4 (there were squashed by my mistake)
- other than above no code change from v4

In v4:
- directly return -EPROBE_DEFER from i2c_acpi_new_device()
- due to above split error handling simplification to separate patches

In v3:
- revisit error codes returned by i2c_acpi_new_device() (Hans, Mika)
- add documentation to exported i2c_acpi_get_i2c_resource() (Mika)
- drop Hans' Rb tag in patch 5 due to changes
- append Mika's Ab tag to patch 6

In v2:
- drop patches to copy fwnode and to handle BOSC0200 device
- append check for amount of devices listed in the driver's mapping
- add Rb tag given by Hans

Andy Shevchenko (15):
  platform/x86: intel_cht_int33fe: Remove duplicate NULL check
  platform/x86: intel_cht_int33fe: Accept errors of
    i2c_acpi_new_device()
  platform/x86: i2c-multi-instantiate: Accept errors of
    i2c_acpi_new_device()
  platform/x86: i2c-multi-instantiate: Defer probe when no adapter found
  i2c: acpi: Return error pointers from i2c_acpi_new_device()
  platform/x86: intel_cht_int33fe: Get rid of obsolete conditional
  platform/x86: i2c-multi-instantiate: Get rid of obsolete conditional
  i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS
  i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  platform/x86: i2c-multi-instantiate: Count I2cSerialBus() resources
  platform/x86: i2c-multi-instantiate: Distinguish IRQ resource type
  platform/x86: i2c-multi-instantiate: Introduce IOAPIC IRQ support
  platform/x86: i2c-multi-instantiate: Allow to have same slaves
  ACPI / scan: Create platform device for INT3515 ACPI nodes
  iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper

 drivers/acpi/scan.c                          |  1 +
 drivers/i2c/i2c-core-acpi.c                  | 64 +++++++++----
 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c   | 16 ++--
 drivers/platform/x86/i2c-multi-instantiate.c | 97 ++++++++++++++++----
 drivers/platform/x86/intel_cht_int33fe.c     | 20 ++--
 drivers/usb/typec/tps6598x.c                 |  8 +-
 include/linux/acpi.h                         | 11 +++
 7 files changed, 157 insertions(+), 60 deletions(-)

--
2.19.2

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH v5 01/15] platform/x86: intel_cht_int33fe: Remove duplicate NULL check
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 02/15] platform/x86: intel_cht_int33fe: Accept errors of i2c_acpi_new_device() Andy Shevchenko
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

Since i2c_unregister_device() became NULL-aware we may remove duplicate
NULL check.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel_cht_int33fe.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c
index 464fe93657b5..431151d4e611 100644
--- a/drivers/platform/x86/intel_cht_int33fe.c
+++ b/drivers/platform/x86/intel_cht_int33fe.c
@@ -213,8 +213,7 @@ static int cht_int33fe_probe(struct platform_device *pdev)
 	i2c_unregister_device(data->fusb302);
 
 out_unregister_max17047:
-	if (data->max17047)
-		i2c_unregister_device(data->max17047);
+	i2c_unregister_device(data->max17047);
 
 	device_connections_remove(data->connections);
 
@@ -227,8 +226,7 @@ static int cht_int33fe_remove(struct platform_device *pdev)
 
 	i2c_unregister_device(data->pi3usb30532);
 	i2c_unregister_device(data->fusb302);
-	if (data->max17047)
-		i2c_unregister_device(data->max17047);
+	i2c_unregister_device(data->max17047);
 
 	device_connections_remove(data->connections);
 
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 02/15] platform/x86: intel_cht_int33fe: Accept errors of i2c_acpi_new_device()
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 01/15] platform/x86: intel_cht_int33fe: Remove duplicate NULL check Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-12-02 15:56   ` Jonathan Cameron
  2018-11-28 11:45 ` [PATCH v5 03/15] platform/x86: i2c-multi-instantiate: " Andy Shevchenko
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

In the future i2c_acpi_new_device() will return error pointer in some cases.
Prepare intel_cht_int33fe driver to support that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel_cht_int33fe.c | 28 +++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c
index 431151d4e611..367d6e304ade 100644
--- a/drivers/platform/x86/intel_cht_int33fe.c
+++ b/drivers/platform/x86/intel_cht_int33fe.c
@@ -168,8 +168,14 @@ static int cht_int33fe_probe(struct platform_device *pdev)
 		board_info.dev_name = "max17047";
 		board_info.properties = max17047_props;
 		data->max17047 = i2c_acpi_new_device(dev, 1, &board_info);
-		if (!data->max17047)
-			return -EPROBE_DEFER; /* Wait for i2c-adapter to load */
+		if (IS_ERR(data->max17047))
+			ret = PTR_ERR(data->max17047);
+		else if (!data->max17047)
+			ret = -EPROBE_DEFER; /* Wait for i2c-adapter to load */
+		else
+			ret = 0;
+		if (ret)
+			return ret;
 	}
 
 	data->connections[0].endpoint[0] = "port0";
@@ -194,7 +200,13 @@ static int cht_int33fe_probe(struct platform_device *pdev)
 	board_info.irq = fusb302_irq;
 
 	data->fusb302 = i2c_acpi_new_device(dev, 2, &board_info);
-	if (!data->fusb302)
+	if (IS_ERR(data->fusb302))
+		ret = PTR_ERR(data->fusb302);
+	else if (!data->fusb302)
+		ret = -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
+	else
+		ret = 0;
+	if (ret)
 		goto out_unregister_max17047;
 
 	memset(&board_info, 0, sizeof(board_info));
@@ -202,7 +214,13 @@ static int cht_int33fe_probe(struct platform_device *pdev)
 	strlcpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
 
 	data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
-	if (!data->pi3usb30532)
+	if (IS_ERR(data->pi3usb30532))
+		ret = PTR_ERR(data->pi3usb30532);
+	else if (!data->pi3usb30532)
+		ret = -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
+	else
+		ret = 0;
+	if (ret)
 		goto out_unregister_fusb302;
 
 	platform_set_drvdata(pdev, data);
@@ -217,7 +235,7 @@ static int cht_int33fe_probe(struct platform_device *pdev)
 
 	device_connections_remove(data->connections);
 
-	return -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
+	return ret;
 }
 
 static int cht_int33fe_remove(struct platform_device *pdev)
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 03/15] platform/x86: i2c-multi-instantiate: Accept errors of i2c_acpi_new_device()
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 01/15] platform/x86: intel_cht_int33fe: Remove duplicate NULL check Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 02/15] platform/x86: intel_cht_int33fe: Accept errors of i2c_acpi_new_device() Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 04/15] platform/x86: i2c-multi-instantiate: Defer probe when no adapter found Andy Shevchenko
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

In the future i2c_acpi_new_device() will return error pointer in some cases.
Prepare i2c-multi-instantiate driver to support that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/i2c-multi-instantiate.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index 5456581b473c..e3345da82c84 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -72,9 +72,14 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 			board_info.irq = ret;
 		}
 		multi->clients[i] = i2c_acpi_new_device(dev, i, &board_info);
-		if (!multi->clients[i]) {
-			dev_err(dev, "Error creating i2c-client, idx %d\n", i);
+		if (IS_ERR(multi->clients[i]))
+			ret = PTR_ERR(multi->clients[i]);
+		else if (!multi->clients[i])
 			ret = -ENODEV;
+		else
+			ret = 0;
+		if (ret) {
+			dev_err(dev, "Error creating i2c-client, idx %d\n", i);
 			goto error;
 		}
 	}
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 04/15] platform/x86: i2c-multi-instantiate: Defer probe when no adapter found
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (2 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 03/15] platform/x86: i2c-multi-instantiate: " Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 05/15] i2c: acpi: Return error pointers from i2c_acpi_new_device() Andy Shevchenko
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

Likewise the rest of the i2c_acpi_new_device() users, defer the probe
of the i2c-multi-intantiate driver in case adapter is not yet found.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/i2c-multi-instantiate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index e3345da82c84..16a0eabe1e31 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -75,7 +75,7 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 		if (IS_ERR(multi->clients[i]))
 			ret = PTR_ERR(multi->clients[i]);
 		else if (!multi->clients[i])
-			ret = -ENODEV;
+			ret = -EPROBE_DEFER; /* Wait for i2c-adapter to load */
 		else
 			ret = 0;
 		if (ret) {
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 05/15] i2c: acpi: Return error pointers from i2c_acpi_new_device()
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (3 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 04/15] platform/x86: i2c-multi-instantiate: Defer probe when no adapter found Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 14:47   ` Mika Westerberg
  2018-11-30  9:53   ` Wolfram Sang
  2018-11-28 11:45 ` [PATCH v5 06/15] platform/x86: intel_cht_int33fe: Get rid of obsolete conditional Andy Shevchenko
                   ` (12 subsequent siblings)
  17 siblings, 2 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

The caller would like to know the reason why the i2c_acpi_new_device() fails.
For example, if adapter is not available, it might be in the future and we
would like to re-probe the clients again. But at the same time we would like to
bail out if the error seems unrecoverable, such as invalid argument supplied.
To achieve this, return error pointer in some cases.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/i2c-core-acpi.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 32affd3fa8bd..689c0c467e97 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -386,20 +386,22 @@ struct notifier_block i2c_acpi_notifier = {
  *
  * Also see i2c_new_device, which this function calls to create the i2c-client.
  *
- * Returns a pointer to the new i2c-client, or NULL if the adapter is not found.
+ * Returns a pointer to the new i2c-client, or error pointer in case of failure.
+ * Specifically, -EPROBE_DEFER is returned if the adapter is not found.
  */
 struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
 				       struct i2c_board_info *info)
 {
 	struct i2c_acpi_lookup lookup;
 	struct i2c_adapter *adapter;
+	struct i2c_client *client;
 	struct acpi_device *adev;
 	LIST_HEAD(resource_list);
 	int ret;
 
 	adev = ACPI_COMPANION(dev);
 	if (!adev)
-		return NULL;
+		return ERR_PTR(-EINVAL);
 
 	memset(&lookup, 0, sizeof(lookup));
 	lookup.info = info;
@@ -408,16 +410,23 @@ struct i2c_client *i2c_acpi_new_device(struct device *dev, int index,
 
 	ret = acpi_dev_get_resources(adev, &resource_list,
 				     i2c_acpi_fill_info, &lookup);
+	if (ret < 0)
+		return ERR_PTR(ret);
+
 	acpi_dev_free_resource_list(&resource_list);
 
-	if (ret < 0 || !info->addr)
-		return NULL;
+	if (!info->addr)
+		return ERR_PTR(-EADDRNOTAVAIL);
 
 	adapter = i2c_acpi_find_adapter_by_handle(lookup.adapter_handle);
 	if (!adapter)
-		return NULL;
+		return ERR_PTR(-EPROBE_DEFER);
+
+	client = i2c_new_device(adapter, info);
+	if (!client)
+		return ERR_PTR(-ENODEV);
 
-	return i2c_new_device(adapter, info);
+	return client;
 }
 EXPORT_SYMBOL_GPL(i2c_acpi_new_device);
 
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 06/15] platform/x86: intel_cht_int33fe: Get rid of obsolete conditional
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (4 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 05/15] i2c: acpi: Return error pointers from i2c_acpi_new_device() Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-12-02 16:35   ` Jonathan Cameron
  2018-11-28 11:45 ` [PATCH v5 07/15] platform/x86: i2c-multi-instantiate: " Andy Shevchenko
                   ` (11 subsequent siblings)
  17 siblings, 1 reply; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

Now, when i2c_acpi_new_device() never returns NULL, there is no point to check
for it. Besides that, i2c_acpi_new_device() returns -EPROBE_DEFER directly and
caller doesn't need to guess is better.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/intel_cht_int33fe.c | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c
index 367d6e304ade..616b8853a91f 100644
--- a/drivers/platform/x86/intel_cht_int33fe.c
+++ b/drivers/platform/x86/intel_cht_int33fe.c
@@ -169,13 +169,7 @@ static int cht_int33fe_probe(struct platform_device *pdev)
 		board_info.properties = max17047_props;
 		data->max17047 = i2c_acpi_new_device(dev, 1, &board_info);
 		if (IS_ERR(data->max17047))
-			ret = PTR_ERR(data->max17047);
-		else if (!data->max17047)
-			ret = -EPROBE_DEFER; /* Wait for i2c-adapter to load */
-		else
-			ret = 0;
-		if (ret)
-			return ret;
+			return PTR_ERR(data->max17047);
 	}
 
 	data->connections[0].endpoint[0] = "port0";
@@ -200,28 +194,20 @@ static int cht_int33fe_probe(struct platform_device *pdev)
 	board_info.irq = fusb302_irq;
 
 	data->fusb302 = i2c_acpi_new_device(dev, 2, &board_info);
-	if (IS_ERR(data->fusb302))
+	if (IS_ERR(data->fusb302)) {
 		ret = PTR_ERR(data->fusb302);
-	else if (!data->fusb302)
-		ret = -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
-	else
-		ret = 0;
-	if (ret)
 		goto out_unregister_max17047;
+	}
 
 	memset(&board_info, 0, sizeof(board_info));
 	board_info.dev_name = "pi3usb30532";
 	strlcpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
 
 	data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
-	if (IS_ERR(data->pi3usb30532))
+	if (IS_ERR(data->pi3usb30532)) {
 		ret = PTR_ERR(data->pi3usb30532);
-	else if (!data->pi3usb30532)
-		ret = -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
-	else
-		ret = 0;
-	if (ret)
 		goto out_unregister_fusb302;
+	}
 
 	platform_set_drvdata(pdev, data);
 
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 07/15] platform/x86: i2c-multi-instantiate: Get rid of obsolete conditional
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (5 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 06/15] platform/x86: intel_cht_int33fe: Get rid of obsolete conditional Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 08/15] i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS Andy Shevchenko
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

Now, when i2c_acpi_new_device() never returns NULL, there is no point to check
for it. Besides that, i2c_acpi_new_device() returns -EPROBE_DEFER directly and
caller doesn't need to guess is better.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/x86/i2c-multi-instantiate.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index 16a0eabe1e31..724535673089 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -72,14 +72,10 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 			board_info.irq = ret;
 		}
 		multi->clients[i] = i2c_acpi_new_device(dev, i, &board_info);
-		if (IS_ERR(multi->clients[i]))
+		if (IS_ERR(multi->clients[i])) {
 			ret = PTR_ERR(multi->clients[i]);
-		else if (!multi->clients[i])
-			ret = -EPROBE_DEFER; /* Wait for i2c-adapter to load */
-		else
-			ret = 0;
-		if (ret) {
-			dev_err(dev, "Error creating i2c-client, idx %d\n", i);
+			if (ret != -EPROBE_DEFER)
+				dev_err(dev, "Error creating i2c-client, idx %d\n", i);
 			goto error;
 		}
 	}
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 08/15] i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (6 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 07/15] platform/x86: i2c-multi-instantiate: " Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-30  9:53   ` Wolfram Sang
  2018-11-28 11:45 ` [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper Andy Shevchenko
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

Convert to use ACPI_FAILURE instead of !ACPI_SUCCESS.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/i2c/i2c-core-acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 689c0c467e97..8a88586e0902 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -65,7 +65,7 @@ static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data)
 	status = acpi_get_handle(lookup->device_handle,
 				 sb->resource_source.string_ptr,
 				 &lookup->adapter_handle);
-	if (!ACPI_SUCCESS(status))
+	if (ACPI_FAILURE(status))
 		return 1;
 
 	info->addr = sb->slave_address;
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (7 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 08/15] i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 14:47   ` Mika Westerberg
                     ` (2 more replies)
  2018-11-28 11:45 ` [PATCH v5 10/15] platform/x86: i2c-multi-instantiate: Count I2cSerialBus() resources Andy Shevchenko
                   ` (8 subsequent siblings)
  17 siblings, 3 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

Besides current two users one more is coming. Definitely makes sense to
introduce a helper.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/i2c/i2c-core-acpi.c | 41 ++++++++++++++++++++++++++-----------
 include/linux/acpi.h        | 11 ++++++++++
 2 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 8a88586e0902..272800692088 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -45,6 +45,33 @@ struct i2c_acpi_lookup {
 	u32 min_speed;
 };
 
+/**
+ * i2c_acpi_get_i2c_resource - Gets I2cSerialBus resource if type matches
+ * @ares:	ACPI resource
+ * @i2c:	Pointer to I2cSerialBus resource will be returned here
+ *
+ * Checks if the given ACPI resource is of type I2cSerialBus.
+ * In this case, returns a pointer to it to the caller.
+ *
+ * Returns true if resource type is of I2cSerialBus, otherwise false.
+ */
+bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares,
+			       struct acpi_resource_i2c_serialbus **i2c)
+{
+	struct acpi_resource_i2c_serialbus *sb;
+
+	if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
+		return false;
+
+	sb = &ares->data.i2c_serial_bus;
+	if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C)
+		return false;
+
+	*i2c = sb;
+	return true;
+}
+EXPORT_SYMBOL_GPL(i2c_acpi_get_i2c_resource);
+
 static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data)
 {
 	struct i2c_acpi_lookup *lookup = data;
@@ -52,11 +79,7 @@ static int i2c_acpi_fill_info(struct acpi_resource *ares, void *data)
 	struct acpi_resource_i2c_serialbus *sb;
 	acpi_status status;
 
-	if (info->addr || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
-		return 1;
-
-	sb = &ares->data.i2c_serial_bus;
-	if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C)
+	if (info->addr || !i2c_acpi_get_i2c_resource(ares, &sb))
 		return 1;
 
 	if (lookup->index != -1 && lookup->n++ != lookup->index)
@@ -534,13 +557,7 @@ i2c_acpi_space_handler(u32 function, acpi_physical_address command,
 		goto err;
 	}
 
-	if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) {
-		ret = AE_BAD_PARAMETER;
-		goto err;
-	}
-
-	sb = &ares->data.i2c_serial_bus;
-	if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+	if (!value64 || !i2c_acpi_get_i2c_resource(ares, &sb)) {
 		ret = AE_BAD_PARAMETER;
 		goto err;
 	}
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index ed80f147bd50..6afc6e3c4c5c 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1054,6 +1054,17 @@ static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
 }
 #endif
 
+#if defined(CONFIG_ACPI) && IS_ENABLED(CONFIG_I2C)
+bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares,
+			       struct acpi_resource_i2c_serialbus **i2c);
+#else
+static inline bool i2c_acpi_get_i2c_resource(struct acpi_resource *ares,
+					     struct acpi_resource_i2c_serialbus **i2c)
+{
+	return false;
+}
+#endif
+
 /* Device properties */
 
 #ifdef CONFIG_ACPI
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 10/15] platform/x86: i2c-multi-instantiate: Count I2cSerialBus() resources
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (8 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 11/15] platform/x86: i2c-multi-instantiate: Distinguish IRQ resource type Andy Shevchenko
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

Instead of relying on hard coded and thus expected number of I2C clients,
count the real amount provided by firmware.

This allows to support non-fixed amount of the slaves.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/i2c-multi-instantiate.c | 41 ++++++++++++++++++--
 1 file changed, 37 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index 724535673089..d99bbaed0ca2 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/types.h>
 
 struct i2c_inst_data {
 	const char *type;
@@ -23,6 +24,31 @@ struct i2c_multi_inst_data {
 	struct i2c_client *clients[0];
 };
 
+static int i2c_multi_inst_count(struct acpi_resource *ares, void *data)
+{
+	struct acpi_resource_i2c_serialbus *sb;
+	int *count = data;
+
+	if (i2c_acpi_get_i2c_resource(ares, &sb))
+		*count = *count + 1;
+
+	return 1;
+}
+
+static int i2c_multi_inst_count_resources(struct acpi_device *adev)
+{
+	LIST_HEAD(r);
+	int count = 0;
+	int ret;
+
+	ret = acpi_dev_get_resources(adev, &r, i2c_multi_inst_count, &count);
+	if (ret < 0)
+		return ret;
+
+	acpi_dev_free_resource_list(&r);
+	return count;
+}
+
 static int i2c_multi_inst_probe(struct platform_device *pdev)
 {
 	struct i2c_multi_inst_data *multi;
@@ -44,17 +70,19 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 	adev = ACPI_COMPANION(dev);
 
 	/* Count number of clients to instantiate */
-	for (i = 0; inst_data[i].type; i++) {}
+	ret = i2c_multi_inst_count_resources(adev);
+	if (ret < 0)
+		return ret;
 
 	multi = devm_kmalloc(dev,
-			offsetof(struct i2c_multi_inst_data, clients[i]),
+			offsetof(struct i2c_multi_inst_data, clients[ret]),
 			GFP_KERNEL);
 	if (!multi)
 		return -ENOMEM;
 
-	multi->num_clients = i;
+	multi->num_clients = ret;
 
-	for (i = 0; i < multi->num_clients; i++) {
+	for (i = 0; i < multi->num_clients && inst_data[i].type; i++) {
 		memset(&board_info, 0, sizeof(board_info));
 		strlcpy(board_info.type, inst_data[i].type, I2C_NAME_SIZE);
 		snprintf(name, sizeof(name), "%s-%s", match->id,
@@ -79,6 +107,11 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 			goto error;
 		}
 	}
+	if (i < multi->num_clients) {
+		dev_err(dev, "Error finding driver, idx %d\n", i);
+		ret = -ENODEV;
+		goto error;
+	}
 
 	platform_set_drvdata(pdev, multi);
 	return 0;
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 11/15] platform/x86: i2c-multi-instantiate: Distinguish IRQ resource type
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (9 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 10/15] platform/x86: i2c-multi-instantiate: Count I2cSerialBus() resources Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 12/15] platform/x86: i2c-multi-instantiate: Introduce IOAPIC IRQ support Andy Shevchenko
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

As a preparatory patch switch the driver to distinguish IRQ resource type.
For now, only GpioInt() is supported.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/i2c-multi-instantiate.c | 27 +++++++++++++-------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index d99bbaed0ca2..99db3e336718 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/bits.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
@@ -14,9 +15,14 @@
 #include <linux/platform_device.h>
 #include <linux/types.h>
 
+#define IRQ_RESOURCE_TYPE	GENMASK(1, 0)
+#define IRQ_RESOURCE_NONE	0
+#define IRQ_RESOURCE_GPIO	1
+
 struct i2c_inst_data {
 	const char *type;
-	int gpio_irq_idx;
+	unsigned int flags;
+	int irq_idx;
 };
 
 struct i2c_multi_inst_data {
@@ -88,16 +94,19 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 		snprintf(name, sizeof(name), "%s-%s", match->id,
 			 inst_data[i].type);
 		board_info.dev_name = name;
-		board_info.irq = 0;
-		if (inst_data[i].gpio_irq_idx != -1) {
-			ret = acpi_dev_gpio_irq_get(adev,
-						    inst_data[i].gpio_irq_idx);
+		switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) {
+		case IRQ_RESOURCE_GPIO:
+			ret = acpi_dev_gpio_irq_get(adev, inst_data[i].irq_idx);
 			if (ret < 0) {
 				dev_err(dev, "Error requesting irq at index %d: %d\n",
-					inst_data[i].gpio_irq_idx, ret);
+					inst_data[i].irq_idx, ret);
 				goto error;
 			}
 			board_info.irq = ret;
+			break;
+		default:
+			board_info.irq = 0;
+			break;
 		}
 		multi->clients[i] = i2c_acpi_new_device(dev, i, &board_info);
 		if (IS_ERR(multi->clients[i])) {
@@ -135,9 +144,9 @@ static int i2c_multi_inst_remove(struct platform_device *pdev)
 }
 
 static const struct i2c_inst_data bsg1160_data[]  = {
-	{ "bmc150_accel", 0 },
-	{ "bmc150_magn", -1 },
-	{ "bmg160", -1 },
+	{ "bmc150_accel", IRQ_RESOURCE_GPIO, 0 },
+	{ "bmc150_magn" },
+	{ "bmg160" },
 	{}
 };
 
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 12/15] platform/x86: i2c-multi-instantiate: Introduce IOAPIC IRQ support
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (10 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 11/15] platform/x86: i2c-multi-instantiate: Distinguish IRQ resource type Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 13/15] platform/x86: i2c-multi-instantiate: Allow to have same slaves Andy Shevchenko
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

If ACPI table provides an Interrupt() resource we may consider to use it
instead of GpioInt() one.

Here we leave an error condition, when getting IRQ resource, to the driver
to decide how to proceed, because some drivers may consider IRQ resource
optional.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/i2c-multi-instantiate.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index 99db3e336718..365457f9c424 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -18,6 +18,7 @@
 #define IRQ_RESOURCE_TYPE	GENMASK(1, 0)
 #define IRQ_RESOURCE_NONE	0
 #define IRQ_RESOURCE_GPIO	1
+#define IRQ_RESOURCE_APIC	2
 
 struct i2c_inst_data {
 	const char *type;
@@ -104,6 +105,14 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 			}
 			board_info.irq = ret;
 			break;
+		case IRQ_RESOURCE_APIC:
+			ret = platform_get_irq(pdev, inst_data[i].irq_idx);
+			if (ret < 0) {
+				dev_dbg(dev, "Error requesting irq at index %d: %d\n",
+					inst_data[i].irq_idx, ret);
+			}
+			board_info.irq = ret;
+			break;
 		default:
 			board_info.irq = 0;
 			break;
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 13/15] platform/x86: i2c-multi-instantiate: Allow to have same slaves
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (11 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 12/15] platform/x86: i2c-multi-instantiate: Introduce IOAPIC IRQ support Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 11:45 ` [PATCH v5 14/15] ACPI / scan: Create platform device for INT3515 ACPI nodes Andy Shevchenko
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

Currently the driver will not enumerate the devices where I2C slaves
are of the same type.

Add an instance number to make them unique.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/i2c-multi-instantiate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index 365457f9c424..2439d4c71118 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -92,8 +92,8 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
 	for (i = 0; i < multi->num_clients && inst_data[i].type; i++) {
 		memset(&board_info, 0, sizeof(board_info));
 		strlcpy(board_info.type, inst_data[i].type, I2C_NAME_SIZE);
-		snprintf(name, sizeof(name), "%s-%s", match->id,
-			 inst_data[i].type);
+		snprintf(name, sizeof(name), "%s-%s.%d", match->id,
+			 inst_data[i].type, i);
 		board_info.dev_name = name;
 		switch (inst_data[i].flags & IRQ_RESOURCE_TYPE) {
 		case IRQ_RESOURCE_GPIO:
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 14/15] ACPI / scan: Create platform device for INT3515 ACPI nodes
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (12 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 13/15] platform/x86: i2c-multi-instantiate: Allow to have same slaves Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-11-28 12:07   ` Heikki Krogerus
  2018-11-29 20:58   ` Rafael J. Wysocki
  2018-11-28 11:45 ` [PATCH v5 15/15] iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper Andy Shevchenko
                   ` (3 subsequent siblings)
  17 siblings, 2 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

The ACPI device with INT3515 _HID is representing a complex USB PD
hardware infrastructure which includes several I2C slave ICs.

We add an ID to the I2C multi instantiate list to enumerate
all I2C slaves correctly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/scan.c                          | 1 +
 drivers/platform/x86/i2c-multi-instantiate.c | 9 +++++++++
 drivers/usb/typec/tps6598x.c                 | 8 ++++----
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index bd1c59fb0e17..e9eda5558c1f 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1541,6 +1541,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
 	static const struct acpi_device_id i2c_multi_instantiate_ids[] = {
 		{"BSG1160", },
 		{"INT33FE", },
+		{"INT3515", },
 		{}
 	};
 
diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index 2439d4c71118..3d893e0ac250 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -159,12 +159,21 @@ static const struct i2c_inst_data bsg1160_data[]  = {
 	{}
 };
 
+static const struct i2c_inst_data int3515_data[]  = {
+	{ "tps6598x", IRQ_RESOURCE_APIC, 0 },
+	{ "tps6598x", IRQ_RESOURCE_APIC, 1 },
+	{ "tps6598x", IRQ_RESOURCE_APIC, 2 },
+	{ "tps6598x", IRQ_RESOURCE_APIC, 3 },
+	{}
+};
+
 /*
  * Note new device-ids must also be added to i2c_multi_instantiate_ids in
  * drivers/acpi/scan.c: acpi_device_enumeration_by_parent().
  */
 static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = {
 	{ "BSG1160", (unsigned long)bsg1160_data },
+	{ "INT3515", (unsigned long)int3515_data },
 	{ }
 };
 MODULE_DEVICE_TABLE(acpi, i2c_multi_inst_acpi_ids);
diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index c84c8c189e90..1c0033ad8738 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -501,19 +501,19 @@ static int tps6598x_remove(struct i2c_client *client)
 	return 0;
 }
 
-static const struct acpi_device_id tps6598x_acpi_match[] = {
-	{ "INT3515", 0 },
+static const struct i2c_device_id tps6598x_id[] = {
+	{ "tps6598x" },
 	{ }
 };
-MODULE_DEVICE_TABLE(acpi, tps6598x_acpi_match);
+MODULE_DEVICE_TABLE(i2c, tps6598x_id);
 
 static struct i2c_driver tps6598x_i2c_driver = {
 	.driver = {
 		.name = "tps6598x",
-		.acpi_match_table = tps6598x_acpi_match,
 	},
 	.probe_new = tps6598x_probe,
 	.remove = tps6598x_remove,
+	.id_table = tps6598x_id,
 };
 module_i2c_driver(tps6598x_i2c_driver);
 
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v5 15/15] iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (13 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 14/15] ACPI / scan: Create platform device for INT3515 ACPI nodes Andy Shevchenko
@ 2018-11-28 11:45 ` Andy Shevchenko
  2018-12-02 16:41   ` Jonathan Cameron
  2018-11-28 13:12 ` [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Heikki Krogerus
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-28 11:45 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel
  Cc: Andy Shevchenko

ACPI provides a generic helper to get I2C Serial Bus resources.
Use it instead of open coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
index d78a10403bac..a961b5a06fe6 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
@@ -91,18 +91,14 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
 
 static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data)
 {
+	struct acpi_resource_i2c_serialbus *sb;
 	u32 *addr = data;
 
-	if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
-		struct acpi_resource_i2c_serialbus *sb;
-
-		sb = &ares->data.i2c_serial_bus;
-		if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
-			if (*addr)
-				*addr |= (sb->slave_address << 16);
-			else
-				*addr = sb->slave_address;
-		}
+	if (i2c_acpi_get_i2c_resource(ares, &sb)) {
+		if (*addr)
+			*addr |= (sb->slave_address << 16);
+		else
+			*addr = sb->slave_address;
 	}
 
 	/* Tell the ACPI core that we already copied this address */
-- 
2.19.2

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 14/15] ACPI / scan: Create platform device for INT3515 ACPI nodes
  2018-11-28 11:45 ` [PATCH v5 14/15] ACPI / scan: Create platform device for INT3515 ACPI nodes Andy Shevchenko
@ 2018-11-28 12:07   ` Heikki Krogerus
  2018-11-29 20:58   ` Rafael J. Wysocki
  1 sibling, 0 replies; 38+ messages in thread
From: Heikki Krogerus @ 2018-11-28 12:07 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, linux-kernel

On Wed, Nov 28, 2018 at 01:45:34PM +0200, Andy Shevchenko wrote:
> The ACPI device with INT3515 _HID is representing a complex USB PD
> hardware infrastructure which includes several I2C slave ICs.
> 
> We add an ID to the I2C multi instantiate list to enumerate
> all I2C slaves correctly.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/acpi/scan.c                          | 1 +
>  drivers/platform/x86/i2c-multi-instantiate.c | 9 +++++++++
>  drivers/usb/typec/tps6598x.c                 | 8 ++++----
>  3 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index bd1c59fb0e17..e9eda5558c1f 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -1541,6 +1541,7 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
>  	static const struct acpi_device_id i2c_multi_instantiate_ids[] = {
>  		{"BSG1160", },
>  		{"INT33FE", },
> +		{"INT3515", },
>  		{}
>  	};
>  
> diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
> index 2439d4c71118..3d893e0ac250 100644
> --- a/drivers/platform/x86/i2c-multi-instantiate.c
> +++ b/drivers/platform/x86/i2c-multi-instantiate.c
> @@ -159,12 +159,21 @@ static const struct i2c_inst_data bsg1160_data[]  = {
>  	{}
>  };
>  
> +static const struct i2c_inst_data int3515_data[]  = {
> +	{ "tps6598x", IRQ_RESOURCE_APIC, 0 },
> +	{ "tps6598x", IRQ_RESOURCE_APIC, 1 },
> +	{ "tps6598x", IRQ_RESOURCE_APIC, 2 },
> +	{ "tps6598x", IRQ_RESOURCE_APIC, 3 },
> +	{}
> +};
> +
>  /*
>   * Note new device-ids must also be added to i2c_multi_instantiate_ids in
>   * drivers/acpi/scan.c: acpi_device_enumeration_by_parent().
>   */
>  static const struct acpi_device_id i2c_multi_inst_acpi_ids[] = {
>  	{ "BSG1160", (unsigned long)bsg1160_data },
> +	{ "INT3515", (unsigned long)int3515_data },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(acpi, i2c_multi_inst_acpi_ids);
> diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
> index c84c8c189e90..1c0033ad8738 100644
> --- a/drivers/usb/typec/tps6598x.c
> +++ b/drivers/usb/typec/tps6598x.c
> @@ -501,19 +501,19 @@ static int tps6598x_remove(struct i2c_client *client)
>  	return 0;
>  }
>  
> -static const struct acpi_device_id tps6598x_acpi_match[] = {
> -	{ "INT3515", 0 },
> +static const struct i2c_device_id tps6598x_id[] = {
> +	{ "tps6598x" },
>  	{ }
>  };
> -MODULE_DEVICE_TABLE(acpi, tps6598x_acpi_match);
> +MODULE_DEVICE_TABLE(i2c, tps6598x_id);
>  
>  static struct i2c_driver tps6598x_i2c_driver = {
>  	.driver = {
>  		.name = "tps6598x",
> -		.acpi_match_table = tps6598x_acpi_match,
>  	},
>  	.probe_new = tps6598x_probe,
>  	.remove = tps6598x_remove,
> +	.id_table = tps6598x_id,
>  };
>  module_i2c_driver(tps6598x_i2c_driver);
>  
> -- 
> 2.19.2

-- 
heikki

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (14 preceding siblings ...)
  2018-11-28 11:45 ` [PATCH v5 15/15] iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper Andy Shevchenko
@ 2018-11-28 13:12 ` Heikki Krogerus
  2018-11-28 14:20 ` Hans de Goede
  2018-12-03 19:44 ` Andy Shevchenko
  17 siblings, 0 replies; 38+ messages in thread
From: Heikki Krogerus @ 2018-11-28 13:12 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, linux-kernel

On Wed, Nov 28, 2018 at 01:45:20PM +0200, Andy Shevchenko wrote:
> Currently i2c-multi-instantiate driver does not support the case
> of INT3515 USB PD device, where:
> 
> - Interrupt() is used instead of GpioInt()
> - All slaves may be the same from IP point of view
> - There can be variadic amount of slaves
> 
> This series is addressing all above.
> 
> Note, series has been smoke tested (Heikki would do BAT or more)
> on Intel Coffee Lake system.
> 
> The idea is to push this either through PDx86 tree (needs Rafael's ACKs) or ACPI.
> In any case it needs tags from Heikki, Hans, Mika, Wolfram and Jonathan.
> 
> Testing and comments are warmly welcome.

Looks good to me. The series, FWIW:

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> In v5:
> - unmess with patches 3 and 4 (there were squashed by my mistake)
> - other than above no code change from v4
> 
> In v4:
> - directly return -EPROBE_DEFER from i2c_acpi_new_device()
> - due to above split error handling simplification to separate patches
> 
> In v3:
> - revisit error codes returned by i2c_acpi_new_device() (Hans, Mika)
> - add documentation to exported i2c_acpi_get_i2c_resource() (Mika)
> - drop Hans' Rb tag in patch 5 due to changes
> - append Mika's Ab tag to patch 6
> 
> In v2:
> - drop patches to copy fwnode and to handle BOSC0200 device
> - append check for amount of devices listed in the driver's mapping
> - add Rb tag given by Hans
> 
> Andy Shevchenko (15):
>   platform/x86: intel_cht_int33fe: Remove duplicate NULL check
>   platform/x86: intel_cht_int33fe: Accept errors of
>     i2c_acpi_new_device()
>   platform/x86: i2c-multi-instantiate: Accept errors of
>     i2c_acpi_new_device()
>   platform/x86: i2c-multi-instantiate: Defer probe when no adapter found
>   i2c: acpi: Return error pointers from i2c_acpi_new_device()
>   platform/x86: intel_cht_int33fe: Get rid of obsolete conditional
>   platform/x86: i2c-multi-instantiate: Get rid of obsolete conditional
>   i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS
>   i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
>   platform/x86: i2c-multi-instantiate: Count I2cSerialBus() resources
>   platform/x86: i2c-multi-instantiate: Distinguish IRQ resource type
>   platform/x86: i2c-multi-instantiate: Introduce IOAPIC IRQ support
>   platform/x86: i2c-multi-instantiate: Allow to have same slaves
>   ACPI / scan: Create platform device for INT3515 ACPI nodes
>   iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper
> 
>  drivers/acpi/scan.c                          |  1 +
>  drivers/i2c/i2c-core-acpi.c                  | 64 +++++++++----
>  drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c   | 16 ++--
>  drivers/platform/x86/i2c-multi-instantiate.c | 97 ++++++++++++++++----
>  drivers/platform/x86/intel_cht_int33fe.c     | 20 ++--
>  drivers/usb/typec/tps6598x.c                 |  8 +-
>  include/linux/acpi.h                         | 11 +++
>  7 files changed, 157 insertions(+), 60 deletions(-)
> 
> --
> 2.19.2

-- 
heikki

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (15 preceding siblings ...)
  2018-11-28 13:12 ` [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Heikki Krogerus
@ 2018-11-28 14:20 ` Hans de Goede
  2018-12-03 19:44 ` Andy Shevchenko
  17 siblings, 0 replies; 38+ messages in thread
From: Hans de Goede @ 2018-11-28 14:20 UTC (permalink / raw)
  To: Andy Shevchenko, Darren Hart, platform-driver-x86,
	Rafael J. Wysocki, linux-acpi, Jonathan Cameron, Wolfram Sang,
	Mika Westerberg, linux-i2c, Heikki Krogerus, linux-kernel

Hi,

On 28-11-18 12:45, Andy Shevchenko wrote:
> Currently i2c-multi-instantiate driver does not support the case
> of INT3515 USB PD device, where:
> 
> - Interrupt() is used instead of GpioInt()
> - All slaves may be the same from IP point of view
> - There can be variadic amount of slaves
> 
> This series is addressing all above.
> 
> Note, series has been smoke tested (Heikki would do BAT or more)
> on Intel Coffee Lake system.
> 
> The idea is to push this either through PDx86 tree (needs Rafael's ACKs) or ACPI.
> In any case it needs tags from Heikki, Hans, Mika, Wolfram and Jonathan.
> 
> Testing and comments are warmly welcome.
> 
> In v5:
> - unmess with patches 3 and 4 (there were squashed by my mistake)
> - other than above no code change from v4

v5 looks good to me, you can add my:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

To the patches which don't have this yet.

Regards,

Hans




> 
> In v4:
> - directly return -EPROBE_DEFER from i2c_acpi_new_device()
> - due to above split error handling simplification to separate patches
> 
> In v3:
> - revisit error codes returned by i2c_acpi_new_device() (Hans, Mika)
> - add documentation to exported i2c_acpi_get_i2c_resource() (Mika)
> - drop Hans' Rb tag in patch 5 due to changes
> - append Mika's Ab tag to patch 6
> 
> In v2:
> - drop patches to copy fwnode and to handle BOSC0200 device
> - append check for amount of devices listed in the driver's mapping
> - add Rb tag given by Hans
> 
> Andy Shevchenko (15):
>    platform/x86: intel_cht_int33fe: Remove duplicate NULL check
>    platform/x86: intel_cht_int33fe: Accept errors of
>      i2c_acpi_new_device()
>    platform/x86: i2c-multi-instantiate: Accept errors of
>      i2c_acpi_new_device()
>    platform/x86: i2c-multi-instantiate: Defer probe when no adapter found
>    i2c: acpi: Return error pointers from i2c_acpi_new_device()
>    platform/x86: intel_cht_int33fe: Get rid of obsolete conditional
>    platform/x86: i2c-multi-instantiate: Get rid of obsolete conditional
>    i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS
>    i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
>    platform/x86: i2c-multi-instantiate: Count I2cSerialBus() resources
>    platform/x86: i2c-multi-instantiate: Distinguish IRQ resource type
>    platform/x86: i2c-multi-instantiate: Introduce IOAPIC IRQ support
>    platform/x86: i2c-multi-instantiate: Allow to have same slaves
>    ACPI / scan: Create platform device for INT3515 ACPI nodes
>    iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper
> 
>   drivers/acpi/scan.c                          |  1 +
>   drivers/i2c/i2c-core-acpi.c                  | 64 +++++++++----
>   drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c   | 16 ++--
>   drivers/platform/x86/i2c-multi-instantiate.c | 97 ++++++++++++++++----
>   drivers/platform/x86/intel_cht_int33fe.c     | 20 ++--
>   drivers/usb/typec/tps6598x.c                 |  8 +-
>   include/linux/acpi.h                         | 11 +++
>   7 files changed, 157 insertions(+), 60 deletions(-)
> 
> --
> 2.19.2
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 05/15] i2c: acpi: Return error pointers from i2c_acpi_new_device()
  2018-11-28 11:45 ` [PATCH v5 05/15] i2c: acpi: Return error pointers from i2c_acpi_new_device() Andy Shevchenko
@ 2018-11-28 14:47   ` Mika Westerberg
  2018-11-30  9:53   ` Wolfram Sang
  1 sibling, 0 replies; 38+ messages in thread
From: Mika Westerberg @ 2018-11-28 14:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

On Wed, Nov 28, 2018 at 01:45:25PM +0200, Andy Shevchenko wrote:
> The caller would like to know the reason why the i2c_acpi_new_device() fails.
> For example, if adapter is not available, it might be in the future and we
> would like to re-probe the clients again. But at the same time we would like to
> bail out if the error seems unrecoverable, such as invalid argument supplied.
> To achieve this, return error pointer in some cases.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  2018-11-28 11:45 ` [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper Andy Shevchenko
@ 2018-11-28 14:47   ` Mika Westerberg
  2018-11-30  9:55   ` Wolfram Sang
  2018-11-30 12:16   ` Wolfram Sang
  2 siblings, 0 replies; 38+ messages in thread
From: Mika Westerberg @ 2018-11-28 14:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

On Wed, Nov 28, 2018 at 01:45:29PM +0200, Andy Shevchenko wrote:
> Besides current two users one more is coming. Definitely makes sense to
> introduce a helper.
> 
> No functional change intended.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 14/15] ACPI / scan: Create platform device for INT3515 ACPI nodes
  2018-11-28 11:45 ` [PATCH v5 14/15] ACPI / scan: Create platform device for INT3515 ACPI nodes Andy Shevchenko
  2018-11-28 12:07   ` Heikki Krogerus
@ 2018-11-29 20:58   ` Rafael J. Wysocki
  2018-11-30  9:56     ` Andy Shevchenko
  1 sibling, 1 reply; 38+ messages in thread
From: Rafael J. Wysocki @ 2018-11-29 20:58 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, Platform Driver, Rafael J. Wysocki,
	ACPI Devel Maling List, jic23, Wolfram Sang, Mika Westerberg,
	linux-i2c, Hans de Goede, Heikki Krogerus,
	Linux Kernel Mailing List

On Wed, Nov 28, 2018 at 12:48 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> The ACPI device with INT3515 _HID is representing a complex USB PD
> hardware infrastructure which includes several I2C slave ICs.
>
> We add an ID to the I2C multi instantiate list to enumerate
> all I2C slaves correctly.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

and I'm assuming that you will route the whole series through the
platform/x86 drivers tree.

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 05/15] i2c: acpi: Return error pointers from i2c_acpi_new_device()
  2018-11-28 11:45 ` [PATCH v5 05/15] i2c: acpi: Return error pointers from i2c_acpi_new_device() Andy Shevchenko
  2018-11-28 14:47   ` Mika Westerberg
@ 2018-11-30  9:53   ` Wolfram Sang
  1 sibling, 0 replies; 38+ messages in thread
From: Wolfram Sang @ 2018-11-30  9:53 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 567 bytes --]

On Wed, Nov 28, 2018 at 01:45:25PM +0200, Andy Shevchenko wrote:
> The caller would like to know the reason why the i2c_acpi_new_device() fails.
> For example, if adapter is not available, it might be in the future and we
> would like to re-probe the clients again. But at the same time we would like to
> bail out if the error seems unrecoverable, such as invalid argument supplied.
> To achieve this, return error pointer in some cases.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Wolfram Sang <wsa@the-dreams.de>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 08/15] i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS
  2018-11-28 11:45 ` [PATCH v5 08/15] i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS Andy Shevchenko
@ 2018-11-30  9:53   ` Wolfram Sang
  0 siblings, 0 replies; 38+ messages in thread
From: Wolfram Sang @ 2018-11-30  9:53 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

On Wed, Nov 28, 2018 at 01:45:28PM +0200, Andy Shevchenko wrote:
> Convert to use ACPI_FAILURE instead of !ACPI_SUCCESS.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Acked-by: Wolfram Sang <wsa@the-dreams.de>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  2018-11-28 11:45 ` [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper Andy Shevchenko
  2018-11-28 14:47   ` Mika Westerberg
@ 2018-11-30  9:55   ` Wolfram Sang
  2018-11-30 10:57     ` Andy Shevchenko
  2018-11-30 12:16   ` Wolfram Sang
  2 siblings, 1 reply; 38+ messages in thread
From: Wolfram Sang @ 2018-11-30  9:55 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 496 bytes --]

On Wed, Nov 28, 2018 at 01:45:29PM +0200, Andy Shevchenko wrote:
> Besides current two users one more is coming. Definitely makes sense to
> introduce a helper.
> 
> No functional change intended.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/i2c/i2c-core-acpi.c | 41 ++++++++++++++++++++++++++-----------
>  include/linux/acpi.h        | 11 ++++++++++

Any reason this is not in i2c.h?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 14/15] ACPI / scan: Create platform device for INT3515 ACPI nodes
  2018-11-29 20:58   ` Rafael J. Wysocki
@ 2018-11-30  9:56     ` Andy Shevchenko
  0 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-30  9:56 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Darren Hart, Platform Driver, Rafael J. Wysocki,
	ACPI Devel Maling List, jic23, Wolfram Sang, Mika Westerberg,
	linux-i2c, Hans de Goede, Heikki Krogerus,
	Linux Kernel Mailing List

On Thu, Nov 29, 2018 at 09:58:51PM +0100, Rafael J. Wysocki wrote:
> On Wed, Nov 28, 2018 at 12:48 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > The ACPI device with INT3515 _HID is representing a complex USB PD
> > hardware infrastructure which includes several I2C slave ICs.
> >
> > We add an ID to the I2C multi instantiate list to enumerate
> > all I2C slaves correctly.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> 
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> and I'm assuming that you will route the whole series through the
> platform/x86 drivers tree.

Thanks, Rafael, will route through PDx86!


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  2018-11-30  9:55   ` Wolfram Sang
@ 2018-11-30 10:57     ` Andy Shevchenko
  2018-11-30 11:06       ` Wolfram Sang
  0 siblings, 1 reply; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-30 10:57 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

On Fri, Nov 30, 2018 at 10:55:33AM +0100, Wolfram Sang wrote:
> On Wed, Nov 28, 2018 at 01:45:29PM +0200, Andy Shevchenko wrote:
> > Besides current two users one more is coming. Definitely makes sense to
> > introduce a helper.
> > 
> > No functional change intended.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> > ---
> >  drivers/i2c/i2c-core-acpi.c | 41 ++++++++++++++++++++++++++-----------
> >  include/linux/acpi.h        | 11 ++++++++++
> 
> Any reason this is not in i2c.h?

Yes. As I explained earlier to some people there are facts affecting this:
- the function is operate on top of solely ACPI structures
- there is already similar function for GPIO and it stays like that

On top of this recently I've discovered, that i2c.h has separate #ifdef for I2C
and ACPI which theoretically might produce a linker error in some cases.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  2018-11-30 10:57     ` Andy Shevchenko
@ 2018-11-30 11:06       ` Wolfram Sang
  2018-11-30 11:45         ` Andy Shevchenko
  0 siblings, 1 reply; 38+ messages in thread
From: Wolfram Sang @ 2018-11-30 11:06 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]


> > >  drivers/i2c/i2c-core-acpi.c | 41 ++++++++++++++++++++++++++-----------
> > >  include/linux/acpi.h        | 11 ++++++++++
> > 
> > Any reason this is not in i2c.h?
> 
> Yes. As I explained earlier to some people there are facts affecting this:
> - the function is operate on top of solely ACPI structures

And moving the function itself to the ACPI realm then?

I don't say this is a show-stopper for this series, but I just wonder...

> - there is already similar function for GPIO and it stays like that
> 
> On top of this recently I've discovered, that i2c.h has separate #ifdef for I2C
> and ACPI which theoretically might produce a linker error in some cases.

Is this something we have to live with or which can be cleaned up
somewhen?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  2018-11-30 11:06       ` Wolfram Sang
@ 2018-11-30 11:45         ` Andy Shevchenko
  2018-11-30 11:49           ` Wolfram Sang
  0 siblings, 1 reply; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-30 11:45 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

On Fri, Nov 30, 2018 at 12:06:52PM +0100, Wolfram Sang wrote:
> > > >  drivers/i2c/i2c-core-acpi.c | 41 ++++++++++++++++++++++++++-----------
> > > >  include/linux/acpi.h        | 11 ++++++++++
> > > 
> > > Any reason this is not in i2c.h?
> > 
> > Yes. As I explained earlier to some people there are facts affecting this:
> > - the function is operate on top of solely ACPI structures
> 
> And moving the function itself to the ACPI realm then?

Unfortunately I don't see the place where it fits good. See below.

> I don't say this is a show-stopper for this series, but I just wonder...
> 
> > - there is already similar function for GPIO and it stays like that
> > 
> > On top of this recently I've discovered, that i2c.h has separate #ifdef for I2C
> > and ACPI which theoretically might produce a linker error in some cases.
> 
> Is this something we have to live with or which can be cleaned up
> somewhen?

My opinion that we might need something like
drivers/acpi/acpi_i2c_lib.c
drivers/acpi/acpi_gpio_lib.c
etc.

But better to ask Rafael and Mika what they think about this.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  2018-11-30 11:45         ` Andy Shevchenko
@ 2018-11-30 11:49           ` Wolfram Sang
  2018-11-30 12:12             ` Mika Westerberg
  0 siblings, 1 reply; 38+ messages in thread
From: Wolfram Sang @ 2018-11-30 11:49 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]


> > Is this something we have to live with or which can be cleaned up
> > somewhen?
> 
> My opinion that we might need something like
> drivers/acpi/acpi_i2c_lib.c
> drivers/acpi/acpi_gpio_lib.c
> etc.
>

Collect all of them in drivers/acpi/acpi_libs.c?

> But better to ask Rafael and Mika what they think about this.

Sure!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  2018-11-30 11:49           ` Wolfram Sang
@ 2018-11-30 12:12             ` Mika Westerberg
  2018-11-30 12:17               ` Andy Shevchenko
  0 siblings, 1 reply; 38+ messages in thread
From: Mika Westerberg @ 2018-11-30 12:12 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Andy Shevchenko, Darren Hart, platform-driver-x86,
	Rafael J. Wysocki, linux-acpi, Jonathan Cameron, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel

On Fri, Nov 30, 2018 at 12:49:50PM +0100, Wolfram Sang wrote:
> 
> > > Is this something we have to live with or which can be cleaned up
> > > somewhen?
> > 
> > My opinion that we might need something like
> > drivers/acpi/acpi_i2c_lib.c
> > drivers/acpi/acpi_gpio_lib.c
> > etc.
> >
> 
> Collect all of them in drivers/acpi/acpi_libs.c?
> 
> > But better to ask Rafael and Mika what they think about this.

IMHO all the bus specific ACPI things should go under those buses (so
the opposite what is proposed here) but I also don't think any of this
is show stopper for the patch series under discussion ;-)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  2018-11-28 11:45 ` [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper Andy Shevchenko
  2018-11-28 14:47   ` Mika Westerberg
  2018-11-30  9:55   ` Wolfram Sang
@ 2018-11-30 12:16   ` Wolfram Sang
  2 siblings, 0 replies; 38+ messages in thread
From: Wolfram Sang @ 2018-11-30 12:16 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

On Wed, Nov 28, 2018 at 01:45:29PM +0200, Andy Shevchenko wrote:
> Besides current two users one more is coming. Definitely makes sense to
> introduce a helper.
> 
> No functional change intended.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Acked-by: Wolfram Sang <wsa@the-dreams.de>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
  2018-11-30 12:12             ` Mika Westerberg
@ 2018-11-30 12:17               ` Andy Shevchenko
  0 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-11-30 12:17 UTC (permalink / raw)
  To: Mika Westerberg
  Cc: Wolfram Sang, Darren Hart, platform-driver-x86,
	Rafael J. Wysocki, linux-acpi, Jonathan Cameron, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel

On Fri, Nov 30, 2018 at 02:12:31PM +0200, Mika Westerberg wrote:
> On Fri, Nov 30, 2018 at 12:49:50PM +0100, Wolfram Sang wrote:
> > 
> > > > Is this something we have to live with or which can be cleaned up
> > > > somewhen?
> > > 
> > > My opinion that we might need something like
> > > drivers/acpi/acpi_i2c_lib.c
> > > drivers/acpi/acpi_gpio_lib.c
> > > etc.
> > >
> > 
> > Collect all of them in drivers/acpi/acpi_libs.c?
> > 
> > > But better to ask Rafael and Mika what they think about this.
> 
> IMHO all the bus specific ACPI things should go under those buses (so
> the opposite what is proposed here) but I also don't think any of this
> is show stopper for the patch series under discussion ;-)

Thank you guys for your input, let me fix this later, out of this series.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 02/15] platform/x86: intel_cht_int33fe: Accept errors of i2c_acpi_new_device()
  2018-11-28 11:45 ` [PATCH v5 02/15] platform/x86: intel_cht_int33fe: Accept errors of i2c_acpi_new_device() Andy Shevchenko
@ 2018-12-02 15:56   ` Jonathan Cameron
  2018-12-02 17:38     ` Andy Shevchenko
  0 siblings, 1 reply; 38+ messages in thread
From: Jonathan Cameron @ 2018-12-02 15:56 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Wolfram Sang, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

On Wed, 28 Nov 2018 13:45:22 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> In the future i2c_acpi_new_device() will return error pointer in some cases.
> Prepare intel_cht_int33fe driver to support that.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Really trivial comment inline.  I haven't checked back to see if there
has been any previous discussion on that bit of code.

Otherwise looks sensible to me.

Jonathan



> ---
>  drivers/platform/x86/intel_cht_int33fe.c | 28 +++++++++++++++++++-----
>  1 file changed, 23 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c
> index 431151d4e611..367d6e304ade 100644
> --- a/drivers/platform/x86/intel_cht_int33fe.c
> +++ b/drivers/platform/x86/intel_cht_int33fe.c
> @@ -168,8 +168,14 @@ static int cht_int33fe_probe(struct platform_device *pdev)
>  		board_info.dev_name = "max17047";
>  		board_info.properties = max17047_props;
>  		data->max17047 = i2c_acpi_new_device(dev, 1, &board_info);
> -		if (!data->max17047)
> -			return -EPROBE_DEFER; /* Wait for i2c-adapter to load */
> +		if (IS_ERR(data->max17047))
> +			ret = PTR_ERR(data->max17047);
Every so slightly nicer to just return directly in these error cases?
> +		else if (!data->max17047)
> +			ret = -EPROBE_DEFER; /* Wait for i2c-adapter to load */
> +		else
> +			ret = 0;

Particularly so as then you don't need to set this ret as it's set in all
paths where it is used below anyway...

> +		if (ret)
> +			return ret;
>  	}
>  
>  	data->connections[0].endpoint[0] = "port0";
> @@ -194,7 +200,13 @@ static int cht_int33fe_probe(struct platform_device *pdev)
>  	board_info.irq = fusb302_irq;
>  
>  	data->fusb302 = i2c_acpi_new_device(dev, 2, &board_info);
> -	if (!data->fusb302)
> +	if (IS_ERR(data->fusb302))
> +		ret = PTR_ERR(data->fusb302);
> +	else if (!data->fusb302)
> +		ret = -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
> +	else
> +		ret = 0;
> +	if (ret)
>  		goto out_unregister_max17047;
>  
>  	memset(&board_info, 0, sizeof(board_info));
> @@ -202,7 +214,13 @@ static int cht_int33fe_probe(struct platform_device *pdev)
>  	strlcpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
>  
>  	data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
> -	if (!data->pi3usb30532)
> +	if (IS_ERR(data->pi3usb30532))
> +		ret = PTR_ERR(data->pi3usb30532);
> +	else if (!data->pi3usb30532)
> +		ret = -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
> +	else
> +		ret = 0;
> +	if (ret)
>  		goto out_unregister_fusb302;
>  
>  	platform_set_drvdata(pdev, data);
> @@ -217,7 +235,7 @@ static int cht_int33fe_probe(struct platform_device *pdev)
>  
>  	device_connections_remove(data->connections);
>  
> -	return -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
> +	return ret;
>  }
>  
>  static int cht_int33fe_remove(struct platform_device *pdev)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 06/15] platform/x86: intel_cht_int33fe: Get rid of obsolete conditional
  2018-11-28 11:45 ` [PATCH v5 06/15] platform/x86: intel_cht_int33fe: Get rid of obsolete conditional Andy Shevchenko
@ 2018-12-02 16:35   ` Jonathan Cameron
  0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2018-12-02 16:35 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Wolfram Sang, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

On Wed, 28 Nov 2018 13:45:26 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Now, when i2c_acpi_new_device() never returns NULL, there is no point to check
> for it. Besides that, i2c_acpi_new_device() returns -EPROBE_DEFER directly and
> caller doesn't need to guess is better.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Ah, the code I commented on earlier goes away anyway.  Not to worry then!

Jonathan

> ---
>  drivers/platform/x86/intel_cht_int33fe.c | 24 +++++-------------------
>  1 file changed, 5 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c
> index 367d6e304ade..616b8853a91f 100644
> --- a/drivers/platform/x86/intel_cht_int33fe.c
> +++ b/drivers/platform/x86/intel_cht_int33fe.c
> @@ -169,13 +169,7 @@ static int cht_int33fe_probe(struct platform_device *pdev)
>  		board_info.properties = max17047_props;
>  		data->max17047 = i2c_acpi_new_device(dev, 1, &board_info);
>  		if (IS_ERR(data->max17047))
> -			ret = PTR_ERR(data->max17047);
> -		else if (!data->max17047)
> -			ret = -EPROBE_DEFER; /* Wait for i2c-adapter to load */
> -		else
> -			ret = 0;
> -		if (ret)
> -			return ret;
> +			return PTR_ERR(data->max17047);
>  	}
>  
>  	data->connections[0].endpoint[0] = "port0";
> @@ -200,28 +194,20 @@ static int cht_int33fe_probe(struct platform_device *pdev)
>  	board_info.irq = fusb302_irq;
>  
>  	data->fusb302 = i2c_acpi_new_device(dev, 2, &board_info);
> -	if (IS_ERR(data->fusb302))
> +	if (IS_ERR(data->fusb302)) {
>  		ret = PTR_ERR(data->fusb302);
> -	else if (!data->fusb302)
> -		ret = -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
> -	else
> -		ret = 0;
> -	if (ret)
>  		goto out_unregister_max17047;
> +	}
>  
>  	memset(&board_info, 0, sizeof(board_info));
>  	board_info.dev_name = "pi3usb30532";
>  	strlcpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
>  
>  	data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
> -	if (IS_ERR(data->pi3usb30532))
> +	if (IS_ERR(data->pi3usb30532)) {
>  		ret = PTR_ERR(data->pi3usb30532);
> -	else if (!data->pi3usb30532)
> -		ret = -EPROBE_DEFER; /* Wait for the i2c-adapter to load */
> -	else
> -		ret = 0;
> -	if (ret)
>  		goto out_unregister_fusb302;
> +	}
>  
>  	platform_set_drvdata(pdev, data);
>  

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 15/15] iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper
  2018-11-28 11:45 ` [PATCH v5 15/15] iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper Andy Shevchenko
@ 2018-12-02 16:41   ` Jonathan Cameron
  0 siblings, 0 replies; 38+ messages in thread
From: Jonathan Cameron @ 2018-12-02 16:41 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Wolfram Sang, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel, linux-iio


+CC linux-iio mostly so I can track it and because others may care.

On Wed, 28 Nov 2018 13:45:35 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> ACPI provides a generic helper to get I2C Serial Bus resources.
> Use it instead of open coded variant.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Thanks,

Jonathan
> ---
>  drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
> index d78a10403bac..a961b5a06fe6 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
> @@ -91,18 +91,14 @@ static int asus_acpi_get_sensor_info(struct acpi_device *adev,
>  
>  static int acpi_i2c_check_resource(struct acpi_resource *ares, void *data)
>  {
> +	struct acpi_resource_i2c_serialbus *sb;
>  	u32 *addr = data;
>  
> -	if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
> -		struct acpi_resource_i2c_serialbus *sb;
> -
> -		sb = &ares->data.i2c_serial_bus;
> -		if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
> -			if (*addr)
> -				*addr |= (sb->slave_address << 16);
> -			else
> -				*addr = sb->slave_address;
> -		}
> +	if (i2c_acpi_get_i2c_resource(ares, &sb)) {
> +		if (*addr)
> +			*addr |= (sb->slave_address << 16);
> +		else
> +			*addr = sb->slave_address;
>  	}
>  
>  	/* Tell the ACPI core that we already copied this address */

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 02/15] platform/x86: intel_cht_int33fe: Accept errors of i2c_acpi_new_device()
  2018-12-02 15:56   ` Jonathan Cameron
@ 2018-12-02 17:38     ` Andy Shevchenko
  0 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-12-02 17:38 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Wolfram Sang, Mika Westerberg, linux-i2c, Hans de Goede,
	Heikki Krogerus, linux-kernel

On Sun, Dec 02, 2018 at 03:56:06PM +0000, Jonathan Cameron wrote:
> On Wed, 28 Nov 2018 13:45:22 +0200
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> > In the future i2c_acpi_new_device() will return error pointer in some cases.
> > Prepare intel_cht_int33fe driver to support that.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> 
> Really trivial comment inline.  I haven't checked back to see if there
> has been any previous discussion on that bit of code.
> 
> Otherwise looks sensible to me.

> >  		data->max17047 = i2c_acpi_new_device(dev, 1, &board_info);
> > -		if (!data->max17047)
> > -			return -EPROBE_DEFER; /* Wait for i2c-adapter to load */
> > +		if (IS_ERR(data->max17047))
> > +			ret = PTR_ERR(data->max17047);
> Every so slightly nicer to just return directly in these error cases?
> > +		else if (!data->max17047)
> > +			ret = -EPROBE_DEFER; /* Wait for i2c-adapter to load */
> > +		else
> > +			ret = 0;

> Particularly so as then you don't need to set this ret as it's set in all
> paths where it is used below anyway...

It doesn't matter much, since the logically it's split to 3 stages:
- preparation
- change API
- drop obsoleted pieces of code

This one is preparation stage. After 3rd stage it will be as you suggested.

> > +		if (ret)
> > +			return ret;

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike
  2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
                   ` (16 preceding siblings ...)
  2018-11-28 14:20 ` Hans de Goede
@ 2018-12-03 19:44 ` Andy Shevchenko
  17 siblings, 0 replies; 38+ messages in thread
From: Andy Shevchenko @ 2018-12-03 19:44 UTC (permalink / raw)
  To: Darren Hart, platform-driver-x86, Rafael J. Wysocki, linux-acpi,
	Jonathan Cameron, Wolfram Sang, Mika Westerberg, linux-i2c,
	Hans de Goede, Heikki Krogerus, linux-kernel

On Wed, Nov 28, 2018 at 01:45:20PM +0200, Andy Shevchenko wrote:
> Currently i2c-multi-instantiate driver does not support the case
> of INT3515 USB PD device, where:
> 
> - Interrupt() is used instead of GpioInt()
> - All slaves may be the same from IP point of view
> - There can be variadic amount of slaves
> 
> This series is addressing all above.
> 
> Note, series has been smoke tested (Heikki would do BAT or more)
> on Intel Coffee Lake system.
> 
> The idea is to push this either through PDx86 tree (needs Rafael's ACKs) or ACPI.
> In any case it needs tags from Heikki, Hans, Mika, Wolfram and Jonathan.
> 
> Testing and comments are warmly welcome.

Thank you everyone, who helped with this series, pushed to my review and testing queue!

> 
> In v5:
> - unmess with patches 3 and 4 (there were squashed by my mistake)
> - other than above no code change from v4
> 
> In v4:
> - directly return -EPROBE_DEFER from i2c_acpi_new_device()
> - due to above split error handling simplification to separate patches
> 
> In v3:
> - revisit error codes returned by i2c_acpi_new_device() (Hans, Mika)
> - add documentation to exported i2c_acpi_get_i2c_resource() (Mika)
> - drop Hans' Rb tag in patch 5 due to changes
> - append Mika's Ab tag to patch 6
> 
> In v2:
> - drop patches to copy fwnode and to handle BOSC0200 device
> - append check for amount of devices listed in the driver's mapping
> - add Rb tag given by Hans
> 
> Andy Shevchenko (15):
>   platform/x86: intel_cht_int33fe: Remove duplicate NULL check
>   platform/x86: intel_cht_int33fe: Accept errors of
>     i2c_acpi_new_device()
>   platform/x86: i2c-multi-instantiate: Accept errors of
>     i2c_acpi_new_device()
>   platform/x86: i2c-multi-instantiate: Defer probe when no adapter found
>   i2c: acpi: Return error pointers from i2c_acpi_new_device()
>   platform/x86: intel_cht_int33fe: Get rid of obsolete conditional
>   platform/x86: i2c-multi-instantiate: Get rid of obsolete conditional
>   i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS
>   i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper
>   platform/x86: i2c-multi-instantiate: Count I2cSerialBus() resources
>   platform/x86: i2c-multi-instantiate: Distinguish IRQ resource type
>   platform/x86: i2c-multi-instantiate: Introduce IOAPIC IRQ support
>   platform/x86: i2c-multi-instantiate: Allow to have same slaves
>   ACPI / scan: Create platform device for INT3515 ACPI nodes
>   iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper
> 
>  drivers/acpi/scan.c                          |  1 +
>  drivers/i2c/i2c-core-acpi.c                  | 64 +++++++++----
>  drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c   | 16 ++--
>  drivers/platform/x86/i2c-multi-instantiate.c | 97 ++++++++++++++++----
>  drivers/platform/x86/intel_cht_int33fe.c     | 20 ++--
>  drivers/usb/typec/tps6598x.c                 |  8 +-
>  include/linux/acpi.h                         | 11 +++
>  7 files changed, 157 insertions(+), 60 deletions(-)
> 
> --
> 2.19.2
> 

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2018-12-03 19:44 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-28 11:45 [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 01/15] platform/x86: intel_cht_int33fe: Remove duplicate NULL check Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 02/15] platform/x86: intel_cht_int33fe: Accept errors of i2c_acpi_new_device() Andy Shevchenko
2018-12-02 15:56   ` Jonathan Cameron
2018-12-02 17:38     ` Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 03/15] platform/x86: i2c-multi-instantiate: " Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 04/15] platform/x86: i2c-multi-instantiate: Defer probe when no adapter found Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 05/15] i2c: acpi: Return error pointers from i2c_acpi_new_device() Andy Shevchenko
2018-11-28 14:47   ` Mika Westerberg
2018-11-30  9:53   ` Wolfram Sang
2018-11-28 11:45 ` [PATCH v5 06/15] platform/x86: intel_cht_int33fe: Get rid of obsolete conditional Andy Shevchenko
2018-12-02 16:35   ` Jonathan Cameron
2018-11-28 11:45 ` [PATCH v5 07/15] platform/x86: i2c-multi-instantiate: " Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 08/15] i2c: acpi: Use ACPI_FAILURE instead of !ACPI_SUCCESS Andy Shevchenko
2018-11-30  9:53   ` Wolfram Sang
2018-11-28 11:45 ` [PATCH v5 09/15] i2c: acpi: Introduce i2c_acpi_get_i2c_resource() helper Andy Shevchenko
2018-11-28 14:47   ` Mika Westerberg
2018-11-30  9:55   ` Wolfram Sang
2018-11-30 10:57     ` Andy Shevchenko
2018-11-30 11:06       ` Wolfram Sang
2018-11-30 11:45         ` Andy Shevchenko
2018-11-30 11:49           ` Wolfram Sang
2018-11-30 12:12             ` Mika Westerberg
2018-11-30 12:17               ` Andy Shevchenko
2018-11-30 12:16   ` Wolfram Sang
2018-11-28 11:45 ` [PATCH v5 10/15] platform/x86: i2c-multi-instantiate: Count I2cSerialBus() resources Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 11/15] platform/x86: i2c-multi-instantiate: Distinguish IRQ resource type Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 12/15] platform/x86: i2c-multi-instantiate: Introduce IOAPIC IRQ support Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 13/15] platform/x86: i2c-multi-instantiate: Allow to have same slaves Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 14/15] ACPI / scan: Create platform device for INT3515 ACPI nodes Andy Shevchenko
2018-11-28 12:07   ` Heikki Krogerus
2018-11-29 20:58   ` Rafael J. Wysocki
2018-11-30  9:56     ` Andy Shevchenko
2018-11-28 11:45 ` [PATCH v5 15/15] iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper Andy Shevchenko
2018-12-02 16:41   ` Jonathan Cameron
2018-11-28 13:12 ` [PATCH v5 00/15] i2c-multi-instantiate: Adapt for INT3515 and alike Heikki Krogerus
2018-11-28 14:20 ` Hans de Goede
2018-12-03 19:44 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.