add a --device option

The "--device" option can be used to set btbridge device name.
The device kernel name has been changed to "/dev/ipmi-bt-host".
Rework the usage message also a bit.

Partially resolves openbmc/openbmc#694

Change-Id: I9d3d7c20a99fe256207096727b8e89b27311a621
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Yi Li <adamliyi@msn.com>
diff --git a/btbridged.c b/btbridged.c
index d504cf2..4d78341 100644
--- a/btbridged.c
+++ b/btbridged.c
@@ -35,9 +35,11 @@
 
 #include <systemd/sd-bus.h>
 
+static const char *bt_bmc_device = "/dev/bt-host";
+
 #define PREFIX "BTBRIDGED"
 
-#define BT_HOST_PATH "/dev/bt-host"
+#define BT_HOST_PATH bt_bmc_device
 #define BT_HOST_TIMEOUT_SEC 1
 #define BT_MAX_MESSAGE 64
 
@@ -601,10 +603,13 @@
 
 static void usage(const char *name)
 {
-	fprintf(stderr, "Usage %s [ --v[v] | --syslog ]\n", name);
-	fprintf(stderr, "\t--v\t Be verbose\n");
-	fprintf(stderr, "\t--vv\t Be verbose and dump entire messages\n");
-	fprintf(stderr, "\t--syslog\t Log output to syslog (pointless without --verbose)\n\n");
+	fprintf(stderr, "\
+Usage %s [--v[v] | --syslog] [-d <DEVICE>]\n\
+  --v                    Be verbose\n\
+  --vv                   Be verbose and dump entire messages\n\
+  -s, --syslog           Log output to syslog (pointless without --verbose)\n\
+  -d, --device <DEVICE>  use <DEVICE> file. Default is '%s'\n\n",
+		name, bt_bmc_device);
 }
 
 static const sd_bus_vtable ipmid_vtable[] = {
@@ -621,6 +626,7 @@
 	int opt, polled, r;
 
 	static const struct option long_options[] = {
+		{ "device",  required_argument, NULL, 'd' },
 		{ "v",       no_argument, (int *)&verbosity, BT_LOG_VERBOSE },
 		{ "vv",      no_argument, (int *)&verbosity, BT_LOG_DEBUG   },
 		{ "syslog",  no_argument, 0,          's'         },
@@ -634,6 +640,9 @@
 		switch (opt) {
 			case 0:
 				break;
+			case 'd':
+				bt_bmc_device = optarg;
+				break;
 			case 's':
 				/* Avoid a double openlog() */
 				if (bt_vlog != &vsyslog) {