public inbox for chrome-platform@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v1 0/2] platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling
@ 2026-01-20 13:12 Andy Shevchenko
  2026-01-20 13:12 ` [PATCH v1 1/2] platform/chrome: cros_typec_switch: Don't touch struct fwnode_handle::dev Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-01-20 13:12 UTC (permalink / raw)
  To: Andy Shevchenko, chrome-platform, linux-kernel
  Cc: Benson Leung, Abhishek Pandit-Subedi, Jameson Thies,
	Andrei Kuchynski, Tzung-Bi Shih

While looking for something else, I have noticed a nasty use of the private
field of struct fwnode_handle in basically the only driver. So, hence the
fix and one following cleanup.

Andy Shevchenko (2):
  platform/chrome: cros_typec_switch: Don't touch  struct
    fwnode_handle::dev
  platform/chrome: cros_typec_switch: simplify code with
    acpi_get_local_u64_address()

 drivers/platform/chrome/cros_typec_switch.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

-- 
2.50.1


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

* [PATCH v1 1/2] platform/chrome: cros_typec_switch: Don't touch  struct fwnode_handle::dev
  2026-01-20 13:12 [PATCH v1 0/2] platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling Andy Shevchenko
@ 2026-01-20 13:12 ` Andy Shevchenko
  2026-01-20 13:12 ` [PATCH v1 2/2] platform/chrome: cros_typec_switch: simplify code with acpi_get_local_u64_address() Andy Shevchenko
  2026-01-21  4:41 ` [PATCH v1 0/2] platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling Tzung-Bi Shih
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-01-20 13:12 UTC (permalink / raw)
  To: Andy Shevchenko, chrome-platform, linux-kernel
  Cc: Benson Leung, Abhishek Pandit-Subedi, Jameson Thies,
	Andrei Kuchynski, Tzung-Bi Shih

The 'dev' field in struct fwnode is special and related to device links,
There no driver should use it for printing messages. Fix incorrect use
of private field.

Fixes: affc804c44c8 ("platform/chrome: cros_typec_switch: Add switch driver")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/chrome/cros_typec_switch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c
index 8d7c34abb0a1..d8a28d4e51a8 100644
--- a/drivers/platform/chrome/cros_typec_switch.c
+++ b/drivers/platform/chrome/cros_typec_switch.c
@@ -230,20 +230,20 @@ static int cros_typec_register_switches(struct cros_typec_switch_data *sdata)
 
 		adev = to_acpi_device_node(fwnode);
 		if (!adev) {
-			dev_err(fwnode->dev, "Couldn't get ACPI device handle\n");
+			dev_err(dev, "Couldn't get ACPI device handle for %pfwP\n", fwnode);
 			ret = -ENODEV;
 			goto err_switch;
 		}
 
 		ret = acpi_evaluate_integer(adev->handle, "_ADR", NULL, &index);
 		if (ACPI_FAILURE(ret)) {
-			dev_err(fwnode->dev, "_ADR wasn't evaluated\n");
+			dev_err(dev, "_ADR wasn't evaluated for %pfwP\n", fwnode);
 			ret = -ENODATA;
 			goto err_switch;
 		}
 
 		if (index >= EC_USB_PD_MAX_PORTS) {
-			dev_err(fwnode->dev, "Invalid port index number: %llu\n", index);
+			dev_err(dev, "%pfwP: Invalid port index number: %llu\n", fwnode, index);
 			ret = -EINVAL;
 			goto err_switch;
 		}
-- 
2.50.1


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

