2013-06-12 08:34:17

by Sachin Kamat

[permalink] [raw]
Subject: [PATCH Resend 1/1] mfd: davinci_voicecodec: Convert to use devm_* APIs

devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <[email protected]>
Cc: Miguel Aguilar <[email protected]>
---
CC'd Lee Jones

Patch is based on mfd-next tree and compile tested.
This driver gives following compilation error (not introduced by this patch):
drivers/mfd/davinci_voicecodec.c:86:3: error: implicit declaration
of function ‘io_v2p’ [-Werror=implicit-function-declaration]
(dma_addr_t)(io_v2p(davinci_vc->base) + DAVINCI_VC_WFIFO);

In order to test my changes I added the following to davinci_voicecodec.h file:
+#define IO_OFFSET 0xfd000000 /* Virtual IO = 0xfec00000 */
+#define io_v2p(va) ((va) - IO_OFFSET)

I am not sure if these changes are right fix for the above error.
---

drivers/mfd/davinci_voicecodec.c | 48 +++++++-------------------------
include/linux/mfd/davinci_voicecodec.h | 2 --
2 files changed, 10 insertions(+), 40 deletions(-)

diff --git a/drivers/mfd/davinci_voicecodec.c b/drivers/mfd/davinci_voicecodec.c
index b6e2973..fb64398 100644
--- a/drivers/mfd/davinci_voicecodec.c
+++ b/drivers/mfd/davinci_voicecodec.c
@@ -46,7 +46,7 @@ void davinci_vc_write(struct davinci_vc *davinci_vc,
static int __init davinci_vc_probe(struct platform_device *pdev)
{
struct davinci_vc *davinci_vc;
- struct resource *res, *mem;
+ struct resource *res;
struct mfd_cell *cell = NULL;
int ret;

@@ -58,7 +58,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
return -ENOMEM;
}

- davinci_vc->clk = clk_get(&pdev->dev, NULL);
+ davinci_vc->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(davinci_vc->clk)) {
dev_dbg(&pdev->dev,
"could not get the clock for voice codec\n");
@@ -67,35 +67,18 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
clk_enable(davinci_vc->clk);

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "no mem resource\n");
- ret = -ENODEV;
- goto fail2;
- }
-
- davinci_vc->pbase = res->start;
- davinci_vc->base_size = resource_size(res);

- mem = request_mem_region(davinci_vc->pbase, davinci_vc->base_size,
- pdev->name);
- if (!mem) {
- dev_err(&pdev->dev, "VCIF region already claimed\n");
- ret = -EBUSY;
- goto fail2;
- }
-
- davinci_vc->base = ioremap(davinci_vc->pbase, davinci_vc->base_size);
- if (!davinci_vc->base) {
- dev_err(&pdev->dev, "can't ioremap mem resource.\n");
- ret = -ENOMEM;
- goto fail3;
+ davinci_vc->base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(davinci_vc->base)) {
+ ret = PTR_ERR(davinci_vc->base);
+ goto fail;
}

res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
if (!res) {
dev_err(&pdev->dev, "no DMA resource\n");
ret = -ENXIO;
- goto fail4;
+ goto fail;
}

davinci_vc->davinci_vcif.dma_tx_channel = res->start;
@@ -106,7 +89,7 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
if (!res) {
dev_err(&pdev->dev, "no DMA resource\n");
ret = -ENXIO;
- goto fail4;
+ goto fail;
}

davinci_vc->davinci_vcif.dma_rx_channel = res->start;
@@ -132,19 +115,13 @@ static int __init davinci_vc_probe(struct platform_device *pdev)
DAVINCI_VC_CELLS, NULL, 0, NULL);
if (ret != 0) {
dev_err(&pdev->dev, "fail to register client devices\n");
- goto fail4;
+ goto fail;
}

return 0;

-fail4:
- iounmap(davinci_vc->base);
-fail3:
- release_mem_region(davinci_vc->pbase, davinci_vc->base_size);
-fail2:
+fail:
clk_disable(davinci_vc->clk);
- clk_put(davinci_vc->clk);
- davinci_vc->clk = NULL;

return ret;
}
@@ -155,12 +132,7 @@ static int davinci_vc_remove(struct platform_device *pdev)

