LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Roel Kluin <12o3l@tiscali.nl>
To: Carlos Aguiar <carlos.aguiar@indt.org.br>
Cc: Pierre Ossman <drzeus-list@drzeus.cx>,
	Tony Lindgren <tony@atomide.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 05/18] MMC: OMAP: Introduce new multislot structure and change driver to use it
Date: Tue, 29 Jan 2008 02:17:12 +0100	[thread overview]
Message-ID: <479E7E98.3080807@tiscali.nl> (raw)
In-Reply-To: <479E27EB.3040502@indt.org.br>

Carlos Aguiar wrote:
> From: Juha Yrjola <juha.yrjola@solidboot.com>
> 
> Introduce new MMC multislot structure and change driver to use it.

> diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c

It could be that I misunderstand, but...

> @@ -897,19 +1037,106 @@ static const struct mmc_host_ops mmc_omap_ops = {
>  	.get_ro		= mmc_omap_get_ro,
>  };
>  
> -static int __init mmc_omap_probe(struct platform_device *pdev)
> +static int __init mmc_omap_new_slot(struct mmc_omap_host *host, int id)
>  {
> -	struct omap_mmc_conf *minfo = pdev->dev.platform_data;
> +	struct mmc_omap_slot *slot = NULL;
>  	struct mmc_host *mmc;
> +	int r;
> +
> +	mmc = mmc_alloc_host(sizeof(struct mmc_omap_slot), host->dev);

since you mmc_alloc_host here...

> +	if (mmc == NULL)
> +		return -ENOMEM;
> +
> +	slot = mmc_priv(mmc);
> +	slot->host = host;
> +	slot->mmc = mmc;
> +	slot->id = id;
> +	slot->pdata = &host->pdata->slots[id];
> +
> +	host->slots[id] = slot;
> +
> +	mmc->caps = MMC_CAP_MULTIWRITE | MMC_CAP_MMC_HIGHSPEED |
> +		    MMC_CAP_SD_HIGHSPEED;
> +	if (host->pdata->conf.wire4)
> +		mmc->caps |= MMC_CAP_4_BIT_DATA;
> +
> +	mmc->ops = &mmc_omap_ops;
> +	mmc->f_min = 400000;
> +
> +	if (cpu_class_is_omap2())
> +		mmc->f_max = 48000000;
> +	else
> +		mmc->f_max = 24000000;
> +	if (host->pdata->max_freq)
> +		mmc->f_max = min(host->pdata->max_freq, mmc->f_max);
> +	mmc->ocr_avail = slot->pdata->ocr_mask;
> +
> +	/* Use scatterlist DMA to reduce per-transfer costs.
> +	 * NOTE max_seg_size assumption that small blocks aren't
> +	 * normally used (except e.g. for reading SD registers).
> +	 */
> +	mmc->max_phys_segs = 32;
> +	mmc->max_hw_segs = 32;
> +	mmc->max_blk_size = 2048;	/* BLEN is 11 bits (+1) */
> +	mmc->max_blk_count = 2048;	/* NBLK is 11 bits (+1) */
> +	mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
> +	mmc->max_seg_size = mmc->max_req_size;
> +
> +	r = mmc_add_host(mmc);
> +	if (r < 0)
> +		return r;

shouldn't you mmc_free_host(mmc) here?

> +
> +	if (slot->pdata->name != NULL) {
> +		r = device_create_file(&mmc->class_dev,
> +					&dev_attr_slot_name);
> +		if (r < 0)
> +			goto err_remove_host;
> +	}
> +
> +	if (slot->pdata->get_ro != NULL) {
> +		r = device_create_file(&mmc->class_dev,
> +					&dev_attr_ro);
> +	}
> +
> +	return 0;
> +
> +err_remove_slot_name:

This label has no goto, so the 2 lines below are dead code...
Ok, now I see It's in the next patch. (maybe better to put these lines
in that patch?)

> +	if (slot->pdata->name != NULL)
> +		device_remove_file(&mmc->class_dev, &dev_attr_ro);
> +err_remove_host:
> +	mmc_remove_host(mmc);

and maybe mmc_free_host(mmc) here?

> +	return r;
> +}

from mmc_omap_probe()

+	for (i = 0; i < pdata->nr_slots; i++) {
+		ret = mmc_omap_new_slot(host, i);
+		if (ret < 0) {
+			while (--i >= 0)
+				mmc_omap_remove_slot(host->slots[i]);

mmc_omap_remove_slot() does a mmc_free_host(), but note the decrement of i:
the current isn't freed.

  reply	other threads:[~2008-01-29  1:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-28 19:07 Carlos Aguiar
2008-01-29  1:17 ` Roel Kluin [this message]
2008-02-07 17:37 ` Pierre Ossman
2008-03-05 20:54   ` Felipe Balbi
2008-03-06  6:34     ` Pierre Ossman
2008-03-14 19:35 [PATCH 00/18] MMC: OMAP: Sync MMC OMAP driver with mainline tree Carlos Aguiar
2008-03-24 12:26 ` Pierre Ossman
2008-03-26 20:08   ` [PATCH 05/18] MMC: OMAP: Introduce new multislot structure and change driver to use it Carlos Aguiar
2008-03-14 19:36 Carlos Aguiar
2008-03-24 12:13 ` Pierre Ossman

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=479E7E98.3080807@tiscali.nl \
    --to=12o3l@tiscali.nl \
    --cc=carlos.aguiar@indt.org.br \
    --cc=drzeus-list@drzeus.cx \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony@atomide.com \
    --subject='Re: [PATCH 05/18] MMC: OMAP: Introduce new multislot structure and change driver to use it' \
    /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

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