Commit 397a544b authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

kernel: support multiple transfers in single write to sysfs vme_data attribute

parent bd29f2cb
......@@ -313,6 +313,7 @@ Reading the @code{configured} file lets you check if the card has been already c
@section Raw access to the VME registers
This is handled via the @code{vme_addr} and @code{vme_data} attributes.
In order to read something from a given address, put the address in @code{vme_addr} file and then read the @code{vme_data} file. Writes are done in the same way.
If more than one value is written into @code{vme_data}, the driver will perform multiple transfers, incrementing the address by 32 bits at each transfer.
@b{Note:} Raw VME access through @code{sysfs} works only if the VME register window is correctly configured.
......
......@@ -232,18 +232,46 @@ ATTR_SHOW_CALLBACK(vme_data)
return snprintf(buf, PAGE_SIZE, "0x%x\n", data);
}
static int __next_token(char **str, char *buf, int buf_length)
{
char *p = *str, *tok;
int len;
while(isspace (*p))
p++;
if(*p == 0)
return 0;
tok = p;
while(*p && !isspace(*p))
p++;
len = min(p - tok + 1, buf_length - 1);
memcpy(buf, tok, len);
buf[len - 1] = 0;
*str = p;
return 1;
}
ATTR_STORE_CALLBACK(vme_data)
{
uint32_t data;
struct svec_dev *card = dev_get_drvdata(pdev);
uint32_t data;
uint32_t addr = card->vme_raw_addr;
char *args = (char *) buf, token[16];
if (!card->cfg_cur.configured)
return -EAGAIN;
if (sscanf(buf, "%i", &data) != 1)
return -EINVAL;
while (__next_token (&args, token, sizeof(token)))
{
if (sscanf(token, "%i", &data) != 1)
return -EINVAL;
iowrite32be(data, card->map[MAP_REG]->kernel_va + card->vme_raw_addr);
iowrite32be(data, card->map[MAP_REG]->kernel_va + addr);
addr += 4;
}
return count;
}
......
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