linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MMC/omap_hsmmc: handle failure of regulator_get better.
@ 2012-07-30  0:12 NeilBrown
  2012-07-30  5:20 ` Rajendra Nayak
  2012-08-08  4:07 ` Chris Ball
  0 siblings, 2 replies; 6+ messages in thread
From: NeilBrown @ 2012-07-30  0:12 UTC (permalink / raw)
  To: Chris Ball, Venkatraman S, Balaji T K, Rajendra Nayak
  Cc: linux-omap, linux-mmc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1004 bytes --]


1/ if regulator_get fails, return an error.  This is important
   if it failed with EPROBE_DEFER, as the probe needs to be
   deferred.

2/ Don't set .set_power until the regulator has been found, or
   the deferred probe will not bother calling omap_hsmmc_reg_get().

Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 389a3ee..f052c29 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -299,12 +299,12 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 	struct regulator *reg;
 	int ocr_value = 0;
 
-	mmc_slot(host).set_power = omap_hsmmc_set_power;
-
 	reg = regulator_get(host->dev, "vmmc");
 	if (IS_ERR(reg)) {
 		dev_dbg(host->dev, "vmmc regulator missing\n");
+		return PTR_ERR(reg);
 	} else {
+		mmc_slot(host).set_power = omap_hsmmc_set_power;
 		host->vcc = reg;
 		ocr_value = mmc_regulator_get_ocrmask(reg);
 		if (!mmc_slot(host).ocr_mask) {

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH] MMC/omap_hsmmc: handle failure of regulator_get better.
  2012-07-30  0:12 [PATCH] MMC/omap_hsmmc: handle failure of regulator_get better NeilBrown
@ 2012-07-30  5:20 ` Rajendra Nayak
  2012-07-30  6:24   ` NeilBrown
  2012-08-08  4:07 ` Chris Ball
  1 sibling, 1 reply; 6+ messages in thread
From: Rajendra Nayak @ 2012-07-30  5:20 UTC (permalink / raw)
  To: NeilBrown
  Cc: Chris Ball, Venkatraman S, Balaji T K, linux-omap, linux-mmc,
	linux-kernel

On Monday 30 July 2012 05:42 AM, NeilBrown wrote:
>
> 1/ if regulator_get fails, return an error.  This is important
>     if it failed with EPROBE_DEFER, as the probe needs to be
>     deferred.
>
> 2/ Don't set .set_power until the regulator has been found, or
>     the deferred probe will not bother calling omap_hsmmc_reg_get().

I am not very sure, but aren't the data structures re-allocated on a
re-probe (after it was deferred) causing .set_power to be lost anyway?

>
> Signed-off-by: NeilBrown<neilb@suse.de>
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 389a3ee..f052c29 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -299,12 +299,12 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>   	struct regulator *reg;
>   	int ocr_value = 0;
>
> -	mmc_slot(host).set_power = omap_hsmmc_set_power;
> -
>   	reg = regulator_get(host->dev, "vmmc");
>   	if (IS_ERR(reg)) {
>   		dev_dbg(host->dev, "vmmc regulator missing\n");
> +		return PTR_ERR(reg);
>   	} else {
> +		mmc_slot(host).set_power = omap_hsmmc_set_power;
>   		host->vcc = reg;
>   		ocr_value = mmc_regulator_get_ocrmask(reg);
>   		if (!mmc_slot(host).ocr_mask) {


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

* Re: [PATCH] MMC/omap_hsmmc: handle failure of regulator_get better.
  2012-07-30  5:20 ` Rajendra Nayak
@ 2012-07-30  6:24   ` NeilBrown
  2012-07-30  6:37     ` Rajendra Nayak
  0 siblings, 1 reply; 6+ messages in thread
From: NeilBrown @ 2012-07-30  6:24 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: Chris Ball, Venkatraman S, Balaji T K, linux-omap, linux-mmc,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1835 bytes --]

On Mon, 30 Jul 2012 10:50:36 +0530 Rajendra Nayak <rnayak@ti.com> wrote:

> On Monday 30 July 2012 05:42 AM, NeilBrown wrote:
> >
> > 1/ if regulator_get fails, return an error.  This is important
> >     if it failed with EPROBE_DEFER, as the probe needs to be
> >     deferred.
> >
> > 2/ Don't set .set_power until the regulator has been found, or
> >     the deferred probe will not bother calling omap_hsmmc_reg_get().
> 
> I am not very sure, but aren't the data structures re-allocated on a
> re-probe (after it was deferred) causing .set_power to be lost anyway?
> 

Apparently not - as I needed to make that change before the re-probe would
work.

Looking at the code to remind myself:

#define mmc_slot(host)		(host->pdata->slots[host->slot_id])

so the slot is inside the platform data which is allocated in
omap_hsmmc_init_one, called from omap_hsmmc_init.
This is all prior to the probing of the device.

So no: once set_power is set, it stays set.

Thanks,
NeilBrown

> >
> > Signed-off-by: NeilBrown<neilb@suse.de>
> >
> > diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> > index 389a3ee..f052c29 100644
> > --- a/drivers/mmc/host/omap_hsmmc.c
> > +++ b/drivers/mmc/host/omap_hsmmc.c
> > @@ -299,12 +299,12 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
> >   	struct regulator *reg;
> >   	int ocr_value = 0;
> >
> > -	mmc_slot(host).set_power = omap_hsmmc_set_power;
> > -
> >   	reg = regulator_get(host->dev, "vmmc");
> >   	if (IS_ERR(reg)) {
> >   		dev_dbg(host->dev, "vmmc regulator missing\n");
> > +		return PTR_ERR(reg);
> >   	} else {
> > +		mmc_slot(host).set_power = omap_hsmmc_set_power;
> >   		host->vcc = reg;
> >   		ocr_value = mmc_regulator_get_ocrmask(reg);
> >   		if (!mmc_slot(host).ocr_mask) {


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH] MMC/omap_hsmmc: handle failure of regulator_get better.
  2012-07-30  6:24   ` NeilBrown
@ 2012-07-30  6:37     ` Rajendra Nayak
  2012-07-30  6:48       ` NeilBrown
  0 siblings, 1 reply; 6+ messages in thread
From: Rajendra Nayak @ 2012-07-30  6:37 UTC (permalink / raw)
  To: NeilBrown
  Cc: Chris Ball, Venkatraman S, Balaji T K, linux-omap, linux-mmc,
	linux-kernel

On Monday 30 July 2012 11:54 AM, NeilBrown wrote:
> On Mon, 30 Jul 2012 10:50:36 +0530 Rajendra Nayak<rnayak@ti.com>  wrote:
>
>> On Monday 30 July 2012 05:42 AM, NeilBrown wrote:
>>>
>>> 1/ if regulator_get fails, return an error.  This is important
>>>      if it failed with EPROBE_DEFER, as the probe needs to be
>>>      deferred.
>>>
>>> 2/ Don't set .set_power until the regulator has been found, or
>>>      the deferred probe will not bother calling omap_hsmmc_reg_get().
>>
>> I am not very sure, but aren't the data structures re-allocated on a
>> re-probe (after it was deferred) causing .set_power to be lost anyway?
>>
>
> Apparently not - as I needed to make that change before the re-probe would
> work.
>
> Looking at the code to remind myself:
>
> #define mmc_slot(host)		(host->pdata->slots[host->slot_id])
>
> so the slot is inside the platform data which is allocated in
> omap_hsmmc_init_one, called from omap_hsmmc_init.
> This is all prior to the probing of the device.
>
> So no: once set_power is set, it stays set.

Thanks for the explanation, makes sense.

Acked-by: Rajendra Nayak <rnayak@ti.com>

Btw, is the support for re-probe/deferred probe already merged
now? or are you testing this with some out of tree patches.

>
> Thanks,
> NeilBrown
>
>>>
>>> Signed-off-by: NeilBrown<neilb@suse.de>
>>>
>>> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
>>> index 389a3ee..f052c29 100644
>>> --- a/drivers/mmc/host/omap_hsmmc.c
>>> +++ b/drivers/mmc/host/omap_hsmmc.c
>>> @@ -299,12 +299,12 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>>>    	struct regulator *reg;
>>>    	int ocr_value = 0;
>>>
>>> -	mmc_slot(host).set_power = omap_hsmmc_set_power;
>>> -
>>>    	reg = regulator_get(host->dev, "vmmc");
>>>    	if (IS_ERR(reg)) {
>>>    		dev_dbg(host->dev, "vmmc regulator missing\n");
>>> +		return PTR_ERR(reg);
>>>    	} else {
>>> +		mmc_slot(host).set_power = omap_hsmmc_set_power;
>>>    		host->vcc = reg;
>>>    		ocr_value = mmc_regulator_get_ocrmask(reg);
>>>    		if (!mmc_slot(host).ocr_mask) {
>


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

* Re: [PATCH] MMC/omap_hsmmc: handle failure of regulator_get better.
  2012-07-30  6:37     ` Rajendra Nayak
@ 2012-07-30  6:48       ` NeilBrown
  0 siblings, 0 replies; 6+ messages in thread
From: NeilBrown @ 2012-07-30  6:48 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: Chris Ball, Venkatraman S, Balaji T K, linux-omap, linux-mmc,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3288 bytes --]

On Mon, 30 Jul 2012 12:07:09 +0530 Rajendra Nayak <rnayak@ti.com> wrote:

> On Monday 30 July 2012 11:54 AM, NeilBrown wrote:
> > On Mon, 30 Jul 2012 10:50:36 +0530 Rajendra Nayak<rnayak@ti.com>  wrote:
> >
> >> On Monday 30 July 2012 05:42 AM, NeilBrown wrote:
> >>>
> >>> 1/ if regulator_get fails, return an error.  This is important
> >>>      if it failed with EPROBE_DEFER, as the probe needs to be
> >>>      deferred.
> >>>
> >>> 2/ Don't set .set_power until the regulator has been found, or
> >>>      the deferred probe will not bother calling omap_hsmmc_reg_get().
> >>
> >> I am not very sure, but aren't the data structures re-allocated on a
> >> re-probe (after it was deferred) causing .set_power to be lost anyway?
> >>
> >
> > Apparently not - as I needed to make that change before the re-probe would
> > work.
> >
> > Looking at the code to remind myself:
> >
> > #define mmc_slot(host)		(host->pdata->slots[host->slot_id])
> >
> > so the slot is inside the platform data which is allocated in
> > omap_hsmmc_init_one, called from omap_hsmmc_init.
> > This is all prior to the probing of the device.
> >
> > So no: once set_power is set, it stays set.
> 
> Thanks for the explanation, makes sense.
> 
> Acked-by: Rajendra Nayak <rnayak@ti.com>

Thanks.

> 
> Btw, is the support for re-probe/deferred probe already merged
> now? or are you testing this with some out of tree patches.

deferred-probe works in 3.5. 

commit 04bf30115f4ba2beda1efb6cfbae49cdc757f3a9
Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
Date:   Sun Mar 11 13:07:56 2012 +0000

    regulator: Support driver probe deferral
 
makes it work for regulators.

commit d1c3414c2a9d10ef7f0f7665f5d2947cd088c093
Author: Grant Likely <grant.likely@secretlab.ca>
Date:   Mon Mar 5 08:47:41 2012 -0700

    drivercore: Add driver probe deferral mechanism

added the basic mechanism.

GPIOs are also supported in 3.6-rc thanks to

commit e93545763021988def06fbda28fe5da133589a96
Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
Date:   Mon Jul 9 12:22:56 2012 +0100

    gpiolib: Defer failed gpio requests by default

so the omap_hsmmc_late_init() stuff can probably be removed, though I haven't
tried and there might be some subtlety in there that isn't covered by
EPROBE_DEFER

NeilBrown


> 
> >
> > Thanks,
> > NeilBrown
> >
> >>>
> >>> Signed-off-by: NeilBrown<neilb@suse.de>
> >>>
> >>> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> >>> index 389a3ee..f052c29 100644
> >>> --- a/drivers/mmc/host/omap_hsmmc.c
> >>> +++ b/drivers/mmc/host/omap_hsmmc.c
> >>> @@ -299,12 +299,12 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
> >>>    	struct regulator *reg;
> >>>    	int ocr_value = 0;
> >>>
> >>> -	mmc_slot(host).set_power = omap_hsmmc_set_power;
> >>> -
> >>>    	reg = regulator_get(host->dev, "vmmc");
> >>>    	if (IS_ERR(reg)) {
> >>>    		dev_dbg(host->dev, "vmmc regulator missing\n");
> >>> +		return PTR_ERR(reg);
> >>>    	} else {
> >>> +		mmc_slot(host).set_power = omap_hsmmc_set_power;
> >>>    		host->vcc = reg;
> >>>    		ocr_value = mmc_regulator_get_ocrmask(reg);
> >>>    		if (!mmc_slot(host).ocr_mask) {
> >


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH] MMC/omap_hsmmc: handle failure of regulator_get better.
  2012-07-30  0:12 [PATCH] MMC/omap_hsmmc: handle failure of regulator_get better NeilBrown
  2012-07-30  5:20 ` Rajendra Nayak
@ 2012-08-08  4:07 ` Chris Ball
  1 sibling, 0 replies; 6+ messages in thread
From: Chris Ball @ 2012-08-08  4:07 UTC (permalink / raw)
  To: NeilBrown
  Cc: Venkatraman S, Balaji T K, Rajendra Nayak, linux-omap, linux-mmc,
	linux-kernel

Hi,

On Sun, Jul 29 2012, NeilBrown wrote:
> 1/ if regulator_get fails, return an error.  This is important
>    if it failed with EPROBE_DEFER, as the probe needs to be
>    deferred.
>
> 2/ Don't set .set_power until the regulator has been found, or
>    the deferred probe will not bother calling omap_hsmmc_reg_get().
>
> Signed-off-by: NeilBrown <neilb@suse.de>
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 389a3ee..f052c29 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -299,12 +299,12 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
>  	struct regulator *reg;
>  	int ocr_value = 0;
>  
> -	mmc_slot(host).set_power = omap_hsmmc_set_power;
> -
>  	reg = regulator_get(host->dev, "vmmc");
>  	if (IS_ERR(reg)) {
>  		dev_dbg(host->dev, "vmmc regulator missing\n");
> +		return PTR_ERR(reg);
>  	} else {
> +		mmc_slot(host).set_power = omap_hsmmc_set_power;
>  		host->vcc = reg;
>  		ocr_value = mmc_regulator_get_ocrmask(reg);
>  		if (!mmc_slot(host).ocr_mask) {

Thanks, pushed to mmc-next for 3.7.

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

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

end of thread, other threads:[~2012-08-08  4:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-30  0:12 [PATCH] MMC/omap_hsmmc: handle failure of regulator_get better NeilBrown
2012-07-30  5:20 ` Rajendra Nayak
2012-07-30  6:24   ` NeilBrown
2012-07-30  6:37     ` Rajendra Nayak
2012-07-30  6:48       ` NeilBrown
2012-08-08  4:07 ` Chris Ball

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