mfd_remove_devices(&pdev->dev);

- iounmap(davinci_vc->base);
- release_mem_region(davinci_vc->pbase, davinci_vc->base_size);
-
clk_disable(davinci_vc->clk);
- clk_put(davinci_vc->clk);
- davinci_vc->clk = NULL;

return 0;
}
diff --git a/include/linux/mfd/davinci_voicecodec.h b/include/linux/mfd/davinci_voicecodec.h
index 0ab6132..94c53d4 100644
--- a/include/linux/mfd/davinci_voicecodec.h
+++ b/include/linux/mfd/davinci_voicecodec.h
@@ -112,8 +112,6 @@ struct davinci_vc {

/* Memory resources */
void __iomem *base;
- resource_size_t pbase;
- size_t base_size;

/* MFD cells */
struct mfd_cell cells[DAVINCI_VC_CELLS];
--
1.7.9.5


2013-06-13 10:49:51

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH Resend 1/1] mfd: davinci_voicecodec: Convert to use devm_* APIs

On Wed, 12 Jun 2013, Sachin Kamat wrote:

> devm_* APIs are device managed and make code simpler.
>
> Signed-off-by: Sachin Kamat <[email protected]>
> Cc: Miguel Aguilar <[email protected]>
> ---
> CC'd Lee Jones

Can you resubmit this based on -rc5 please?

There have been some related changes since you wrote this patch.

--
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2013-06-14 04:20:42

by Sachin Kamat

[permalink] [raw]
Subject: Re: [PATCH Resend 1/1] mfd: davinci_voicecodec: Convert to use devm_* APIs

Hi Lee,

On 13 June 2013 16:19, Lee Jones <[email protected]> wrote:
> On Wed, 12 Jun 2013, Sachin Kamat wrote:
>
>> devm_* APIs are device managed and make code simpler.
>>
>> Signed-off-by: Sachin Kamat <[email protected]>
>> Cc: Miguel Aguilar <[email protected]>
>> ---
>> CC'd Lee Jones
>
> Can you resubmit this based on -rc5 please?
>
> There have been some related changes since you wrote this patch.

This patch is based on Samuel's mfd-next tree [1].
This patch is dependent on your patch "mfd: davinci_voicecodec:
Convert to managed resources for allocating memory"
which is applied in mfd-next.

Please let me know which other tree you want me to rebase this patch
on considering the dependency.

[1] http://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next.git
--
With warm regards,
Sachin

2013-06-14 07:06:49

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH Resend 1/1] mfd: davinci_voicecodec: Convert to use devm_* APIs

On Fri, 14 Jun 2013, Sachin Kamat wrote:

> Hi Lee,
>
> On 13 June 2013 16:19, Lee Jones <[email protected]> wrote:
> > On Wed, 12 Jun 2013, Sachin Kamat wrote:
> >
> >> devm_* APIs are device managed and make code simpler.
> >>
> >> Signed-off-by: Sachin Kamat <[email protected]>
> >> Cc: Miguel Aguilar <[email protected]>
> >> ---
> >> CC'd Lee Jones
> >
> > Can you resubmit this based on -rc5 please?
> >
> > There have been some related changes since you wrote this patch.
>
> This patch is based on Samuel's mfd-next tree [1].
> This patch is dependent on your patch "mfd: davinci_voicecodec:
> Convert to managed resources for allocating memory"
> which is applied in mfd-next.
>
> Please let me know which other tree you want me to rebase this patch
> on considering the dependency.
>
> [1] http://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next.git

I believe Sam's branch has been updated considerably since you wrote
the patch. Would you mind rebasing it onto Sam's latest master branch
please? Should be commit: d8c5d658f425bd25bbfb137f2617f59ed4fdee7d.

--
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2013-06-14 08:18:36

by Sachin Kamat

[permalink] [raw]
Subject: Re: [PATCH Resend 1/1] mfd: davinci_voicecodec: Convert to use devm_* APIs

