summaryrefslogtreecommitdiff
path: root/extra/usb_serial/add_usb_serial_id
diff options
context:
space:
mode:
Diffstat (limited to 'extra/usb_serial/add_usb_serial_id')
-rwxr-xr-xextra/usb_serial/add_usb_serial_id32
1 files changed, 32 insertions, 0 deletions
diff --git a/extra/usb_serial/add_usb_serial_id b/extra/usb_serial/add_usb_serial_id
new file mode 100755
index 0000000000..ef8336afdc
--- /dev/null
+++ b/extra/usb_serial/add_usb_serial_id
@@ -0,0 +1,32 @@
+#!/bin/sh -e
+#
+# Copyright 2016 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Add a USB VID:PID device ID to the usbserial list of handled devices
+
+if [ $# -ne 2 ]; then
+ echo ""
+ echo "Usage: $0 <VID> <PID>"
+ echo ""
+ echo "Add a USB VID:PID device identification pair to the list of devices"
+ echo "that usbserial will recognize. This script ensures that a device is"
+ echo "not added more than once."
+ echo ""
+ exit 1
+fi
+
+#
+# Firts ensure that the usbserial module is loaded. This is required as there
+# may be no other USB serial adaptor connected yet.
+#
+modprobe usbserial
+
+device_id="$1 $2"
+file="/sys/bus/usb-serial/drivers/generic/new_id"
+
+#
+# Only add the device ID pair if it isn't already in the ID list.
+#
+grep -q "$device_id" $file || echo $device_id > $file