* [PATCH v1 2/2] platform/chrome: cros_typec_switch: simplify code with acpi_get_local_u64_address()
  2026-01-20 13:12 [PATCH v1 0/2] platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling Andy Shevchenko
  2026-01-20 13:12 ` [PATCH v1 1/2] platform/chrome: cros_typec_switch: Don't touch struct fwnode_handle::dev Andy Shevchenko
@ 2026-01-20 13:12 ` Andy Shevchenko
  2026-01-21  4:41 ` [PATCH v1 0/2] platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling Tzung-Bi Shih
  2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-01-20 13:12 UTC (permalink / raw)
  To: Andy Shevchenko, chrome-platform, linux-kernel
  Cc: Benson Leung, Abhishek Pandit-Subedi, Jameson Thies,
	Andrei Kuchynski, Tzung-Bi Shih

Now we have a helper so there's no need to open-code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/platform/chrome/cros_typec_switch.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/chrome/cros_typec_switch.c b/drivers/platform/chrome/cros_typec_switch.c
index d8a28d4e51a8..fe0eddd2cf45 100644
--- a/drivers/platform/chrome/cros_typec_switch.c
+++ b/drivers/platform/chrome/cros_typec_switch.c
@@ -211,9 +211,8 @@ static int cros_typec_register_switches(struct cros_typec_switch_data *sdata)
 	struct cros_typec_port *port;
 	struct device *dev = sdata->dev;
 	struct fwnode_handle *fwnode;
-	struct acpi_device *adev;
-	unsigned long long index;
 	int nports, ret;
+	u64 index;
 
 	nports = device_get_child_node_count(dev);
 	if (nports == 0) {
@@ -228,17 +227,9 @@ static int cros_typec_register_switches(struct cros_typec_switch_data *sdata)
 			goto err_switch;
 		}
 
-		adev = to_acpi_device_node(fwnode);
-		if (!adev) {
-			dev_err(dev, "Couldn't get ACPI device handle for %pfwP\n", fwnode);
-			ret = -ENODEV;
-			goto err_switch;
-		}
-
-		ret = acpi_evaluate_integer(adev->handle, "_ADR", NULL, &index);
-		if (ACPI_FAILURE(ret)) {
+		ret = acpi_get_local_u64_address(ACPI_HANDLE_FWNODE(fwnode), &index);
+		if (ret) {
 			dev_err(dev, "_ADR wasn't evaluated for %pfwP\n", fwnode);
-			ret = -ENODATA;
 			goto err_switch;
 		}
 
-- 
2.50.1


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

* Re: [PATCH v1 0/2] platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling
  2026-01-20 13:12 [PATCH v1 0/2] platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling Andy Shevchenko
  2026-01-20 13:12 ` [PATCH v1 1/2] platform/chrome: cros_typec_switch: Don't touch struct fwnode_handle::dev Andy Shevchenko
  2026-01-20 13:12 ` [PATCH v1 2/2] platform/chrome: cros_typec_switch: simplify code with acpi_get_local_u64_address() Andy Shevchenko
@ 2026-01-21  4:41 ` Tzung-Bi Shih
  2 siblings, 0 replies; 4+ messages in thread
From: Tzung-Bi Shih @ 2026-01-21  4:41 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: chrome-platform, linux-kernel, Benson Leung,
	Abhishek Pandit-Subedi, Jameson Thies, Andrei Kuchynski

On Tue, Jan 20, 2026 at 02:12:29PM +0100, Andy Shevchenko wrote:
> While looking for something else, I have noticed a nasty use of the private
> field of struct fwnode_handle in basically the only driver. So, hence the
> fix and one following cleanup.
> 
> Andy Shevchenko (2):
>   platform/chrome: cros_typec_switch: Don't touch  struct
>     fwnode_handle::dev
>   platform/chrome: cros_typec_switch: simplify code with
>     acpi_get_local_u64_address()
> 
> [...]

Applied to

    https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next

[1/2] platform/chrome: cros_typec_switch: Don't touch struct fwnode_handle::dev
      commit: e1adf48853bc715f4deea074932aa1c44eb7abea
[2/2] platform/chrome: cros_typec_switch: simplify code with acpi_get_local_u64_address()
      commit: a4065662998fbee4a0ca9886b9aa50aa9694e0e7

Thanks!

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

end of thread, other threads:[~2026-01-21  4:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-20 13:12 [PATCH v1 0/2] platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling Andy Shevchenko
2026-01-20 13:12 ` [PATCH v1 1/2] platform/chrome: cros_typec_switch: Don't touch struct fwnode_handle::dev Andy Shevchenko
2026-01-20 13:12 ` [PATCH v1 2/2] platform/chrome: cros_typec_switch: simplify code with acpi_get_local_u64_address() Andy Shevchenko
2026-01-21  4:41 ` [PATCH v1 0/2] platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling Tzung-Bi Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox