Re: [PATCH 2/2] serial: amba-pl010: Use devres APIs

2014-06-26 Thread Tushar Behera
On 06/23/2014 06:16 PM, Daniel Thompson wrote:
> On 23/06/14 06:59, Tushar Behera wrote:
>> Migrating to use devres managed APIs devm_kzalloc, devm_ioremap and
>> devm_clk_get.
>>
>> Signed-off-by: Tushar Behera 
>> ---
>>  drivers/tty/serial/amba-pl010.c |   46 
>> ++-
>>  1 file changed, 16 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/tty/serial/amba-pl010.c 
>> b/drivers/tty/serial/amba-pl010.c
>> index 971af1e..af8deba 100644
>> --- a/drivers/tty/serial/amba-pl010.c
>> +++ b/drivers/tty/serial/amba-pl010.c
>> @@ -46,6 +46,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  
>>  #include 
> 
> Adding  makes including  redundant.
> 

Okay, I will remove the  in next iteration.

> 
>> @@ -688,28 +689,22 @@ static int pl010_probe(struct amba_device *dev, const 
>> struct amba_id *id)
>>  if (amba_ports[i] == NULL)
>>  break;
>>  
>> -if (i == ARRAY_SIZE(amba_ports)) {
>> -ret = -EBUSY;
>> -goto out;
>> -}
>> +if (i == ARRAY_SIZE(amba_ports))
>> +return -EBUSY;
>>  
>> -uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
>> -if (!uap) {
>> -ret = -ENOMEM;
>> -goto out;
>> -}
>> +uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
>> +   GFP_KERNEL);
>> +if (!uap)
>> +return -ENOMEM;
>>  
>> -base = ioremap(dev->res.start, resource_size(&dev->res));
>> -if (!base) {
>> -ret = -ENOMEM;
>> -goto free;
>> -}
>> +base = devm_ioremap(&dev->dev, dev->res.start,
>> +resource_size(&dev->res));
>> +if (!base)
>> +return -ENOMEM;
>>  
>> -uap->clk = clk_get(&dev->dev, NULL);
>> -if (IS_ERR(uap->clk)) {
>> -ret = PTR_ERR(uap->clk);
>> -goto unmap;
>> -}
>> +uap->clk = devm_clk_get(&dev->dev, NULL);
>> +if (IS_ERR(uap->clk))
>> +return PTR_ERR(uap->clk);
>>  
>>  uap->port.dev = &dev->dev;
>>  uap->port.mapbase = dev->res.start;
>> @@ -727,15 +722,9 @@ static int pl010_probe(struct amba_device *dev, const 
>> struct amba_id *id)
>>  
>>  amba_set_drvdata(dev, uap);
>>  ret = uart_add_one_port(&amba_reg, &uap->port);
>> -if (ret) {
>> +if (ret)
>>  amba_ports[i] = NULL;
>> -clk_put(uap->clk);
>> - unmap:
>> -iounmap(base);
>> - free:
>> -kfree(uap);
>> -}
>> - out:
>> +
>>  return ret;
>>  }
>>  
>> @@ -750,9 +739,6 @@ static int pl010_remove(struct amba_device *dev)
>>  if (amba_ports[i] == uap)
>>  amba_ports[i] = NULL;
>>  
>> -iounmap(uap->port.membase);
>> -clk_put(uap->clk);
>> -kfree(uap);
>>  return 0;
>>  }
> 
> Reviewed-by: Daniel Thompson 
> 

Thanks for reviewing.

-- 
Tushar Behera
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] serial: amba-pl010: Use devres APIs

2014-06-23 Thread Daniel Thompson
On 23/06/14 06:59, Tushar Behera wrote:
> Migrating to use devres managed APIs devm_kzalloc, devm_ioremap and
> devm_clk_get.
> 
> Signed-off-by: Tushar Behera 
> ---
>  drivers/tty/serial/amba-pl010.c |   46 
> ++-
>  1 file changed, 16 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
> index 971af1e..af8deba 100644
> --- a/drivers/tty/serial/amba-pl010.c
> +++ b/drivers/tty/serial/amba-pl010.c
> @@ -46,6 +46,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 

Adding  makes including  redundant.