On 14 June 2013 12:36, Lee Jones <[email protected]> wrote:
> On Fri, 14 Jun 2013, Sachin Kamat wrote:
>
>> Hi Lee,
>>
>> On 13 June 2013 16:19, Lee Jones <[email protected]> wrote:
>> > On Wed, 12 Jun 2013, Sachin Kamat wrote:
>> >
>> >> devm_* APIs are device managed and make code simpler.
>> >>
>> >> Signed-off-by: Sachin Kamat <[email protected]>
>> >> Cc: Miguel Aguilar <[email protected]>
>> >> ---
>> >> CC'd Lee Jones
>> >
>> > Can you resubmit this based on -rc5 please?
>> >
>> > There have been some related changes since you wrote this patch.
>>
>> This patch is based on Samuel's mfd-next tree [1].
>> This patch is dependent on your patch "mfd: davinci_voicecodec:
>> Convert to managed resources for allocating memory"
>> which is applied in mfd-next.
>>
>> Please let me know which other tree you want me to rebase this patch
>> on considering the dependency.
>>
>> [1] http://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-next.git
>
> I believe Sam's branch has been updated considerably since you wrote
> the patch. Would you mind rebasing it onto Sam's latest master branch
> please? Should be commit: d8c5d658f425bd25bbfb137f2617f59ed4fdee7d.

It applies cleanly on top of the commit:
d8c5d658f425bd25bbfb137f2617f59ed4fdee7d
("Merge tag 'am335x_tsc-adc' of git://breakpoint.cc/bigeasy/linux").

I am surprised that you are getting errors. Anyway resending once again.

--
With warm regards,
Sachin

2013-06-18 08:41:05

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH Resend 1/1] mfd: davinci_voicecodec: Convert to use devm_* APIs

Hi Sachin,

On Wed, Jun 12, 2013 at 01:49:42PM +0530, Sachin Kamat wrote:
> devm_* APIs are device managed and make code simpler.
>
> Signed-off-by: Sachin Kamat <[email protected]>
> Cc: Miguel Aguilar <[email protected]>
> ---
> CC'd Lee Jones
>
> Patch is based on mfd-next tree and compile tested.
> This driver gives following compilation error (not introduced by this patch):
> drivers/mfd/davinci_voicecodec.c:86:3: error: implicit declaration
> of function ‘io_v2p’ [-Werror=implicit-function-declaration]
> (dma_addr_t)(io_v2p(davinci_vc->base) + DAVINCI_VC_WFIFO);
>
> In order to test my changes I added the following to davinci_voicecodec.h file:
> +#define IO_OFFSET 0xfd000000 /* Virtual IO = 0xfec00000 */
> +#define io_v2p(va) ((va) - IO_OFFSET)
>
> I am not sure if these changes are right fix for the above error.
io_v2p is define in davinci's mach/hardware.h so I believe this is what
you should include in davinci_voicecodec.h.

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/

2013-06-18 08:43:52

by Sachin Kamat

[permalink] [raw]
Subject: Re: [PATCH Resend 1/1] mfd: davinci_voicecodec: Convert to use devm_* APIs

Hi Samuel,

On 18 June 2013 14:10, Samuel Ortiz <[email protected]> wrote:
> Hi Sachin,
>
> On Wed, Jun 12, 2013 at 01:49:42PM +0530, Sachin Kamat wrote:
>> devm_* APIs are device managed and make code simpler.
>>
>> Signed-off-by: Sachin Kamat <[email protected]>
>> Cc: Miguel Aguilar <[email protected]>
>> ---
>> CC'd Lee Jones
>>
>> Patch is based on mfd-next tree and compile tested.
>> This driver gives following compilation error (not introduced by this patch):
>> drivers/mfd/davinci_voicecodec.c:86:3: error: implicit declaration
>> of function ?io_v2p? [-Werror=implicit-function-declaration]
>> (dma_addr_t)(io_v2p(davinci_vc->base) + DAVINCI_VC_WFIFO);
>>
>> In order to test my changes I added the following to davinci_voicecodec.h file:
>> +#define IO_OFFSET 0xfd000000 /* Virtual IO = 0xfec00000 */
>> +#define io_v2p(va) ((va) - IO_OFFSET)
>>
>> I am not sure if these changes are right fix for the above error.
> io_v2p is define in davinci's mach/hardware.h so I believe this is what
> you should include in davinci_voicecodec.h.

