[PATCH] tty: atmel_serial: Use devm_platform_ioremap_resource()

Mihai Sain posted 1 patch 2 weeks, 4 days ago
drivers/tty/serial/atmel_serial.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
[PATCH] tty: atmel_serial: Use devm_platform_ioremap_resource()
Posted by Mihai Sain 2 weeks, 4 days ago
Simplify the request port function by using a single call
to devm_platform_ioremap_resource().

This will also enhance the printing from /proc/iomem:

cat /proc/iomem | grep flexcom ; cat /proc/iomem | grep serial

f0004000-f00041ff : f0004000.flexcom flexcom@f0004000
f8020000-f80201ff : f8020000.flexcom flexcom@f8020000
f0004200-f00043ff : f0004200.serial serial@200
f8020200-f80203ff : f8020200.serial serial@200
fffff200-fffff3ff : fffff200.serial serial@fffff200

Signed-off-by: Mihai Sain <mihai.sain@microchip.com>
---
 drivers/tty/serial/atmel_serial.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 09b246c9e389..e1107f14ec98 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -2419,17 +2419,11 @@ static void atmel_release_port(struct uart_port *port)
 static int atmel_request_port(struct uart_port *port)
 {
 	struct platform_device *mpdev = to_platform_device(port->dev->parent);
-	int size = resource_size(mpdev->resource);
-
-	if (!request_mem_region(port->mapbase, size, "atmel_serial"))
-		return -EBUSY;
 
 	if (port->flags & UPF_IOREMAP) {
-		port->membase = ioremap(port->mapbase, size);
-		if (port->membase == NULL) {
-			release_mem_region(port->mapbase, size);
-			return -ENOMEM;
-		}
+		port->membase = devm_platform_ioremap_resource(mpdev, 0);
+		if (IS_ERR(port->membase))
+			return PTR_ERR(port->membase);
 	}
 
 	return 0;

base-commit: 2e1b3cc9d7f790145a80cb705b168f05dab65df2
-- 
2.47.0
Re: [PATCH] tty: atmel_serial: Use devm_platform_ioremap_resource()
Posted by Hari.PrasathGE@microchip.com 2 weeks, 4 days ago

On 11/5/24 6:49 PM, Mihai Sain wrote:
> Simplify the request port function by using a single call
> to devm_platform_ioremap_resource().
> 
> This will also enhance the printing from /proc/iomem:
> 

Thanks Mihai.

Reviewed-by: Hari Prasath Gujulan Elango <hari.prasathge@microchip.com>


> cat /proc/iomem | grep flexcom ; cat /proc/iomem | grep serial
> 
> f0004000-f00041ff : f0004000.flexcom flexcom@f0004000
> f8020000-f80201ff : f8020000.flexcom flexcom@f8020000
> f0004200-f00043ff : f0004200.serial serial@200
> f8020200-f80203ff : f8020200.serial serial@200
> fffff200-fffff3ff : fffff200.serial serial@fffff200
> 
> Signed-off-by: Mihai Sain <mihai.sain@microchip.com>
> ---
>   drivers/tty/serial/atmel_serial.c | 12 +++---------
>   1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 09b246c9e389..e1107f14ec98 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -2419,17 +2419,11 @@ static void atmel_release_port(struct uart_port *port)
>   static int atmel_request_port(struct uart_port *port)
>   {
>   	struct platform_device *mpdev = to_platform_device(port->dev->parent);
> -	int size = resource_size(mpdev->resource);
> -
> -	if (!request_mem_region(port->mapbase, size, "atmel_serial"))
> -		return -EBUSY;
>   
>   	if (port->flags & UPF_IOREMAP) {
> -		port->membase = ioremap(port->mapbase, size);
> -		if (port->membase == NULL) {
> -			release_mem_region(port->mapbase, size);
> -			return -ENOMEM;
> -		}
> +		port->membase = devm_platform_ioremap_resource(mpdev, 0);
> +		if (IS_ERR(port->membase))
> +			return PTR_ERR(port->membase);
>   	}
>   
>   	return 0;
> 
> base-commit: 2e1b3cc9d7f790145a80cb705b168f05dab65df2
Re: [PATCH] tty: atmel_serial: Use devm_platform_ioremap_resource()
Posted by Andrei Simion 2 weeks, 4 days ago
On 05.11.2024 15:19, Mihai Sain wrote:
> Simplify the request port function by using a single call
> to devm_platform_ioremap_resource().
> 
> This will also enhance the printing from /proc/iomem:
> 
> cat /proc/iomem | grep flexcom ; cat /proc/iomem | grep serial
> 
> f0004000-f00041ff : f0004000.flexcom flexcom@f0004000
> f8020000-f80201ff : f8020000.flexcom flexcom@f8020000
> f0004200-f00043ff : f0004200.serial serial@200
> f8020200-f80203ff : f8020200.serial serial@200
> fffff200-fffff3ff : fffff200.serial serial@fffff200
> 
> Signed-off-by: Mihai Sain <mihai.sain@microchip.com>

Hi,

Tested-by: Andrei Simion <andrei.simion@microchip.com>

Best Regards,
Andrei

> ---
>  drivers/tty/serial/atmel_serial.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 09b246c9e389..e1107f14ec98 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -2419,17 +2419,11 @@ static void atmel_release_port(struct uart_port *port)
>  static int atmel_request_port(struct uart_port *port)
>  {
>  	struct platform_device *mpdev = to_platform_device(port->dev->parent);
> -	int size = resource_size(mpdev->resource);
> -
> -	if (!request_mem_region(port->mapbase, size, "atmel_serial"))
> -		return -EBUSY;
>  
>  	if (port->flags & UPF_IOREMAP) {
> -		port->membase = ioremap(port->mapbase, size);
> -		if (port->membase == NULL) {
> -			release_mem_region(port->mapbase, size);
> -			return -ENOMEM;
> -		}
> +		port->membase = devm_platform_ioremap_resource(mpdev, 0);
> +		if (IS_ERR(port->membase))
> +			return PTR_ERR(port->membase);
>  	}
>  
>  	return 0;
> 
> base-commit: 2e1b3cc9d7f790145a80cb705b168f05dab65df2