linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] iio: dac: stm32-dac: improve reset controller use
@ 2020-01-13 13:14 Fabrice Gasnier
  2020-01-13 13:14 ` [PATCH 1/2] iio: dac: stm32-dac: use reset controller only at probe time Fabrice Gasnier
  2020-01-13 13:14 ` [PATCH 2/2] iio: dac: stm32-dac: better handle reset controller failures Fabrice Gasnier
  0 siblings, 2 replies; 5+ messages in thread
From: Fabrice Gasnier @ 2020-01-13 13:14 UTC (permalink / raw)
  To: jic23
  Cc: linux-arm-kernel, linux-kernel, mcoquelin.stm32,
	alexandre.torgue, fabrice.gasnier, olivier.moysan, linux-iio,
	lars, knaack.h, pmeerw, linux-stm32, etienne.carriere

This patch series does some cleanup on driver private struct (precursor patch).
Then it better uses the reset controller API to propagate errors to the caller.

Etienne Carriere (2):
  iio: dac: stm32-dac: use reset controller only at probe time
  iio: dac: stm32-dac: better handle reset controller failures

 drivers/iio/dac/stm32-dac-core.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

-- 
2.7.4


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

* [PATCH 1/2] iio: dac: stm32-dac: use reset controller only at probe time
  2020-01-13 13:14 [PATCH 0/2] iio: dac: stm32-dac: improve reset controller use Fabrice Gasnier
@ 2020-01-13 13:14 ` Fabrice Gasnier
  2020-01-18 14:30   ` Jonathan Cameron
  2020-01-13 13:14 ` [PATCH 2/2] iio: dac: stm32-dac: better handle reset controller failures Fabrice Gasnier
  1 sibling, 1 reply; 5+ messages in thread
From: Fabrice Gasnier @ 2020-01-13 13:14 UTC (permalink / raw)
  To: jic23
  Cc: linux-arm-kernel, linux-kernel, mcoquelin.stm32,
	alexandre.torgue, fabrice.gasnier, olivier.moysan, linux-iio,
	lars, knaack.h, pmeerw, linux-stm32, etienne.carriere

From: Etienne Carriere <etienne.carriere@st.com>

This change removes the reset controller reference from the local
DAC instance since it is used only at probe time.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
---
 drivers/iio/dac/stm32-dac-core.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/stm32-dac-core.c b/drivers/iio/dac/stm32-dac-core.c
index 9e6b4cd..4d93446 100644
--- a/drivers/iio/dac/stm32-dac-core.c
+++ b/drivers/iio/dac/stm32-dac-core.c
@@ -20,13 +20,11 @@
 /**
  * struct stm32_dac_priv - stm32 DAC core private data
  * @pclk:		peripheral clock common for all DACs
- * @rst:		peripheral reset control
  * @vref:		regulator reference
  * @common:		Common data for all DAC instances
  */
 struct stm32_dac_priv {
 	struct clk *pclk;
-	struct reset_control *rst;
 	struct regulator *vref;
 	struct stm32_dac_common common;
 };
@@ -94,6 +92,7 @@ static int stm32_dac_probe(struct platform_device *pdev)
 	struct regmap *regmap;
 	struct resource *res;
 	void __iomem *mmio;
+	struct reset_control *rst;
 	int ret;
 
 	if (!dev->of_node)
@@ -148,11 +147,11 @@ static int stm32_dac_probe(struct platform_device *pdev)
 	priv->common.vref_mv = ret / 1000;
 	dev_dbg(dev, "vref+=%dmV\n", priv->common.vref_mv);
 
-	priv->rst = devm_reset_control_get_exclusive(dev, NULL);
-	if (!IS_ERR(priv->rst)) {
-		reset_control_assert(priv->rst);
+	rst = devm_reset_control_get_exclusive(dev, NULL);
+	if (!IS_ERR(rst)) {
+		reset_control_assert(rst);
 		udelay(2);
-		reset_control_deassert(priv->rst);
+		reset_control_deassert(rst);
 	}
 
 	if (cfg && cfg->has_hfsel) {
-- 
2.7.4


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

* [PATCH 2/2] iio: dac: stm32-dac: better handle reset controller failures
  2020-01-13 13:14 [PATCH 0/2] iio: dac: stm32-dac: improve reset controller use Fabrice Gasnier
  2020-01-13 13:14 ` [PATCH 1/2] iio: dac: stm32-dac: use reset controller only at probe time Fabrice Gasnier