Thanks. That was only required for compile testing my patch.
Does the patch look good?


--
With warm regards,
Sachin

2013-06-18 09:18:29

by Samuel Ortiz

[permalink] [raw]
Subject: Re: [PATCH Resend 1/1] mfd: davinci_voicecodec: Convert to use devm_* APIs

On Tue, Jun 18, 2013 at 02:13:48PM +0530, Sachin Kamat wrote:
> Hi Samuel,
>
> On 18 June 2013 14:10, Samuel Ortiz <[email protected]> wrote:
> > Hi Sachin,
> >
> > On Wed, Jun 12, 2013 at 01:49:42PM +0530, Sachin Kamat wrote:
> >> devm_* APIs are device managed and make code simpler.
> >>
> >> Signed-off-by: Sachin Kamat <[email protected]>
> >> Cc: Miguel Aguilar <[email protected]>
> >> ---
> >> CC'd Lee Jones
> >>
> >> Patch is based on mfd-next tree and compile tested.
> >> This driver gives following compilation error (not introduced by this patch):
> >> drivers/mfd/davinci_voicecodec.c:86:3: error: implicit declaration
> >> of function ‘io_v2p’ [-Werror=implicit-function-declaration]
> >> (dma_addr_t)(io_v2p(davinci_vc->base) + DAVINCI_VC_WFIFO);
> >>
> >> In order to test my changes I added the following to davinci_voicecodec.h file:
> >> +#define IO_OFFSET 0xfd000000 /* Virtual IO = 0xfec00000 */
> >> +#define io_v2p(va) ((va) - IO_OFFSET)
> >>
> >> I am not sure if these changes are right fix for the above error.
> > io_v2p is define in davinci's mach/hardware.h so I believe this is what
> > you should include in davinci_voicecodec.h.
>
> Thanks. That was only required for compile testing my patch.
> Does the patch look good?
Yes, but I'd appreciate if you could also fix the driver build failures
as well.

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/

2013-06-18 09:23:39

by Sachin Kamat

[permalink] [raw]
Subject: Re: [PATCH Resend 1/1] mfd: davinci_voicecodec: Convert to use devm_* APIs

On 18 June 2013 14:47, Samuel Ortiz <[email protected]> wrote:
> On Tue, Jun 18, 2013 at 02:13:48PM +0530, Sachin Kamat wrote:
>> Hi Samuel,
>>
>> On 18 June 2013 14:10, Samuel Ortiz <[email protected]> wrote:
>> > Hi Sachin,
>> >
>> > On Wed, Jun 12, 2013 at 01:49:42PM +0530, Sachin Kamat wrote:
>> >> devm_* APIs are device managed and make code simpler.
>> >>
>> >> Signed-off-by: Sachin Kamat <[email protected]>
>> >> Cc: Miguel Aguilar <[email protected]>
>> >> ---
>> >> CC'd Lee Jones
>> >>
>> >> Patch is based on mfd-next tree and compile tested.
>> >> This driver gives following compilation error (not introduced by this patch):
>> >> drivers/mfd/davinci_voicecodec.c:86:3: error: implicit declaration
>> >> of function ?io_v2p? [-Werror=implicit-function-declaration]
>> >> (dma_addr_t)(io_v2p(davinci_vc->base) + DAVINCI_VC_WFIFO);
>> >>
>> >> In order to test my changes I added the following to davinci_voicecodec.h file:
>> >> +#define IO_OFFSET 0xfd000000 /* Virtual IO = 0xfec00000 */
>> >> +#define io_v2p(va) ((va) - IO_OFFSET)
>> >>
>> >> I am not sure if these changes are right fix for the above error.
>> > io_v2p is define in davinci's mach/hardware.h so I believe this is what
>> > you should include in davinci_voicecodec.h.
>>
>> Thanks. That was only required for compile testing my patch.
>> Does the patch look good?
> Yes, but I'd appreciate if you could also fix the driver build failures
> as well.

OK. I will send the fix for build error as well.
However I was wondering if it is ok to include <mach/*> header
considering multiplatform support.
I am unsure in this case, hence just asking.

--
With warm regards,
Sachin