ACPI: Use ACPI_COMPANION() directly to simplify code
Subsystems (11)
cover ACPI: Use ACPI_COMPANION() directly to simplify code
Hi All,
The patches in this series are all independent, but they make analogous changes, which are to replace the combination of ACPI_HANDLE() and acpi_bus_get_device() with ACPI_COMPANION() that gets the same result in a much simpler way.
Thanks!
PATCH 1/7 gpio-amdpt: ACPI: Use the ACPI_COMPANION() macro directly
From: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify pt_gpio_probe() accordingly (no intentional functional impact).
--- drivers/gpio/gpio-amdpt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpio/gpio-amdpt.c +1 -3
@@ -72,12 +72,10 @@ static void pt_gpio_free(struct gpio_chistatic int pt_gpio_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct acpi_device *acpi_dev; -acpi_handle handle =ACPI_HANDLE (dev);struct pt_gpio_chip *pt_gpio;int ret =0 ; -if (acpi_bus_get_device (handle, &acpi_dev)) { +if (!ACPI_COMPANION (dev)) {dev_err (dev,"PT GPIO device node not found\n" );return -ENODEV ; }
Re: [PATCH v1 1/7] gpio-amdpt: ACPI: Use the ACPI_COMPANION() macro directly
Quoted 27 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
ACPI_HANDLE()macro is a wrapper arond theACPI_COMPANION()macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former toacpi_bus_get_device().Modify
pt_gpio_probe()accordingly (no intentional functional impact).Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/gpio/gpio-amdpt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)Index:
linux-pm/drivers/gpio/gpio-amdpt.c
===================================================================drivers/gpio/gpio-amdpt.c +0
-0@@ -72,12 +72,10 @@ static void pt_gpio_free(struct gpio_chistatic int pt_gpio_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
drivers/gpio/gpio-amdpt.c static void pt_gpio_free(struct gpio_chi · line 81
Quoted 10 lines
drivers/gpio/gpio-amdpt.c +1
-3-struct acpi_device *acpi_dev; -acpi_handle handle =ACPI_HANDLE (dev);struct pt_gpio_chip *pt_gpio;int ret =0 ; -if (acpi_bus_get_device (handle, &acpi_dev)) { +if (!ACPI_COMPANION (dev)) {dev_err (dev,"PT GPIO device node not found\n" );return -ENODEV ; }
PATCH v2 1/7 gpio-amdpt: ACPI: Use the ACPI_COMPANION() macro directly
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify pt_gpio_probe() accordingly (no intentional functional impact).
---
v1 -> v2:
* Resend with a different From and S-o-b address and with ACK from Bart. No other changes.
--- drivers/gpio/gpio-amdpt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpio/gpio-amdpt.c +1 -3
@@ -72,12 +72,10 @@ static void pt_gpio_free(struct gpio_chistatic int pt_gpio_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct acpi_device *acpi_dev; -acpi_handle handle =ACPI_HANDLE (dev);struct pt_gpio_chip *pt_gpio;int ret =0 ; -if (acpi_bus_get_device (handle, &acpi_dev)) { +if (!ACPI_COMPANION (dev)) {dev_err (dev,"PT GPIO device node not found\n" );return -ENODEV ; }
PATCH 2/7 nouveau: ACPI: Use the ACPI_COMPANION() macro directly
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify nouveau_acpi_edid() accordingly (no intentional functional impact).
--- drivers/gpu/drm/nouveau/nouveau_acpi.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/nouveau_acpi.c +2 -7
@@ -364,7 +364,6 @@ void * nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { struct acpi_device *acpidev; -acpi_handle handle;int type, ret;void *edid;
@@ -377,12 +376,8 @@ nouveau_acpi_edid(struct drm_device *devreturn NULL ; } - handle =ACPI_HANDLE (dev->dev); -if (!handle) -return NULL ; - - ret =acpi_bus_get_device (handle, &acpidev); -if (ret) + acpidev =ACPI_COMPANION (dev->dev); +if (!acpidev)return NULL ; ret =acpi_video_get_edid (acpidev, type,-1 , &edid);
Re: [PATCH v1 2/7] nouveau: ACPI: Use the ACPI_COMPANION() macro directly
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
ACPI_HANDLE()macro is a wrapper arond theACPI_COMPANION()macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former toacpi_bus_get_device().
Quoted 4 lines
Modify
nouveau_acpi_edid()accordingly (no intentional functional impact).Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 34 lines
--- drivers/gpu/drm/nouveau/nouveau_acpi.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)Index:
linux-pm/drivers/gpu/drm/nouveau/nouveau_acpi.c
===================================================================drivers/gpu/drm/nouveau/nouveau_acpi.c +2
-7@@ -364,7 +364,6 @@ void * nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { struct acpi_device *acpidev; -acpi_handle handle;int type, ret;void *edid;@@ -377,12 +376,8 @@ nouveau_acpi_edid(struct drm_device *devreturn NULL ; } - handle =ACPI_HANDLE (dev->dev); -if (!handle) -return NULL ; - - ret =acpi_bus_get_device (handle, &acpidev); -if (ret) + acpidev =ACPI_COMPANION (dev->dev); +if (!acpidev)return NULL ; ret =acpi_video_get_edid (acpidev, type,-1 , &edid);
PATCH v2 2/7 nouveau: ACPI: Use the ACPI_COMPANION() macro directly
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify nouveau_acpi_edid() accordingly (no intentional functional impact).
---
v1 -> v2:
* Resend with a different From and S-o-b address and with R-by from Ben. No other changes.
--- drivers/gpu/drm/nouveau/nouveau_acpi.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/nouveau_acpi.c +2 -7
@@ -364,7 +364,6 @@ void * nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { struct acpi_device *acpidev; -acpi_handle handle;int type, ret;void *edid;
@@ -377,12 +376,8 @@ nouveau_acpi_edid(struct drm_device *devreturn NULL ; } - handle =ACPI_HANDLE (dev->dev); -if (!handle) -return NULL ; - - ret =acpi_bus_get_device (handle, &acpidev); -if (ret) + acpidev =ACPI_COMPANION (dev->dev); +if (!acpidev)return NULL ; ret =acpi_video_get_edid (acpidev, type,-1 , &edid);
PATCH 3/7 i2c: i2c-amd-mp2-plat: ACPI: Use ACPI_COMPANION() directly
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify i2c_amd_probe() accordingly (no intentional functional impact).
--- drivers/i2c/busses/i2c-amd-mp2-plat.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-amd-mp2-plat.c +2 -3
@@ -246,12 +246,11 @@ static int i2c_amd_probe(struct platform {int ret;struct amd_i2c_dev *i2c_dev; -acpi_handle handle =ACPI_HANDLE (&pdev->dev); -struct acpi_device *adev; +struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);struct amd_mp2_dev *mp2_dev;const char *uid; -if (acpi_bus_get_device (handle, &adev)) +if (!adev)return -ENODEV ;/* The ACPI namespace doesn't contain information about which MP2 PCI
Re: [PATCH v1 3/7] i2c: i2c-amd-mp2-plat: ACPI: Use ACPI_COMPANION() directly
Quoted 11 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
ACPI_HANDLE()macro is a wrapper arond theACPI_COMPANION()macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former toacpi_bus_get_device().Modify
i2c_amd_probe()accordingly (no intentional functional impact).Signed-off-by Rafael J. Wysocki <[email protected]>
Looks good to me.
Quoted 26 lines
--- drivers/i2c/busses/i2c-amd-mp2-plat.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)Index:
linux-pm/drivers/i2c/busses/i2c-amd-mp2-plat.c
===================================================================drivers/i2c/busses/i2c-amd-mp2-plat.c +2
-3@@ -246,12 +246,11 @@ static int i2c_amd_probe(struct platform {int ret;struct amd_i2c_dev *i2c_dev; -acpi_handle handle =ACPI_HANDLE (&pdev->dev); -struct acpi_device *adev; +struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);struct amd_mp2_dev *mp2_dev;const char *uid; -if (acpi_bus_get_device (handle, &adev)) +if (!adev)return -ENODEV ;/* The ACPI namespace doesn't contain information about which MP2 PCI
PATCH v2 3/7 i2c: i2c-amd-mp2-plat: ACPI: Use ACPI_COMPANION() directly
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify i2c_amd_probe() accordingly (no intentional functional impact).
---
v1 -> v2:
* Resend with a different From and S-o-b address and with maintainer ACK. No other changes.
--- drivers/i2c/busses/i2c-amd-mp2-plat.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-amd-mp2-plat.c +2 -3
@@ -246,12 +246,11 @@ static int i2c_amd_probe(struct platform {int ret;struct amd_i2c_dev *i2c_dev; -acpi_handle handle =ACPI_HANDLE (&pdev->dev); -struct acpi_device *adev; +struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);struct amd_mp2_dev *mp2_dev;const char *uid; -if (acpi_bus_get_device (handle, &adev)) +if (!adev)return -ENODEV ;/* The ACPI namespace doesn't contain information about which MP2 PCI
Wolfram Sang
AppliedRe: [PATCH v2 3/7] i2c: i2c-amd-mp2-plat: ACPI: Use ACPI_COMPANION() directly
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
ACPI_HANDLE()macro is a wrapper arond theACPI_COMPANION()macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former toacpi_bus_get_device().
Quoted 4 lines
Modify
i2c_amd_probe()accordingly (no intentional functional impact).Signed-off-by Rafael J. Wysocki <[email protected]>Acked-by Shyam Sundar S K <[email protected]>
Applied to for-next, thanks!
PATCH 4/7 surface: surface3-wmi: Use ACPI_COMPANION() directly
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify s3_wmi_check_platform_device() accordingly (no intentional functional impact).
--- drivers/platform/surface/surface3-wmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/platform/surface/surface3-wmi.c +4 -5
@@ -139,13 +139,12 @@ static acpi_status s3_wmi_attach_spi_devstatic int s3_wmi_check_platform_device (struct device *dev,void *data) { -struct acpi_device *adev, *ts_adev =NULL ; -acpi_handle handle; +struct acpi_device *adev =ACPI_COMPANION (dev); +struct acpi_device *ts_adev =NULL ;acpi_status status;/* ignore non ACPI devices */ - handle =ACPI_HANDLE (dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) +if (!adev)return 0 ;/* check for LID ACPI switch */
@@ -159,7 +158,7 @@ static int s3_wmi_check_platform_device( strlen(SPI_CTL_OBJ_NAME)))return 0 ; - status =acpi_walk_namespace (ACPI_TYPE_DEVICE , handle,1 , + status =acpi_walk_namespace (ACPI_TYPE_DEVICE , adev->handle,1 , s3_wmi_attach_spi_device,NULL , &ts_adev,NULL );if (ACPI_FAILURE (status))
Re: [PATCH v1 4/7] surface: surface3-wmi: Use ACPI_COMPANION() directly
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
ACPI_HANDLE()macro is a wrapper arond theACPI_COMPANION()macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former toacpi_bus_get_device().
Quoted 4 lines
Modify
s3_wmi_check_platform_device()accordingly (no intentional functional impact).Signed-off-by Rafael J. Wysocki <[email protected]>
Looks good to me.
Quoted 37 lines
--- drivers/platform/surface/surface3-wmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)Index:
linux-pm/drivers/platform/surface/surface3-wmi.c
===================================================================drivers/platform/surface/surface3-wmi.c +4
-5@@ -139,13 +139,12 @@ static acpi_status s3_wmi_attach_spi_devstatic int s3_wmi_check_platform_device (struct device *dev,void *data) { -struct acpi_device *adev, *ts_adev =NULL ; -acpi_handle handle; +struct acpi_device *adev =ACPI_COMPANION (dev); +struct acpi_device *ts_adev =NULL ;acpi_status status;/* ignore non ACPI devices */ - handle =ACPI_HANDLE (dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) +if (!adev)return 0 ;/* check for LID ACPI switch */ @@ -159,7 +158,7 @@ static int s3_wmi_check_platform_device( strlen(SPI_CTL_OBJ_NAME)))return 0 ; - status =acpi_walk_namespace (ACPI_TYPE_DEVICE , handle,1 , + status =acpi_walk_namespace (ACPI_TYPE_DEVICE , adev->handle,1 , s3_wmi_attach_spi_device,NULL , &ts_adev,NULL );if (ACPI_FAILURE (status))
PATCH v2 4/7 surface: surface3-wmi: Use ACPI_COMPANION() directly
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify s3_wmi_check_platform_device() accordingly (no intentional functional impact).
---
v1 -> v2:
* Resend with a different From and S-o-b address and with R-by from Maximilian. No other changes.
--- drivers/platform/surface/surface3-wmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/platform/surface/surface3-wmi.c +4 -5
@@ -139,13 +139,12 @@ static acpi_status s3_wmi_attach_spi_devstatic int s3_wmi_check_platform_device (struct device *dev,void *data) { -struct acpi_device *adev, *ts_adev =NULL ; -acpi_handle handle; +struct acpi_device *adev =ACPI_COMPANION (dev); +struct acpi_device *ts_adev =NULL ;acpi_status status;/* ignore non ACPI devices */ - handle =ACPI_HANDLE (dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) +if (!adev)return 0 ;/* check for LID ACPI switch */
@@ -159,7 +158,7 @@ static int s3_wmi_check_platform_device( strlen(SPI_CTL_OBJ_NAME)))return 0 ; - status =acpi_walk_namespace (ACPI_TYPE_DEVICE , handle,1 , + status =acpi_walk_namespace (ACPI_TYPE_DEVICE , adev->handle,1 , s3_wmi_attach_spi_device,NULL , &ts_adev,NULL );if (ACPI_FAILURE (status))
Re: [PATCH v2 4/7] surface: surface3-wmi: Use ACPI_COMPANION() directly
Hi,
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
ACPI_HANDLE()macro is a wrapper arond theACPI_COMPANION()macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former toacpi_bus_get_device().
Quoted 5 lines
Modify
s3_wmi_check_platform_device()accordingly (no intentional functional impact).Signed-off-by Rafael J. Wysocki <[email protected]>Reviewed-by Maximilian Luz <[email protected]>
Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans
Quoted 43 lines
---
v1 -> v2:
* Resend with a different From and S-o-b address and with R-by from Maximilian. No other changes.--- drivers/platform/surface/surface3-wmi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)Index:
linux-pm/drivers/platform/surface/surface3-wmi.c
===================================================================drivers/platform/surface/surface3-wmi.c +4
-5@@ -139,13 +139,12 @@ static acpi_status s3_wmi_attach_spi_devstatic int s3_wmi_check_platform_device (struct device *dev,void *data) { -struct acpi_device *adev, *ts_adev =NULL ; -acpi_handle handle; +struct acpi_device *adev =ACPI_COMPANION (dev); +struct acpi_device *ts_adev =NULL ;acpi_status status;/* ignore non ACPI devices */ - handle =ACPI_HANDLE (dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) +if (!adev)return 0 ;/* check for LID ACPI switch */ @@ -159,7 +158,7 @@ static int s3_wmi_check_platform_device( strlen(SPI_CTL_OBJ_NAME)))return 0 ; - status =acpi_walk_namespace (ACPI_TYPE_DEVICE , handle,1 , + status =acpi_walk_namespace (ACPI_TYPE_DEVICE , adev->handle,1 , s3_wmi_attach_spi_device,NULL , &ts_adev,NULL );if (ACPI_FAILURE (status))
PATCH 5/7 surface: surface3_power: Use ACPI_COMPANION() directly
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify mshw0011_notify() accordingly (no intentional functional impact).
--- drivers/platform/surface/surface3_power.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/platform/surface/surface3_power.c +4 -5
@@ -160,15 +160,14 @@ mshw0011_notify(struct mshw0011_data *cd {union acpi_object *obj;struct acpi_device *adev; -acpi_handle handle;unsigned int i; - handle =ACPI_HANDLE (&cdata->adp1->dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) + adev =ACPI_COMPANION (&cdata->adp1->dev); +if (!adev)return -ENODEV ; - obj =acpi_evaluate_dsm_typed (handle, &mshw0011_guid, arg1, arg2,NULL , -ACPI_TYPE_BUFFER ); + obj =acpi_evaluate_dsm_typed (adev->handle, &mshw0011_guid, arg1, arg2, +NULL ,ACPI_TYPE_BUFFER );if (!obj) {dev_err (&cdata->adp1->dev,"device _DSM execution failed\n" );return -ENODEV ;
Maximilian Luz
maintainerRe: [PATCH v1 5/7] surface: surface3_power: Use ACPI_COMPANION() directly
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
ACPI_HANDLE()macro is a wrapper arond theACPI_COMPANION()macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former toacpi_bus_get_device().
Quoted 4 lines
Modify
mshw0011_notify()accordingly (no intentional functional impact).Signed-off-by Rafael J. Wysocki <[email protected]>
Looks mostly good to me, small comment/question inline.
Quoted 10 lines
--- drivers/platform/surface/surface3_power.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)Index:
linux-pm/drivers/platform/surface/surface3_power.c
===================================================================drivers/platform/surface/surface3_power.c +0
-0@@ -160,15 +160,14 @@ mshw0011_notify(struct mshw0011_data *cd {
drivers/platform/surface/surface3_power.c mshw0011_notify(struct mshw0011_data *cd · line 167
Quoted 10 lines
drivers/platform/surface/surface3_power.c +2
-3union acpi_object *obj;struct acpi_device *adev; -acpi_handle handle;unsigned int i; - handle =ACPI_HANDLE (&cdata->adp1->dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) + adev =ACPI_COMPANION (&cdata->adp1->dev); +if (!adev)return -ENODEV ;
Do we need to get the ACPI device (adev) here? To me it looks like only its handle is actually used so why not keep ACPI_HANDLE() and remove the acpi_bus_get_device() call instead?
drivers/platform/surface/surface3_power.c mshw0011_notify(struct mshw0011_data *cd
Quoted 11 lines
drivers/platform/surface/surface3_power.c +2
-2- obj =acpi_evaluate_dsm_typed (handle, &mshw0011_guid, arg1, arg2,NULL , -ACPI_TYPE_BUFFER ); + obj =acpi_evaluate_dsm_typed (adev->handle, &mshw0011_guid, arg1, arg2, +NULL ,ACPI_TYPE_BUFFER );if (!obj) {dev_err (&cdata->adp1->dev,"device _DSM execution failed\n" );return -ENODEV ;
Regards,
Max
Rafael J. Wysocki
maintainerRe: [PATCH v1 5/7] surface: surface3_power: Use ACPI_COMPANION() directly
Quoted 32 lines · Maximilian Luz
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
ACPI_HANDLE()macro is a wrapper arond theACPI_COMPANION()macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former toacpi_bus_get_device().Quoted 4 lines
Modify
mshw0011_notify()accordingly (no intentional functional impact).Signed-off-by Rafael J. Wysocki <[email protected]>Looks mostly good to me, small comment/question inline.
Quoted 15 lines
--- drivers/platform/surface/surface3_power.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)Index:
linux-pm/drivers/platform/surface/surface3_power.c
===================================================================drivers/platform/surface/surface3_power.c +0
-1@@ -160,15 +160,14 @@ mshw0011_notify(struct mshw0011_data *cd {union acpi_object *obj;struct acpi_device *adev; -acpi_handle handle;unsigned int i;
Quoted 9 lines
drivers/platform/surface/surface3_power.c mshw0011_notify(struct mshw0011_data *cd · line 167
Quoted 5 lines
drivers/platform/surface/surface3_power.c +2
-2- handle =ACPI_HANDLE (&cdata->adp1->dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) + adev =ACPI_COMPANION (&cdata->adp1->dev); +if (!adev)return -ENODEV ;Do we need to get the ACPI device (adev) here? To me it looks like only its handle is actually used so why not keep
ACPI_HANDLE()and remove theacpi_bus_get_device()call instead?
It actually doesn't really matter, but you're right, acpi_bus_get_device() is simply redundant here, so ACPI_HANDLE() is sufficient.
I'll send a v2 of this one.
Quoted 14 lines
drivers/platform/surface/surface3_power.c mshw0011_notify(struct mshw0011_data *cd
Quoted 11 lines
drivers/platform/surface/surface3_power.c +2
-2- obj =acpi_evaluate_dsm_typed (handle, &mshw0011_guid, arg1, arg2,NULL , -ACPI_TYPE_BUFFER ); + obj =acpi_evaluate_dsm_typed (adev->handle, &mshw0011_guid, arg1, arg2, +NULL ,ACPI_TYPE_BUFFER );if (!obj) {dev_err (&cdata->adp1->dev,"device _DSM execution failed\n" );return -ENODEV ;Regards,
Max
PATCH v2 5/7 surface: surface3_power: Drop redundant acpi_bus_get_device() call
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
If the ACPI companion of a given device is not present, the result of the ACPI_HANDLE() evaluation for it will be NULL, so calling acpi_bus_get_device() on ACPI_HANDLE() result in order to validate it is redundant.
Drop the redundant acpi_bus_get_device() call from mshw0011_notify() along with a local variable related to it.
No intentional functional impact.
---
v1 -> v2:
* Instead of switching over to using ACPI_COMPANION(), just drop the redundant acpi_bus_get_device() call from mshw0011_notify() and update the subject and changelog accordingly.
--- drivers/platform/surface/surface3_power.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/platform/surface/surface3_power.c +1 -2
@@ -159,12 +159,11 @@ mshw0011_notify(struct mshw0011_data *cd unsigned int *ret_value) {union acpi_object *obj; -struct acpi_device *adev;acpi_handle handle;unsigned int i; handle =ACPI_HANDLE (&cdata->adp1->dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) +if (!handle)return -ENODEV ; obj = acpi_evaluate_dsm_typed(handle, &mshw0011_guid, arg1, arg2, NULL,
Re: [PATCH v2 5/7] surface: surface3_power: Drop redundant acpi_bus_get_device() call
Quoted 12 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If the ACPI companion of a given device is not present, the result of the
ACPI_HANDLE()evaluation for it will be NULL, so callingacpi_bus_get_device()onACPI_HANDLE()result in order to validate it is redundant.Drop the redundant
acpi_bus_get_device()call frommshw0011_notify()along with a local variable related to it.No intentional functional impact.
Quoted 8 lines
Signed-off-by Rafael J. Wysocki <[email protected]>---
v1 -> v2:
* Instead of switching over to usingACPI_COMPANION(), just drop the redundantacpi_bus_get_device()call frommshw0011_notify()and update the subject and changelog accordingly.
Thanks, looks good to me!
Quoted 25 lines
--- drivers/platform/surface/surface3_power.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Index:
linux-pm/drivers/platform/surface/surface3_power.c
===================================================================drivers/platform/surface/surface3_power.c +1
-2@@ -159,12 +159,11 @@ mshw0011_notify(struct mshw0011_data *cd unsigned int *ret_value) {union acpi_object *obj; -struct acpi_device *adev;acpi_handle handle;unsigned int i; handle =ACPI_HANDLE (&cdata->adp1->dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) +if (!handle)return -ENODEV ; obj = acpi_evaluate_dsm_typed(handle, &mshw0011_guid, arg1, arg2, NULL,
PATCH v3 5/7 surface: surface3_power: Drop redundant acpi_bus_get_device() call
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
If the ACPI companion of a given device is not present, the result of the ACPI_HANDLE() evaluation for it will be NULL, so calling acpi_bus_get_device() on ACPI_HANDLE() result in order to validate it is redundant.
Drop the redundant acpi_bus_get_device() call from mshw0011_notify() along with a local variable related to it.
No intentional functional impact.
---
v2 -> v3:
* Resend with a different From and S-o-b address and with R-by from Maximilian. No other changes.
--- drivers/platform/surface/surface3_power.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/platform/surface/surface3_power.c +1 -2
@@ -159,12 +159,11 @@ mshw0011_notify(struct mshw0011_data *cd unsigned int *ret_value) {union acpi_object *obj; -struct acpi_device *adev;acpi_handle handle;unsigned int i; handle =ACPI_HANDLE (&cdata->adp1->dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) +if (!handle)return -ENODEV ; obj = acpi_evaluate_dsm_typed(handle, &mshw0011_guid, arg1, arg2, NULL,
Re: [PATCH v3 5/7] surface: surface3_power: Drop redundant acpi_bus_get_device() call
Hi,
Quoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If the ACPI companion of a given device is not present, the result of the
ACPI_HANDLE()evaluation for it will be NULL, so callingacpi_bus_get_device()onACPI_HANDLE()result in order to validate it is redundant.
Quoted 7 lines
Drop the redundant
acpi_bus_get_device()call frommshw0011_notify()along with a local variable related to it.No intentional functional impact.
Signed-off-by Rafael J. Wysocki <[email protected]>Reviewed-by Maximilian Luz <[email protected]>
Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans
Quoted 31 lines
---
v2 -> v3:
* Resend with a different From and S-o-b address and with R-by from Maximilian. No other changes.--- drivers/platform/surface/surface3_power.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Index:
linux-pm/drivers/platform/surface/surface3_power.c
===================================================================drivers/platform/surface/surface3_power.c +1
-2@@ -159,12 +159,11 @@ mshw0011_notify(struct mshw0011_data *cd unsigned int *ret_value) {union acpi_object *obj; -struct acpi_device *adev;acpi_handle handle;unsigned int i; handle =ACPI_HANDLE (&cdata->adp1->dev); -if (!handle ||acpi_bus_get_device (handle, &adev)) +if (!handle)return -ENODEV ; obj = acpi_evaluate_dsm_typed(handle, &mshw0011_guid, arg1, arg2, NULL,
PATCH 6/7 platform: x86: ideapad-laptop: Use ACPI_COMPANION() directly
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify ideapad_acpi_add() accordingly (no intentional functional impact).
--- drivers/platform/x86/ideapad-laptop.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/platform/x86/ideapad-laptop.c +2 -6
@@ -1534,17 +1534,13 @@ static void ideapad_check_features(strucstatic int ideapad_acpi_add (struct platform_device *pdev) { +struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);struct ideapad_private *priv; -struct acpi_device *adev;acpi_status status;unsigned long cfg;int err, i; - err =acpi_bus_get_device (ACPI_HANDLE (&pdev->dev), &adev); -if (err) -return -ENODEV ; - -if (eval_int (adev->handle,"_CFG" , &cfg)) +if (!adev ||eval_int (adev->handle,"_CFG" , &cfg))return -ENODEV ; priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );
PATCH v2 6/7 platform: x86: ideapad-laptop: Use ACPI_COMPANION() directly
From: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify ideapad_acpi_add() accordingly (no intentional functional impact).
---
v1 -> v2:
* Resend with a different From and S-o-b address. No other changes.
--- drivers/platform/x86/ideapad-laptop.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/platform/x86/ideapad-laptop.c +2 -6
@@ -1534,17 +1534,13 @@ static void ideapad_check_features(strucstatic int ideapad_acpi_add (struct platform_device *pdev) { +struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);struct ideapad_private *priv; -struct acpi_device *adev;acpi_status status;unsigned long cfg;int err, i; - err =acpi_bus_get_device (ACPI_HANDLE (&pdev->dev), &adev); -if (err) -return -ENODEV ; - -if (eval_int (adev->handle,"_CFG" , &cfg)) +if (!adev ||eval_int (adev->handle,"_CFG" , &cfg))return -ENODEV ; priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );
Re: [PATCH v2 6/7] platform: x86: ideapad-laptop: Use ACPI_COMPANION() directly
Hi,
Quoted 8 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
ACPI_HANDLE()macro is a wrapper arond theACPI_COMPANION()macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former toacpi_bus_get_device().
Quoted 4 lines
Modify
ideapad_acpi_add()accordingly (no intentional functional impact).Signed-off-by Rafael J. Wysocki <[email protected]>
Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans
Quoted 36 lines
---
v1 -> v2:
* Resend with a different From and S-o-b address. No other changes.--- drivers/platform/x86/ideapad-laptop.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)Index:
linux-pm/drivers/platform/x86/ideapad-laptop.c
===================================================================drivers/platform/x86/ideapad-laptop.c +2
-6@@ -1534,17 +1534,13 @@ static void ideapad_check_features(strucstatic int ideapad_acpi_add (struct platform_device *pdev) { +struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);struct ideapad_private *priv; -struct acpi_device *adev;acpi_status status;unsigned long cfg;int err, i; - err =acpi_bus_get_device (ACPI_HANDLE (&pdev->dev), &adev); -if (err) -return -ENODEV ; - -if (eval_int (adev->handle,"_CFG" , &cfg)) +if (!adev ||eval_int (adev->handle,"_CFG" , &cfg))return -ENODEV ; priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL );
PATCH 7/7 perf: qcom_l2_pmu: ACPI: Use ACPI_COMPANION() directly
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify l2_cache_pmu_probe_cluster() accordingly (no intentional functional impact).
While at it, rename the ACPI device pointer to adev for more clarity.
--- drivers/perf/qcom_l2_pmu.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/perf/qcom_l2_pmu.c +2 -5
@@ -840,17 +840,14 @@ static int l2_cache_pmu_probe_cluster(st {struct platform_device *pdev =to_platform_device (dev->parent);struct platform_device *sdev =to_platform_device (dev); +struct acpi_device *adev =ACPI_COMPANION (dev);struct l2cache_pmu *l2cache_pmu = data;struct cluster_pmu *cluster; -struct acpi_device *device;unsigned long fw_cluster_id;int err;int irq; -if (acpi_bus_get_device (ACPI_HANDLE (dev), &device)) -return -ENODEV ; - -if (kstrtoul (device->pnp.unique_id,10 , &fw_cluster_id) <0 ) { +if (!adev ||kstrtoul (adev->pnp.unique_id,10 , &fw_cluster_id) <0 ) {dev_err (&pdev->dev,"unable to read ACPI uid\n" );return -ENODEV ; }
PATCH v2 7/7 perf: qcom_l2_pmu: ACPI: Use ACPI_COMPANION() directly
From: Rafael J. Wysocki <[email protected]>
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device().
Modify l2_cache_pmu_probe_cluster() accordingly (no intentional functional impact).
While at it, rename the ACPI device pointer to adev for more clarity.
---
v1 -> v2:
* Resend with a different From and S-o-b address. No other changes.
--- drivers/perf/qcom_l2_pmu.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/perf/qcom_l2_pmu.c +2 -5
@@ -840,17 +840,14 @@ static int l2_cache_pmu_probe_cluster(st {struct platform_device *pdev =to_platform_device (dev->parent);struct platform_device *sdev =to_platform_device (dev); +struct acpi_device *adev =ACPI_COMPANION (dev);struct l2cache_pmu *l2cache_pmu = data;struct cluster_pmu *cluster; -struct acpi_device *device;unsigned long fw_cluster_id;int err;int irq; -if (acpi_bus_get_device (ACPI_HANDLE (dev), &device)) -return -ENODEV ; - -if (kstrtoul (device->pnp.unique_id,10 , &fw_cluster_id) <0 ) { +if (!adev ||kstrtoul (adev->pnp.unique_id,10 , &fw_cluster_id) <0 ) {dev_err (&pdev->dev,"unable to read ACPI uid\n" );return -ENODEV ; }
Rafael J. Wysocki
maintainerRe: [PATCH v2 7/7] perf: qcom_l2_pmu: ACPI: Use ACPI_COMPANION() directly
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
The
ACPI_HANDLE()macro is a wrapper arond theACPI_COMPANION()macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former toacpi_bus_get_device().
Quoted 7 lines
Modify
l2_cache_pmu_probe_cluster()accordingly (no intentional functional impact).While at it, rename the ACPI device pointer to adev for more clarity.
Signed-off-by Rafael J. Wysocki <[email protected]>
If nobody nas any concerns regarding this patch, I will queue it up for 5.16 in the ACPI tree, because it is requisite for further changes.
Thanks!
Quoted 36 lines
---
v1 -> v2:
* Resend with a different From and S-o-b address. No other changes.--- drivers/perf/qcom_l2_pmu.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)Index:
linux-pm/drivers/perf/qcom_l2_pmu.c
===================================================================drivers/perf/qcom_l2_pmu.c +2
-5@@ -840,17 +840,14 @@ static int l2_cache_pmu_probe_cluster(st {struct platform_device *pdev =to_platform_device (dev->parent);struct platform_device *sdev =to_platform_device (dev); +struct acpi_device *adev =ACPI_COMPANION (dev);struct l2cache_pmu *l2cache_pmu = data;struct cluster_pmu *cluster; -struct acpi_device *device;unsigned long fw_cluster_id;int err;int irq; -if (acpi_bus_get_device (ACPI_HANDLE (dev), &device)) -return -ENODEV ; - -if (kstrtoul (device->pnp.unique_id,10 , &fw_cluster_id) <0 ) { +if (!adev ||kstrtoul (adev->pnp.unique_id,10 , &fw_cluster_id) <0 ) {dev_err (&pdev->dev,"unable to read ACPI uid\n" );return -ENODEV ; }