Commit ef2d12ce authored by Udi Atar's avatar Udi Atar Committed by Mauro Carvalho Chehab

V4L/DVB (12450): Siano: Fixed SDIO compilation bugs

Fixed SDIO compilation bugs
Also fixed a memory overrun issue in buffer management.
Signed-off-by: default avatarUdi Atar <udia@siano-ms.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent f2e26ae7
......@@ -46,6 +46,7 @@
#define SMSSDIO_DATA 0x00
#define SMSSDIO_INT 0x04
#define SMSSDIO_BLOCK_SIZE 128
static const struct sdio_device_id smssdio_ids[] = {
{SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_STELLAR),
......@@ -85,7 +86,8 @@ static int smssdio_sendrequest(void *context, void *buffer, size_t size)
sdio_claim_host(smsdev->func);
while (size >= smsdev->func->cur_blksize) {
ret = sdio_write_blocks(smsdev->func, SMSSDIO_DATA, buffer, 1);
ret = sdio_memcpy_toio(smsdev->func, SMSSDIO_DATA,
buffer, smsdev->func->cur_blksize);
if (ret)
goto out;
......@@ -94,8 +96,8 @@ static int smssdio_sendrequest(void *context, void *buffer, size_t size)
}
if (size) {
ret = sdio_write_bytes(smsdev->func, SMSSDIO_DATA,
buffer, size);
ret = sdio_memcpy_toio(smsdev->func, SMSSDIO_DATA,
buffer, size);
}
out:
......@@ -125,23 +127,23 @@ static void smssdio_interrupt(struct sdio_func *func)
*/
isr = sdio_readb(func, SMSSDIO_INT, &ret);
if (ret) {
dev_err(&smsdev->func->dev,
"Unable to read interrupt register!\n");
sms_err("Unable to read interrupt register!\n");
return;
}
if (smsdev->split_cb == NULL) {
cb = smscore_getbuffer(smsdev->coredev);
if (!cb) {
dev_err(&smsdev->func->dev,
"Unable to allocate data buffer!\n");
sms_err("Unable to allocate data buffer!\n");
return;
}
ret = sdio_read_blocks(smsdev->func, cb->p, SMSSDIO_DATA, 1);
ret = sdio_memcpy_fromio(smsdev->func,
cb->p,
SMSSDIO_DATA,
SMSSDIO_BLOCK_SIZE);
if (ret) {
dev_err(&smsdev->func->dev,
"Error %d reading initial block!\n", ret);
sms_err("Error %d reading initial block!\n", ret);
return;
}
......@@ -152,7 +154,10 @@ static void smssdio_interrupt(struct sdio_func *func)
return;
}
size = hdr->msgLength - smsdev->func->cur_blksize;
if (hdr->msgLength > smsdev->func->cur_blksize)
size = hdr->msgLength - smsdev->func->cur_blksize;
else
size = 0;
} else {
cb = smsdev->split_cb;
hdr = cb->p;
......@@ -162,23 +167,24 @@ static void smssdio_interrupt(struct sdio_func *func)
smsdev->split_cb = NULL;
}
if (hdr->msgLength > smsdev->func->cur_blksize) {
if (size) {
void *buffer;
size = ALIGN(size, 128);
buffer = cb->p + hdr->msgLength;
buffer = cb->p + (hdr->msgLength - size);
size = ALIGN(size, SMSSDIO_BLOCK_SIZE);
BUG_ON(smsdev->func->cur_blksize != 128);
BUG_ON(smsdev->func->cur_blksize != SMSSDIO_BLOCK_SIZE);
/*
* First attempt to transfer all of it in one go...
*/
ret = sdio_read_blocks(smsdev->func, buffer,
SMSSDIO_DATA, size / 128);
ret = sdio_memcpy_fromio(smsdev->func,
buffer,
SMSSDIO_DATA,
size);
if (ret && ret != -EINVAL) {
smscore_putbuffer(smsdev->coredev, cb);
dev_err(&smsdev->func->dev,
"Error %d reading data from card!\n", ret);
sms_err("Error %d reading data from card!\n", ret);
return;
}
......@@ -191,12 +197,12 @@ static void smssdio_interrupt(struct sdio_func *func)
*/
if (ret == -EINVAL) {
while (size) {
ret = sdio_read_blocks(smsdev->func,
buffer, SMSSDIO_DATA, 1);
ret = sdio_memcpy_fromio(smsdev->func,
buffer, SMSSDIO_DATA,
smsdev->func->cur_blksize);
if (ret) {
smscore_putbuffer(smsdev->coredev, cb);
dev_err(&smsdev->func->dev,
"Error %d reading "
sms_err("Error %d reading "
"data from card!\n", ret);
return;
}
......@@ -269,7 +275,7 @@ static int smssdio_probe(struct sdio_func *func,
if (ret)
goto release;
ret = sdio_set_block_size(func, 128);
ret = sdio_set_block_size(func, SMSSDIO_BLOCK_SIZE);
if (ret)
goto disable;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment