summaryrefslogtreecommitdiff
path: root/system-linux.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2021-06-19 08:11:21 +0200
committerFelix Fietkau <nbd@nbd.name>2021-06-19 08:11:23 +0200
commitff3764ce28e0672d8290e925d13a34ddbf38c984 (patch)
treebed6a1077beba41c0b31c24f11e0fcb95bacf96b /system-linux.c
parentb0d0906883021baca9ef6e80ba0480ac3e2a4b7a (diff)
downloadnetifd-ff3764ce28e0672d8290e925d13a34ddbf38c984.tar.gz
device: move hotplug handling logic from system-linux.c to device.c
Preparation for dealing with wifi per-station devices Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'system-linux.c')
-rw-r--r--system-linux.c40
1 files changed, 6 insertions, 34 deletions
diff --git a/system-linux.c b/system-linux.c
index b9e440e..d914a20 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -678,18 +678,13 @@ handle_hotplug_msg(char *data, int size)
{
const char *subsystem = NULL, *interface = NULL, *interface_old = NULL;
char *cur, *end, *sep;
- struct device *dev;
int skip;
- bool add, move = false;
+ bool add;
- if (!strncmp(data, "add@", 4))
+ if (!strncmp(data, "add@", 4) || !strncmp(data, "move@", 5))
add = true;
else if (!strncmp(data, "remove@", 7))
add = false;
- else if (!strncmp(data, "move@", 5)) {
- add = true;
- move = true;
- }
else
return;
@@ -717,36 +712,13 @@ handle_hotplug_msg(char *data, int size)
}
}
- if (subsystem && interface) {
- if (move && interface_old)
- goto move;
- else
- goto found;
- }
-
- return;
-
-move:
- dev = device_find(interface_old);
- if (!dev)
+ if (!subsystem || !interface)
return;
- if (dev->type != &simple_device_type)
- goto found;
-
- device_set_present(dev, false);
-
- return;
-
-found:
- dev = device_find(interface);
- if (!dev)
- return;
-
- if (dev->type != &simple_device_type)
- return;
+ if (interface_old)
+ device_hotplug_event(interface_old, false);
- device_set_present(dev, add);
+ device_hotplug_event(interface, add);
}
static void