summaryrefslogtreecommitdiff
path: root/tools/usb/usbip/libsrc/sysfs_utils.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2014-09-08 14:39:01 -0500
committerFelipe Balbi <balbi@ti.com>2014-09-08 14:39:01 -0500
commitf7cc38b16e2741186253be3dff61a9d124112126 (patch)
treeefce170d7c0c4baf6924275e6a42d11fa47c9290 /tools/usb/usbip/libsrc/sysfs_utils.c
parentefb540c895d2cb77b1472edda6ca45d40719a041 (diff)
parent2ce7598c9a453e0acd0e07be7be3f5eb39608ebd (diff)
Merge tag 'v3.17-rc4' into next
Merge Linux 3.17-rc4 here so we have all the latest fixes on next too. This also cleans up a few conflicts when applying patches. Signed-off-by: Felipe Balbi <balbi@ti.com> Conflicts: drivers/usb/gadget/Makefile drivers/usb/gadget/function/Makefile drivers/usb/gadget/legacy/Makefile drivers/usb/phy/phy-samsung-usb.h
Diffstat (limited to 'tools/usb/usbip/libsrc/sysfs_utils.c')
-rw-r--r--tools/usb/usbip/libsrc/sysfs_utils.c31
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 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "sysfs_utils.h"
+#include "usbip_common.h"
+
+int write_sysfs_attribute(const char *attr_path, const char *new_value,
+ size_t len)
+{
+ int fd;
+ int length;
+
+ fd = open(attr_path, O_WRONLY);
+ if (fd < 0) {
+ dbg("error opening attribute %s", attr_path);
+ return -1;
+ }
+
+ length = write(fd, new_value, len);
+ if (length < 0) {
+ dbg("error writing to attribute %s", attr_path);
+ close(fd);
+ return -1;
+ }
+
+ close(fd);
+
+ return 0;
+}