Re: [PATCH 2/5 V2] MMC: wbsd.c fix shadowing of 'dma' variable

Previous thread: [RFT] x86 acpi: normalize segment descriptor register on resume by Rafael J. Wysocki on Monday, June 30, 2008 - 4:48 pm. (53 messages)

Next thread: [PATCH] Add btgpio driver by Michael Buesch on Monday, June 30, 2008 - 5:06 pm. (8 messages)
From: Tomas Winkler
Date: Monday, June 30, 2008 - 4:53 pm

From: Benzi Zbit <Benzi.Zbit@intel.com>

This adds reading and using of enable_timeout from the CIS

Signed-off-by: Benzi Zbit <Benzi.Zbit@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/mmc/core/sdio_cis.c   |    2 ++
 drivers/mmc/core/sdio_io.c    |    7 ++-----
 include/linux/mmc/sdio_func.h |    1 +
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c
index d5e51b1..e3a9797 100644
--- a/drivers/mmc/core/sdio_cis.c
+++ b/drivers/mmc/core/sdio_cis.c
@@ -129,6 +129,8 @@ static int cistpl_funce_func(struct sdio_func *func,
 	/* TPLFE_MAX_BLK_SIZE */
 	func->max_blksize = buf[12] | (buf[13] << 8);
 
+	/* TPLFE_ENABLE_TIMEOUT_VAL */
+	func->enable_timeout = buf[28] | (buf[29] << 8);
 	return 0;
 }
 
diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c
index 625b92c..252c4fd 100644
--- a/drivers/mmc/core/sdio_io.c
+++ b/drivers/mmc/core/sdio_io.c
@@ -76,11 +76,8 @@ int sdio_enable_func(struct sdio_func *func)
 	if (ret)
 		goto err;
 
-	/*
-	 * FIXME: This should timeout based on information in the CIS,
-	 * but we don't have card to parse that yet.
-	 */
-	timeout = jiffies + HZ;
+	/* max enable timeout is in units of 10mS */
+	timeout = jiffies + msecs_to_jiffies(func->enable_timeout * 10);
 
 	while (1) {
 		ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IORx, 0, &reg);
diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h
index b050f4d..8de40f1 100644
--- a/include/linux/mmc/sdio_func.h
+++ b/include/linux/mmc/sdio_func.h
@@ -46,6 +46,7 @@ struct sdio_func {
 	unsigned		max_blksize;	/* maximum block size */
 	unsigned		cur_blksize;	/* current block size */
 
+	unsigned		enable_timeout;	/* max enable timeout in units of 10mS steps */
 	unsigned int		state;		/* function state */
 #define SDIO_STATE_PRESENT	(1<<0)		/* present in sysfs */
 
-- ...
From: Tomas Winkler
Date: Monday, June 30, 2008 - 4:53 pm

This patch fix warning :shadowing dma variable
and made use of module_param_named instead of module_param

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/mmc/host/wbsd.c |   39 ++++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c
index 67e5a9b..9dffe5f 100644
--- a/drivers/mmc/host/wbsd.c
+++ b/drivers/mmc/host/wbsd.c
@@ -68,16 +68,16 @@ static const int unlock_codes[] = { 0x83, 0x87 };
 
 static const int valid_ids[] = {
 	0x7112,
-	};
+};
 
 #ifdef CONFIG_PNP
-static unsigned int nopnp = 0;
+static unsigned int param_nopnp = 0;
 #else
-static const unsigned int nopnp = 1;
+static const unsigned int param_nopnp = 1;
 #endif
-static unsigned int io = 0x248;
-static unsigned int irq = 6;
-static int dma = 2;
+static unsigned int param_io = 0x248;
+static unsigned int param_irq = 6;
+static int param_dma = 2;
 
 /*
  * Basic functions
@@ -1765,7 +1765,7 @@ static void __devexit wbsd_shutdown(struct device *dev, int pnp)
 static int __devinit wbsd_probe(struct platform_device *dev)
 {
 	/* Use the module parameters for resources */
-	return wbsd_init(&dev->dev, io, irq, dma, 0);
+	return wbsd_init(&dev->dev, param_io, param_irq, param_dma, 0);
 }
 
 static int __devexit wbsd_remove(struct platform_device *dev)
