mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Georgi Djakov <georgi.djakov@linaro.org>, linux-pm@vger.kernel.org
Cc: bjorn.andersson@linaro.org, agross@kernel.org,
	evgreen@chromium.org, daidavid1@codeaurora.org,
	masneyb@onstation.org, sibis@codeaurora.org,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 5/5] interconnect: qcom: Use the new common helper for node removal
Date: Thu, 28 Nov 2019 16:43:00 +0300	[thread overview]
Message-ID: <5686a003-d72f-7a20-4851-9ebb3d2e9b20@gmail.com> (raw)
In-Reply-To: <20191128133435.25667-5-georgi.djakov@linaro.org>

28.11.2019 16:34, Georgi Djakov пишет:
> There is a new helper function for removing all nodes. Let's use it instead
> of duplicating the code.
> 
> In addition to the above, instead of duplicating the code, simplify the
> probe function error path by calling driver removal function directly.
> 
> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
> ---
>  drivers/interconnect/qcom/msm8974.c | 40 ++++++++++-------------------
>  drivers/interconnect/qcom/qcs404.c  | 31 ++++++++--------------
>  drivers/interconnect/qcom/sdm845.c  | 29 +++++++--------------
>  3 files changed, 33 insertions(+), 67 deletions(-)
> 
> diff --git a/drivers/interconnect/qcom/msm8974.c b/drivers/interconnect/qcom/msm8974.c
> index 0a1a8ba6afa7..8823dce811c3 100644
> --- a/drivers/interconnect/qcom/msm8974.c
> +++ b/drivers/interconnect/qcom/msm8974.c
> @@ -644,6 +644,15 @@ static int msm8974_icc_set(struct icc_node *src, struct icc_node *dst)
>  	return 0;
>  }
>  
> +static int msm8974_icc_remove(struct platform_device *pdev)
> +{
> +	struct msm8974_icc_provider *qp = platform_get_drvdata(pdev);
> +
> +	icc_nodes_remove(&qp->provider);
> +	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
> +	return icc_provider_del(&qp->provider);
> +}
> +
>  static int msm8974_icc_probe(struct platform_device *pdev)
>  {
>  	const struct msm8974_icc_desc *desc;
> @@ -701,7 +710,8 @@ static int msm8974_icc_probe(struct platform_device *pdev)
>  	ret = icc_provider_add(provider);
>  	if (ret) {
>  		dev_err(dev, "error adding interconnect provider: %d\n", ret);
> -		goto err_disable_clks;
> +		clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
> +		return ret;
>  	}
>  
>  	for (i = 0; i < num_nodes; i++) {
> @@ -710,7 +720,7 @@ static int msm8974_icc_probe(struct platform_device *pdev)
>  		node = icc_node_create(qnodes[i]->id);
>  		if (IS_ERR(node)) {
>  			ret = PTR_ERR(node);
> -			goto err_del_icc;
> +			goto err;
>  		}
>  
>  		node->name = qnodes[i]->name;
> @@ -731,34 +741,12 @@ static int msm8974_icc_probe(struct platform_device *pdev)
>  
>  	return 0;
>  
> -err_del_icc:
> -	list_for_each_entry_safe(node, &provider->nodes, node_list) {
> -		icc_node_del(node);
> -		icc_node_destroy(node->id);
> -	}
> -	icc_provider_del(provider);
> -
> -err_disable_clks:
> -	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
> +err:
> +	msm8974_icc_remove(pdev);
>  
>  	return ret;
>  }
>  
> -static int msm8974_icc_remove(struct platform_device *pdev)
> -{
> -	struct msm8974_icc_provider *qp = platform_get_drvdata(pdev);
> -	struct icc_provider *provider = &qp->provider;
> -	struct icc_node *n;
> -
> -	list_for_each_entry_safe(n, &provider->nodes, node_list) {
> -		icc_node_del(n);
> -		icc_node_destroy(n->id);
> -	}
> -	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
> -
> -	return icc_provider_del(provider);
> -}
> -
>  static const struct of_device_id msm8974_noc_of_match[] = {
>  	{ .compatible = "qcom,msm8974-bimc", .data = &msm8974_bimc},
>  	{ .compatible = "qcom,msm8974-cnoc", .data = &msm8974_cnoc},
> diff --git a/drivers/interconnect/qcom/qcs404.c b/drivers/interconnect/qcom/qcs404.c
> index d2b455021416..a4c6ba715f61 100644
> --- a/drivers/interconnect/qcom/qcs404.c
> +++ b/drivers/interconnect/qcom/qcs404.c
> @@ -406,6 +406,15 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
>  	return 0;
>  }
>  
> +static int qnoc_remove(struct platform_device *pdev)
> +{
> +	struct qcom_icc_provider *qp = platform_get_drvdata(pdev);
> +
> +	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
> +	icc_nodes_remove(&qp->provider);
> +	return icc_provider_del(&qp->provider);
> +}
> +
>  static int qnoc_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -494,31 +503,11 @@ static int qnoc_probe(struct platform_device *pdev)
>  
>  	return 0;
>  err:
> -	list_for_each_entry_safe(node, &provider->nodes, node_list) {
> -		icc_node_del(node);
> -		icc_node_destroy(node->id);
> -	}
> -	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
> -	icc_provider_del(provider);
> +	qnoc_remove(pdev);
>  
>  	return ret;
>  }
>  
> -static int qnoc_remove(struct platform_device *pdev)
> -{
> -	struct qcom_icc_provider *qp = platform_get_drvdata(pdev);
> -	struct icc_provider *provider = &qp->provider;
> -	struct icc_node *n;
> -
> -	list_for_each_entry_safe(n, &provider->nodes, node_list) {
> -		icc_node_del(n);
> -		icc_node_destroy(n->id);
> -	}
> -	clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks);
> -
> -	return icc_provider_del(provider);
> -}
> -
>  static const struct of_device_id qcs404_noc_of_match[] = {
>  	{ .compatible = "qcom,qcs404-bimc", .data = &qcs404_bimc },
>  	{ .compatible = "qcom,qcs404-pcnoc", .data = &qcs404_pcnoc },
> diff --git a/drivers/interconnect/qcom/sdm845.c b/drivers/interconnect/qcom/sdm845.c
> index 924c2d056d85..2b8f13e78471 100644
> --- a/drivers/interconnect/qcom/sdm845.c
> +++ b/drivers/interconnect/qcom/sdm845.c
> @@ -768,6 +768,14 @@ static int cmp_vcd(const void *_l, const void *_r)
>  		return 1;
>  }
>  
> +static int qnoc_remove(struct platform_device *pdev)
> +{
> +	struct qcom_icc_provider *qp = platform_get_drvdata(pdev);
> +
> +	icc_nodes_remove(&qp->provider);
> +	return icc_provider_del(&qp->provider);
> +}
> +
>  static int qnoc_probe(struct platform_device *pdev)
>  {
>  	const struct qcom_icc_desc *desc;
> @@ -855,29 +863,10 @@ static int qnoc_probe(struct platform_device *pdev)
>  
>  	return ret;
>  err:
> -	list_for_each_entry(node, &provider->nodes, node_list) {
> -		icc_node_del(node);
> -		icc_node_destroy(node->id);
> -	}
> -
> -	icc_provider_del(provider);
> +	qnoc_remove(pdev);

This is wrong because platform_set_drvdata() is invoked at the end of
qnoc_probe(), thus platform_get_drvdata() of qnoc_remove() returns NULL
here.

>  	return ret;
>  }
>  
> -static int qnoc_remove(struct platform_device *pdev)
> -{
> -	struct qcom_icc_provider *qp = platform_get_drvdata(pdev);
> -	struct icc_provider *provider = &qp->provider;
> -	struct icc_node *n;
> -
> -	list_for_each_entry_safe(n, &provider->nodes, node_list) {
> -		icc_node_del(n);
> -		icc_node_destroy(n->id);
> -	}
> -
> -	return icc_provider_del(provider);
> -}
> -
>  static const struct of_device_id qnoc_of_match[] = {
>  	{ .compatible = "qcom,sdm845-rsc-hlos", .data = &sdm845_rsc_hlos },
>  	{ },
> 


  reply	other threads:[~2019-11-28 13:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28 13:34 [PATCH 1/5] interconnect: qcom: sdm845: Walk the list safely on " Georgi Djakov
2019-11-28 13:34 ` [PATCH 2/5] interconnect: qcom: qcs404: " Georgi Djakov
2019-11-28 13:34 ` [PATCH 3/5] interconnect: qcom: msm8974: " Georgi Djakov
2019-11-28 15:15   ` Brian Masney
2019-11-28 13:34 ` [PATCH 4/5] interconnect: Add a common helper for removing all nodes Georgi Djakov
2019-11-28 18:20   ` Bjorn Andersson
2019-11-28 13:34 ` [PATCH 5/5] interconnect: qcom: Use the new common helper for node removal Georgi Djakov
2019-11-28 13:43   ` Dmitry Osipenko [this message]
2019-11-28 13:52     ` Georgi Djakov
2019-11-28 18:14 ` [PATCH 1/5] interconnect: qcom: sdm845: Walk the list safely on " Bjorn Andersson

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=5686a003-d72f-7a20-4851-9ebb3d2e9b20@gmail.com \
    --to=digetx@gmail.com \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=daidavid1@codeaurora.org \
    --cc=evgreen@chromium.org \
    --cc=georgi.djakov@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=masneyb@onstation.org \
    --cc=sibis@codeaurora.org \
    /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

Powered by JetHome