Re: [PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()

2015-03-17 Thread Linus Walleij
On Tue, Mar 10, 2015 at 11:08 PM, Rafael J. Wysocki  wrote:

> From: Rafael J. Wysocki 
>
> 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.
>
> Signed-off-by: Rafael J. Wysocki 

Patch applied with review and ACK tags.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()

2015-03-17 Thread Linus Walleij
On Tue, Mar 10, 2015 at 11:08 PM, Rafael J. Wysocki r...@rjwysocki.net wrote:

 From: Rafael J. Wysocki rafael.j.wyso...@intel.com

 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.

 Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com

Patch applied with review and ACK tags.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()

2015-03-11 Thread Mika Westerberg
On Tue, Mar 10, 2015 at 11:08:57PM +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki 
> 
> 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.
> 
> Signed-off-by: Rafael J. Wysocki 

Acked-by: Mika Westerberg 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()

2015-03-11 Thread Mika Westerberg
On Tue, Mar 10, 2015 at 11:08:57PM +0100, Rafael J. Wysocki wrote:
 From: Rafael J. Wysocki rafael.j.wyso...@intel.com
 
 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.
 
 Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com

Acked-by: Mika Westerberg mika.westerb...@linux.intel.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()

2015-03-10 Thread Hanjun Guo
On 2015/3/11 6:08, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki 
>
> 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.
>
> Signed-off-by: Rafael J. Wysocki 

Quite straight forward to me, for both two patches,

Reviewed-by: Hanjun Guo 

Thanks
Hanjun

> ---
>  drivers/gpio/gpiolib.c |   16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> Index: linux-pm/drivers/gpio/gpiolib.c
> ===
> --- linux-pm.orig/drivers/gpio/gpiolib.c
> +++ linux-pm/drivers/gpio/gpiolib.c
> @@ -1865,13 +1865,15 @@ struct gpio_desc *__must_check __gpiod_g
>  
>   dev_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, );
> - } 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, );
> + 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, );
> + } else if (ACPI_COMPANION(dev)) {
> + dev_dbg(dev, "using ACPI for GPIO lookup\n");
> + desc = acpi_find_gpio(dev, con_id, idx, );
> + }
>   }
>  
>   /*
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> .
>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()

2015-03-10 Thread Rafael J. Wysocki
From: Rafael J. Wysocki 

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.

Signed-off-by: Rafael J. Wysocki 
---
 drivers/gpio/gpiolib.c |   16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

Index: linux-pm/drivers/gpio/gpiolib.c
===
--- linux-pm.orig/drivers/gpio/gpiolib.c
+++ linux-pm/drivers/gpio/gpiolib.c
@@ -1865,13 +1865,15 @@ struct gpio_desc *__must_check __gpiod_g
 
dev_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, );
-   } 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, );
+   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, );
+   } else if (ACPI_COMPANION(dev)) {
+   dev_dbg(dev, "using ACPI for GPIO lookup\n");
+   desc = acpi_find_gpio(dev, con_id, idx, );
+   }
}
 
/*

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()

2015-03-10 Thread Hanjun Guo
On 2015/3/11 6:08, Rafael J. Wysocki wrote:
 From: Rafael J. Wysocki rafael.j.wyso...@intel.com

 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.

 Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com

Quite straight forward to me, for both two patches,

Reviewed-by: Hanjun Guo hanjun@linaro.org

Thanks
Hanjun

 ---
  drivers/gpio/gpiolib.c |   16 +---
  1 file changed, 9 insertions(+), 7 deletions(-)

 Index: linux-pm/drivers/gpio/gpiolib.c
 ===
 --- linux-pm.orig/drivers/gpio/gpiolib.c
 +++ linux-pm/drivers/gpio/gpiolib.c
 @@ -1865,13 +1865,15 @@ struct gpio_desc *__must_check __gpiod_g
  
   dev_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 majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

 .



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] gpio / ACPI: Avoid unnecessary checks in __gpiod_get_index()

2015-03-10 Thread Rafael J. Wysocki
From: Rafael J. Wysocki rafael.j.wyso...@intel.com

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.

Signed-off-by: Rafael J. Wysocki rafael.j.wyso...@intel.com
---
 drivers/gpio/gpiolib.c |   16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

Index: linux-pm/drivers/gpio/gpiolib.c
===
--- linux-pm.orig/drivers/gpio/gpiolib.c
+++ linux-pm/drivers/gpio/gpiolib.c
@@ -1865,13 +1865,15 @@ struct gpio_desc *__must_check __gpiod_g
 
dev_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-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/