linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] serial: amba-pl01x: Clean up patches
@ 2014-06-23  5:59 Tushar Behera
  2014-06-23  5:59 ` [PATCH 1/2] serial: amba-pl011: Remove redundant label Tushar Behera
  2014-06-23  5:59 ` [PATCH 2/2] serial: amba-pl010: Use devres APIs Tushar Behera
  0 siblings, 2 replies; 6+ messages in thread
From: Tushar Behera @ 2014-06-23  5:59 UTC (permalink / raw)
  To: linux-kernel, linux-serial, jslaby, gregkh, linux; +Cc: trblinux

The patches are based next-20140620 and they have only been build
tested.

Tushar Behera (2):
  serial: amba-pl011: Simplify goto statements
  serial: amba-pl010: Use devres APIs

 drivers/tty/serial/amba-pl010.c |   46 ++++++++++++++-------------------------
 drivers/tty/serial/amba-pl011.c |   30 +++++++++----------------
 2 files changed, 26 insertions(+), 50 deletions(-)

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] serial: amba-pl011: Remove redundant label
  2014-06-23  5:59 [PATCH 0/2] serial: amba-pl01x: Clean up patches Tushar Behera
@ 2014-06-23  5:59 ` Tushar Behera
  2014-06-23 12:37   ` Daniel Thompson
  2014-06-23  5:59 ` [PATCH 2/2] serial: amba-pl010: Use devres APIs Tushar Behera
  1 sibling, 1 reply; 6+ messages in thread
From: Tushar Behera @ 2014-06-23  5:59 UTC (permalink / raw)
  To: linux-kernel, linux-serial, jslaby, gregkh, linux; +Cc: trblinux

The label 'out' is only used to return the error code. We can return the
error code directly and remove 'out' label.

Signed-off-by: Tushar Behera <tushar.b@samsung.com>
---
 drivers/tty/serial/amba-pl011.c |   30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 0e26dcb..8572f2a 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -1484,7 +1484,7 @@ static int pl011_hwinit(struct uart_port *port)
 	 */
 	retval = clk_prepare_enable(uap->clk);
 	if (retval)
-		goto out;
+		return retval;
 
 	uap->port.uartclk = clk_get_rate(uap->clk);
 
@@ -1507,8 +1507,6 @@ static int pl011_hwinit(struct uart_port *port)
 			plat->init();
 	}
 	return 0;
- out:
-	return retval;
 }
 
 static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h)
@@ -2131,32 +2129,24 @@ static int pl011_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 = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
 			   GFP_KERNEL);
-	if (uap == NULL) {
-		ret = -ENOMEM;
-		goto out;
-	}
+	if (uap == NULL)
+		return -ENOMEM;
 
 	i = pl011_probe_dt_alias(i, &dev->dev);
 
 	base = devm_ioremap(&dev->dev, dev->res.start,
 			    resource_size(&dev->res));
-	if (!base) {
-		ret = -ENOMEM;
-		goto out;
-	}
+	if (!base)
+		return -ENOMEM;
 
 	uap->clk = devm_clk_get(&dev->dev, NULL);
-	if (IS_ERR(uap->clk)) {
-		ret = PTR_ERR(uap->clk);
-		goto out;
-	}
+	if (IS_ERR(uap->clk))
+		return PTR_ERR(uap->clk);
 
 	uap->vendor = vendor;
 	uap->lcrh_rx = vendor->lcrh_rx;
@@ -2198,7 +2188,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
 		uart_unregister_driver(&amba_reg);
 		pl011_dma_remove(uap);
 	}
- out:
+
 	return ret;
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] serial: amba-pl010: Use devres APIs
  2014-06-23  5:59 [PATCH 0/2] serial: amba-pl01x: Clean up patches Tushar Behera
  2014-06-23  5:59 ` [PATCH 1/2] serial: amba-pl011: Remove redundant label Tushar Behera
@ 2014-06-23  5:59 ` Tushar Behera
  2014-06-23 12:46   ` Daniel Thompson
  1 sibling, 1 reply; 6+ messages in thread
From: Tushar Behera @ 2014-06-23  5:59 UTC (permalink / raw)
  To: linux-kernel, linux-serial, jslaby, gregkh, linux; +Cc: trblinux

Migrating to use devres managed APIs devm_kzalloc, devm_ioremap and
devm_clk_get.

Signed-off-by: Tushar Behera <tushar.b@samsung.com>
---
 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 <linux/amba/serial.h>
 #include <linux/clk.h>
 #include <linux/slab.h>
+#include <linux/io.h>
 
 #include <asm/io.h>
 
