platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling
cover platform/chrome: cros_typec_switch: Fix fwnode and _ADR handling
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(-)
Signature · 1 line
2.50.1
PATCH 2/2 platform/chrome: cros_typec_switch: simplify code with acpi_get_local_u64_address()
Now we have a helper so there's no need to open-code.
--- drivers/platform/chrome/cros_typec_switch.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/platform/chrome/cros_typec_switch.c +3 -12
@@ -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; }
Signature · 1 line
2.50.1
PATCH 1/2 platform/chrome: cros_typec_switch: Don't touch struct fwnode_handle::dev
In reply to Andy ShevchenkoThe '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.
--- drivers/platform/chrome/cros_typec_switch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/platform/chrome/cros_typec_switch.c +3 -3
@@ -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; }
Signature · 1 line
2.50.1
Tzung-Bi Shih
maintainerQuoted 11 lines · Andy Shevchenko
While looking for something else, I have noticed a nasty use of the private field of struct
fwnode_handlein 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 withacpi_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: a4065662998fbee4a0ca9886b9aa50aa9694e0e7Thanks!