From: Valentina Manea Date: Sat, 8 Mar 2014 12:53:25 +0000 (+0200) Subject: staging: usbip: userspace: move sysfs_utils to libsrc X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=ecc13b72555323458c5e6931edf81918d9c9abbc;p=deliverable%2Flinux.git staging: usbip: userspace: move sysfs_utils to libsrc Since it offers a API to both usbip tools and libusbip, it is more appropriate to be place in the library. Signed-off-by: Valentina Manea Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/usbip/userspace/libsrc/Makefile.am b/drivers/staging/usbip/userspace/libsrc/Makefile.am index 4921189e0260..7c8f8a4d54e4 100644 --- a/drivers/staging/usbip/userspace/libsrc/Makefile.am +++ b/drivers/staging/usbip/userspace/libsrc/Makefile.am @@ -4,4 +4,5 @@ libusbip_la_LDFLAGS = -version-info @LIBUSBIP_VERSION@ lib_LTLIBRARIES := libusbip.la libusbip_la_SOURCES := names.c names.h usbip_host_driver.c usbip_host_driver.h \ - usbip_common.c usbip_common.h vhci_driver.c vhci_driver.h + usbip_common.c usbip_common.h vhci_driver.c vhci_driver.h \ + sysfs_utils.c sysfs_utils.h diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c new file mode 100644 index 000000000000..36ac88ece0b8 --- /dev/null +++ b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +#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; +} diff --git a/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h new file mode 100644 index 000000000000..32ac1d105d18 --- /dev/null +++ b/drivers/staging/usbip/userspace/libsrc/sysfs_utils.h @@ -0,0 +1,8 @@ + +#ifndef __SYSFS_UTILS_H +#define __SYSFS_UTILS_H + +int write_sysfs_attribute(const char *attr_path, const char *new_value, + size_t len); + +#endif diff --git a/drivers/staging/usbip/userspace/src/Makefile.am b/drivers/staging/usbip/userspace/src/Makefile.am index 6c91bcb1e3bf..e81a4ebadeff 100644 --- a/drivers/staging/usbip/userspace/src/Makefile.am +++ b/drivers/staging/usbip/userspace/src/Makefile.am @@ -6,8 +6,6 @@ sbin_PROGRAMS := usbip usbipd usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \ usbip_attach.c usbip_detach.c usbip_list.c \ - usbip_bind.c usbip_unbind.c usbip_port.c \ - sysfs_utils.c - + usbip_bind.c usbip_unbind.c usbip_port.c usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.c b/drivers/staging/usbip/userspace/src/sysfs_utils.c deleted file mode 100644 index 36ac88ece0b8..000000000000 --- a/drivers/staging/usbip/userspace/src/sysfs_utils.c +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include -#include -#include - -#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; -} diff --git a/drivers/staging/usbip/userspace/src/sysfs_utils.h b/drivers/staging/usbip/userspace/src/sysfs_utils.h deleted file mode 100644 index 32ac1d105d18..000000000000 --- a/drivers/staging/usbip/userspace/src/sysfs_utils.h +++ /dev/null @@ -1,8 +0,0 @@ - -#ifndef __SYSFS_UTILS_H -#define __SYSFS_UTILS_H - -int write_sysfs_attribute(const char *attr_path, const char *new_value, - size_t len); - -#endif