@@ -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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] serial: amba-pl011: Remove redundant label
  2014-06-23  5:59 ` [PATCH 1/2] serial: amba-pl011: Remove redundant label Tushar Behera
@ 2014-06-23 12:37   ` Daniel Thompson
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Thompson @ 2014-06-23 12:37 UTC (permalink / raw)
  To: Tushar Behera, linux-kernel, linux-serial, jslaby, gregkh, linux; +Cc: trblinux

On 23/06/14 06:59, Tushar Behera wrote:
> The label 'out' is only used to return the error code. We can return the
> error code directly and remove 'out' label.
> 
> Signed-off-by: Tushar Behera <tushar.b@samsung.com>
> ---
>  drivers/tty/serial/amba-pl011.c |   30 ++++++++++--------------------
>  1 file changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> index 0e26dcb..8572f2a 100644
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -1484,7 +1484,7 @@ static int pl011_hwinit(struct uart_port *port)
>  	 */
>  	retval = clk_prepare_enable(uap->clk);
>  	if (retval)
> -		goto out;
> +		return retval;
>  
>  	uap->port.uartclk = clk_get_rate(uap->clk);
>  
> @@ -1507,8 +1507,6 @@ static int pl011_hwinit(struct uart_port *port)
>  			plat->init();
>  	}
>  	return 0;
> - out:
> -	return retval;
>  }
>  
>  static void pl011_write_lcr_h(struct uart_amba_port *uap, unsigned int lcr_h)
> @@ -2131,32 +2129,24 @@ static int pl011_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 = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
>  			   GFP_KERNEL);
> -	if (uap == NULL) {
> -		ret = -ENOMEM;
> -		goto out;
> -	}
> +	if (uap == NULL)
> +		return -ENOMEM;
>  
>  	i = pl011_probe_dt_alias(i, &dev->dev);
>  
>  	base = devm_ioremap(&dev->dev, dev->res.start,
>  			    resource_size(&dev->res));
> -	if (!base) {
> -		ret = -ENOMEM;
> -		goto out;
> -	}
> +	if (!base)
> +		return -ENOMEM;
>  
>  	uap->clk = devm_clk_get(&dev->dev, NULL);
> -	if (IS_ERR(uap->clk)) {
> -		ret = PTR_ERR(uap->clk);
> -		goto out;
> -	}
> +	if (IS_ERR(uap->clk))
> +		return PTR_ERR(uap->clk);
>  
>  	uap->vendor = vendor;
>  	uap->lcrh_rx = vendor->lcrh_rx;
> @@ -2198,7 +2188,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
>  		uart_unregister_driver(&amba_reg);
>  		pl011_dma_remove(uap);
>  	}
> - out:
> +
>  	return ret;
>  }

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] serial: amba-pl010: Use devres APIs
  2014-06-23  5:59 ` [PATCH 2/2] serial: amba-pl010: Use devres APIs Tushar Behera
@ 2014-06-23 12:46   ` Daniel Thompson
  2014-06-26  9:37     ` Tushar Behera
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Thompson @ 2014-06-23 12:46 UTC (permalink / raw)
  To: Tushar Behera, linux-kernel, linux-serial, jslaby, gregkh, linux; +Cc: trblinux

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 <tushar.b@samsung.com>
> ---
>  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 <linux/amba/serial.h>
>  #include <linux/clk.h>
>  #include <linux/slab.h>
> +#include <linux/io.h>
>  
>  #include <asm/io.h>

Adding <linux/io.h> makes including <asm/io.h> 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 <daniel.thompson@linaro.org>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] serial: amba-pl010: Use devres APIs
  2014-06-23 12:46   ` Daniel Thompson
@ 2014-06-26  9:37     ` Tushar Behera
  0 siblings, 0 replies; 6+ messages in thread
From: Tushar Behera @ 2014-06-26  9:37 UTC (permalink / raw)
  To: Daniel Thompson, Tushar Behera, linux-kernel, linux-serial,
	jslaby, gregkh, linux

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 <tushar.b@samsung.com>
>> ---
>>  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 <linux/amba/serial.h>
>>  #include <linux/clk.h>
>>  #include <linux/slab.h>
>> +#include <linux/io.h>
>>  
>>  #include <asm/io.h>
> 
> Adding <linux/io.h> makes including <asm/io.h> redundant.
> 

Okay, I will remove the <asm/io.h> 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 <daniel.thompson@linaro.org>
> 

Thanks for reviewing.

-- 
Tushar Behera

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-26  9:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-23  5:59 [PATCH 0/2] serial: amba-pl01x: Clean up patches Tushar Behera
2014-06-23  5:59 ` [PATCH 1/2] serial: amba-pl011: Remove redundant label Tushar Behera
2014-06-23 12:37   ` Daniel Thompson
2014-06-23  5:59 ` [PATCH 2/2] serial: amba-pl010: Use devres APIs Tushar Behera
2014-06-23 12:46   ` Daniel Thompson
2014-06-26  9:37     ` Tushar Behera

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).