* [PATCH 1/2] spi: sh-msiof: Use devm_* managed allocators
@ 2013-11-28 1:39 Laurent Pinchart
[not found] ` <1385602783-3439-1-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2013-11-28 10:27 ` [PATCH 1/2] spi: sh-msiof: Use devm_* managed allocators Mark Brown
0 siblings, 2 replies; 6+ messages in thread
From: Laurent Pinchart @ 2013-11-28 1:39 UTC (permalink / raw)
To: linux-sh-u79uwXL29TY76Z2rM5mHXA
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown
This simplifies error and cleanup code paths.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
---
drivers/spi/spi-sh-msiof.c | 37 ++++++++++++++-----------------------
1 file changed, 14 insertions(+), 23 deletions(-)
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index c74298c..541e1ec 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -635,8 +635,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
master = spi_alloc_master(&pdev->dev, sizeof(struct sh_msiof_spi_priv));
if (master == NULL) {
dev_err(&pdev->dev, "failed to allocate spi master\n");
- ret = -ENOMEM;
- goto err0;
+ return -ENOMEM;
}
p = spi_master_get_devdata(master);
@@ -655,32 +654,32 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
init_completion(&p->done);
- p->clk = clk_get(&pdev->dev, NULL);
+ p->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(p->clk)) {
dev_err(&pdev->dev, "cannot get clock\n");
ret = PTR_ERR(p->clk);
goto err1;
}
- r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
i = platform_get_irq(pdev, 0);
- if (!r || i < 0) {
- dev_err(&pdev->dev, "cannot get platform resources\n");
+ if (i < 0) {
+ dev_err(&pdev->dev, "cannot get platform IRQ\n");
ret = -ENOENT;
- goto err2;
+ goto err1;
}
- p->mapbase = ioremap_nocache(r->start, resource_size(r));
- if (!p->mapbase) {
- dev_err(&pdev->dev, "unable to ioremap\n");
- ret = -ENXIO;
- goto err2;
+
+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ p->mapbase = devm_ioremap_resource(&pdev->dev, r);
+ if (IS_ERR(p->mapbase)) {
+ ret = PTR_ERR(p->mapbase);
+ goto err1;
}
- ret = request_irq(i, sh_msiof_spi_irq, 0,
- dev_name(&pdev->dev), p);
+ ret = devm_request_irq(&pdev->dev, i, sh_msiof_spi_irq, 0,
+ dev_name(&pdev->dev), p);
if (ret) {
dev_err(&pdev->dev, "unable to request irq\n");
- goto err3;
+ goto err1;
}
p->pdev = pdev;
@@ -719,13 +718,8 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
return 0;
pm_runtime_disable(&pdev->dev);
- err3:
- iounmap(p->mapbase);
- err2:
- clk_put(p->clk);
err1:
spi_master_put(master);
- err0:
return ret;
}
@@ -737,9 +731,6 @@ static int sh_msiof_spi_remove(struct platform_device *pdev)
ret = spi_bitbang_stop(&p->bitbang);
if (!ret) {
pm_runtime_disable(&pdev->dev);
- free_irq(platform_get_irq(pdev, 0), p);
- iounmap(p->mapbase);
- clk_put(p->clk);
spi_master_put(p->bitbang.master);
}
return ret;
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
[parent not found: <1385602783-3439-1-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>]
* [PATCH 2/2] spi: sh-msiof: Convert to clk_prepare/unprepare
[not found] ` <1385602783-3439-1-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
@ 2013-11-28 1:39 ` Laurent Pinchart
[not found] ` <1385602783-3439-2-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Laurent Pinchart @ 2013-11-28 1:39 UTC (permalink / raw)
To: linux-sh-u79uwXL29TY76Z2rM5mHXA
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA, Mark Brown
Get the driver ready for the migration to the common clock framework by
calling clk_prepare() and clk_unprepare(). The calls are added in the
probe and remove handlers as the clk_enable() and clk_disable() calls
are located in atomic context and there's no callback function in
non-atomic context that can be used to prepare/unprepare the clock.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
---
drivers/spi/spi-sh-msiof.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
index 541e1ec..fbbe949 100644
--- a/drivers/spi/spi-sh-msiof.c
+++ b/drivers/spi/spi-sh-msiof.c
@@ -682,6 +682,12 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
goto err1;
}
+ ret = clk_prepare(p->clk);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "unable to prepare clock\n");
+ goto err1;
+ }
+
p->pdev = pdev;
pm_runtime_enable(&pdev->dev);
@@ -718,6 +724,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
return 0;
pm_runtime_disable(&pdev->dev);
+ clk_unprepare(p->clk);
err1:
spi_master_put(master);
return ret;
@@ -731,6 +738,7 @@ static int sh_msiof_spi_remove(struct platform_device *pdev)
ret = spi_bitbang_stop(&p->bitbang);
if (!ret) {
pm_runtime_disable(&pdev->dev);
+ clk_unprepare(p->clk);
spi_master_put(p->bitbang.master);
}
return ret;
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] spi: sh-msiof: Use devm_* managed allocators
2013-11-28 1:39 [PATCH 1/2] spi: sh-msiof: Use devm_* managed allocators Laurent Pinchart
[not found] ` <1385602783-3439-1-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
@ 2013-11-28 10:27 ` Mark Brown
1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2013-11-28 10:27 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: linux-sh, linux-spi
[-- Attachment #1: Type: text/plain, Size: 132 bytes --]
On Thu, Nov 28, 2013 at 02:39:42AM +0100, Laurent Pinchart wrote:
> This simplifies error and cleanup code paths.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-11-28 16:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-28 1:39 [PATCH 1/2] spi: sh-msiof: Use devm_* managed allocators Laurent Pinchart
[not found] ` <1385602783-3439-1-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2013-11-28 1:39 ` [PATCH 2/2] spi: sh-msiof: Convert to clk_prepare/unprepare Laurent Pinchart
[not found] ` <1385602783-3439-2-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2013-11-28 10:34 ` Mark Brown
[not found] ` <20131128103407.GI14725-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-28 14:16 ` Laurent Pinchart
2013-11-28 16:44 ` Mark Brown
2013-11-28 10:27 ` [PATCH 1/2] spi: sh-msiof: Use devm_* managed allocators Mark Brown
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).