All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: always save error codes in mmc_regulator_get_supply()
@ 2012-06-27 15:18 Guennadi Liakhovetski
  2012-07-02  4:26 ` Pankaj Jangra
  2012-07-03 23:01 ` Chris Ball
  0 siblings, 2 replies; 4+ messages in thread
From: Guennadi Liakhovetski @ 2012-06-27 15:18 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball

If mmc_regulator_get_supply() fails to obtain any of the regulators, store
the error codes in struct mmc_host to unify error reporting to the host
driver.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

Chris, if you don't mind rebasing your mmc-next branch, feel free to roll 
this patch into the original "mmc: add a function to get regulators, 
supplying card's power". Otherwise, committing it as an incremental patch 
is also ok.

 drivers/mmc/core/core.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 385cadf..d0f17d8 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1020,13 +1020,12 @@ int mmc_regulator_get_supply(struct mmc_host *mmc)
 	int ret;
 
 	supply = devm_regulator_get(dev, "vmmc");
+	mmc->supply.vmmc = supply;
+	mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc");
 
 	if (IS_ERR(supply))
 		return PTR_ERR(supply);
 
-	mmc->supply.vmmc = supply;
-	mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc");
-
 	ret = mmc_regulator_get_ocrmask(supply);
 	if (ret > 0)
 		mmc->ocr_avail = ret;
-- 
1.7.2.5


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

* Re: [PATCH] mmc: always save error codes in mmc_regulator_get_supply()
  2012-06-27 15:18 [PATCH] mmc: always save error codes in mmc_regulator_get_supply() Guennadi Liakhovetski
@ 2012-07-02  4:26 ` Pankaj Jangra
  2012-07-02  8:10   ` Guennadi Liakhovetski
  2012-07-03 23:01 ` Chris Ball
  1 sibling, 1 reply; 4+ messages in thread
From: Pankaj Jangra @ 2012-07-02  4:26 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: linux-mmc, Chris Ball, linux-kernel

Hi,

On Wed, Jun 27, 2012 at 8:48 PM, Guennadi Liakhovetski
<g.liakhovetski@gmx.de> wrote:
> If mmc_regulator_get_supply() fails to obtain any of the regulators, store
> the error codes in struct mmc_host to unify error reporting to the host
> driver.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>
> Chris, if you don't mind rebasing your mmc-next branch, feel free to roll
> this patch into the original "mmc: add a function to get regulators,
> supplying card's power". Otherwise, committing it as an incremental patch
> is also ok.
>
>  drivers/mmc/core/core.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 385cadf..d0f17d8 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -1020,13 +1020,12 @@ int mmc_regulator_get_supply(struct mmc_host *mmc)
>         int ret;
>
>         supply = devm_regulator_get(dev, "vmmc");
> +       mmc->supply.vmmc = supply;
> +       mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc");
>
>         if (IS_ERR(supply))
>                 return PTR_ERR(supply);
>
> -       mmc->supply.vmmc = supply;
> -       mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc");
> -

I have a doubt here. Though  i am not much know to mmc code, but could
you please explain what is the benefit of moving these
statements above the error checking. I mean if you are not able to get
"vmmc" supply then why do you care to get the supply "vqmmc"
while by this error check you want to bail out from here ASAP and also
by doing this you are unnecessarily increasing the consumer
for "vqmmc" supply.  Please let me know if i am missing something here.

Also if you want to save the error code only you may want to move the
statement "mmc->supply.vmmc = supply"  only above the error
checking right?

>         ret = mmc_regulator_get_ocrmask(supply);
>         if (ret > 0)
>                 mmc->ocr_avail = ret;
> --

Regards,
Pankaj Jangra

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

* Re: [PATCH] mmc: always save error codes in mmc_regulator_get_supply()
  2012-07-02  4:26 ` Pankaj Jangra
