linux-samsung-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Tamseel Shams <m.shams@samsung.com>,
	krzysztof.kozlowski@canonical.com, gregkh@linuxfoundation.org
Cc: linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-kernel@vger.kernel.org, alim.akhtar@samsung.com
Subject: Re: [PATCH v3] serial: samsung: Checks the return value of function
Date: Wed, 7 Jul 2021 10:14:48 +0200	[thread overview]
Message-ID: <9fedfbde-64e3-7ebf-576a-056819a0c1e0@kernel.org> (raw)
In-Reply-To: <20210706061909.17555-1-m.shams@samsung.com>

On 06. 07. 21, 8:19, Tamseel Shams wrote:
> "uart_add_one_port" function call may fail and return
> some error code, so adding a check for return value.
> If it is returning some error code, then displaying the
> result, unregistering the driver and then returning from
> probe function with error code.
> 
> Signed-off-by: Tamseel Shams <m.shams@samsung.com>
> ---
> Changes since v1:
> 1. Added support to unregister driver on failure of "uart_add_one_port"
> function call.
> 2. Commit message updated.
> 
> Changes since v2:
> 1. Added support to unwind clocks on failure of "uart_add_one_port"
> function call.
> 
>   drivers/tty/serial/samsung_tty.c | 17 ++++++++++++++++-
>   1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
> index 9fbc61151c2e..a3f3a17fb54b 100644
> --- a/drivers/tty/serial/samsung_tty.c
> +++ b/drivers/tty/serial/samsung_tty.c
> @@ -2253,7 +2253,11 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
>   	}
>   
>   	dev_dbg(&pdev->dev, "%s: adding port\n", __func__);
> -	uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
> +	ret = uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "Failed to add uart port, err %d\n", ret);
> +		goto add_port_error;
> +	}
>   	platform_set_drvdata(pdev, &ourport->port);
>   
>   	/*
> @@ -2272,6 +2276,17 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
>   	probe_index++;
>   
>   	return 0;
> +
> +add_port_error:
> +	ourport->port.mapbase = 0;
> +	clk_disable_unprepare(ourport->clk);
> +	clk_put(ourport->clk);
> +	if (!IS_ERR(ourport->baudclk)) {
> +		clk_disable_unprepare(ourport->baudclk);
> +		clk_put(ourport->baudclk);
> +	}


LGTM, now I only wonder why s3c24xx_serial_remove() does not put clocks?

> +	uart_unregister_driver(&s3c24xx_uart_drv);
> +	return ret;
>   }
>   
>   static int s3c24xx_serial_remove(struct platform_device *dev)
> 


-- 
js
suse labs

  reply	other threads:[~2021-07-07  8:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210706061710epcas5p2c11d1bf5afb14774c4d4db93f2b83b33@epcas5p2.samsung.com>
2021-07-06  6:19 ` [PATCH v3] serial: samsung: Checks the return value of function Tamseel Shams
2021-07-07  8:14   ` Jiri Slaby [this message]
2021-07-07 15:55   ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9fedfbde-64e3-7ebf-576a-056819a0c1e0@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzysztof.kozlowski@canonical.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=m.shams@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).