gpio / ACPI: Two minor cleanups related to ACPI_HANDLE()
PATCH 1/2 gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
If dev is NULL in __gpiod_get_index() and both ACPI and OF are enabled, it will be checked twice before the code decides to give up with DT/ACPI lookup, so avoid that.
Also use the observation that ACPI_COMPANION() is much more efficient than ACPI_HANDLE(), because the latter uses the former and carries out a check and a pointer dereference on top of it, so replace the ACPI_HANDLE() check with an ACPI_COMPANION() one which does not require the additional IS_ENABLED(CONFIG_ACPI) check too.
--- drivers/gpio/gpiolib.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpio/gpiolib.c +9 -7
@@ -1865,13 +1865,15 @@ struct gpio_desc *__must_check __gpiod_gdev_dbg (dev,"GPIO lookup for consumer %s\n" , con_id); -/* Using device tree? */ -if (IS_ENABLED (CONFIG_OF ) && dev && dev->of_node) { -dev_dbg (dev,"using device tree for GPIO lookup\n" ); - desc =of_find_gpio (dev, con_id, idx, &lookupflags); - }else if (IS_ENABLED (CONFIG_ACPI ) && dev &&ACPI_HANDLE (dev)) { -dev_dbg (dev,"using ACPI for GPIO lookup\n" ); - desc =acpi_find_gpio (dev, con_id, idx, &lookupflags); +if (dev) { +/* Using device tree? */ +if (IS_ENABLED (CONFIG_OF ) && dev->of_node) { +dev_dbg (dev,"using device tree for GPIO lookup\n" ); + desc =of_find_gpio (dev, con_id, idx, &lookupflags); + }else if (ACPI_COMPANION (dev)) { +dev_dbg (dev,"using ACPI for GPIO lookup\n" ); + desc =acpi_find_gpio (dev, con_id, idx, &lookupflags); + } }/*
PATCH 2/2 gpio / ACPI: Use local variable instead of ACPI_HANDLE()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
In acpi_gpiochip_request_interrupts() the handle local variable already contains the value that we want to pass to acpi_walk_resources(), so it is better to use that variable instead of evaluating ACPI_HANDLE() once more for the same device.
--- drivers/gpio/gpiolib-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib-acpi.c +1 -1
@@ -300,7 +300,7 @@ void acpi_gpiochip_request_interrupts(streturn ;INIT_LIST_HEAD (&acpi_gpio->events); -acpi_walk_resources (ACPI_HANDLE (chip->dev),"_AEI" , +acpi_walk_resources (handle,"_AEI" , acpi_gpiochip_request_interrupt, acpi_gpio); }
cover gpio / ACPI: Two minor cleanups related to ACPI_HANDLE()
Hi,
As per the subject, avoid evaluating ACPI_HANDLE() if we can as that one is rather costly.
Kind regards,
Rafael
Re: [PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()
In reply to Rafael J. WysockiQuoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If dev is NULL in
__gpiod_get_index()and both ACPI and OF are enabled, it will be checked twice before the code decides to give up with DT/ACPI lookup, so avoid that.
Quoted 7 lines
Also use the observation that
ACPI_COMPANION()is much more efficient thanACPI_HANDLE(), because the latter uses the former and carries out a check and a pointer dereference on top of it, so replace theACPI_HANDLE()check with anACPI_COMPANION()one which does not require the additionalIS_ENABLED(CONFIG_ACPI)check too.Signed-off-by Rafael J. Wysocki <[email protected]>
Quite straight forward to me, for both two patches,
Thanks
Hanjun
Quoted 39 lines
--- drivers/gpio/gpiolib.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)Index:
linux-pm/drivers/gpio/gpiolib.c
===================================================================drivers/gpio/gpiolib.c +9
-8@@ -1865,13 +1865,15 @@ struct gpio_desc *__must_check __gpiod_gdev_dbg (dev,"GPIO lookup for consumer %s\n" , con_id); -/* Using device tree? */ -if (IS_ENABLED (CONFIG_OF ) && dev && dev->of_node) { -dev_dbg (dev,"using device tree for GPIO lookup\n" ); - desc =of_find_gpio (dev, con_id, idx, &lookupflags); - }else if (IS_ENABLED (CONFIG_ACPI ) && dev &&ACPI_HANDLE (dev)) { -dev_dbg (dev,"using ACPI for GPIO lookup\n" ); - desc =acpi_find_gpio (dev, con_id, idx, &lookupflags); +if (dev) { +/* Using device tree? */ +if (IS_ENABLED (CONFIG_OF ) && dev->of_node) { +dev_dbg (dev,"using device tree for GPIO lookup\n" ); + desc =of_find_gpio (dev, con_id, idx, &lookupflags); + }else if (ACPI_COMPANION (dev)) { +dev_dbg (dev,"using ACPI for GPIO lookup\n" ); + desc =acpi_find_gpio (dev, con_id, idx, &lookupflags); + } }/* -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html.
Re: [PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()
In reply to Rafael J. WysockiQuoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If dev is NULL in
__gpiod_get_index()and both ACPI and OF are enabled, it will be checked twice before the code decides to give up with DT/ACPI lookup, so avoid that.
Quoted 7 lines
Also use the observation that
ACPI_COMPANION()is much more efficient thanACPI_HANDLE(), because the latter uses the former and carries out a check and a pointer dereference on top of it, so replace theACPI_HANDLE()check with anACPI_COMPANION()one which does not require the additionalIS_ENABLED(CONFIG_ACPI)check too.Signed-off-by Rafael J. Wysocki <[email protected]>
Re: [PATCH 2/2] gpio / ACPI: Use local variable instead of ACPI_HANDLE()
In reply to Rafael J. WysockiQuoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
In
acpi_gpiochip_request_interrupts()the handle local variable already contains the value that we want to pass toacpi_walk_resources(), so it is better to use that variable instead of evaluatingACPI_HANDLE()once more for the same device.Signed-off-by Rafael J. Wysocki <[email protected]>
Quoted 4 lines · Rafael J. Wysocki
Hi,
As per the subject, avoid evaluating
ACPI_HANDLE()if we can as that one is rather costly.
Linus, Alexandre, any objections to this series?
If not, would there be any problem if I took these to my tree? I'll probably have material on top of them.
Rafael
Re: [PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()
In reply to Rafael J. WysockiQuoted 6 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If dev is NULL in
__gpiod_get_index()and both ACPI and OF are enabled, it will be checked twice before the code decides to give up with DT/ACPI lookup, so avoid that.
Quoted 7 lines
Also use the observation that
ACPI_COMPANION()is much more efficient thanACPI_HANDLE(), because the latter uses the former and carries out a check and a pointer dereference on top of it, so replace theACPI_HANDLE()check with anACPI_COMPANION()one which does not require the additionalIS_ENABLED(CONFIG_ACPI)check too.Signed-off-by Rafael J. Wysocki <[email protected]>
Patch applied with review and ACK tags.
Yours,
Linus Walleij
Re: [PATCH 2/2] gpio / ACPI: Use local variable instead of ACPI_HANDLE()
In reply to Rafael J. WysockiQuoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
In
acpi_gpiochip_request_interrupts()the handle local variable already contains the value that we want to pass toacpi_walk_resources(), so it is better to use that variable instead of evaluatingACPI_HANDLE()once more for the same device.Signed-off-by Rafael J. Wysocki <[email protected]>
Patch applied with Mika's ACK.
Yours,
Linus Walleij
Quoted 10 lines · Rafael J. Wysocki
Quoted 4 lines · Rafael J. Wysocki
Hi,
As per the subject, avoid evaluating
ACPI_HANDLE()if we can as that one is rather costly.Linus, Alexandre, any objections to this series?
If not, would there be any problem if I took these to my tree? I'll probably have material on top of them.
Sorry for the delay. Looks like Linus just took the patches in his tree, I hope that's ok?
Quoted 7 lines · Alexandre Courbot
Quoted 6 lines · Rafael J. Wysocki
Quoted 4 lines · Rafael J. Wysocki
Hi,
As per the subject, avoid evaluating
ACPI_HANDLE()if we can as that one is rather costly.
Quoted 7 lines
Quoted 4 lines
Linus, Alexandre, any objections to this series?
If not, would there be any problem if I took these to my tree? I'll probably have material on top of them.
Sorry for the delay. Looks like Linus just took the patches in his tree, I hope that's ok?
Yes, that's fine, thanks!
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.