@ 2012-07-02  8:10   ` Guennadi Liakhovetski
  0 siblings, 0 replies; 4+ messages in thread
From: Guennadi Liakhovetski @ 2012-07-02  8:10 UTC (permalink / raw)
  To: Pankaj Jangra; +Cc: linux-mmc, Chris Ball, linux-kernel

Hi

On Mon, 2 Jul 2012, Pankaj Jangra wrote:

> Hi,
> 
> On Wed, Jun 27, 2012 at 8:48 PM, Guennadi Liakhovetski
> <g.liakhovetski@gmx.de> wrote:
> > If mmc_regulator_get_supply() fails to obtain any of the regulators, store
> > the error codes in struct mmc_host to unify error reporting to the host
> > driver.
> >
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> > ---
> >
> > Chris, if you don't mind rebasing your mmc-next branch, feel free to roll
> > this patch into the original "mmc: add a function to get regulators,
> > supplying card's power". Otherwise, committing it as an incremental patch
> > is also ok.
> >
> >  drivers/mmc/core/core.c |    5 ++---
> >  1 files changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> > index 385cadf..d0f17d8 100644
> > --- a/drivers/mmc/core/core.c
> > +++ b/drivers/mmc/core/core.c
> > @@ -1020,13 +1020,12 @@ int mmc_regulator_get_supply(struct mmc_host *mmc)
> >         int ret;
> >
> >         supply = devm_regulator_get(dev, "vmmc");
> > +       mmc->supply.vmmc = supply;
> > +       mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc");
> >
> >         if (IS_ERR(supply))
> >                 return PTR_ERR(supply);
> >
> > -       mmc->supply.vmmc = supply;
> > -       mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc");
> > -
> 
> I have a doubt here. Though  i am not much know to mmc code, but could
> you please explain what is the benefit of moving these
> statements above the error checking. I mean if you are not able to get
> "vmmc" supply then why do you care to get the supply "vqmmc"

I'm not sure about this. I moving those assignments I achieve two goals:

1. consistency: upon return from that function both supply struct members 
contain either a pointer to the respective regulator, or an error code, 
and both regulators have been tried.
2. maximum flexibility: we try both regulators in any case and let 
individual drivers decide what is acceptable to them. It does seem more 
natural to rely more on the "vmmc" supply than on "vqmmc," but if a driver 
decides to go only with the latter one - why should we prohibit that?

Thanks
Guennadi

> while by this error check you want to bail out from here ASAP and also
> by doing this you are unnecessarily increasing the consumer
> for "vqmmc" supply.  Please let me know if i am missing something here.
> 
> Also if you want to save the error code only you may want to move the
> statement "mmc->supply.vmmc = supply"  only above the error
> checking right?
> 
> >         ret = mmc_regulator_get_ocrmask(supply);
> >         if (ret > 0)
> >                 mmc->ocr_avail = ret;
> > --
> 
> Regards,
> Pankaj Jangra
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* Re: [PATCH] mmc: always save error codes in mmc_regulator_get_supply()
  2012-06-27 15:18 [PATCH] mmc: always save error codes in mmc_regulator_get_supply() Guennadi Liakhovetski
  2012-07-02  4:26 ` Pankaj Jangra
@ 2012-07-03 23:01 ` Chris Ball
  1 sibling, 0 replies; 4+ messages in thread
From: Chris Ball @ 2012-07-03 23:01 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: linux-mmc

Hi,

On Wed, Jun 27 2012, Guennadi Liakhovetski wrote:
> If mmc_regulator_get_supply() fails to obtain any of the regulators, store
> the error codes in struct mmc_host to unify error reporting to the host
> driver.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>
> Chris, if you don't mind rebasing your mmc-next branch, feel free to roll 
> this patch into the original "mmc: add a function to get regulators, 
> supplying card's power". Otherwise, committing it as an incremental patch 
> is also ok.
>
>  drivers/mmc/core/core.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 385cadf..d0f17d8 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -1020,13 +1020,12 @@ int mmc_regulator_get_supply(struct mmc_host *mmc)
>  	int ret;
>  
>  	supply = devm_regulator_get(dev, "vmmc");
> +	mmc->supply.vmmc = supply;
> +	mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc");
>  
>  	if (IS_ERR(supply))
>  		return PTR_ERR(supply);
>  
> -	mmc->supply.vmmc = supply;
> -	mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc");
> -
>  	ret = mmc_regulator_get_ocrmask(supply);
>  	if (ret > 0)
>  		mmc->ocr_avail = ret;

Thanks, I rebased it and pushed out to mmc-next.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

end of thread, other threads:[~2012-07-03 23:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-27 15:18 [PATCH] mmc: always save error codes in mmc_regulator_get_supply() Guennadi Liakhovetski
2012-07-02  4:26 ` Pankaj Jangra
2012-07-02  8:10   ` Guennadi Liakhovetski
2012-07-03 23:01 ` Chris Ball

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.