* [PATCH 3/3] MMC/SD: add callback function to detect card
@ 2009-12-04 7:55 r66093
2010-01-06 2:40 ` Huang Changming-R66093
2010-08-27 19:05 ` Chris Ball
0 siblings, 2 replies; 9+ messages in thread
From: r66093 @ 2009-12-04 7:55 UTC (permalink / raw)
To: linux-mmc; +Cc: Jerry Huang
From: Jerry Huang <Chang-Ming.Huang@freescale.com>
Add callback function to check if the card has been removed.
in order to check if the card has been removed, the function mmc_send_status will send commad CMD13 to card and ask the card to send its status register to driver, which will generate interrupt repeatly and make the system bad.
Therefore, get_cd callback is used to detect the card if the driver has.
Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
---
drivers/mmc/core/mmc.c | 5 ++++-
drivers/mmc/core/sd.c | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 06084db..c5c676d 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -494,7 +494,10 @@ static void mmc_detect(struct mmc_host *host)
/*
* Just check if our card has been removed.
*/
- err = mmc_send_status(host->card, NULL);
+ if (host->ops->get_cd)
+ err = !host->ops->get_cd(host);
+ else
+ err = mmc_send_status(host->card, NULL);
mmc_release_host(host);
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index cd81c39..3cf1f38 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -548,7 +548,10 @@ static void mmc_sd_detect(struct mmc_host *host)
/*
* Just check if our card has been removed.
*/
- err = mmc_send_status(host->card, NULL);
+ if (host->ops->get_cd)
+ err = !host->ops->get_cd(host);
+ else
+ err = mmc_send_status(host->card, NULL);
mmc_release_host(host);
--
1.6.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH 3/3] MMC/SD: add callback function to detect card
2009-12-04 7:55 [PATCH 3/3] MMC/SD: add callback function to detect card r66093
@ 2010-01-06 2:40 ` Huang Changming-R66093
2010-08-27 19:05 ` Chris Ball
1 sibling, 0 replies; 9+ messages in thread
From: Huang Changming-R66093 @ 2010-01-06 2:40 UTC (permalink / raw)
To: Huang Changming-R66093, linux-mmc
Dear all,
Have any advice about these patchs for SDHC?
Thanks and Best Regards
Jerry Huang
Beijing office, Freescale Semiconductor
> -----Original Message-----
> From: Huang Changming-R66093
> Sent: Friday, December 04, 2009 3:55 PM
> To: linux-mmc@vger.kernel.org
> Cc: Huang Changming-R66093
> Subject: [PATCH 3/3] MMC/SD: add callback function to detect card
>
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>
> Add callback function to check if the card has been removed.
>
> in order to check if the card has been removed, the function
> mmc_send_status will send commad CMD13 to card and ask the
> card to send its status register to driver, which will
> generate interrupt repeatly and make the system bad.
> Therefore, get_cd callback is used to detect the card if the
> driver has.
>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> ---
> drivers/mmc/core/mmc.c | 5 ++++-
> drivers/mmc/core/sd.c | 5 ++++-
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 06084db..c5c676d 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -494,7 +494,10 @@ static void mmc_detect(struct mmc_host *host)
> /*
> * Just check if our card has been removed.
> */
> - err = mmc_send_status(host->card, NULL);
> + if (host->ops->get_cd)
> + err = !host->ops->get_cd(host);
> + else
> + err = mmc_send_status(host->card, NULL);
>
> mmc_release_host(host);
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index cd81c39..3cf1f38 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -548,7 +548,10 @@ static void mmc_sd_detect(struct mmc_host *host)
> /*
> * Just check if our card has been removed.
> */
> - err = mmc_send_status(host->card, NULL);
> + if (host->ops->get_cd)
> + err = !host->ops->get_cd(host);
> + else
> + err = mmc_send_status(host->card, NULL);
>
> mmc_release_host(host);
>
> --
> 1.6.4
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] MMC/SD: add callback function to detect card
2009-12-04 7:55 [PATCH 3/3] MMC/SD: add callback function to detect card r66093
2010-01-06 2:40 ` Huang Changming-R66093
@ 2010-08-27 19:05 ` Chris Ball
2010-08-31 19:10 ` Matt Fleming
1 sibling, 1 reply; 9+ messages in thread
From: Chris Ball @ 2010-08-27 19:05 UTC (permalink / raw)
To: r66093; +Cc: linux-mmc, Jerry Huang
Hi,
On Fri, Dec 04, 2009 at 03:55:09PM +0800, r66093@freescale.com wrote:
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>
> Add callback function to check if the card has been removed.
>
> in order to check if the card has been removed, the function mmc_send_status will send commad CMD13 to card and ask the card to send its status register to driver, which will generate interrupt repeatly and make the system bad.
> Therefore, get_cd callback is used to detect the card if the driver has.
>
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> ---
> drivers/mmc/core/mmc.c | 5 ++++-
> drivers/mmc/core/sd.c | 5 ++++-
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 06084db..c5c676d 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -494,7 +494,10 @@ static void mmc_detect(struct mmc_host *host)
> /*
> * Just check if our card has been removed.
> */
> - err = mmc_send_status(host->card, NULL);
> + if (host->ops->get_cd)
> + err = !host->ops->get_cd(host);
> + else
> + err = mmc_send_status(host->card, NULL);
>
> mmc_release_host(host);
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index cd81c39..3cf1f38 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -548,7 +548,10 @@ static void mmc_sd_detect(struct mmc_host *host)
> /*
> * Just check if our card has been removed.
> */
> - err = mmc_send_status(host->card, NULL);
> + if (host->ops->get_cd)
> + err = !host->ops->get_cd(host);
> + else
> + err = mmc_send_status(host->card, NULL);
>
> mmc_release_host(host);
>
> --
> 1.6.4
This patchset wasn't replied to -- any comments on it from the list?
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] MMC/SD: add callback function to detect card
2010-08-27 19:05 ` Chris Ball
@ 2010-08-31 19:10 ` Matt Fleming
2010-08-31 19:23 ` Adrian Hunter
0 siblings, 1 reply; 9+ messages in thread
From: Matt Fleming @ 2010-08-31 19:10 UTC (permalink / raw)
To: Chris Ball; +Cc: r66093, linux-mmc, Jerry Huang
On Fri, Aug 27, 2010 at 08:05:13PM +0100, Chris Ball wrote:
> Hi,
>
> On Fri, Dec 04, 2009 at 03:55:09PM +0800, r66093@freescale.com wrote:
> > From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> >
> > Add callback function to check if the card has been removed.
> >
> > in order to check if the card has been removed, the function mmc_send_status will send commad CMD13 to card and ask the card to send its status register to driver, which will generate interrupt repeatly and make the system bad.
> > Therefore, get_cd callback is used to detect the card if the driver has.
> >
> > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > ---
> > drivers/mmc/core/mmc.c | 5 ++++-
> > drivers/mmc/core/sd.c | 5 ++++-
> > 2 files changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> > index 06084db..c5c676d 100644
> > --- a/drivers/mmc/core/mmc.c
> > +++ b/drivers/mmc/core/mmc.c
> > @@ -494,7 +494,10 @@ static void mmc_detect(struct mmc_host *host)
> > /*
> > * Just check if our card has been removed.
> > */
> > - err = mmc_send_status(host->card, NULL);
> > + if (host->ops->get_cd)
> > + err = !host->ops->get_cd(host);
> > + else
> > + err = mmc_send_status(host->card, NULL);
> >
> > mmc_release_host(host);
> >
> > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> > index cd81c39..3cf1f38 100644
> > --- a/drivers/mmc/core/sd.c
> > +++ b/drivers/mmc/core/sd.c
> > @@ -548,7 +548,10 @@ static void mmc_sd_detect(struct mmc_host *host)
> > /*
> > * Just check if our card has been removed.
> > */
> > - err = mmc_send_status(host->card, NULL);
> > + if (host->ops->get_cd)
> > + err = !host->ops->get_cd(host);
> > + else
> > + err = mmc_send_status(host->card, NULL);
> >
> > mmc_release_host(host);
> >
> > --
> > 1.6.4
>
> This patchset wasn't replied to -- any comments on it from the list?
I think this change makes sense, although it needs to be a bit smarter
with error handling because the get_cd() functions can return -ENOSYS if
they are not implemented (but the function pointer is still valid).
int err = 0;
if (host->ops->get_cd) {
err = host->ops->get_cd(host);
if (err >= 0)
err = !err;
}
if (!host->ops->get_cd || err < 0)
err = mmc_send_status(host->card, NULL);
Thoughts?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] MMC/SD: add callback function to detect card
2010-08-31 19:10 ` Matt Fleming
@ 2010-08-31 19:23 ` Adrian Hunter
2010-08-31 19:38 ` Matt Fleming
2010-08-31 19:40 ` Adrian Hunter
0 siblings, 2 replies; 9+ messages in thread
From: Adrian Hunter @ 2010-08-31 19:23 UTC (permalink / raw)
To: Matt Fleming
Cc: Chris Ball, r66093@freescale.com, linux-mmc@vger.kernel.org,
Jerry Huang
Matt Fleming wrote:
> On Fri, Aug 27, 2010 at 08:05:13PM +0100, Chris Ball wrote:
>> Hi,
>>
>> On Fri, Dec 04, 2009 at 03:55:09PM +0800, r66093@freescale.com wrote:
>>> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>>>
>>> Add callback function to check if the card has been removed.
>>>
>>> in order to check if the card has been removed, the function mmc_send_status will send commad CMD13 to card and ask the card to send its status register to driver, which will generate interrupt repeatly and make the system bad.
>>> Therefore, get_cd callback is used to detect the card if the driver has.
>>>
>>> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
>>> ---
>>> drivers/mmc/core/mmc.c | 5 ++++-
>>> drivers/mmc/core/sd.c | 5 ++++-
>>> 2 files changed, 8 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>>> index 06084db..c5c676d 100644
>>> --- a/drivers/mmc/core/mmc.c
>>> +++ b/drivers/mmc/core/mmc.c
>>> @@ -494,7 +494,10 @@ static void mmc_detect(struct mmc_host *host)
>>> /*
>>> * Just check if our card has been removed.
>>> */
>>> - err = mmc_send_status(host->card, NULL);
>>> + if (host->ops->get_cd)
>>> + err = !host->ops->get_cd(host);
>>> + else
>>> + err = mmc_send_status(host->card, NULL);
>>>
>>> mmc_release_host(host);
>>>
>>> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
>>> index cd81c39..3cf1f38 100644
>>> --- a/drivers/mmc/core/sd.c
>>> +++ b/drivers/mmc/core/sd.c
>>> @@ -548,7 +548,10 @@ static void mmc_sd_detect(struct mmc_host *host)
>>> /*
>>> * Just check if our card has been removed.
>>> */
>>> - err = mmc_send_status(host->card, NULL);
>>> + if (host->ops->get_cd)
>>> + err = !host->ops->get_cd(host);
>>> + else
>>> + err = mmc_send_status(host->card, NULL);
>>>
>>> mmc_release_host(host);
>>>
>>> --
>>> 1.6.4
>> This patchset wasn't replied to -- any comments on it from the list?
>
> I think this change makes sense, although it needs to be a bit smarter
> with error handling because the get_cd() functions can return -ENOSYS if
> they are not implemented (but the function pointer is still valid).
>
> int err = 0;
>
> if (host->ops->get_cd) {
> err = host->ops->get_cd(host);
> if (err >= 0)
> err = !err;
> }
>
> if (!host->ops->get_cd || err < 0)
> err = mmc_send_status(host->card, NULL);
>
> Thoughts?
I am not sure it won't cause problems.
If you change the card then card detect will return true because
there is a card but send status will fail because the card is not
initialised. So the two do not seem equivalent.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] MMC/SD: add callback function to detect card
2010-08-31 19:23 ` Adrian Hunter
@ 2010-08-31 19:38 ` Matt Fleming
2010-08-31 19:40 ` Adrian Hunter
1 sibling, 0 replies; 9+ messages in thread
From: Matt Fleming @ 2010-08-31 19:38 UTC (permalink / raw)
To: Adrian Hunter
Cc: Chris Ball, r66093@freescale.com, linux-mmc@vger.kernel.org,
Jerry Huang
On Tue, Aug 31, 2010 at 10:23:23PM +0300, Adrian Hunter wrote:
> Matt Fleming wrote:
> >On Fri, Aug 27, 2010 at 08:05:13PM +0100, Chris Ball wrote:
> >>Hi,
> >>
> >>On Fri, Dec 04, 2009 at 03:55:09PM +0800, r66093@freescale.com wrote:
> >>>From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> >>>
> >>>Add callback function to check if the card has been removed.
> >>>
> >>>in order to check if the card has been removed, the function mmc_send_status will send commad CMD13 to card and ask the card to send its status register to driver, which will generate interrupt repeatly and make the system bad.
> >>>Therefore, get_cd callback is used to detect the card if the driver has.
> >>>
> >>>Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> >>>---
> >>> drivers/mmc/core/mmc.c | 5 ++++-
> >>> drivers/mmc/core/sd.c | 5 ++++-
> >>> 2 files changed, 8 insertions(+), 2 deletions(-)
> >>>
> >>>diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> >>>index 06084db..c5c676d 100644
> >>>--- a/drivers/mmc/core/mmc.c
> >>>+++ b/drivers/mmc/core/mmc.c
> >>>@@ -494,7 +494,10 @@ static void mmc_detect(struct mmc_host *host)
> >>> /*
> >>> * Just check if our card has been removed.
> >>> */
> >>>- err = mmc_send_status(host->card, NULL);
> >>>+ if (host->ops->get_cd)
> >>>+ err = !host->ops->get_cd(host);
> >>>+ else
> >>>+ err = mmc_send_status(host->card, NULL);
> >>> mmc_release_host(host);
> >>>diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> >>>index cd81c39..3cf1f38 100644
> >>>--- a/drivers/mmc/core/sd.c
> >>>+++ b/drivers/mmc/core/sd.c
> >>>@@ -548,7 +548,10 @@ static void mmc_sd_detect(struct mmc_host *host)
> >>> /*
> >>> * Just check if our card has been removed.
> >>> */
> >>>- err = mmc_send_status(host->card, NULL);
> >>>+ if (host->ops->get_cd)
> >>>+ err = !host->ops->get_cd(host);
> >>>+ else
> >>>+ err = mmc_send_status(host->card, NULL);
> >>> mmc_release_host(host);
> >>>--
> >>>1.6.4
> >>This patchset wasn't replied to -- any comments on it from the list?
> >
> >I think this change makes sense, although it needs to be a bit smarter
> >with error handling because the get_cd() functions can return -ENOSYS if
> >they are not implemented (but the function pointer is still valid).
> >
> > int err = 0;
> >
> > if (host->ops->get_cd) {
> > err = host->ops->get_cd(host);
> > if (err >= 0)
> > err = !err;
> > }
> >
> > if (!host->ops->get_cd || err < 0)
> > err = mmc_send_status(host->card, NULL);
> >
> >Thoughts?
>
> I am not sure it won't cause problems.
>
> If you change the card then card detect will return true because
> there is a card but send status will fail because the card is not
> initialised. So the two do not seem equivalent.
Are you sure that the SEND_STATUS will fail if the card hasn't been
initialised? We don't actually look at the response from the SEND_STATUS
command, just whether the command itself failed or succeeded. Even if
the card isn't initialised, the command should succeed. And when we
return from mmc_rescan() we'll initialise the card anyway.
I'm not sure it won't cause problems either and I'd feel a lot more
confident if someone could test it on their hardware though ;-) None of
my boards implement the get_cd function.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] MMC/SD: add callback function to detect card
2010-08-31 19:23 ` Adrian Hunter
2010-08-31 19:38 ` Matt Fleming
@ 2010-08-31 19:40 ` Adrian Hunter
2010-08-31 19:57 ` Adrian Hunter
1 sibling, 1 reply; 9+ messages in thread
From: Adrian Hunter @ 2010-08-31 19:40 UTC (permalink / raw)
To: Matt Fleming
Cc: Chris Ball, r66093@freescale.com, linux-mmc@vger.kernel.org,
Jerry Huang
Adrian Hunter wrote:
> Matt Fleming wrote:
>> On Fri, Aug 27, 2010 at 08:05:13PM +0100, Chris Ball wrote:
>>> Hi,
>>>
>>> On Fri, Dec 04, 2009 at 03:55:09PM +0800, r66093@freescale.com wrote:
>>>> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>>>>
>>>> Add callback function to check if the card has been removed.
>>>>
>>>> in order to check if the card has been removed, the function mmc_send_status will send commad CMD13 to card and ask the card to send its status register to driver, which will generate interrupt repeatly and make the system bad.
>>>> Therefore, get_cd callback is used to detect the card if the driver has.
>>>>
>>>> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
>>>> ---
>>>> drivers/mmc/core/mmc.c | 5 ++++-
>>>> drivers/mmc/core/sd.c | 5 ++++-
>>>> 2 files changed, 8 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>>>> index 06084db..c5c676d 100644
>>>> --- a/drivers/mmc/core/mmc.c
>>>> +++ b/drivers/mmc/core/mmc.c
>>>> @@ -494,7 +494,10 @@ static void mmc_detect(struct mmc_host *host)
>>>> /*
>>>> * Just check if our card has been removed.
>>>> */
>>>> - err = mmc_send_status(host->card, NULL);
>>>> + if (host->ops->get_cd)
>>>> + err = !host->ops->get_cd(host);
>>>> + else
>>>> + err = mmc_send_status(host->card, NULL);
>>>>
>>>> mmc_release_host(host);
>>>>
>>>> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
>>>> index cd81c39..3cf1f38 100644
>>>> --- a/drivers/mmc/core/sd.c
>>>> +++ b/drivers/mmc/core/sd.c
>>>> @@ -548,7 +548,10 @@ static void mmc_sd_detect(struct mmc_host *host)
>>>> /*
>>>> * Just check if our card has been removed.
>>>> */
>>>> - err = mmc_send_status(host->card, NULL);
>>>> + if (host->ops->get_cd)
>>>> + err = !host->ops->get_cd(host);
>>>> + else
>>>> + err = mmc_send_status(host->card, NULL);
>>>>
>>>> mmc_release_host(host);
>>>>
>>>> --
>>>> 1.6.4
>>> This patchset wasn't replied to -- any comments on it from the list?
>> I think this change makes sense, although it needs to be a bit smarter
>> with error handling because the get_cd() functions can return -ENOSYS if
>> they are not implemented (but the function pointer is still valid).
>>
>> int err = 0;
>>
>> if (host->ops->get_cd) {
>> err = host->ops->get_cd(host);
>> if (err >= 0)
>> err = !err;
>> }
>>
>> if (!host->ops->get_cd || err < 0)
>> err = mmc_send_status(host->card, NULL);
>>
>> Thoughts?
>
> I am not sure it won't cause problems.
>
> If you change the card then card detect will return true because
> there is a card but send status will fail because the card is not
> initialised. So the two do not seem equivalent.
But maybe the following?
int err = 0;
if (host->ops->get_cd)
err = !host->ops->get_cd(host);
if (!err)
err = mmc_send_status(host->card, NULL);
>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] MMC/SD: add callback function to detect card
2010-08-31 19:40 ` Adrian Hunter
@ 2010-08-31 19:57 ` Adrian Hunter
2010-09-05 21:46 ` Matt Fleming
0 siblings, 1 reply; 9+ messages in thread
From: Adrian Hunter @ 2010-08-31 19:57 UTC (permalink / raw)
To: Matt Fleming
Cc: Chris Ball, r66093@freescale.com, linux-mmc@vger.kernel.org,
Jerry Huang
Adrian Hunter wrote:
> Adrian Hunter wrote:
>> Matt Fleming wrote:
>>> On Fri, Aug 27, 2010 at 08:05:13PM +0100, Chris Ball wrote:
>>>> Hi,
>>>>
>>>> On Fri, Dec 04, 2009 at 03:55:09PM +0800, r66093@freescale.com wrote:
>>>>> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>>>>>
>>>>> Add callback function to check if the card has been removed.
>>>>>
>>>>> in order to check if the card has been removed, the function mmc_send_status will send commad CMD13 to card and ask the card to send its status register to driver, which will generate interrupt repeatly and make the system bad.
>>>>> Therefore, get_cd callback is used to detect the card if the driver has.
>>>>>
>>>>> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
>>>>> ---
>>>>> drivers/mmc/core/mmc.c | 5 ++++-
>>>>> drivers/mmc/core/sd.c | 5 ++++-
>>>>> 2 files changed, 8 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>>>>> index 06084db..c5c676d 100644
>>>>> --- a/drivers/mmc/core/mmc.c
>>>>> +++ b/drivers/mmc/core/mmc.c
>>>>> @@ -494,7 +494,10 @@ static void mmc_detect(struct mmc_host *host)
>>>>> /*
>>>>> * Just check if our card has been removed.
>>>>> */
>>>>> - err = mmc_send_status(host->card, NULL);
>>>>> + if (host->ops->get_cd)
>>>>> + err = !host->ops->get_cd(host);
>>>>> + else
>>>>> + err = mmc_send_status(host->card, NULL);
>>>>>
>>>>> mmc_release_host(host);
>>>>>
>>>>> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
>>>>> index cd81c39..3cf1f38 100644
>>>>> --- a/drivers/mmc/core/sd.c
>>>>> +++ b/drivers/mmc/core/sd.c
>>>>> @@ -548,7 +548,10 @@ static void mmc_sd_detect(struct mmc_host *host)
>>>>> /*
>>>>> * Just check if our card has been removed.
>>>>> */
>>>>> - err = mmc_send_status(host->card, NULL);
>>>>> + if (host->ops->get_cd)
>>>>> + err = !host->ops->get_cd(host);
>>>>> + else
>>>>> + err = mmc_send_status(host->card, NULL);
>>>>>
>>>>> mmc_release_host(host);
>>>>>
>>>>> --
>>>>> 1.6.4
>>>> This patchset wasn't replied to -- any comments on it from the list?
>>> I think this change makes sense, although it needs to be a bit smarter
>>> with error handling because the get_cd() functions can return -ENOSYS if
>>> they are not implemented (but the function pointer is still valid).
>>>
>>> int err = 0;
>>>
>>> if (host->ops->get_cd) {
>>> err = host->ops->get_cd(host);
>>> if (err >= 0)
>>> err = !err;
>>> }
>>>
>>> if (!host->ops->get_cd || err < 0)
>>> err = mmc_send_status(host->card, NULL);
>>>
>>> Thoughts?
>> I am not sure it won't cause problems.
>>
>> If you change the card then card detect will return true because
>> there is a card but send status will fail because the card is not
>> initialised. So the two do not seem equivalent.
>
> But maybe the following?
>
> int err = 0;
>
> if (host->ops->get_cd)
> err = !host->ops->get_cd(host);
>
> if (!err)
> err = mmc_send_status(host->card, NULL);
But now I think it should be in the mmc_rescan() function
because that is where the main other use of .get_cd()
is, and also the only call of .detect().
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>
>>
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] MMC/SD: add callback function to detect card
2010-08-31 19:57 ` Adrian Hunter
@ 2010-09-05 21:46 ` Matt Fleming
0 siblings, 0 replies; 9+ messages in thread
From: Matt Fleming @ 2010-09-05 21:46 UTC (permalink / raw)
To: Adrian Hunter
Cc: Chris Ball, r66093@freescale.com, linux-mmc@vger.kernel.org,
Jerry Huang
On Tue, Aug 31, 2010 at 10:57:25PM +0300, Adrian Hunter wrote:
>
> But now I think it should be in the mmc_rescan() function
> because that is where the main other use of .get_cd()
> is, and also the only call of .detect().
That's a very good point. Aren't we duplicating the code in mmc_rescan()
with this patch? If there's something that mmc_rescan() isn't doing,
wouldn't it be better to modify that function instead of pushing it down
into the bus_ops detect functions?
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-09-05 21:46 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-04 7:55 [PATCH 3/3] MMC/SD: add callback function to detect card r66093
2010-01-06 2:40 ` Huang Changming-R66093
2010-08-27 19:05 ` Chris Ball
2010-08-31 19:10 ` Matt Fleming
2010-08-31 19:23 ` Adrian Hunter
2010-08-31 19:38 ` Matt Fleming
2010-08-31 19:40 ` Adrian Hunter
2010-08-31 19:57 ` Adrian Hunter
2010-09-05 21:46 ` Matt Fleming
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).