tree-wide: use device_in_subsystem() and device_is_devtype()
This commit is contained in:
@@ -780,14 +780,14 @@ static void acquire_ether_link_info(int *fd, LinkInfo *link) {
|
||||
|
||||
static void acquire_wlan_link_info(LinkInfo *link) {
|
||||
_cleanup_(sd_netlink_unrefp) sd_netlink *genl = NULL;
|
||||
const char *type = NULL;
|
||||
int r, k = 0;
|
||||
|
||||
assert(link);
|
||||
|
||||
if (link->sd_device)
|
||||
(void) sd_device_get_devtype(link->sd_device, &type);
|
||||
if (!streq_ptr(type, "wlan"))
|
||||
if (!link->sd_device)
|
||||
return;
|
||||
|
||||
if (!device_is_devtype(link->sd_device, "wlan"))
|
||||
return;
|
||||
|
||||
r = sd_genl_socket_open(&genl);
|
||||
|
||||
@@ -164,7 +164,6 @@ static int manager_connect_bus(Manager *m) {
|
||||
static int manager_process_uevent(sd_device_monitor *monitor, sd_device *device, void *userdata) {
|
||||
Manager *m = ASSERT_PTR(userdata);
|
||||
sd_device_action_t action;
|
||||
const char *s;
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
@@ -173,20 +172,12 @@ static int manager_process_uevent(sd_device_monitor *monitor, sd_device *device,
|
||||
if (r < 0)
|
||||
return log_device_warning_errno(device, r, "Failed to get udev action, ignoring: %m");
|
||||
|
||||
r = sd_device_get_subsystem(device, &s);
|
||||
if (r < 0)
|
||||
return log_device_warning_errno(device, r, "Failed to get subsystem, ignoring: %m");
|
||||
|
||||
if (streq(s, "net"))
|
||||
if (device_in_subsystem(device, "net"))
|
||||
r = manager_udev_process_link(m, device, action);
|
||||
else if (streq(s, "ieee80211"))
|
||||
else if (device_in_subsystem(device, "ieee80211"))
|
||||
r = manager_udev_process_wiphy(m, device, action);
|
||||
else if (streq(s, "rfkill"))
|
||||
else if (device_in_subsystem(device, "rfkill"))
|
||||
r = manager_udev_process_rfkill(m, device, action);
|
||||
else {
|
||||
log_device_debug(device, "Received device with unexpected subsystem \"%s\", ignoring.", s);
|
||||
return 0;
|
||||
}
|
||||
if (r < 0)
|
||||
log_device_warning_errno(device, r, "Failed to process \"%s\" uevent, ignoring: %m",
|
||||
device_action_to_string(action));
|
||||
|
||||
@@ -118,11 +118,7 @@ static int link_get_wiphy(Link *link, Wiphy **ret) {
|
||||
if (!link->dev)
|
||||
return -ENODEV;
|
||||
|
||||
r = sd_device_get_devtype(link->dev, &s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!streq_ptr(s, "wlan"))
|
||||
if (!device_is_devtype(link->dev, "wlan"))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
r = sd_device_new_child(&phy, link->dev, "phy80211");
|
||||
|
||||
Reference in New Issue
Block a user