All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed
@ 2021-05-21 12:36 ` Christophe JAILLET
  0 siblings, 0 replies; 10+ messages in thread
From: Christophe JAILLET @ 2021-05-21 12:36 UTC (permalink / raw)
  To: ulf.hansson, shawnguo, s.hauer, kernel, festevam, linux-imx,
	wsa+renesas, dianders, rmfrfs, cjb, linux-arm-kernel
  Cc: linux-mmc, linux-kernel, kernel-janitors, Christophe JAILLET

The 'reg_vmmc' regulator is never disabled. Neither in the error handling
of the probe, nor in the remove function.

Add a managed action to do the required clean-up before a 'regulator_put()'
call.

Fixes: 4dc5a79f1350 ("mmc: mxs-mmc: enable regulator for mmc slot")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/mmc/host/mxs-mmc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 947581de7860..b043d53dd728 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -552,6 +552,13 @@ static const struct of_device_id mxs_mmc_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
 
+static void regulator_disable_action(void *_data)
+{
+	struct regulator *regulator = _data;
+
+	regulator_disable(regulator);
+}
+
 static int mxs_mmc_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
@@ -591,6 +598,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 				"Failed to enable vmmc regulator: %d\n", ret);
 			goto out_mmc_free;
 		}
+		ret = devm_add_action_or_reset(&pdev->dev,
+					regulator_disable_action, reg_vmmc);
+		if (ret)
+			goto out_mmc_free;
 	}
 
 	ssp->clk = devm_clk_get(&pdev->dev, NULL);
-- 
2.30.2


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

* [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed
@ 2021-05-21 12:36 ` Christophe JAILLET
  0 siblings, 0 replies; 10+ messages in thread
From: Christophe JAILLET @ 2021-05-21 12:36 UTC (permalink / raw)
  To: ulf.hansson, shawnguo, s.hauer, kernel, festevam, linux-imx,
	wsa+renesas, dianders, rmfrfs, cjb, linux-arm-kernel
  Cc: linux-mmc, linux-kernel, kernel-janitors, Christophe JAILLET

The 'reg_vmmc' regulator is never disabled. Neither in the error handling
of the probe, nor in the remove function.

Add a managed action to do the required clean-up before a 'regulator_put()'
call.

Fixes: 4dc5a79f1350 ("mmc: mxs-mmc: enable regulator for mmc slot")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/mmc/host/mxs-mmc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 947581de7860..b043d53dd728 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -552,6 +552,13 @@ static const struct of_device_id mxs_mmc_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
 
+static void regulator_disable_action(void *_data)
+{
+	struct regulator *regulator = _data;
+
+	regulator_disable(regulator);
+}
+
 static int mxs_mmc_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
@@ -591,6 +598,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 				"Failed to enable vmmc regulator: %d\n", ret);
 			goto out_mmc_free;
 		}
+		ret = devm_add_action_or_reset(&pdev->dev,
+					regulator_disable_action, reg_vmmc);
+		if (ret)
+			goto out_mmc_free;
 	}
 
 	ssp->clk = devm_clk_get(&pdev->dev, NULL);
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed
  2021-05-21 12:36 ` Christophe JAILLET
@ 2021-05-24 13:59   ` Ulf Hansson
  -1 siblings, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2021-05-24 13:59 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Shawn Guo, Sascha Hauer, Sascha Hauer, Fabio Estevam,
	dl-linux-imx, Wolfram Sang, Doug Anderson, Rui Miguel Silva,
	Chris Ball, Linux ARM, linux-mmc, Linux Kernel Mailing List,
	kernel-janitors

On Fri, 21 May 2021 at 14:36, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> The 'reg_vmmc' regulator is never disabled. Neither in the error handling
> of the probe, nor in the remove function.
>
> Add a managed action to do the required clean-up before a 'regulator_put()'
> call.
>
> Fixes: 4dc5a79f1350 ("mmc: mxs-mmc: enable regulator for mmc slot")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/mmc/host/mxs-mmc.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 947581de7860..b043d53dd728 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -552,6 +552,13 @@ static const struct of_device_id mxs_mmc_dt_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
>
> +static void regulator_disable_action(void *_data)
> +{
> +       struct regulator *regulator = _data;
> +
> +       regulator_disable(regulator);
> +}
> +
>  static int mxs_mmc_probe(struct platform_device *pdev)
>  {
>         struct device_node *np = pdev->dev.of_node;
> @@ -591,6 +598,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>                                 "Failed to enable vmmc regulator: %d\n", ret);
>                         goto out_mmc_free;
>                 }
> +               ret = devm_add_action_or_reset(&pdev->dev,
> +                                       regulator_disable_action, reg_vmmc);
> +               if (ret)
> +                       goto out_mmc_free;