@@ -1979,14 +1979,14 @@ static int __init wbsd_drv_init(void)
 
 #ifdef CONFIG_PNP
 
-	if (!nopnp) {
+	if (!param_nopnp) {
 		result = pnp_register_driver(&wbsd_pnp_driver);
 		if (result < 0)
 			return result;
 	}
 #endif /* CONFIG_PNP */
 
-	if (nopnp) {
+	if (param_nopnp) {
 		result = platform_driver_register(&wbsd_driver);
 		if (result < 0)
 			return result;
@@ -2012,12 +2012,12 @@ static void __exit wbsd_drv_exit(void)
 {
 #ifdef CONFIG_PNP
 
-	if (!nopnp)
+	if (!param_nopnp)
 		pnp_unregister_driver(&wbsd_pnp_driver);
 
 #endif /* CONFIG_PNP */
 
-	if (nopnp) {
+	if (param_nopnp) {
 ...
From: Tomas Winkler
Date: Monday, June 30, 2008 - 4:53 pm

This patch fixes sdio_io sparse errors.
This fix changes signature of API functions,
changing
unsigned char -> u8
unsigned short -> u16
unsigned long -> u32 - this was probably a bug in 64 bit platforms

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/mmc/core/sdio_io.c    |   43 +++++++++++++++-------------------------
 include/linux/mmc/sdio_func.h |   33 ++++++++++++++-----------------
 2 files changed, 31 insertions(+), 45 deletions(-)
 mode change 100644 => 100755 drivers/mmc/core/sdio_io.c
 mode change 100644 => 100755 include/linux/mmc/sdio_func.h

diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c
old mode 100644
new mode 100755
index 252c4fd..62ebeba
--- a/drivers/mmc/core/sdio_io.c
+++ b/drivers/mmc/core/sdio_io.c
@@ -164,10 +164,8 @@ int sdio_set_block_size(struct sdio_func *func, unsigned blksz)
 		return -EINVAL;
 
 	if (blksz == 0) {
-		blksz = min(min(
-			func->max_blksize,
-			func->card->host->max_blk_size),
-			512u);
+		blksz = min(func->max_blksize, func->card->host->max_blk_size);
+		blksz = min(blksz, 512u);
 	}
 
 	ret = mmc_io_rw_direct(func->card, 1, 0,
@@ -183,7 +181,6 @@ int sdio_set_block_size(struct sdio_func *func, unsigned blksz)
 	func->cur_blksize = blksz;
 	return 0;
 }
-
 EXPORT_SYMBOL_GPL(sdio_set_block_size);
 
 /* Split an arbitrarily sized data transfer into several
@@ -200,10 +197,9 @@ static int sdio_io_rw_ext_helper(struct sdio_func *func, int write,
 		/* Blocks per command is limited by host count, host transfer
 		 * size (we only use a single sg entry) and the maximum for
 		 * IO_RW_EXTENDED of 511 blocks. */
-		max_blocks = min(min(
-			func->card->host->max_blk_count,
-			func->card->host->max_seg_size / func->cur_blksize),
-			511u);
+		max_blocks = min(func->card->host->max_blk_count,
+			func->card->host->max_seg_size / func->cur_blksize);
+		max_blocks = min(max_blocks, 511u);
 
 		while (remainder > func->cur_blksize) {
 			unsigned blocks;
@@ -257,11 +253,10 @@ ...
From: Tomas Winkler
Date: Monday, June 30, 2008 - 4:53 pm

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/mmc/host/sdhci.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6441e44..aa268e3 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -386,12 +386,12 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
 	}
 
 	if (host->flags & SDHCI_REQ_USE_DMA) {
-		int count;
+		int dma_cnt;
 
-		count = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
+		dma_cnt = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
 				(data->flags & MMC_DATA_READ) ?
 					DMA_FROM_DEVICE : DMA_TO_DEVICE);
-		WARN_ON(count != 1);
+		WARN_ON(dma_cnt != 1);
 
 		writel(sg_dma_address(data->sg),
 			host->ioaddr + SDHCI_DMA_ADDRESS);
@@ -1224,7 +1224,7 @@ int sdhci_add_host(struct sdhci_host *host)
 
 	/* XXX: Hack to get MMC layer to avoid highmem */
 	if (!(host->flags & SDHCI_USE_DMA))
-		mmc_dev(host->mmc)->dma_mask = 0;
+		mmc_dev(host->mmc)->dma_mask = NULL;
 
 	host->max_clk =
 		(caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT;
-- 
1.5.4.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

--

From: Tomas Winkler
Date: Monday, June 30, 2008 - 4:53 pm

This patch cleans up endianity conversions im mmc core

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/mmc/card/block.c   |    5 ++---
 drivers/mmc/core/mmc_ops.c |   12 ++++++------
 drivers/mmc/core/sd_ops.c  |    7 ++++---
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index f9ad960..4b840de 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -144,7 +144,7 @@ struct mmc_blk_request {
 static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
 {
 	int err;
-	u32 blocks;
+	__be32 blocks;
 
 	struct mmc_request mrq;
 	struct mmc_command cmd;
@@ -203,9 +203,8 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card)
 	if (cmd.error || data.error)
 		return (u32)-1;
 
-	blocks = ntohl(blocks);
 
-	return blocks;
+	return be32_to_cpu(blocks);
 }
 
 static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index e6703e5..3ad340c 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -271,17 +271,17 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
 int mmc_send_csd(struct mmc_card *card, u32 *csd)
 {
 	int ret, i;
-
+	__be32 csd_buf[4];
 	if (!mmc_host_is_spi(card->host))
 		return mmc_send_cxd_native(card->host, card->rca << 16,
 				csd, MMC_SEND_CSD);
 
-	ret = mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16);
+	ret = mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd_buf, 16);
 	if (ret)
 		return ret;
 
 	for (i = 0;i < 4;i++)
-		csd[i] = be32_to_cpu(csd[i]);
+		csd[i] = be32_to_cpu(csd_buf[i]);
 
 	return 0;
 }
@@ -289,7 +289,7 @@ int mmc_send_csd(struct mmc_card *card, u32 *csd)
 int mmc_send_cid(struct mmc_host *host, u32 *cid)
 {
 	int ret, i;
-
+	__be32 cid_buf[4];
 	if (!mmc_host_is_spi(host)) {
 		if (!host->card)
 			return -EINVAL;
@@ -297,12 +297,12 @@ int mmc_send_cid(struct mmc_host *host, u32 ...
From: Marcel Holtmann
Date: Monday, June 30, 2008 - 6:51 pm

what is up with this empty line removal. I would keep the empty line

While you are at it. Add the missing whitespace in the for statement :)

Otherwise, looks good to me.

Regards

Marcel


--

From: Marcel Holtmann
Date: Monday, June 30, 2008 - 6:47 pm

can you include what sparse error this is trying to fix. From the patch
itself, I can't see it.

Regards

Marcel


--

From: Marcel Holtmann
Date: Monday, June 30, 2008 - 6:54 pm

I agree that your version is more readable, but I would be still
interested in which sparse error this fixes.

Other than that the patch looks good.

Regards

Marcel


--

From: Marcel Holtmann
Date: Monday, June 30, 2008 - 6:44 pm

looks good to me.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel


--

From: Pierre Ossman
Date: Saturday, July 5, 2008 - 3:38 pm

On Tue,  1 Jul 2008 02:53:01 +0300

Ooops. It should of course been this I applied. Redone with the right
patch. :)

--=20
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  rdesktop, core developer          http://www.rdesktop.org

  WARNING: This correspondence is being monitored by the
  Swedish government. Make sure your server uses encryption
  for SMTP traffic and consider using PGP for end-to-end
  encryption.
From: Marcel Holtmann
Date: Monday, June 30, 2008 - 6:45 pm

looks good.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel


--

Previous thread: [RFT] x86 acpi: normalize segment descriptor register on resume by Rafael J. Wysocki on Monday, June 30, 2008 - 4:48 pm. (53 messages)

Next thread: [PATCH] Add btgpio driver by Michael Buesch on Monday, June 30, 2008 - 5:06 pm. (8 messages)