public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Aaron Lu <aaron.lu@amd.com>
To: Huang Changming-R66093 <r66093@freescale.com>
Cc: "linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	Chris Ball <cjb@laptop.org>
Subject: Re: [PATCH 2/4 v4] MMC/SD: Add callback function to detect card
Date: Fri, 13 Jan 2012 14:27:32 +0800	[thread overview]
Message-ID: <20120113062730.GB2701@ladygaga> (raw)
In-Reply-To: <8A2FC72B45BB5A4C9F801431E06AE48F1166949C@039-SN1MPN1-005.039d.mgd.msft.net>

Hi,

On Fri, Jan 13, 2012 at 04:52:42AM +0000, Huang Changming-R66093 wrote:
> 
> > For sd hosts, this should only happen for hosts which have
> > SDHCI_QUIRK_BROKEN_CARD_DETECTION set.
> Yes, but which will impact the performance.

You only set this bit when your host broke, and if your host has other
means to detect this, then go with your newly added callback.

> 
> 
> > > >
> > > > Therefore, add callback function get_cd() to check whether the card
> > > > has been removed when the driver has this callback function.
> > 
> > I don't quite get the meaning of cd, what does get_cd suppose to mean?
> This get_cd callback is implement in the special platform, because some SOC don't support this feature
> 
> > > >
> > > > If the card is present, 1 will return, if the card is absent, 0 will
> > > > return.
> > > > If the controller will not support this feature, -ENOSYS will return.
> > 
> > What about get_present, return 0 for present, and return error code
> > otherwise like the alive function does.
> The hook to detect card is get_cd in the kernel, don't need the new.
> 

I didn't mean to add a new function, I just can't get the meaning of cd.
I just did a grep of the code and find some same fuction names in
various host files, I think it's OK to continue with this name.

> > > >
> > > > Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> > > > CC: Chris Ball <cjb@laptop.org>
> > > > ---
> > > > changes for v2:
> > > >         - when controller don't support get_cd, return -ENOSYS
> > > >         - add the CC
> > > > changes for v3:
> > > >         - enalbe the controller clock in platform, instead of core
> > > > changes for v4:
> > > > 	- move the detect code to core.c according to the new structure
> > > >
> > > >  drivers/mmc/core/core.c |   10 ++++++++--
> > > >  1 files changed, 8 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index
> > > > 6db6621..d570c72 100644
> > > > --- a/drivers/mmc/core/core.c
> > > > +++ b/drivers/mmc/core/core.c
> > > > @@ -2060,7 +2060,7 @@ static int mmc_rescan_try_freq(struct mmc_host
> > > > *host, unsigned freq)
> > > >
> > 
> > snip
> > > >  int _mmc_detect_card_removed(struct mmc_host *host)  {
> > > > -	int ret;
> > > > +	int ret = -ENOSYS;
> > > >
> > > >  	if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
> > > >  		return 0;
> > > > @@ -2068,7 +2068,13 @@ int _mmc_detect_card_removed(struct mmc_host
> > *host)
> > > >  	if (!host->card || mmc_card_removed(host->card))
> > > >  		return 1;
> > > >
> > > > -	ret = host->bus_ops->alive(host);
> > > > +	if (host->ops->get_cd) {
> > > > +		ret = host->ops->get_cd(host);
> > > > +		if (ret >= 0)
> > > > +			ret = !ret;
> > > > +	}
> > > > +	if (ret < 0)
> > > > +		ret = host->bus_ops->alive(host);
> > > >  	if (ret) {
> > > >  		mmc_card_set_removed(host->card);
> > > >  		pr_debug("%s: card remove detected\n", mmc_hostname(host));
> > > > --
> > > > 1.7.5.4
> > 
> > And the code can be changed to something like:
> > 	if (host->ops->get_present)
> > 		ret = host->ops->get_present(host);
> > 	else
> > 		ret = host->bus_ops->alive(host);
> > 	if (ret) {
> > 		mmc_card_set_removed(host->card);
> >   		pr_debug("%s: card remove detected\n", mmc_hostname(host));
> > 	}
> > 
> > 
> > Does this make sense?
> No.
> Because the get_cd is the hook to detect card in mmc_host_ops structure in include/linux/mmc/host.h.
> We don't need to add new.
>

I just suggested to change the name and use a different return value for
this get_cd function, not to add a new function call.



  reply	other threads:[~2012-01-13  6:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-27  8:00 [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
2012-01-13  2:25 ` Huang Changming-R66093
2012-01-13  3:26   ` Aaron Lu
2012-01-13  4:52     ` Huang Changming-R66093
2012-01-13  6:27       ` Aaron Lu [this message]
2012-01-13  7:05         ` Huang Changming-R66093
2012-01-13  7:36           ` Aaron Lu
  -- strict thread matches above, loose matches on Subject: below --
2012-10-30  8:12 [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on() r66093
2012-10-30  8:12 ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
2012-10-30 11:34   ` Girish K S
2012-10-31  2:23     ` Huang Changming-R66093
2012-10-31  4:29       ` Jaehoon Chung
2012-10-31  5:52         ` Huang Changming-R66093
2012-11-01 15:57   ` Johan Rudholm
2012-11-02  1:37     ` Huang Changming-R66093
2012-11-02 10:33       ` Johan Rudholm
2012-11-05  3:17         ` Huang Changming-R66093
2012-11-05 14:07           ` Johan Rudholm
2012-11-06  1:55             ` Huang Changming-R66093
2012-11-06  1:55             ` Huang Changming-R66093
2012-11-13  7:50               ` Huang Changming-R66093
2012-11-19  2:48             ` Huang Changming-R66093
2012-11-19  3:05   ` Anton Vorontsov
2012-11-19  3:11     ` Huang Changming-R66093

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120113062730.GB2701@ladygaga \
    --to=aaron.lu@amd.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=r66093@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox