diff options
| author | Takashi Iwai <[email protected]> | 2017-08-02 17:11:45 +0200 |
|---|---|---|
| committer | Takashi Iwai <[email protected]> | 2017-08-02 17:11:45 +0200 |
| commit | 5ef26e966d3fd105ad9a7e8e8f6d12c7fbd4c03d (patch) | |
| tree | dd5c2ce3daab2e398ab8c0fb852587b647131568 /tools/lib/api/fs/fs.c | |
| parent | 3f3c371421e601fa93b6cb7fb52da9ad59ec90b4 (diff) | |
| parent | 60668a2dcafcf8aad0860f5a5c93eb2d7438052e (diff) | |
Merge tag 'asoc-fix-v4.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Fixes for v4.13
Quite a few fixes here that have been sent since the merge window, the
biggest one is the fix from Tony for some confusion with the device
property API which was causing issues with the of-graph card. This is
fixed with some changes in the graph API itself as it seemed very likely
to be error prone.
Diffstat (limited to 'tools/lib/api/fs/fs.c')
| -rw-r--r-- | tools/lib/api/fs/fs.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c index 809c7721cd24..a7ecf8f469f4 100644 --- a/tools/lib/api/fs/fs.c +++ b/tools/lib/api/fs/fs.c @@ -387,6 +387,22 @@ int filename__read_str(const char *filename, char **buf, size_t *sizep) return err; } +int filename__write_int(const char *filename, int value) +{ + int fd = open(filename, O_WRONLY), err = -1; + char buf[64]; + + if (fd < 0) + return err; + + sprintf(buf, "%d", value); + if (write(fd, buf, sizeof(buf)) == sizeof(buf)) + err = 0; + + close(fd); + return err; +} + int procfs__read_str(const char *entry, char **buf, size_t *sizep) { char path[PATH_MAX]; @@ -480,3 +496,17 @@ int sysctl__read_int(const char *sysctl, int *value) return filename__read_int(path, value); } + +int sysfs__write_int(const char *entry, int value) +{ + char path[PATH_MAX]; + const char *sysfs = sysfs__mountpoint(); + + if (!sysfs) + return -1; + + if (snprintf(path, sizeof(path), "%s/%s", sysfs, entry) >= PATH_MAX) + return -1; + + return filename__write_int(path, value); +} |