allow the device data to override the interface
authorFelix Fietkau <nbd@openwrt.org>
Thu, 30 May 2013 17:25:40 +0000 (19:25 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 30 May 2013 17:25:40 +0000 (19:25 +0200)
switch.c
switch.h

index b73fe018f978861d143c5cd450694d959b8d222c..7c5cff4831ba637b909eb6bb56a9a2c2bb8f5756 100644 (file)
--- a/switch.c
+++ b/switch.c
@@ -1,5 +1,12 @@
 #include "switch.h"
 
+enum {
+       DATA_MODE,
+       DATA_MSG,
+       DATA_INTERFACE,
+       __DATA_MAX
+};
+
 static void handle_generic(struct usbdev_data *data, struct blob_attr **tb)
 {
        fprintf(stderr, "Do generic switch!\n");
@@ -85,12 +92,16 @@ void handle_switch(struct usbdev_data *data)
        static const struct blobmsg_policy data_policy[__DATA_MAX] = {
                [DATA_MODE] = { .name = "mode", .type = BLOBMSG_TYPE_STRING },
                [DATA_MSG] = { .name = "msg", .type = BLOBMSG_TYPE_ARRAY },
+               [DATA_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_INT32 },
        };
        struct blob_attr *tb[__DATA_MAX];
        int mode = MODE_GENERIC;
 
        blobmsg_parse(data_policy, __DATA_MAX, tb, blobmsg_data(data->info), blobmsg_data_len(data->info));
 
+       if (tb[DATA_INTERFACE])
+               data->interface = blobmsg_get_u32(tb[DATA_INTERFACE]);
+
        if (tb[DATA_MODE]) {
                const char *modestr;
                int i;
index a6d5297deea3a296436874b3561cbaae558bf520..eb5968f217225b6c1c5ca43c3e5528d1cfaed3cc 100644 (file)
--- a/switch.h
+++ b/switch.h
@@ -15,14 +15,6 @@ struct usbdev_data {
        char mfg[128], prod[128], serial[128];
 };
 
-enum {
-       DATA_MODE,
-       DATA_MSG,
-       DATA_MSG2,
-       DATA_MSG3,
-       __DATA_MAX
-};
-
 void handle_switch(struct usbdev_data *data);
 
 #endif