summaryrefslogtreecommitdiffhomepage
path: root/device.c
diff options
context:
space:
mode:
authorArne Kappen <akappen@inet.tu-berlin.de>2016-08-18 11:35:28 +0200
committerFelix Fietkau <nbd@nbd.name>2016-08-26 10:38:46 +0200
commitf56a7fbaa6f155c654e7d01b5c4c0594f21239d6 (patch)
tree08e2b400aa2d70cf9655274c5f7885623acdcf40 /device.c
parent61e5fa84eca4176bc5b4f9769a5af79d85cf11c6 (diff)
device: prepare for adding device handlers dynamically
- remove const from device handler struct - pass device handler type to create function Signed-off-by: Arne Kappen <akappen@inet.tu-berlin.de> Signed-off-by: Felix Fietkau <nbd@nbd.name> [cleanup]
Diffstat (limited to 'device.c')
-rw-r--r--device.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/device.c b/device.c
index fa3d00f..07ec82f 100644
--- a/device.c
+++ b/device.c
@@ -118,11 +118,15 @@ simple_device_set_state(struct device *dev, bool state)
}
static struct device *
-simple_device_create(const char *name, struct blob_attr *attr)
+simple_device_create(const char *name, struct device_type *devtype,
+ struct blob_attr *attr)
{
struct blob_attr *tb[__DEV_ATTR_MAX];
struct device *dev = NULL;
+ /* device type is unused for simple devices */
+ devtype = NULL;
+
blobmsg_parse(dev_attrs, __DEV_ATTR_MAX, tb, blob_data(attr), blob_len(attr));
dev = device_get(name, true);
if (!dev)
@@ -141,7 +145,7 @@ static void simple_device_free(struct device *dev)
free(dev);
}
-const struct device_type simple_device_type = {
+struct device_type simple_device_type = {
.name = "Network device",
.config_params = &device_attr_list,
@@ -417,7 +421,7 @@ int device_check_state(struct device *dev)
return dev->type->check_state(dev);
}
-void device_init_virtual(struct device *dev, const struct device_type *type, const char *name)
+void device_init_virtual(struct device *dev, struct device_type *type, const char *name)
{
assert(dev);
assert(type);
@@ -434,7 +438,7 @@ void device_init_virtual(struct device *dev, const struct device_type *type, con
dev->set_state = set_device_state;
}
-int device_init(struct device *dev, const struct device_type *type, const char *ifname)
+int device_init(struct device *dev, struct device_type *type, const char *ifname)
{
int ret;
@@ -729,7 +733,7 @@ device_init_pending(void)
}
static enum dev_change_type
-device_set_config(struct device *dev, const struct device_type *type,
+device_set_config(struct device *dev, struct device_type *type,
struct blob_attr *attr)
{
struct blob_attr *tb[__DEV_ATTR_MAX];
@@ -758,7 +762,7 @@ device_set_config(struct device *dev, const struct device_type *type,
}
enum dev_change_type
-device_apply_config(struct device *dev, const struct device_type *type,
+device_apply_config(struct device *dev, struct device_type *type,
struct blob_attr *config)
{
enum dev_change_type change;
@@ -883,7 +887,7 @@ device_set_default_ps(bool state)
}
struct device *
-device_create(const char *name, const struct device_type *type,
+device_create(const char *name, struct device_type *type,
struct blob_attr *config)
{
struct device *odev = NULL, *dev;
@@ -908,7 +912,7 @@ device_create(const char *name, const struct device_type *type,
if (!config)
return NULL;
- dev = type->create(name, config);
+ dev = type->create(name, type, config);
if (!dev)
return NULL;