MMC: core - fix the use of hard coded timeout value.
Subsystems (3)
PATCH v2 1/5 MMC: core - fix the use of hard coded timeout value.
From: Benzi Zbit <[email protected]>
This adds reading and using of enable_timeout from the CIS
--- 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(-)
drivers/mmc/core/sdio_cis.c +2 -0
@@ -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 ; }
drivers/mmc/core/sdio_io.c +2 -5
@@ -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 , ®);
include/linux/mmc/sdio_func.h +1 -0
@@ -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 */
Signature · 9 lines
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.
PATCH v2 2/5 MMC: wbsd.c fix shadowing of 'dma' variable
This patch fix warning :shadowing dma variable and made use of module_param_named instead of module_param
--- drivers/mmc/host/wbsd.c | 39 ++++++++++++++++++++------------------- 1 files changed, 20 insertions(+), 19 deletions(-)
drivers/mmc/host/wbsd.c +20 -19
@@ -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) {platform_device_unregister (wbsd_device);platform_driver_unregister (&wbsd_driver);
@@ -2029,15 +2029,11 @@ static void __exit wbsd_drv_exit(void)module_init (wbsd_drv_init);module_exit (wbsd_drv_exit);#ifdef CONFIG_PNP -module_param (nopnp, uint,0444 ); +module_param_named (nopnp, param_nopnp, uint,0444 );#endif -module_param (io, uint,0444 ); -module_param (irq, uint,0444 ); -module_param (dma, int,0444 ); - -MODULE_LICENSE ("GPL" ); -MODULE_AUTHOR ("Pierre Ossman <[email protected]>" ); -MODULE_DESCRIPTION ("Winbond W83L51xD SD/MMC card interface driver" ); +module_param_named (io, param_io, uint,0444 ); +module_param_named (irq, param_irq, uint,0444 ); +module_param_named (dma, param_dma, int,0444 );#ifdef CONFIG_PNP MODULE_PARM_DESC (nopnp,"Scan for device instead of relying on PNP. (default 0)" );
@@ -2045,3 +2041,8 @@ MODULE_PARM_DESC(nopnp, "Scan for device instead of relying on PNP. (default 0)"MODULE_PARM_DESC (io,"I/O base to allocate. Must be 8 byte aligned. (default 0x248)" );MODULE_PARM_DESC (irq,"IRQ to allocate. (default 6)" );MODULE_PARM_DESC (dma,"DMA channel to allocate. -1 for no DMA. (default 2)" ); + +MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR ("Pierre Ossman <[email protected]>" ); +MODULE_DESCRIPTION ("Winbond W83L51xD SD/MMC card interface driver" ); +
Signature · 9 lines
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.
PATCH 3/5 MMC: fix sdio_io sparse errors
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
--- 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
drivers/mmc/core/sdio_io.c +16 -27
@@ -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 @@ static int sdio_io_rw_ext_helper(struct sdio_func *func, int write,* function. If there is a problem reading the address, 0xff * is returned and @err_ret will contain the error code. */ -unsigned char sdio_readb (struct sdio_func *func,unsigned int addr, -int *err_ret) +u8 sdio_readb (struct sdio_func *func,unsigned int addr,int *err_ret) {int ret; -unsigned char val; +u8 val;BUG_ON (!func);
@@ -290,8 +285,7 @@ EXPORT_SYMBOL_GPL(sdio_readb);* function. @err_ret will contain the status of the actual * transfer. */ -void sdio_writeb (struct sdio_func *func,unsigned char b,unsigned int addr, -int *err_ret) +void sdio_writeb (struct sdio_func *func,u8 b,unsigned int addr,int *err_ret) {int ret;
@@ -352,7 +346,6 @@ int sdio_readsb(struct sdio_func *func, void *dst, unsigned int addr, {return sdio_io_rw_ext_helper (func,0 , addr,0 , dst, count); } -EXPORT_SYMBOL_GPL (sdio_readsb);/**
@@ -382,8 +375,7 @@ EXPORT_SYMBOL_GPL(sdio_writesb);* function. If there is a problem reading the address, 0xffff * is returned and @err_ret will contain the error code. */ -unsigned short sdio_readw (struct sdio_func *func,unsigned int addr, -int *err_ret) +u16 sdio_readw (struct sdio_func *func,unsigned int addr,int *err_ret) {int ret;
@@ -397,7 +389,7 @@ unsigned short sdio_readw(struct sdio_func *func, unsigned int addr,return 0xFFFF ; } -return le16_to_cpu (*(u16 *)func->tmpbuf); +return le16_to_cpup ((__le16 *)func->tmpbuf); }EXPORT_SYMBOL_GPL (sdio_readw);
@@ -412,12 +404,11 @@ EXPORT_SYMBOL_GPL(sdio_readw);* function. @err_ret will contain the status of the actual * transfer. */ -void sdio_writew (struct sdio_func *func,unsigned short b,unsigned int addr, -int *err_ret) +void sdio_writew (struct sdio_func *func,u16 b,unsigned int addr,int *err_ret) {int ret; - *(u16 *)func->tmpbuf =cpu_to_le16 (b); + *(__le16 *)func->tmpbuf =cpu_to_le16 (b); ret =sdio_memcpy_toio (func, addr, func->tmpbuf,2 );if (err_ret)
@@ -436,8 +427,7 @@ EXPORT_SYMBOL_GPL(sdio_writew);* 0xffffffff is returned and @err_ret will contain the error * code. */ -unsigned long sdio_readl (struct sdio_func *func,unsigned int addr, -int *err_ret) +u32 sdio_readl (struct sdio_func *func,unsigned int addr,int *err_ret) {int ret;
@@ -451,7 +441,7 @@ unsigned long sdio_readl(struct sdio_func *func, unsigned int addr,return 0xFFFFFFFF ; } -return le32_to_cpu (*(u32 *)func->tmpbuf); +return le32_to_cpup ((__le32 *)func->tmpbuf); }EXPORT_SYMBOL_GPL (sdio_readl);
@@ -466,12 +456,11 @@ EXPORT_SYMBOL_GPL(sdio_readl);* function. @err_ret will contain the status of the actual * transfer. */ -void sdio_writel (struct sdio_func *func,unsigned long b,unsigned int addr, -int *err_ret) +void sdio_writel (struct sdio_func *func,u32 b,unsigned int addr,int *err_ret) {int ret; - *(u32 *)func->tmpbuf =cpu_to_le32 (b); + *(__le32 *)func->tmpbuf =cpu_to_le32 (b); ret =sdio_memcpy_toio (func, addr, func->tmpbuf,4 );if (err_ret)
include/linux/mmc/sdio_func.h +15 -18
@@ -121,34 +121,31 @@ extern int sdio_set_block_size(struct sdio_func *func, unsigned blksz);extern int sdio_claim_irq (struct sdio_func *func,sdio_irq_handler_t *handler);extern int sdio_release_irq (struct sdio_func *func); -extern unsigned char sdio_readb (struct sdio_func *func, -unsigned int addr,int *err_ret); -extern unsigned short sdio_readw (struct sdio_func *func, -unsigned int addr,int *err_ret); -extern unsigned long sdio_readl (struct sdio_func *func, -unsigned int addr,int *err_ret); +extern u8 sdio_readb (struct sdio_func *func,unsigned int addr,int *err_ret); +extern u16 sdio_readw (struct sdio_func *func,unsigned int addr,int *err_ret); +extern u32 sdio_readl (struct sdio_func *func,unsigned int addr,int *err_ret);extern int sdio_memcpy_fromio (struct sdio_func *func,void *dst, -unsigned int addr,int count); +unsigned int addr,int count);extern int sdio_readsb (struct sdio_func *func,void *dst, -unsigned int addr,int count); +unsigned int addr,int count); -extern void sdio_writeb (struct sdio_func *func,unsigned char b, -unsigned int addr,int *err_ret); -extern void sdio_writew (struct sdio_func *func,unsigned short b, -unsigned int addr,int *err_ret); -extern void sdio_writel (struct sdio_func *func,unsigned long b, -unsigned int addr,int *err_ret); +extern void sdio_writeb (struct sdio_func *func,u8 b, +unsigned int addr,int *err_ret); +extern void sdio_writew (struct sdio_func *func,u16 b, +unsigned int addr,int *err_ret); +extern void sdio_writel (struct sdio_func *func,u32 b, +unsigned int addr,int *err_ret);extern int sdio_memcpy_toio (struct sdio_func *func,unsigned int addr, -void *src,int count); +void *src,int count);extern int sdio_writesb (struct sdio_func *func,unsigned int addr, -void *src,int count); +void *src,int count);extern unsigned char sdio_f0_readb (struct sdio_func *func, -unsigned int addr,int *err_ret); +unsigned int addr,int *err_ret);extern void sdio_f0_writeb (struct sdio_func *func,unsigned char b, -unsigned int addr,int *err_ret); +unsigned int addr,int *err_ret);#endif
Signature · 9 lines
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.
PATCH 4/5 MMC: fix spares errors of sdhci.c
--- drivers/mmc/host/sdhci.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci.c +4 -4
@@ -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 ;
Signature · 9 lines
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.
PATCH 5/5 MMC: cleanup endianity conversions
This patch cleans up endianity conversions im mmc core
--- 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(-)
drivers/mmc/card/block.c +2 -3
@@ -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)
drivers/mmc/core/mmc_ops.c +6 -6
@@ -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 *cid) cid, MMC_SEND_CID); } - ret =mmc_send_cxd_data (NULL , host,MMC_SEND_CID , cid,16 ); + ret =mmc_send_cxd_data (NULL , host,MMC_SEND_CID , cid_buf,16 );if (ret)return ret;for (i =0 ;i <4 ;i++) - cid[i] =be32_to_cpu (cid[i]); + cid[i] =be32_to_cpu (cid_buf[i]);return 0 ; }
drivers/mmc/core/sd_ops.c +4 -3
@@ -254,6 +254,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)struct mmc_command cmd;struct mmc_data data;struct scatterlist sg; +__be32 scr_buf[2 ];BUG_ON (!card);BUG_ON (!card->host);
@@ -282,7 +283,7 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) data.sg = &sg; data.sg_len =1 ; -sg_init_one (&sg, scr,8 ); +sg_init_one (&sg, scr_buf,8 );mmc_set_data_timeout (&data, card);
@@ -293,8 +294,8 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr)if (data.error)return data.error; - scr[0 ] =be32_to_cpu (scr[0 ]); - scr[1 ] =be32_to_cpu (scr[1 ]); + scr[0 ] =be32_to_cpu (scr_buf[0 ]); + scr[1 ] =be32_to_cpu (scr_buf[1 ]);return 0 ; }
Signature · 9 lines
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.
Re: [PATCH 5/5] MMC: cleanup endianity conversions
Hi Tomas,
Quoted 6 lines
static int
mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)drivers/mmc/core/mmc_ops.c +0
-0
drivers/mmc/core/mmc_ops.c mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, · line 277
Quoted 8 lines
drivers/mmc/core/mmc_ops.c +1
-1@@ -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 );
what is up with this empty line removal. I would keep the empty line after the variable declaration.
drivers/mmc/core/mmc_ops.c mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, · line 284
Quoted 3 lines
drivers/mmc/core/mmc_ops.c +1
-1for (i =0 ;i <4 ;i++) - csd[i] =be32_to_cpu (csd[i]); + csd[i] =be32_to_cpu (csd_buf[i]);
While you are at it. Add the missing whitespace in the for statement :)
Otherwise, looks good to me.
Regards
Marcel
Re: [PATCH 4/5] MMC: fix spares errors of sdhci.c
In reply to Tomas WinklerHi Tomas,
drivers/mmc/host/sdhci.c static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) · line 394
Quoted 10 lines
drivers/mmc/host/sdhci.c +3
-3if (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 );
can you include what sparse error this is trying to fix. From the patch itself, I can't see it.
Regards
Marcel
Re: [PATCH 3/5] MMC: fix sdio_io sparse errors
In reply to Tomas WinklerHi Tomas,
drivers/mmc/core/sdio_io.c int sdio_set_block_size(struct sdio_func *func, unsigned blksz) · line 169
Quoted 8 lines
drivers/mmc/core/sdio_io.c +2
-4if (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 ); }
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
Re: [PATCH 2/5 V2] MMC: wbsd.c fix shadowing of 'dma' variable
In reply to Tomas WinklerHi Tomas,
Quoted 4 lines
This patch fix warning :shadowing dma variable and made use of
module_param_namedinstead ofmodule_paramSigned-off-by Tomas Winkler <[email protected]>
looks good to me.
Regards
Marcel
Re: [PATCH 2/5 V2] MMC: wbsd.c fix shadowing of 'dma' variable
In reply to Tomas WinklerQuoted 5 lines · On Tue, 1 Jul 2008 02:53:01 +0300 Tomas Winkler <[email protected]>…
This patch fix warning :shadowing dma variable and made use of
module_param_namedinstead ofmodule_paramSigned-off-by Tomas Winkler <[email protected]>---
Ooops. It should of course been this I applied. Redone with the right patch. :)
Signature · 9 lines
-- 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.
Hi Tomas,
Quoted 4 lines
This adds reading and using of
enable_timeoutfrom the CISSigned-off-by Benzi Zbit <[email protected]>Signed-off-by Tomas Winkler <[email protected]>
looks good.
Regards
Marcel