Even if this improves the behaviour, there is a standardized way for
how we deal with regulators for mmc.

1. Call mmc_regulator_get_supply() during probe to fetch the optional
regulator. If a regulator is found a corresponding OCR mask, in
host->ocr_avail is assigned.

2. In the ->set_ios() callback, invoke mmc_regulator_set_ocr(). This
will also set the correct voltage-level and turn on/off the regulator,
depending on the requested OCR/voltage-level.

>         }
>
>         ssp->clk = devm_clk_get(&pdev->dev, NULL);
> --
> 2.30.2
>

Kind regards
Uffe

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

* Re: [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed
@ 2021-05-24 13:59   ` Ulf Hansson
  0 siblings, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2021-05-24 13:59 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Shawn Guo, Sascha Hauer, Sascha Hauer, Fabio Estevam,
	dl-linux-imx, Wolfram Sang, Doug Anderson, Rui Miguel Silva,
	Chris Ball, Linux ARM, linux-mmc, Linux Kernel Mailing List,
	kernel-janitors

On Fri, 21 May 2021 at 14:36, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> The 'reg_vmmc' regulator is never disabled. Neither in the error handling
> of the probe, nor in the remove function.
>
> Add a managed action to do the required clean-up before a 'regulator_put()'
> call.
>
> Fixes: 4dc5a79f1350 ("mmc: mxs-mmc: enable regulator for mmc slot")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/mmc/host/mxs-mmc.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 947581de7860..b043d53dd728 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -552,6 +552,13 @@ static const struct of_device_id mxs_mmc_dt_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
>
> +static void regulator_disable_action(void *_data)
> +{
> +       struct regulator *regulator = _data;
> +
> +       regulator_disable(regulator);
> +}
> +
>  static int mxs_mmc_probe(struct platform_device *pdev)
>  {
>         struct device_node *np = pdev->dev.of_node;
> @@ -591,6 +598,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>                                 "Failed to enable vmmc regulator: %d\n", ret);
>                         goto out_mmc_free;
>                 }
> +               ret = devm_add_action_or_reset(&pdev->dev,
> +                                       regulator_disable_action, reg_vmmc);
> +               if (ret)
> +                       goto out_mmc_free;

Even if this improves the behaviour, there is a standardized way for
how we deal with regulators for mmc.

1. Call mmc_regulator_get_supply() during probe to fetch the optional
regulator. If a regulator is found a corresponding OCR mask, in
host->ocr_avail is assigned.

2. In the ->set_ios() callback, invoke mmc_regulator_set_ocr(). This
will also set the correct voltage-level and turn on/off the regulator,
depending on the requested OCR/voltage-level.

>         }
>
>         ssp->clk = devm_clk_get(&pdev->dev, NULL);
> --
> 2.30.2
>

Kind regards
Uffe

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed
  2021-05-24 13:59   ` Ulf Hansson
@ 2021-05-25 19:31     ` Christophe JAILLET
  -1 siblings, 0 replies; 10+ messages in thread
From: Christophe JAILLET @ 2021-05-25 19:31 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, Sascha Hauer, Sascha Hauer, Fabio Estevam,
	dl-linux-imx, Wolfram Sang, Doug Anderson, Rui Miguel Silva,
	Chris Ball, Linux ARM, linux-mmc, Linux Kernel Mailing List,
	kernel-janitors

Le 24/05/2021 à 15:59, Ulf Hansson a écrit :
> On Fri, 21 May 2021 at 14:36, Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
>>
>> The 'reg_vmmc' regulator is never disabled. Neither in the error handling
>> of the probe, nor in the remove function.
>>
>> Add a managed action to do the required clean-up before a 'regulator_put()'
>> call.
>>
>> Fixes: 4dc5a79f1350 ("mmc: mxs-mmc: enable regulator for mmc slot")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   drivers/mmc/host/mxs-mmc.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
>> index 947581de7860..b043d53dd728 100644
>> --- a/drivers/mmc/host/mxs-mmc.c
>> +++ b/drivers/mmc/host/mxs-mmc.c
>> @@ -552,6 +552,13 @@ static const struct of_device_id mxs_mmc_dt_ids[] = {
>>   };
>>   MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
>>
>> +static void regulator_disable_action(void *_data)
>> +{
>> +       struct regulator *regulator = _data;
>> +
>> +       regulator_disable(regulator);
>> +}
>> +
>>   static int mxs_mmc_probe(struct platform_device *pdev)
>>   {
>>          struct device_node *np = pdev->dev.of_node;
>> @@ -591,6 +598,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>>                                  "Failed to enable vmmc regulator: %d\n", ret);
>>                          goto out_mmc_free;
>>                  }
>> +               ret = devm_add_action_or_reset(&pdev->dev,
>> +                                       regulator_disable_action, reg_vmmc);
>> +               if (ret)
>> +                       goto out_mmc_free;
> 
> Even if this improves the behaviour, there is a standardized way for
> how we deal with regulators for mmc.
> 
> 1. Call mmc_regulator_get_supply() during probe to fetch the optional
> regulator. If a regulator is found a corresponding OCR mask, in
> host->ocr_avail is assigned.
> 
> 2. In the ->set_ios() callback, invoke mmc_regulator_set_ocr(). This
> will also set the correct voltage-level and turn on/off the regulator,
> depending on the requested OCR/voltage-level.

Hi,
I don't know this API.
I've tried to look at a few drivers to see how it was used, but it 
didn't help me either.

So, I won't be able to provide any other proposal on this. It would only 
be trial/error.
It is yours if something needs to be fixed here.

Anyway, thanks for your time for answering and trying to show the right 
direction.

CJ

> 
>>          }
>>
>>          ssp->clk = devm_clk_get(&pdev->dev, NULL);
>> --
>> 2.30.2
>>
> 
> Kind regards
> Uffe
> 


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

* Re: [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed
@ 2021-05-25 19:31     ` Christophe JAILLET
  0 siblings, 0 replies; 10+ messages in thread
From: Christophe JAILLET @ 2021-05-25 19:31 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, Sascha Hauer, Sascha Hauer, Fabio Estevam,
	dl-linux-imx, Wolfram Sang, Doug Anderson, Rui Miguel Silva,
	Chris Ball, Linux ARM, linux-mmc, Linux Kernel Mailing List,
	kernel-janitors

Le 24/05/2021 à 15:59, Ulf Hansson a écrit :
> On Fri, 21 May 2021 at 14:36, Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
>>
>> The 'reg_vmmc' regulator is never disabled. Neither in the error handling
>> of the probe, nor in the remove function.
>>
>> Add a managed action to do the required clean-up before a 'regulator_put()'
>> call.
>>
>> Fixes: 4dc5a79f1350 ("mmc: mxs-mmc: enable regulator for mmc slot")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   drivers/mmc/host/mxs-mmc.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
>> index 947581de7860..b043d53dd728 100644
>> --- a/drivers/mmc/host/mxs-mmc.c
>> +++ b/drivers/mmc/host/mxs-mmc.c
>> @@ -552,6 +552,13 @@ static const struct of_device_id mxs_mmc_dt_ids[] = {
>>   };
>>   MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
>>
>> +static void regulator_disable_action(void *_data)
>> +{
>> +       struct regulator *regulator = _data;
>> +
>> +       regulator_disable(regulator);
>> +}
>> +
>>   static int mxs_mmc_probe(struct platform_device *pdev)
>>   {
>>          struct device_node *np = pdev->dev.of_node;
>> @@ -591,6 +598,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>>                                  "Failed to enable vmmc regulator: %d\n", ret);
>>                          goto out_mmc_free;
>>                  }
>> +               ret = devm_add_action_or_reset(&pdev->dev,
>> +                                       regulator_disable_action, reg_vmmc);
>> +               if (ret)
>> +                       goto out_mmc_free;
> 
> Even if this improves the behaviour, there is a standardized way for
> how we deal with regulators for mmc.
> 
> 1. Call mmc_regulator_get_supply() during probe to fetch the optional
> regulator. If a regulator is found a corresponding OCR mask, in
> host->ocr_avail is assigned.
> 
> 2. In the ->set_ios() callback, invoke mmc_regulator_set_ocr(). This
> will also set the correct voltage-level and turn on/off the regulator,
> depending on the requested OCR/voltage-level.