@ 2020-01-13 13:14 ` Fabrice Gasnier
  2020-01-18 14:32   ` Jonathan Cameron
  1 sibling, 1 reply; 5+ messages in thread
From: Fabrice Gasnier @ 2020-01-13 13:14 UTC (permalink / raw)
  To: jic23
  Cc: linux-arm-kernel, linux-kernel, mcoquelin.stm32,
	alexandre.torgue, fabrice.gasnier, olivier.moysan, linux-iio,
	lars, knaack.h, pmeerw, linux-stm32, etienne.carriere

From: Etienne Carriere <etienne.carriere@st.com>

Use devm_reset_control_get_optional_exclusive() instead of
devm_reset_control_get_exclusive() as reset controller is optional.

Nevertheless if reset controller is expected but reports an
error, propagate the error code to the caller. In such case
a nice error trace is emitted unless we're deferring the probe
operation.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
---
 drivers/iio/dac/stm32-dac-core.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/dac/stm32-dac-core.c b/drivers/iio/dac/stm32-dac-core.c
index 4d93446..7e5809b 100644
--- a/drivers/iio/dac/stm32-dac-core.c
+++ b/drivers/iio/dac/stm32-dac-core.c
@@ -147,8 +147,16 @@ static int stm32_dac_probe(struct platform_device *pdev)
 	priv->common.vref_mv = ret / 1000;
 	dev_dbg(dev, "vref+=%dmV\n", priv->common.vref_mv);
 