> @@ -688,28 +689,22 @@ static int pl010_probe(struct amba_device *dev, const 
> struct amba_id *id)
>   if (amba_ports[i] == NULL)
>   break;
>  
> - if (i == ARRAY_SIZE(amba_ports)) {
> - ret = -EBUSY;
> - goto out;
> - }
> + if (i == ARRAY_SIZE(amba_ports))
> + return -EBUSY;
>  
> - uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
> - if (!uap) {
> - ret = -ENOMEM;
> - goto out;
> - }
> + uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
> +GFP_KERNEL);
> + if (!uap)
> + return -ENOMEM;
>  
> - base = ioremap(dev->res.start, resource_size(&dev->res));
> - if (!base) {
> - ret = -ENOMEM;
> - goto free;
> - }
> + base = devm_ioremap(&dev->dev, dev->res.start,
> + resource_size(&dev->res));
> + if (!base)
> + return -ENOMEM;
>  
> - uap->clk = clk_get(&dev->dev, NULL);
> - if (IS_ERR(uap->clk)) {
> - ret = PTR_ERR(uap->clk);
> - goto unmap;
> - }
> + uap->clk = devm_clk_get(&dev->dev, NULL);
> + if (IS_ERR(uap->clk))
> + return PTR_ERR(uap->clk);
>  
>   uap->port.dev = &dev->dev;
>   uap->port.mapbase = dev->res.start;
> @@ -727,15 +722,9 @@ static int pl010_probe(struct amba_device *dev, const 
> struct amba_id *id)
>  
>   amba_set_drvdata(dev, uap);
>   ret = uart_add_one_port(&amba_reg, &uap->port);
> - if (ret) {
> + if (ret)
>   amba_ports[i] = NULL;
> - clk_put(uap->clk);
> - unmap:
> - iounmap(base);
> - free:
> - kfree(uap);
> - }
> - out:
> +
>   return ret;
>  }
>  
> @@ -750,9 +739,6 @@ static int pl010_remove(struct amba_device *dev)
>   if (amba_ports[i] == uap)
>   amba_ports[i] = NULL;
>  
> - iounmap(uap->port.membase);
> - clk_put(uap->clk);
> - kfree(uap);
>   return 0;
>  }

Reviewed-by: Daniel Thompson 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] serial: amba-pl010: Use devres APIs

2014-06-22 Thread Tushar Behera
Migrating to use devres managed APIs devm_kzalloc, devm_ioremap and
devm_clk_get.

Signed-off-by: Tushar Behera 
---
 drivers/tty/serial/amba-pl010.c |   46 ++-
 1 file changed, 16 insertions(+), 30 deletions(-)

diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index 971af1e..af8deba 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -688,28 +689,22 @@ static int pl010_probe(struct amba_device *dev, const 
struct amba_id *id)
if (amba_ports[i] == NULL)
break;
 
-   if (i == ARRAY_SIZE(amba_ports)) {
-   ret = -EBUSY;
-   goto out;
-   }
+   if (i == ARRAY_SIZE(amba_ports))
+   return -EBUSY;
 
-   uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL);
-   if (!uap) {
-   ret = -ENOMEM;
-   goto out;
-   }
+   uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
+  GFP_KERNEL);
+   if (!uap)
+   return -ENOMEM;
 
-   base = ioremap(dev->res.start, resource_size(&dev->res));
-   if (!base) {
-   ret = -ENOMEM;
-   goto free;
-   }
+   base = devm_ioremap(&dev->dev, dev->res.start,
+   resource_size(&dev->res));
+   if (!base)
+   return -ENOMEM;
 
-   uap->clk = clk_get(&dev->dev, NULL);
-   if (IS_ERR(uap->clk)) {
-   ret = PTR_ERR(uap->clk);
-   goto unmap;
-   }
+   uap->clk = devm_clk_get(&dev->dev, NULL);
+   if (IS_ERR(uap->clk))
+   return PTR_ERR(uap->clk);
 
uap->port.dev = &dev->dev;
uap->port.mapbase = dev->res.start;
@@ -727,15 +722,9 @@ static int pl010_probe(struct amba_device *dev, const 
struct amba_id *id)
 
amba_set_drvdata(dev, uap);
ret = uart_add_one_port(&amba_reg, &uap->port);
-   if (ret) {
+   if (ret)
amba_ports[i] = NULL;
-   clk_put(uap->clk);
- unmap:
-   iounmap(base);
- free:
-   kfree(uap);
-   }
- out:
+
return ret;
 }
 
@@ -750,9 +739,6 @@ static int pl010_remove(struct amba_device *dev)
if (amba_ports[i] == uap)
amba_ports[i] = NULL;
 
-   iounmap(uap->port.membase);
-   clk_put(uap->clk);
-   kfree(uap);
return 0;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/