From: Felix Fietkau Date: Thu, 30 May 2013 17:25:40 +0000 (+0200) Subject: allow the device data to override the interface X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=5da2894852546646990c6fee47c9521143176c1a;p=project%2Fusbmode.git allow the device data to override the interface --- diff --git a/switch.c b/switch.c index b73fe01..7c5cff4 100644 --- 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; diff --git a/switch.h b/switch.h index a6d5297..eb5968f 100644 --- 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