Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 65628
b: refs/heads/master
c: 9a08f82
h: refs/heads/master
v: v3
  • Loading branch information
David Vrabel authored and Pierre Ossman committed Sep 23, 2007
1 parent 5ec75ca commit 388d606
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7616ee95f27a04fd5a6434e9ef4a82cec4b2807c
refs/heads/master: 9a08f82b3cc522f727ace580a2aaee5402435bc8
9 changes: 9 additions & 0 deletions trunk/drivers/mmc/core/sdio_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,20 @@ static int sdio_bus_probe(struct device *dev)
struct sdio_driver *drv = to_sdio_driver(dev->driver);
struct sdio_func *func = dev_to_sdio_func(dev);
const struct sdio_device_id *id;
int ret;

id = sdio_match_device(func, drv);
if (!id)
return -ENODEV;

/* Set the default block size so the driver is sure it's something
* sensible. */
sdio_claim_host(func);
ret = sdio_set_block_size(func, 0);
sdio_release_host(func);
if (ret)
return ret;

return drv->probe(func, id);
}

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/mmc/core/sdio_cis.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static int cistpl_funce_func(struct sdio_func *func,
return -EINVAL;

/* TPLFE_MAX_BLK_SIZE */
func->blksize = buf[12] | (buf[13] << 8);
func->max_blksize = buf[12] | (buf[13] << 8);

return 0;
}
Expand Down
49 changes: 49 additions & 0 deletions trunk/drivers/mmc/core/sdio_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,55 @@ int sdio_disable_func(struct sdio_func *func)
}
EXPORT_SYMBOL_GPL(sdio_disable_func);

/**
* sdio_set_block_size - set the block size of an SDIO function
* @func: SDIO function to change
* @blksz: new block size or 0 to use the default.
*
* The default block size is the largest supported by both the function
* and the host, with a maximum of 512 to ensure that arbitrarily sized
* data transfer use the optimal (least) number of commands.
*
* A driver may call this to override the default block size set by the
* core. This can be used to set a block size greater than the maximum
* that reported by the card; it is the driver's responsibility to ensure
* it uses a value that the card supports.
*
* Returns 0 on success, -EINVAL if the host does not support the
* requested block size, or -EIO (etc.) if one of the resultant FBR block
* size register writes failed.
*
*/
int sdio_set_block_size(struct sdio_func *func, unsigned blksz)
{
int ret;

if (blksz > func->card->host->max_blk_size)
return -EINVAL;

if (blksz == 0) {
blksz = min(min(
func->max_blksize,
func->card->host->max_blk_size),
512u);
}

ret = mmc_io_rw_direct(func->card, 1, 0,
SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE,
blksz & 0xff, NULL);
if (ret)
return ret;
ret = mmc_io_rw_direct(func->card, 1, 0,
SDIO_FBR_BASE(func->num) + SDIO_FBR_BLKSIZE + 1,
(blksz >> 8) & 0xff, NULL);
if (ret)
return ret;
func->cur_blksize = blksz;
return 0;
}

EXPORT_SYMBOL_GPL(sdio_set_block_size);

/**
* sdio_readb - read a single byte from a SDIO function
* @func: SDIO function to access
Expand Down
5 changes: 4 additions & 1 deletion trunk/include/linux/mmc/sdio_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ struct sdio_func {
unsigned short vendor; /* vendor id */
unsigned short device; /* device id */

unsigned short blksize; /* maximum block size */
unsigned max_blksize; /* maximum block size */
unsigned cur_blksize; /* current block size */

unsigned int state; /* function state */
#define SDIO_STATE_PRESENT (1<<0) /* present in sysfs */
Expand Down Expand Up @@ -111,6 +112,8 @@ extern void sdio_release_host(struct sdio_func *func);
extern int sdio_enable_func(struct sdio_func *func);
extern int sdio_disable_func(struct sdio_func *func);

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

Expand Down

0 comments on commit 388d606

Please sign in to comment.