-	rst = devm_reset_control_get_exclusive(dev, NULL);
-	if (!IS_ERR(rst)) {
+	rst = devm_reset_control_get_optional_exclusive(dev, NULL);
+	if (rst) {
+		if (IS_ERR(rst)) {
+			ret = PTR_ERR(rst);
+			if (ret != -EPROBE_DEFER)
+				dev_err(dev, "reset get failed, %d\n", ret);
+
+			goto err_hw_stop;
+		}
+
 		reset_control_assert(rst);
 		udelay(2);
 		reset_control_deassert(rst);
-- 
2.7.4


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

* Re: [PATCH 1/2] iio: dac: stm32-dac: use reset controller only at probe time
  2020-01-13 13:14 ` [PATCH 1/2] iio: dac: stm32-dac: use reset controller only at probe time Fabrice Gasnier
@ 2020-01-18 14:30   ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2020-01-18 14:30 UTC (permalink / raw)
  To: Fabrice Gasnier
  Cc: linux-arm-kernel, linux-kernel, mcoquelin.stm32,
	alexandre.torgue, olivier.moysan, linux-iio, lars, knaack.h,
	pmeerw, linux-stm32, etienne.carriere

On Mon, 13 Jan 2020 14:14:25 +0100
Fabrice Gasnier <fabrice.gasnier@st.com> wrote:

> From: Etienne Carriere <etienne.carriere@st.com>
> 
> This change removes the reset controller reference from the local
> DAC instance since it is used only at probe time.
> 
> Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Makes sense.

Applied to the togreg branch of iio.git and pushed out as testing
to let those autobuilders poke at it for a few hours.

Thanks,

Jonathan

> ---
>  drivers/iio/dac/stm32-dac-core.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/dac/stm32-dac-core.c b/drivers/iio/dac/stm32-dac-core.c
> index 9e6b4cd..4d93446 100644
> --- a/drivers/iio/dac/stm32-dac-core.c
> +++ b/drivers/iio/dac/stm32-dac-core.c
> @@ -20,13 +20,11 @@
>  /**
>   * struct stm32_dac_priv - stm32 DAC core private data
>   * @pclk:		peripheral clock common for all DACs
> - * @rst:		peripheral reset control
>   * @vref:		regulator reference
>   * @common:		Common data for all DAC instances
>   */
>  struct stm32_dac_priv {
>  	struct clk *pclk;
> -	struct reset_control *rst;
>  	struct regulator *vref;
>  	struct stm32_dac_common common;
>  };
> @@ -94,6 +92,7 @@ static int stm32_dac_probe(struct platform_device *pdev)
>  	struct regmap *regmap;
>  	struct resource *res;
>  	void __iomem *mmio;
> +	struct reset_control *rst;
>  	int ret;
>  
>  	if (!dev->of_node)
> @@ -148,11 +147,11 @@ static int stm32_dac_probe(struct platform_device *pdev)
>  	priv->common.vref_mv = ret / 1000;
>  	dev_dbg(dev, "vref+=%dmV\n", priv->common.vref_mv);
>  
> -	priv->rst = devm_reset_control_get_exclusive(dev, NULL);
> -	if (!IS_ERR(priv->rst)) {
> -		reset_control_assert(priv->rst);
> +	rst = devm_reset_control_get_exclusive(dev, NULL);
> +	if (!IS_ERR(rst)) {
> +		reset_control_assert(rst);
>  		udelay(2);
> -		reset_control_deassert(priv->rst);
> +		reset_control_deassert(rst);
>  	}
>  
>  	if (cfg && cfg->has_hfsel) {


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

* Re: [PATCH 2/2] iio: dac: stm32-dac: better handle reset controller failures
  2020-01-13 13:14 ` [PATCH 2/2] iio: dac: stm32-dac: better handle reset controller failures Fabrice Gasnier
@ 2020-01-18 14:32   ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2020-01-18 14:32 UTC (permalink / raw)
  To: Fabrice Gasnier
  Cc: linux-arm-kernel, linux-kernel, mcoquelin.stm32,
	alexandre.torgue, olivier.moysan, linux-iio, lars, knaack.h,
	pmeerw, linux-stm32, etienne.carriere

On Mon, 13 Jan 2020 14:14:26 +0100
Fabrice Gasnier <fabrice.gasnier@st.com> wrote:

> From: Etienne Carriere <etienne.carriere@st.com>
> 
> Use devm_reset_control_get_optional_exclusive() instead of
> devm_reset_control_get_exclusive() as reset controller is optional.
> 
> Nevertheless if reset controller is expected but reports an
> error, propagate the error code to the caller. In such case
> a nice error trace is emitted unless we're deferring the probe
> operation.
> 
> Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan

> ---
>  drivers/iio/dac/stm32-dac-core.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/dac/stm32-dac-core.c b/drivers/iio/dac/stm32-dac-core.c
> index 4d93446..7e5809b 100644
> --- a/drivers/iio/dac/stm32-dac-core.c
> +++ b/drivers/iio/dac/stm32-dac-core.c
> @@ -147,8 +147,16 @@ static int stm32_dac_probe(struct platform_device *pdev)
>  	priv->common.vref_mv = ret / 1000;
>  	dev_dbg(dev, "vref+=%dmV\n", priv->common.vref_mv);
>  
> -	rst = devm_reset_control_get_exclusive(dev, NULL);
> -	if (!IS_ERR(rst)) {
> +	rst = devm_reset_control_get_optional_exclusive(dev, NULL);
> +	if (rst) {
> +		if (IS_ERR(rst)) {
> +			ret = PTR_ERR(rst);
> +			if (ret != -EPROBE_DEFER)
> +				dev_err(dev, "reset get failed, %d\n", ret);
> +
> +			goto err_hw_stop;
> +		}
> +
>  		reset_control_assert(rst);
>  		udelay(2);
>  		reset_control_deassert(rst);


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

end of thread, other threads:[~2020-01-18 14:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-13 13:14 [PATCH 0/2] iio: dac: stm32-dac: improve reset controller use Fabrice Gasnier
2020-01-13 13:14 ` [PATCH 1/2] iio: dac: stm32-dac: use reset controller only at probe time Fabrice Gasnier
2020-01-18 14:30   ` Jonathan Cameron
2020-01-13 13:14 ` [PATCH 2/2] iio: dac: stm32-dac: better handle reset controller failures Fabrice Gasnier
2020-01-18 14:32   ` Jonathan Cameron

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