* [PATCH 0/3] Optimize the u8500_hsem hwlock driver
@ 2019-09-27 8:27 Baolin Wang
2019-09-27 8:27 ` [PATCH 1/3] hwspinlock: u8500_hsem: Change to use devm_platform_ioremap_resource() Baolin Wang
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Baolin Wang @ 2019-09-27 8:27 UTC (permalink / raw)
To: linus.walleij, ohad, bjorn.andersson
Cc: baolin.wang, linux-arm-kernel, linux-remoteproc, linux-kernel
This patch set did some Optimization with changing to use devm_xxx()
APIs to simplify the code and make code more readable.
Baolin Wang (3):
hwspinlock: u8500_hsem: Change to use
devm_platform_ioremap_resource()
hwspinlock: u8500_hsem: Use devm_kzalloc() to allocate memory
hwspinlock: u8500_hsem: Use devm_hwspin_lock_register() to register
hwlock controller
drivers/hwspinlock/u8500_hsem.c | 46 +++++++++++----------------------------
1 file changed, 13 insertions(+), 33 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] hwspinlock: u8500_hsem: Change to use devm_platform_ioremap_resource()
2019-09-27 8:27 [PATCH 0/3] Optimize the u8500_hsem hwlock driver Baolin Wang
@ 2019-09-27 8:27 ` Baolin Wang
2019-10-04 21:35 ` Linus Walleij
2019-09-27 8:27 ` [PATCH 2/3] hwspinlock: u8500_hsem: Use devm_kzalloc() to allocate memory Baolin Wang
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Baolin Wang @ 2019-09-27 8:27 UTC (permalink / raw)
To: linus.walleij, ohad, bjorn.andersson
Cc: baolin.wang, linux-arm-kernel, linux-remoteproc, linux-kernel
Use the new helper that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together, which can simpify the code.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
drivers/hwspinlock/u8500_hsem.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/hwspinlock/u8500_hsem.c b/drivers/hwspinlock/u8500_hsem.c
index 572ca79..c247a87 100644
--- a/drivers/hwspinlock/u8500_hsem.c
+++ b/drivers/hwspinlock/u8500_hsem.c
@@ -88,7 +88,6 @@ static int u8500_hsem_probe(struct platform_device *pdev)
struct hwspinlock_pdata *pdata = pdev->dev.platform_data;
struct hwspinlock_device *bank;
struct hwspinlock *hwlock;
- struct resource *res;
void __iomem *io_base;
int i, ret, num_locks = U8500_MAX_SEMAPHORE;
ulong val;
@@ -96,13 +95,9 @@ static int u8500_hsem_probe(struct platform_device *pdev)
if (!pdata)
return -ENODEV;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -ENODEV;
-
- io_base = ioremap(res->start, resource_size(res));
- if (!io_base)
- return -ENOMEM;
+ io_base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(io_base))
+ return PTR_ERR(io_base);
/* make sure protocol 1 is selected */
val = readl(io_base + HSEM_CTRL_REG);
@@ -112,10 +107,8 @@ static int u8500_hsem_probe(struct platform_device *pdev)
writel(0xFFFF, io_base + HSEM_ICRALL);
bank = kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL);
- if (!bank) {
- ret = -ENOMEM;
- goto iounmap_base;
- }
+ if (!bank)
+ return -ENOMEM;
platform_set_drvdata(pdev, bank);
@@ -135,8 +128,6 @@ static int u8500_hsem_probe(struct platform_device *pdev)
reg_fail:
pm_runtime_disable(&pdev->dev);
kfree(bank);
-iounmap_base:
- iounmap(io_base);
return ret;
}
@@ -156,7 +147,6 @@ static int u8500_hsem_remove(struct platform_device *pdev)
}
pm_runtime_disable(&pdev->dev);
- iounmap(io_base);
kfree(bank);
return 0;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] hwspinlock: u8500_hsem: Use devm_kzalloc() to allocate memory
2019-09-27 8:27 [PATCH 0/3] Optimize the u8500_hsem hwlock driver Baolin Wang
2019-09-27 8:27 ` [PATCH 1/3] hwspinlock: u8500_hsem: Change to use devm_platform_ioremap_resource() Baolin Wang
@ 2019-09-27 8:27 ` Baolin Wang
2019-10-04 21:36 ` Linus Walleij
2019-09-27 8:27 ` [PATCH 3/3] hwspinlock: u8500_hsem: Use devm_hwspin_lock_register() to register hwlock controller Baolin Wang
2019-10-05 4:01 ` [PATCH 0/3] Optimize the u8500_hsem hwlock driver Bjorn Andersson
3 siblings, 1 reply; 8+ messages in thread
From: Baolin Wang @ 2019-09-27 8:27 UTC (permalink / raw)
To: linus.walleij, ohad, bjorn.andersson
Cc: baolin.wang, linux-arm-kernel, linux-remoteproc, linux-kernel
Use devm_kzalloc() to allocate memory.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
drivers/hwspinlock/u8500_hsem.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/hwspinlock/u8500_hsem.c b/drivers/hwspinlock/u8500_hsem.c
index c247a87..0e8d4ff 100644
--- a/drivers/hwspinlock/u8500_hsem.c
+++ b/drivers/hwspinlock/u8500_hsem.c
@@ -106,7 +106,8 @@ static int u8500_hsem_probe(struct platform_device *pdev)
/* clear all interrupts */
writel(0xFFFF, io_base + HSEM_ICRALL);
- bank = kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL);
+ bank = devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks),
+ GFP_KERNEL);
if (!bank)
return -ENOMEM;
@@ -120,15 +121,12 @@ static int u8500_hsem_probe(struct platform_device *pdev)
ret = hwspin_lock_register(bank, &pdev->dev, &u8500_hwspinlock_ops,
pdata->base_id, num_locks);
- if (ret)
- goto reg_fail;
+ if (ret) {
+ pm_runtime_disable(&pdev->dev);
+ return ret;
+ }
return 0;
-
-reg_fail:
- pm_runtime_disable(&pdev->dev);
- kfree(bank);
- return ret;
}
static int u8500_hsem_remove(struct platform_device *pdev)
@@ -147,7 +145,6 @@ static int u8500_hsem_remove(struct platform_device *pdev)
}
pm_runtime_disable(&pdev->dev);
- kfree(bank);
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] hwspinlock: u8500_hsem: Use devm_hwspin_lock_register() to register hwlock controller
2019-09-27 8:27 [PATCH 0/3] Optimize the u8500_hsem hwlock driver Baolin Wang
2019-09-27 8:27 ` [PATCH 1/3] hwspinlock: u8500_hsem: Change to use devm_platform_ioremap_resource() Baolin Wang
2019-09-27 8:27 ` [PATCH 2/3] hwspinlock: u8500_hsem: Use devm_kzalloc() to allocate memory Baolin Wang
@ 2019-09-27 8:27 ` Baolin Wang
2019-10-04 21:38 ` Linus Walleij
2019-10-05 4:01 ` [PATCH 0/3] Optimize the u8500_hsem hwlock driver Bjorn Andersson
3 siblings, 1 reply; 8+ messages in thread
From: Baolin Wang @ 2019-09-27 8:27 UTC (permalink / raw)
To: linus.walleij, ohad, bjorn.andersson
Cc: baolin.wang, linux-arm-kernel, linux-remoteproc, linux-kernel
Use devm_hwspin_lock_register() to register the hwlock controller instead of
unregistering the hwlock controller explicitly when removing the device.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
drivers/hwspinlock/u8500_hsem.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/hwspinlock/u8500_hsem.c b/drivers/hwspinlock/u8500_hsem.c
index 0e8d4ff..b31141a 100644
--- a/drivers/hwspinlock/u8500_hsem.c
+++ b/drivers/hwspinlock/u8500_hsem.c
@@ -119,8 +119,8 @@ static int u8500_hsem_probe(struct platform_device *pdev)
/* no pm needed for HSem but required to comply with hwspilock core */
pm_runtime_enable(&pdev->dev);
- ret = hwspin_lock_register(bank, &pdev->dev, &u8500_hwspinlock_ops,
- pdata->base_id, num_locks);
+ ret = devm_hwspin_lock_register(&pdev->dev, bank, &u8500_hwspinlock_ops,
+ pdata->base_id, num_locks);
if (ret) {
pm_runtime_disable(&pdev->dev);
return ret;
@@ -133,17 +133,10 @@ static int u8500_hsem_remove(struct platform_device *pdev)
{
struct hwspinlock_device *bank = platform_get_drvdata(pdev);
void __iomem *io_base = bank->lock[0].priv - HSEM_REGISTER_OFFSET;
- int ret;
/* clear all interrupts */
writel(0xFFFF, io_base + HSEM_ICRALL);
- ret = hwspin_lock_unregister(bank);
- if (ret) {
- dev_err(&pdev->dev, "%s failed: %d\n", __func__, ret);
- return ret;
- }
-
pm_runtime_disable(&pdev->dev);
return 0;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] hwspinlock: u8500_hsem: Change to use devm_platform_ioremap_resource()
2019-09-27 8:27 ` [PATCH 1/3] hwspinlock: u8500_hsem: Change to use devm_platform_ioremap_resource() Baolin Wang
@ 2019-10-04 21:35 ` Linus Walleij
0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2019-10-04 21:35 UTC (permalink / raw)
To: Baolin Wang
Cc: Ohad Ben-Cohen, Bjorn Andersson, Linux ARM, linux-remoteproc,
linux-kernel
On Fri, Sep 27, 2019 at 10:28 AM Baolin Wang <baolin.wang@linaro.org> wrote:
> Use the new helper that wraps the calls to platform_get_resource()
> and devm_ioremap_resource() together, which can simpify the code.
>
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] hwspinlock: u8500_hsem: Use devm_kzalloc() to allocate memory
2019-09-27 8:27 ` [PATCH 2/3] hwspinlock: u8500_hsem: Use devm_kzalloc() to allocate memory Baolin Wang
@ 2019-10-04 21:36 ` Linus Walleij
0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2019-10-04 21:36 UTC (permalink / raw)
To: Baolin Wang
Cc: Ohad Ben-Cohen, Bjorn Andersson, Linux ARM, linux-remoteproc,
linux-kernel
On Fri, Sep 27, 2019 at 10:28 AM Baolin Wang <baolin.wang@linaro.org> wrote:
> Use devm_kzalloc() to allocate memory.
>
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] hwspinlock: u8500_hsem: Use devm_hwspin_lock_register() to register hwlock controller
2019-09-27 8:27 ` [PATCH 3/3] hwspinlock: u8500_hsem: Use devm_hwspin_lock_register() to register hwlock controller Baolin Wang
@ 2019-10-04 21:38 ` Linus Walleij
0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2019-10-04 21:38 UTC (permalink / raw)
To: Baolin Wang
Cc: Ohad Ben-Cohen, Bjorn Andersson, Linux ARM, linux-remoteproc,
linux-kernel
On Fri, Sep 27, 2019 at 10:28 AM Baolin Wang <baolin.wang@linaro.org> wrote:
> Use devm_hwspin_lock_register() to register the hwlock controller instead of
> unregistering the hwlock controller explicitly when removing the device.
>
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/3] Optimize the u8500_hsem hwlock driver
2019-09-27 8:27 [PATCH 0/3] Optimize the u8500_hsem hwlock driver Baolin Wang
` (2 preceding siblings ...)
2019-09-27 8:27 ` [PATCH 3/3] hwspinlock: u8500_hsem: Use devm_hwspin_lock_register() to register hwlock controller Baolin Wang
@ 2019-10-05 4:01 ` Bjorn Andersson
3 siblings, 0 replies; 8+ messages in thread
From: Bjorn Andersson @ 2019-10-05 4:01 UTC (permalink / raw)
To: Baolin Wang
Cc: linus.walleij, ohad, linux-arm-kernel, linux-remoteproc, linux-kernel
On Fri 27 Sep 01:27 PDT 2019, Baolin Wang wrote:
> This patch set did some Optimization with changing to use devm_xxx()
> APIs to simplify the code and make code more readable.
>
Applied, with Linus' r-b
Thanks,
Bjorn
> Baolin Wang (3):
> hwspinlock: u8500_hsem: Change to use
> devm_platform_ioremap_resource()
> hwspinlock: u8500_hsem: Use devm_kzalloc() to allocate memory
> hwspinlock: u8500_hsem: Use devm_hwspin_lock_register() to register
> hwlock controller
>
> drivers/hwspinlock/u8500_hsem.c | 46 +++++++++++----------------------------
> 1 file changed, 13 insertions(+), 33 deletions(-)
>
> --
> 1.7.9.5
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-10-05 4:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27 8:27 [PATCH 0/3] Optimize the u8500_hsem hwlock driver Baolin Wang
2019-09-27 8:27 ` [PATCH 1/3] hwspinlock: u8500_hsem: Change to use devm_platform_ioremap_resource() Baolin Wang
2019-10-04 21:35 ` Linus Walleij
2019-09-27 8:27 ` [PATCH 2/3] hwspinlock: u8500_hsem: Use devm_kzalloc() to allocate memory Baolin Wang
2019-10-04 21:36 ` Linus Walleij
2019-09-27 8:27 ` [PATCH 3/3] hwspinlock: u8500_hsem: Use devm_hwspin_lock_register() to register hwlock controller Baolin Wang
2019-10-04 21:38 ` Linus Walleij
2019-10-05 4:01 ` [PATCH 0/3] Optimize the u8500_hsem hwlock driver Bjorn Andersson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).