.next = { &device_attr_list },
};
-static struct device *bridge_create(struct blob_attr *attr);
+static struct device *bridge_create(const char *name, struct blob_attr *attr);
static void bridge_config_init(struct device *dev);
static void bridge_free(struct device *dev);
static void bridge_dump_info(struct device *dev, struct blob_buf *b);
}
static struct device *
-bridge_create(struct blob_attr *attr)
+bridge_create(const char *name, struct blob_attr *attr)
{
struct blob_attr *tb_dev[__DEV_ATTR_MAX];
struct blob_attr *tb_br[__BRIDGE_ATTR_MAX];
struct bridge_state *bst;
struct device *dev = NULL;
- const char *name;
blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, tb_dev,
blob_data(attr), blob_len(attr));
blobmsg_parse(bridge_attrs, __BRIDGE_ATTR_MAX, tb_br,
blob_data(attr), blob_len(attr));
- if (!tb_dev[DEV_ATTR_NAME])
- return NULL;
-
if (!tb_br[BRIDGE_ATTR_IFNAME])
return NULL;
- name = blobmsg_data(tb_dev[DEV_ATTR_NAME]);
-
bst = calloc(1, sizeof(*bst));
if (!bst)
return NULL;
static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = {
[DEV_ATTR_TYPE] = { "type", BLOBMSG_TYPE_STRING },
- [DEV_ATTR_NAME] = { "name", BLOBMSG_TYPE_STRING },
[DEV_ATTR_IFNAME] = { "ifname", BLOBMSG_TYPE_ARRAY },
[DEV_ATTR_MTU] = { "mtu", BLOBMSG_TYPE_INT32 },
[DEV_ATTR_MACADDR] = { "macaddr", BLOBMSG_TYPE_STRING },
};
static struct device *
-simple_device_create(struct blob_attr *attr)
+simple_device_create(const char *name, struct blob_attr *attr)
{
struct blob_attr *tb[__DEV_ATTR_MAX];
struct device *dev = NULL;
- const char *name;
blobmsg_parse(dev_attrs, __DEV_ATTR_MAX, tb, blob_data(attr), blob_len(attr));
- if (!tb[DEV_ATTR_NAME])
- return NULL;
-
- name = blobmsg_data(tb[DEV_ATTR_NAME]);
- if (!name)
- return NULL;
-
dev = device_get(name, true);
if (!dev)
return NULL;
} else
D(DEVICE, "Create new device '%s' (%s)\n", name, type->name);
- dev = type->create(config);
+ dev = type->create(name, config);
if (!dev)
return NULL;
enum {
DEV_ATTR_TYPE,
- DEV_ATTR_NAME,
DEV_ATTR_IFNAME,
DEV_ATTR_MTU,
DEV_ATTR_MACADDR,
const struct config_param_list *config_params;
- struct device *(*create)(struct blob_attr *attr);
+ struct device *(*create)(const char *name, struct blob_attr *attr);
void (*config_init)(struct device *);
enum dev_change_type (*reload)(struct device *, struct blob_attr *);
void (*dump_info)(struct device *, struct blob_buf *buf);