Hi,
I don't know this API.
I've tried to look at a few drivers to see how it was used, but it 
didn't help me either.

So, I won't be able to provide any other proposal on this. It would only 
be trial/error.
It is yours if something needs to be fixed here.

Anyway, thanks for your time for answering and trying to show the right 
direction.

CJ

> 
>>          }
>>
>>          ssp->clk = devm_clk_get(&pdev->dev, NULL);
>> --
>> 2.30.2
>>
> 
> Kind regards
> Uffe
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed
  2021-05-25 19:31     ` Christophe JAILLET
@ 2021-05-25 22:47       ` Ulf Hansson
  -1 siblings, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2021-05-25 22:47 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Shawn Guo, Sascha Hauer, Sascha Hauer, Fabio Estevam,
	dl-linux-imx, Wolfram Sang, Doug Anderson, Rui Miguel Silva,
	Chris Ball, Linux ARM, linux-mmc, Linux Kernel Mailing List,
	kernel-janitors

On Tue, 25 May 2021 at 21:31, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Le 24/05/2021 à 15:59, Ulf Hansson a écrit :
> > On Fri, 21 May 2021 at 14:36, Christophe JAILLET
> > <christophe.jaillet@wanadoo.fr> wrote:
> >>
> >> The 'reg_vmmc' regulator is never disabled. Neither in the error handling
> >> of the probe, nor in the remove function.
> >>
> >> Add a managed action to do the required clean-up before a 'regulator_put()'
> >> call.
> >>
> >> Fixes: 4dc5a79f1350 ("mmc: mxs-mmc: enable regulator for mmc slot")
> >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> >> ---
> >>   drivers/mmc/host/mxs-mmc.c | 11 +++++++++++
> >>   1 file changed, 11 insertions(+)
> >>
> >> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> >> index 947581de7860..b043d53dd728 100644
> >> --- a/drivers/mmc/host/mxs-mmc.c
> >> +++ b/drivers/mmc/host/mxs-mmc.c
> >> @@ -552,6 +552,13 @@ static const struct of_device_id mxs_mmc_dt_ids[] = {
> >>   };
> >>   MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
> >>
> >> +static void regulator_disable_action(void *_data)
> >> +{
> >> +       struct regulator *regulator = _data;
> >> +
> >> +       regulator_disable(regulator);
> >> +}
> >> +
> >>   static int mxs_mmc_probe(struct platform_device *pdev)
> >>   {
> >>          struct device_node *np = pdev->dev.of_node;
> >> @@ -591,6 +598,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> >>                                  "Failed to enable vmmc regulator: %d\n", ret);
> >>                          goto out_mmc_free;
> >>                  }
> >> +               ret = devm_add_action_or_reset(&pdev->dev,
> >> +                                       regulator_disable_action, reg_vmmc);
> >> +               if (ret)
> >> +                       goto out_mmc_free;
> >
> > Even if this improves the behaviour, there is a standardized way for
> > how we deal with regulators for mmc.
> >
> > 1. Call mmc_regulator_get_supply() during probe to fetch the optional
> > regulator. If a regulator is found a corresponding OCR mask, in
> > host->ocr_avail is assigned.
> >
> > 2. In the ->set_ios() callback, invoke mmc_regulator_set_ocr(). This
> > will also set the correct voltage-level and turn on/off the regulator,
> > depending on the requested OCR/voltage-level.
>
> Hi,
> I don't know this API.
> I've tried to look at a few drivers to see how it was used, but it
> didn't help me either.

