ASoC: samsung-ac97: Use devm_clk_get()
Subsystems (4)
PATCH 1/2 ASoC: samsung-ac97: Use devm_clk_get()
--- sound/soc/samsung/ac97.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
sound/soc/samsung/ac97.c +1 -3
@@ -440,7 +440,7 @@ static int s3c_ac97_probe(struct platform_device *pdev) goto err1; } - s3c_ac97.ac97_clk =clk_get (&pdev->dev,"ac97" ); + s3c_ac97.ac97_clk =devm_clk_get (&pdev->dev,"ac97" );if (IS_ERR (s3c_ac97.ac97_clk)) {dev_err (&pdev->dev,"ac97 failed to get ac97_clock\n" ); ret = -ENODEV ;
@@ -480,7 +480,6 @@ err5: err4: err3:clk_disable_unprepare (s3c_ac97.ac97_clk); -clk_put (s3c_ac97.ac97_clk); err2:iounmap (s3c_ac97.regs); err1:
@@ -501,7 +500,6 @@ static int s3c_ac97_remove(struct platform_device *pdev)free_irq (irq_res->start,NULL );clk_disable_unprepare (s3c_ac97.ac97_clk); -clk_put (s3c_ac97.ac97_clk);iounmap (s3c_ac97.regs);
Signature · 1 line
1.8.3.1
PATCH 2/2 ASoC: samsung-ac97: Convert to devm_ioremap_resource()
--- sound/soc/samsung/ac97.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
sound/soc/samsung/ac97.c +3 -19
@@ -417,8 +417,8 @@ static int s3c_ac97_probe(struct platform_device *pdev)return -ENXIO ; } -if (!request_mem_region (mem_res->start, -resource_size (mem_res),"ac97" )) { + s3c_ac97.regs =devm_ioremap_resource (&pdev->dev, mem_res); +if (!s3c_ac97.regs) {dev_err (&pdev->dev,"Unable to request register region\n" );return -EBUSY ; }
@@ -433,13 +433,6 @@ static int s3c_ac97_probe(struct platform_device *pdev)init_completion (&s3c_ac97.done);mutex_init (&s3c_ac97.lock); - s3c_ac97.regs =ioremap (mem_res->start,resource_size (mem_res)); -if (s3c_ac97.regs ==NULL ) { -dev_err (&pdev->dev,"Unable to ioremap register region\n" ); - ret = -ENXIO ; - goto err1; - } - s3c_ac97.ac97_clk =devm_clk_get (&pdev->dev,"ac97" );if (IS_ERR (s3c_ac97.ac97_clk)) {dev_err (&pdev->dev,"ac97 failed to get ac97_clock\n" );
@@ -481,16 +474,13 @@ err4: err3:clk_disable_unprepare (s3c_ac97.ac97_clk); err2: -iounmap (s3c_ac97.regs); -err1: -release_mem_region (mem_res->start,resource_size (mem_res));return ret; }static int s3c_ac97_remove (struct platform_device *pdev) { -struct resource *mem_res, *irq_res; +struct resource *irq_res;asoc_dma_platform_unregister (&pdev->dev);snd_soc_unregister_component (&pdev->dev);
@@ -501,12 +491,6 @@ static int s3c_ac97_remove(struct platform_device *pdev)clk_disable_unprepare (s3c_ac97.ac97_clk); -iounmap (s3c_ac97.regs); - - mem_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (mem_res) -release_mem_region (mem_res->start,resource_size (mem_res)); -return 0 ; }
Signature · 1 line
1.8.3.1
Re: [PATCH 2/2] ASoC: samsung-ac97: Convert to devm_ioremap_resource()
Quoted 11 lines · Mark Brown
Signed-off-by Mark Brown <[email protected]>--- sound/soc/samsung/ac97.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)sound/soc/samsung/ac97.c +0
-0
sound/soc/samsung/ac97.c static int s3c_ac97_probe(struct platform_device *pdev) · line 423
Quoted 9 lines
sound/soc/samsung/ac97.c +2
-2@@ -417,8 +417,8 @@ static int s3c_ac97_probe(struct platform_device *pdev)return -ENXIO ; } -if (!request_mem_region (mem_res->start, -resource_size (mem_res),"ac97" )) { + s3c_ac97.regs =devm_ioremap_resource (&pdev->dev, mem_res); +if (!s3c_ac97.regs) {dev_err (&pdev->dev,"Unable to request register region\n" );return -EBUSY ;
CC'ed Thierry Reding, Sachin Kamat,
According to the comment of devm_ioremap_resource(), (lib/devres.c)
* Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
* on failure. Usage example:
*
* res = platform_get_resource(pdev, IORESOURCE_MEM, 0); * base = devm_ioremap_resource(&pdev->dev, res); * if (IS_ERR(base))
* return PTR_ERR(base);
*/
Thus, the following would be better.
+ s3c_ac97.regs = devm_ioremap_resource(&pdev->dev, mem_res);
+ if (IS_ERR(s3c_ac97.regs))
+ return PTR_ERR(s3c_ac97.regs);
Best regards,
Jingoo Han
Quoted 53 lines
sound/soc/samsung/ac97.c +1
-18}@@ -433,13 +433,6 @@ static int s3c_ac97_probe(struct platform_device *pdev)init_completion (&s3c_ac97.done);mutex_init (&s3c_ac97.lock); - s3c_ac97.regs =ioremap (mem_res->start,resource_size (mem_res)); -if (s3c_ac97.regs ==NULL ) { -dev_err (&pdev->dev,"Unable to ioremap register region\n" ); - ret = -ENXIO ; - goto err1; - } - s3c_ac97.ac97_clk =devm_clk_get (&pdev->dev,"ac97" );if (IS_ERR (s3c_ac97.ac97_clk)) {dev_err (&pdev->dev,"ac97 failed to get ac97_clock\n" );@@ -481,16 +474,13 @@ err4: err3:clk_disable_unprepare (s3c_ac97.ac97_clk); err2: -iounmap (s3c_ac97.regs); -err1: -release_mem_region (mem_res->start,resource_size (mem_res));return ret; }static int s3c_ac97_remove (struct platform_device *pdev) { -struct resource *mem_res, *irq_res; +struct resource *irq_res;asoc_dma_platform_unregister (&pdev->dev);snd_soc_unregister_component (&pdev->dev);@@ -501,12 +491,6 @@ static int s3c_ac97_remove(struct platform_device *pdev)clk_disable_unprepare (s3c_ac97.ac97_clk); -iounmap (s3c_ac97.regs); - - mem_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (mem_res) -release_mem_region (mem_res->start,resource_size (mem_res)); -return 0 ; } --1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] ASoC: samsung-ac97: Convert to devm_ioremap_resource()
Quoted 40 lines · On Wednesday 26 of June 2013 19:00:44 Jingoo Han wrote:
Quoted 21 lines · Mark Brown
Signed-off-by Mark Brown <[email protected]>---
sound/soc/samsung/ac97.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)sound/soc/samsung/ac97.c +2
-2@@ -417,8 +417,8 @@ static int s3c_ac97_probe(struct platform_device *pdev)> return -ENXIO ; } -if (!request_mem_region (mem_res->start, -resource_size (mem_res),"ac97" )) { + s3c_ac97.regs =devm_ioremap_resource (&pdev->dev, mem_res); +if (!s3c_ac97.regs) {sound/soc/samsung/ac97.c static int s3c_ac97_probe(struct platform_device *pdev) · line 423
Quoted 2 lines
sound/soc/samsung/ac97.c +0
-0dev_err (&pdev->dev,"Unable to request register region\n" );return -EBUSY ;CC'ed Thierry Reding, Sachin Kamat,
According to the comment of
devm_ioremap_resource(), (lib/devres.c)* Returns a pointer to the remapped memory or an
ERR_PTR()encoded error
code * on failure. Usage example:
** res = platform_get_resource(pdev, IORESOURCE_MEM, 0); * base = devm_ioremap_resource(&pdev->dev, res); * if (IS_ERR(base))* return
PTR_ERR(base);
*/Thus, the following would be better.
Review
Quoted 3 lines
(quoted diff) +3
-0+ s3c_ac97.regs = devm_ioremap_resource(&pdev->dev, mem_res); + if (IS_ERR(s3c_ac97.regs)) + return PTR_ERR(s3c_ac97.regs);
Right.
I was caught on doing exactly the same and I think this was caused by moving from devm_request_and_ioremap() which used to return NULL on failure to devm_ioremap_resource() which returns ERR_PTR.
By the way, Mark, does this driver work for you? I have tried it on both mini6410 and smdk6410 (configured to use the onboard AC97 codec), with both old and new DMA drivers and I couldn't get it to play a single sound.
Best regards,
Tomasz
Quoted 74 lines
Best regards,
Jingoo HanQuoted 57 lines
sound/soc/samsung/ac97.c +0
-7}@@ -433,13 +433,6 @@ static int s3c_ac97_probe(struct platform_device *pdev)>init_completion (&s3c_ac97.done);mutex_init (&s3c_ac97.lock); - s3c_ac97.regs =ioremap (mem_res->start,resource_size (mem_res)); -if (s3c_ac97.regs ==NULL ) { -dev_err (&pdev->dev,"Unable to ioremap register region\n" ); - ret = -ENXIO ; - goto err1; - } - s3c_ac97.ac97_clk =devm_clk_get (&pdev->dev,"ac97" );sound/soc/samsung/ac97.c +1
-4if (IS_ERR (s3c_ac97.ac97_clk)) {dev_err (&pdev->dev,"ac97 failed to get ac97_clock\n" );@@ -481,16 +474,13 @@ err4: err3:clk_disable_unprepare (s3c_ac97.ac97_clk); err2: -iounmap (s3c_ac97.regs); -err1: -release_mem_region (mem_res->start,resource_size (mem_res));return ret; }static int s3c_ac97_remove (struct platform_device *pdev) { -struct resource *mem_res, *irq_res; +struct resource *irq_res;sound/soc/samsung/ac97.c +0
-6asoc_dma_platform_unregister (&pdev->dev);snd_soc_unregister_component (&pdev->dev);@@ -501,12 +491,6 @@ static int s3c_ac97_remove(struct platform_device *pdev)>clk_disable_unprepare (s3c_ac97.ac97_clk); -iounmap (s3c_ac97.regs); - - mem_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (mem_res) -release_mem_region (mem_res->start,resource_size (mem_res)); -return 0 ;}
Quoted 8 lines
--
1.8.3.1--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Brown
maintainerRe: [PATCH 2/2] ASoC: samsung-ac97: Convert to devm_ioremap_resource()
Quoted 3 lines · Tomasz Figa
By the way, Mark, does this driver work for you? I have tried it on both mini6410 and smdk6410 (configured to use the onboard AC97 codec), with both old and new DMA drivers and I couldn't get it to play a single sound.
I've no access to any hardware which might use this driver, though IIRC it didn't work last time I did have such access.
Quoted 2 lines · Mark Brown
Signed-off-by Mark Brown <[email protected]>
It looks good.
Best regards,
Jingoo Han
Quoted 36 lines
--- sound/soc/samsung/ac97.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)sound/soc/samsung/ac97.c +1
-4@@ -440,7 +440,7 @@ static int s3c_ac97_probe(struct platform_device *pdev) goto err1; } - s3c_ac97.ac97_clk =clk_get (&pdev->dev,"ac97" ); + s3c_ac97.ac97_clk =devm_clk_get (&pdev->dev,"ac97" );if (IS_ERR (s3c_ac97.ac97_clk)) {dev_err (&pdev->dev,"ac97 failed to get ac97_clock\n" ); ret = -ENODEV ;@@ -480,7 +480,6 @@ err5: err4: err3:clk_disable_unprepare (s3c_ac97.ac97_clk); -clk_put (s3c_ac97.ac97_clk); err2:iounmap (s3c_ac97.regs); err1:@@ -501,7 +500,6 @@ static int s3c_ac97_remove(struct platform_device *pdev)free_irq (irq_res->start,NULL );clk_disable_unprepare (s3c_ac97.ac97_clk); -clk_put (s3c_ac97.ac97_clk);iounmap (s3c_ac97.regs); --1.8.3.1