diff options
author | Mark Brown <broonie@kernel.org> | 2014-10-20 12:55:07 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-10-20 13:27:32 -0400 |
commit | b7a40242c82cd73cfcea305f23e67d068dd8401a (patch) | |
tree | 251b49d19cd7c371847ae1f951e1b537ca0e1c15 /tools/usb/usbip/libsrc/sysfs_utils.c | |
parent | d26833bfce5e56017bea9f1f50838f20e18e7b7e (diff) | |
parent | 9c6de47d53a3ce8df1642ae67823688eb98a190a (diff) |
Merge branch 'fix/dw' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi into spi-dw
Conflicts:
drivers/spi/spi-dw-mid.c
Diffstat (limited to 'tools/usb/usbip/libsrc/sysfs_utils.c')
-rw-r--r-- | tools/usb/usbip/libsrc/sysfs_utils.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/usb/usbip/libsrc/sysfs_utils.c b/tools/usb/usbip/libsrc/sysfs_utils.c new file mode 100644 index 000000000000..36ac88ece0b8 --- /dev/null +++ b/tools/usb/usbip/libsrc/sysfs_utils.c | |||
@@ -0,0 +1,31 @@ | |||
1 | #include <sys/types.h> | ||
2 | #include <sys/stat.h> | ||
3 | #include <fcntl.h> | ||
4 | #include <errno.h> | ||
5 | |||
6 | #include "sysfs_utils.h" | ||
7 | #include "usbip_common.h" | ||
8 | |||
9 | int write_sysfs_attribute(const char *attr_path, const char *new_value, | ||
10 | size_t len) | ||
11 | { | ||
12 | int fd; | ||
13 | int length; | ||
14 | |||
15 | fd = open(attr_path, O_WRONLY); | ||
16 | if (fd < 0) { | ||
17 | dbg("error opening attribute %s", attr_path); | ||
18 | return -1; | ||
19 | } | ||
20 | |||
21 | length = write(fd, new_value, len); | ||
22 | if (length < 0) { | ||
23 | dbg("error writing to attribute %s", attr_path); | ||
24 | close(fd); | ||
25 | return -1; | ||
26 | } | ||
27 | |||
28 | close(fd); | ||
29 | |||
30 | return 0; | ||
31 | } | ||