[PATCH v2] gpio/omap: add *remove* callback in platform_driver

Subsystems: gpio subsystem, omap gpio driver, the rest

STALE5145d REVIEWED: 1 (0M)

1 review trailer.

3 messages, 2 authors, 2012-08-08 · open the first message on its own page

[PATCH v2] gpio/omap: add *remove* callback in platform_driver

From: Tarun Kanti DebBarma <hidden>
Date: 2012-08-08 13:58:51

Add *remove* callback so that necessary cleanup operations are
performed when device is unregistered. The device is deleted
from the list and associated clock handle is released by
calling clk_put() and irq descriptor is released using the
irq_free_desc() api.

Signed-off-by: Tarun Kanti DebBarma <redacted>
Reported-by: Paul Walmsley <paul@pwsan.com>
Reviewed-by: Jon Hunter <redacted>
Cc: Kevin Hilman <redacted>
Cc: Rajendra Nayak <redacted>
Cc: Santosh Shilimkar <redacted>
Cc: Cousson, Benoit <redacted>
Cc: Paul Walmsley <paul@pwsan.com>
---
v2:
Baseline: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

(1) Use irq_free_descs() instead of irq_free_desc().
    Besides, irq_free_desc() was using wrong parameter,
    irq_base, instead of bank->irq.
(2) irq_free_descs() moved outside spin_lock/unlock_*()
    in order to avoid exception warnings.

(3) pm_runtime_disable() added so that bind can happen successfully

Test Detail:
Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
#echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind

Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
#echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind

Step 3: Execute read/write GPIO test case.

 drivers/gpio/gpio-omap.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index e6efd77..50de875 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1152,6 +1152,40 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
 	return ret;
 }
 
+/**
+ * omap_gpio_remove - cleanup a registered gpio device
+ * @pdev:       pointer to current gpio platform device
+ *
+ * Called by driver framework whenever a gpio device is unregistered.
+ * GPIO is deleted from the list and associated clock handle freed.
+ */
+static int __devexit omap_gpio_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct gpio_bank *bank;
+	unsigned long flags;
+	int ret = -EINVAL;
+
+	list_for_each_entry(bank, &omap_gpio_list, node) {
+		spin_lock_irqsave(&bank->lock, flags);
+		if (bank->dev == dev) {
+			clk_put(bank->dbck);
+			list_del(&bank->node);
+			ret = 0;
+			spin_unlock_irqrestore(&bank->lock, flags);
+			break;
+		}
+		spin_unlock_irqrestore(&bank->lock, flags);
+	}
+
+	if (!ret) {
+		pm_runtime_disable(bank->dev);
+		irq_free_descs(bank->irq_base, bank->width);
+	}
+
+	return ret;
+}
+
 #ifdef CONFIG_ARCH_OMAP2PLUS
 
 #if defined(CONFIG_PM_RUNTIME)
@@ -1478,6 +1512,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match);
 
 static struct platform_driver omap_gpio_driver = {
 	.probe		= omap_gpio_probe,
+	.remove = __devexit_p(omap_gpio_remove),
 	.driver		= {
 		.name	= "omap_gpio",
 		.pm	= &gpio_pm_ops,
-- 
1.7.0.4

Re: [PATCH v2] gpio/omap: add *remove* callback in platform_driver

From: Shilimkar, Santosh <hidden>
Date: 2012-08-08 14:03:38

On Wed, Aug 8, 2012 at 7:28 PM, Tarun Kanti DebBarma [off-list ref] wrote:
Add *remove* callback so that necessary cleanup operations are
performed when device is unregistered. The device is deleted
from the list and associated clock handle is released by
calling clk_put() and irq descriptor is released using the
irq_free_desc() api.

Signed-off-by: Tarun Kanti DebBarma <redacted>
Reported-by: Paul Walmsley <paul@pwsan.com>
Reviewed-by: Jon Hunter <redacted>
Cc: Kevin Hilman <redacted>
Cc: Rajendra Nayak <redacted>
Cc: Santosh Shilimkar <redacted>
Cc: Cousson, Benoit <redacted>
Cc: Paul Walmsley <paul@pwsan.com>
---
v2:
Baseline: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

(1) Use irq_free_descs() instead of irq_free_desc().
    Besides, irq_free_desc() was using wrong parameter,
    irq_base, instead of bank->irq.
(2) irq_free_descs() moved outside spin_lock/unlock_*()
    in order to avoid exception warnings.

(3) pm_runtime_disable() added so that bind can happen successfully

Test Detail:
Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
#echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind

Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
#echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind

Step 3: Execute read/write GPIO test case.
Thanks details about test. Whe  you to "Unbind->bind", do
you see that PM is not broken.

In other words, can you also test and ensure that the OMAP3 suspend and
CPUIDLE are not broken because of this patch.
PER and CORE domains should transition to low power states.

Regards
Santosh

Re: [PATCH v2] gpio/omap: add *remove* callback in platform_driver

From: DebBarma, Tarun Kanti <hidden>
Date: 2012-08-08 14:08:12

On Wed, Aug 8, 2012 at 7:33 PM, Shilimkar, Santosh
[off-list ref] wrote:
On Wed, Aug 8, 2012 at 7:28 PM, Tarun Kanti DebBarma [off-list ref] wrote:
quoted
Add *remove* callback so that necessary cleanup operations are
performed when device is unregistered. The device is deleted
from the list and associated clock handle is released by
calling clk_put() and irq descriptor is released using the
irq_free_desc() api.

Signed-off-by: Tarun Kanti DebBarma <redacted>
Reported-by: Paul Walmsley <paul@pwsan.com>
Reviewed-by: Jon Hunter <redacted>
Cc: Kevin Hilman <redacted>
Cc: Rajendra Nayak <redacted>
Cc: Santosh Shilimkar <redacted>
Cc: Cousson, Benoit <redacted>
Cc: Paul Walmsley <paul@pwsan.com>
---
v2:
Baseline: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Commit: 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (Linux 3.6-rc1)

(1) Use irq_free_descs() instead of irq_free_desc().
    Besides, irq_free_desc() was using wrong parameter,
    irq_base, instead of bank->irq.
(2) irq_free_descs() moved outside spin_lock/unlock_*()
    in order to avoid exception warnings.

(3) pm_runtime_disable() added so that bind can happen successfully

Test Detail:
Step 1: Unbind gpio.5 device in order to invoke the *remove* callback.
#echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/unbind

Step 2: Bind gpio.5 device and confirm probe() for the device succeeds.
#echo "omap_gpio.5" > sys/bus/platform/drivers/omap_gpio/bind

Step 3: Execute read/write GPIO test case.
Thanks details about test. Whe  you to "Unbind->bind", do
you see that PM is not broken.

In other words, can you also test and ensure that the OMAP3 suspend and
CPUIDLE are not broken because of this patch.
PER and CORE domains should transition to low power states.
Sure, I will do the PM test on OMAP3 and confirm this.
---
Tarun
Regards
Santosh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help