summaryrefslogtreecommitdiff
path: root/tools/usb/usbip/src/utils.c
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2014-09-24 05:03:03 (GMT)
committerOlof Johansson <olof@lixom.net>2014-09-24 05:03:42 (GMT)
commit2fee8c1dd07260329e9788984b79b099456a9d11 (patch)
treeeb7a0b1069ea85a135f4f1df3703236a8003036c /tools/usb/usbip/src/utils.c
parent01100c022df5d9b8ac56d3705e33e69dc012a6e2 (diff)
parent31957609db529d401658adc2e91ef7df7ea42699 (diff)
downloadlinux-2fee8c1dd07260329e9788984b79b099456a9d11.tar.xz
Merge tag 'fixes-v3.18-not-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into next/fixes-non-critical
Merge "non-urgent omap fixes for v3.18 merge window" from Tony Lindgren: Fixes for omaps that were not considered urgent enough for the -rc cycle: - Fixes for .dts files to differentiate panda and beaglebone versions - Powerdomain fixes from Nishant Menon mostly for newer omaps - Fixes for __initconst and of_device_ids const usage * tag 'fixes-v3.18-not-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap: ARM: OMAP2+: make of_device_ids const ARM: omap2: make arrays containing machine compatible strings const ARM: OMAP4+: PM: Use only valid low power state for CPU hotplug ARM: OMAP4+: PM: use only valid low power state for suspend ARM: OMAP4+: PM: Make logic state programmable ARM: OMAP2+: powerdomain: introduce logic for finding valid power domain ARM: OMAP2+: powerdomain: pwrdm_for_each_clkdm iterate only valid clkdms ARM: OMAP5: powerdomain data: fix powerdomain powerstate ARM: OMAP: DRA7: powerdomain data: fix powerdomain powerstate ARM: dts: am335x-bone*: Fix model name and update compatibility information ARM: dts: omap4-panda: Fix model and SoC family details + Linux 3.17-rc3 Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'tools/usb/usbip/src/utils.c')
-rw-r--r--tools/usb/usbip/src/utils.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/usb/usbip/src/utils.c b/tools/usb/usbip/src/utils.c
new file mode 100644
index 0000000..2b3d6d2
--- /dev/null
+++ b/tools/usb/usbip/src/utils.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
+ * 2005-2007 Takahiro Hirofuchi
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "usbip_common.h"
+#include "utils.h"
+#include "sysfs_utils.h"
+
+int modify_match_busid(char *busid, int add)
+{
+ char attr_name[] = "match_busid";
+ char command[SYSFS_BUS_ID_SIZE + 4];
+ char match_busid_attr_path[SYSFS_PATH_MAX];
+ int rc;
+
+ snprintf(match_busid_attr_path, sizeof(match_busid_attr_path),
+ "%s/%s/%s/%s/%s/%s", SYSFS_MNT_PATH, SYSFS_BUS_NAME,
+ SYSFS_BUS_TYPE, SYSFS_DRIVERS_NAME, USBIP_HOST_DRV_NAME,
+ attr_name);
+
+ if (add)
+ snprintf(command, SYSFS_BUS_ID_SIZE + 4, "add %s", busid);
+ else
+ snprintf(command, SYSFS_BUS_ID_SIZE + 4, "del %s", busid);
+
+ rc = write_sysfs_attribute(match_busid_attr_path, command,
+ sizeof(command));
+ if (rc < 0) {
+ dbg("failed to write match_busid: %s", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}