Skip to content
Snippets Groups Projects
Commit aa5743c9 authored by Federico Vaga's avatar Federico Vaga
Browse files

core: change buffer and trigger only if different from current ones


Signed-off-by: default avatarFederico Vaga <federico.vaga@gmail.com>
Acked-by: default avatarAlessandro Rubini <rubini@gnudd.com>
parent 47133c57
Branches
Tags
No related merge requests found
...@@ -801,12 +801,16 @@ static ssize_t zobj_store_cur_trig(struct device *dev, ...@@ -801,12 +801,16 @@ static ssize_t zobj_store_cur_trig(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
char buf_tmp[ZIO_OBJ_NAME_LEN]; char buf_tmp[ZIO_OBJ_NAME_LEN];
int err; struct zio_cset *cset;
int err = 0;
if (strlen(buf) > ZIO_OBJ_NAME_LEN+1) if (strlen(buf) > ZIO_OBJ_NAME_LEN+1)
return -EINVAL; /* name too long */ return -EINVAL; /* name too long */
sscanf(buf, "%s\n", buf_tmp); sscanf(buf, "%s\n", buf_tmp);
err = zio_change_current_trigger(to_zio_cset(dev), buf_tmp); cset = to_zio_cset(dev);
/* change trigger only if is different then current */
if (strcmp(buf_tmp, cset->trig->head.name))
err = zio_change_current_trigger(cset, buf_tmp);
return err ? err : count; return err ? err : count;
} }
/* Print the current buffer name */ /* Print the current buffer name */
...@@ -821,12 +825,16 @@ static ssize_t zobj_store_cur_zbuf(struct device *dev, ...@@ -821,12 +825,16 @@ static ssize_t zobj_store_cur_zbuf(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
char buf_tmp[ZIO_OBJ_NAME_LEN]; char buf_tmp[ZIO_OBJ_NAME_LEN];
int err; struct zio_cset *cset;
int err = 0;
if (strlen(buf) > ZIO_OBJ_NAME_LEN+1) if (strlen(buf) > ZIO_OBJ_NAME_LEN+1)
return -EINVAL; /* name too long */ return -EINVAL; /* name too long */
sscanf(buf, "%s\n", buf_tmp); sscanf(buf, "%s\n", buf_tmp);
err = zio_change_current_buffer(to_zio_cset(dev), buf_tmp); cset = to_zio_cset(dev);
/* change buffer only if is different then current */
if (strcmp(buf_tmp, cset->trig->head.name))
err = zio_change_current_buffer(cset, buf_tmp);
return err ? err : count; return err ? err : count;
} }
/* Print the current enable status */ /* Print the current enable status */
......
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