Okay.

>
> So, I won't be able to provide any other proposal on this. It would only
> be trial/error.
> It is yours if something needs to be fixed here.
>
> Anyway, thanks for your time for answering and trying to show the right
> direction.

If I put together some patch and submit it, would you be able help to
run some tests of it, as I don't have access to HW?

Kind regards
Uffe

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

* Re: [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed
@ 2021-05-25 22:47       ` Ulf Hansson
  0 siblings, 0 replies; 10+ messages in thread
From: Ulf Hansson @ 2021-05-25 22:47 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Shawn Guo, Sascha Hauer, Sascha Hauer, Fabio Estevam,
	dl-linux-imx, Wolfram Sang, Doug Anderson, Rui Miguel Silva,
	Chris Ball, Linux ARM, linux-mmc, Linux Kernel Mailing List,
	kernel-janitors

On Tue, 25 May 2021 at 21:31, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Le 24/05/2021 à 15:59, Ulf Hansson a écrit :
> > On Fri, 21 May 2021 at 14:36, Christophe JAILLET
> > <christophe.jaillet@wanadoo.fr> wrote:
> >>
> >> The 'reg_vmmc' regulator is never disabled. Neither in the error handling
> >> of the probe, nor in the remove function.
> >>
> >> Add a managed action to do the required clean-up before a 'regulator_put()'
> >> call.
> >>
> >> Fixes: 4dc5a79f1350 ("mmc: mxs-mmc: enable regulator for mmc slot")
> >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> >> ---
> >>   drivers/mmc/host/mxs-mmc.c | 11 +++++++++++
> >>   1 file changed, 11 insertions(+)
> >>
> >> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> >> index 947581de7860..b043d53dd728 100644
> >> --- a/drivers/mmc/host/mxs-mmc.c
> >> +++ b/drivers/mmc/host/mxs-mmc.c
> >> @@ -552,6 +552,13 @@ static const struct of_device_id mxs_mmc_dt_ids[] = {
> >>   };
> >>   MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
> >>
> >> +static void regulator_disable_action(void *_data)
> >> +{
> >> +       struct regulator *regulator = _data;
> >> +
> >> +       regulator_disable(regulator);
> >> +}
> >> +
> >>   static int mxs_mmc_probe(struct platform_device *pdev)
> >>   {
> >>          struct device_node *np = pdev->dev.of_node;
> >> @@ -591,6 +598,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> >>                                  "Failed to enable vmmc regulator: %d\n", ret);
> >>                          goto out_mmc_free;
> >>                  }
> >> +               ret = devm_add_action_or_reset(&pdev->dev,
> >> +                                       regulator_disable_action, reg_vmmc);
> >> +               if (ret)
> >> +                       goto out_mmc_free;
> >
> > Even if this improves the behaviour, there is a standardized way for
> > how we deal with regulators for mmc.
> >
> > 1. Call mmc_regulator_get_supply() during probe to fetch the optional
> > regulator. If a regulator is found a corresponding OCR mask, in
> > host->ocr_avail is assigned.
> >
> > 2. In the ->set_ios() callback, invoke mmc_regulator_set_ocr(). This
> > will also set the correct voltage-level and turn on/off the regulator,
> > depending on the requested OCR/voltage-level.
>
> Hi,
> I don't know this API.
> I've tried to look at a few drivers to see how it was used, but it
> didn't help me either.

Okay.

>
> So, I won't be able to provide any other proposal on this. It would only
> be trial/error.
> It is yours if something needs to be fixed here.
>
> Anyway, thanks for your time for answering and trying to show the right
> direction.

If I put together some patch and submit it, would you be able help to
run some tests of it, as I don't have access to HW?

Kind regards
Uffe

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed
  2021-05-25 22:47       ` Ulf Hansson
@ 2021-05-26  7:46         ` Christophe JAILLET
  -1 siblings, 0 replies; 10+ messages in thread
From: Christophe JAILLET @ 2021-05-26  7:46 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, Sascha Hauer, Sascha Hauer, Fabio Estevam,
	dl-linux-imx, Wolfram Sang, Doug Anderson, Rui Miguel Silva,
	Chris Ball, Linux ARM, linux-mmc, Linux Kernel Mailing List,
	kernel-janitors

Le 26/05/2021 à 00:47, Ulf Hansson a écrit :
> If I put together some patch and submit it, would you be able help to
> run some tests of it, as I don't have access to HW?

No, I won't be able to help.
This only got triggered by a static analysis checker (a own made 
coccinelle script) and I don't have the hardware to test anything.

This is why I can't propose an updated proposal. Trial & error 
development when you can't test by yourself is only counterproductive.

CJ

> 
> Kind regards
> Uffe
> 


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

* Re: [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed
@ 2021-05-26  7:46         ` Christophe JAILLET
  0 siblings, 0 replies; 10+ messages in thread
From: Christophe JAILLET @ 2021-05-26  7:46 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Shawn Guo, Sascha Hauer, Sascha Hauer, Fabio Estevam,
	dl-linux-imx, Wolfram Sang, Doug Anderson, Rui Miguel Silva,
	Chris Ball, Linux ARM, linux-mmc, Linux Kernel Mailing List,
	kernel-janitors

Le 26/05/2021 à 00:47, Ulf Hansson a écrit :
> If I put together some patch and submit it, would you be able help to
> run some tests of it, as I don't have access to HW?

No, I won't be able to help.
This only got triggered by a static analysis checker (a own made 
coccinelle script) and I don't have the hardware to test anything.

This is why I can't propose an updated proposal. Trial & error 
development when you can't test by yourself is only counterproductive.

CJ

> 
> Kind regards
> Uffe
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-05-26  7:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 12:36 [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed Christophe JAILLET
2021-05-21 12:36 ` Christophe JAILLET
2021-05-24 13:59 ` Ulf Hansson
2021-05-24 13:59   ` Ulf Hansson
2021-05-25 19:31   ` Christophe JAILLET
2021-05-25 19:31     ` Christophe JAILLET
2021-05-25 22:47     ` Ulf Hansson
2021-05-25 22:47       ` Ulf Hansson
2021-05-26  7:46       ` Christophe JAILLET
2021-05-26  7:46         ` Christophe JAILLET

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.