All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] gpio: mb86s7x: Use devm_clk_get_optional() to get the input clock
@ 2020-05-12 18:26 Andy Shevchenko
  2020-05-12 18:26 ` [PATCH v1 2/2] gpio: mb86s7x: Remove superfluous test for ACPI companion Andy Shevchenko
  2020-05-18  7:15 ` [PATCH v1 1/2] gpio: mb86s7x: Use devm_clk_get_optional() to get the input clock Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2020-05-12 18:26 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio; +Cc: Andy Shevchenko

Simplify the code which fetches the input clock by using
devm_clk_get_optional(). If no input clock is present
devm_clk_get_optional() will return NULL instead of an error
which matches the behavior of the old code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-mb86s7x.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-mb86s7x.c b/drivers/gpio/gpio-mb86s7x.c
index 501e89548f533b..3be2e56f7c4321 100644
--- a/drivers/gpio/gpio-mb86s7x.c
+++ b/drivers/gpio/gpio-mb86s7x.c
@@ -168,15 +168,13 @@ static int mb86s70_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(gchip->base))
 		return PTR_ERR(gchip->base);
 
-	if (!has_acpi_companion(&pdev->dev)) {
-		gchip->clk = devm_clk_get(&pdev->dev, NULL);
-		if (IS_ERR(gchip->clk))
-			return PTR_ERR(gchip->clk);
-
-		ret = clk_prepare_enable(gchip->clk);
-		if (ret)
-			return ret;
-	}
+	gchip->clk = devm_clk_get_optional(&pdev->dev, NULL);
+	if (IS_ERR(gchip->clk))
+		return PTR_ERR(gchip->clk);
+
+	ret = clk_prepare_enable(gchip->clk);
+	if (ret)
+		return ret;
 
 	spin_lock_init(&gchip->lock);
 
-- 
2.26.2


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

* [PATCH v1 2/2] gpio: mb86s7x: Remove superfluous test for ACPI companion
  2020-05-12 18:26 [PATCH v1 1/2] gpio: mb86s7x: Use devm_clk_get_optional() to get the input clock Andy Shevchenko
@ 2020-05-12 18:26 ` Andy Shevchenko
  2020-05-18  7:16   ` Linus Walleij
  2020-05-18  7:15 ` [PATCH v1 1/2] gpio: mb86s7x: Use devm_clk_get_optional() to get the input clock Linus Walleij
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2020-05-12 18:26 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio; +Cc: Andy Shevchenko

acpi_gpiochip_request_interrupts() will check for ACPI handle of
the GPIO chip parent device and bail out if there is none defined.
Thus, has_acpi_companion() is effectively repeating above and
is not needed in the individual driver.

Assigning ->to_irq() unconditionally doesn't change anything, except
an error code, but this we fix as well by propagating it from
platform_get_irq().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-mb86s7x.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-mb86s7x.c b/drivers/gpio/gpio-mb86s7x.c
index 3be2e56f7c4321..37c5363e391ef1 100644
--- a/drivers/gpio/gpio-mb86s7x.c
+++ b/drivers/gpio/gpio-mb86s7x.c
@@ -145,7 +145,9 @@ static int mb86s70_gpio_to_irq(struct gpio_chip *gc, unsigned int offset)
 
 	for (index = 0;; index++) {
 		irq = platform_get_irq(to_platform_device(gc->parent), index);
-		if (irq <= 0)
+		if (irq < 0)
+			return irq;
+		if (irq == 0)
 			break;
 		if (irq_get_irq_data(irq)->hwirq == offset)
 			return irq;
@@ -184,15 +186,13 @@ static int mb86s70_gpio_probe(struct platform_device *pdev)
 	gchip->gc.free = mb86s70_gpio_free;
 	gchip->gc.get = mb86s70_gpio_get;
 	gchip->gc.set = mb86s70_gpio_set;
+	gchip->gc.to_irq = mb86s70_gpio_to_irq;
 	gchip->gc.label = dev_name(&pdev->dev);
 	gchip->gc.ngpio = 32;
 	gchip->gc.owner = THIS_MODULE;
 	gchip->gc.parent = &pdev->dev;
 	gchip->gc.base = -1;
 
-	if (has_acpi_companion(&pdev->dev))
-		gchip->gc.to_irq = mb86s70_gpio_to_irq;
-
 	ret = gpiochip_add_data(&gchip->gc, gchip);
 	if (ret) {
 		dev_err(&pdev->dev, "couldn't register gpio driver\n");
@@ -200,8 +200,7 @@ static int mb86s70_gpio_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	if (has_acpi_companion(&pdev->dev))
-		acpi_gpiochip_request_interrupts(&gchip->gc);
+	acpi_gpiochip_request_interrupts(&gchip->gc);
 
 	return 0;
 }
@@ -210,8 +209,7 @@ static int mb86s70_gpio_remove(struct platform_device *pdev)
 {
 	struct mb86s70_gpio_chip *gchip = platform_get_drvdata(pdev);
 
-	if (has_acpi_companion(&pdev->dev))
-		acpi_gpiochip_free_interrupts(&gchip->gc);
+	acpi_gpiochip_free_interrupts(&gchip->gc);
 	gpiochip_remove(&gchip->gc);
 	clk_disable_unprepare(gchip->clk);
 
-- 
2.26.2


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

* Re: [PATCH v1 1/2] gpio: mb86s7x: Use devm_clk_get_optional() to get the input clock
  2020-05-12 18:26 [PATCH v1 1/2] gpio: mb86s7x: Use devm_clk_get_optional() to get the input clock Andy Shevchenko
  2020-05-12 18:26 ` [PATCH v1 2/2] gpio: mb86s7x: Remove superfluous test for ACPI companion Andy Shevchenko
@ 2020-05-18  7:15 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2020-05-18  7:15 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM

On Tue, May 12, 2020 at 8:26 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Simplify the code which fetches the input clock by using
> devm_clk_get_optional(). If no input clock is present
> devm_clk_get_optional() will return NULL instead of an error
> which matches the behavior of the old code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH v1 2/2] gpio: mb86s7x: Remove superfluous test for ACPI companion
  2020-05-12 18:26 ` [PATCH v1 2/2] gpio: mb86s7x: Remove superfluous test for ACPI companion Andy Shevchenko
@ 2020-05-18  7:16   ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2020-05-18  7:16 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Bartosz Golaszewski, open list:GPIO SUBSYSTEM

On Tue, May 12, 2020 at 8:26 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> acpi_gpiochip_request_interrupts() will check for ACPI handle of
> the GPIO chip parent device and bail out if there is none defined.
> Thus, has_acpi_companion() is effectively repeating above and
> is not needed in the individual driver.
>
> Assigning ->to_irq() unconditionally doesn't change anything, except
> an error code, but this we fix as well by propagating it from
> platform_get_irq().
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Patch applied.

Yours,
Linus Walleij

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

end of thread, other threads:[~2020-05-18  7:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 18:26 [PATCH v1 1/2] gpio: mb86s7x: Use devm_clk_get_optional() to get the input clock Andy Shevchenko
2020-05-12 18:26 ` [PATCH v1 2/2] gpio: mb86s7x: Remove superfluous test for ACPI companion Andy Shevchenko
2020-05-18  7:16   ` Linus Walleij
2020-05-18  7:15 ` [PATCH v1 1/2] gpio: mb86s7x: Use devm_clk_get_optional() to get the input clock Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.