mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
udev/builtins: make skip_subsystem() and skip_virtio() alike
The two functions do not implement identical logic, so they shouldn't have identical structure, but let's make them both a bit simpler and more alike.
This commit is contained in:
parent
d3d2e3abda
commit
d340bdd1bd
@ -78,25 +78,23 @@ struct virtfn_info {
|
|||||||
|
|
||||||
/* skip intermediate virtio devices */
|
/* skip intermediate virtio devices */
|
||||||
static sd_device *skip_virtio(sd_device *dev) {
|
static sd_device *skip_virtio(sd_device *dev) {
|
||||||
sd_device *parent;
|
|
||||||
|
|
||||||
/* there can only ever be one virtio bus per parent device, so we can
|
/* there can only ever be one virtio bus per parent device, so we can
|
||||||
* safely ignore any virtio buses. see
|
* safely ignore any virtio buses. see
|
||||||
* http://lists.linuxfoundation.org/pipermail/virtualization/2015-August/030331.html */
|
* http://lists.linuxfoundation.org/pipermail/virtualization/2015-August/030331.html */
|
||||||
for (parent = dev; parent; ) {
|
while (dev) {
|
||||||
const char *subsystem;
|
const char *subsystem;
|
||||||
|
|
||||||
if (sd_device_get_subsystem(parent, &subsystem) < 0)
|
if (sd_device_get_subsystem(dev, &subsystem) < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!streq(subsystem, "virtio"))
|
if (!streq(subsystem, "virtio"))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (sd_device_get_parent(parent, &parent) < 0)
|
if (sd_device_get_parent(dev, &dev) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_virtfn_info(sd_device *dev, struct netnames *names, struct virtfn_info *ret) {
|
static int get_virtfn_info(sd_device *dev, struct netnames *names, struct virtfn_info *ret) {
|
||||||
|
@ -80,22 +80,19 @@ static int format_lun_number(sd_device *dev, char **path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static sd_device *skip_subsystem(sd_device *dev, const char *subsys) {
|
static sd_device *skip_subsystem(sd_device *dev, const char *subsys) {
|
||||||
sd_device *parent;
|
|
||||||
|
|
||||||
assert(dev);
|
assert(dev);
|
||||||
assert(subsys);
|
assert(subsys);
|
||||||
|
|
||||||
for (parent = dev; ; ) {
|
for (;;) {
|
||||||
const char *subsystem;
|
const char *subsystem;
|
||||||
|
|
||||||
if (sd_device_get_subsystem(parent, &subsystem) < 0)
|
if (sd_device_get_subsystem(dev, &subsystem) < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!streq(subsystem, subsys))
|
if (!streq(subsystem, subsys))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
dev = parent;
|
if (sd_device_get_parent(dev, &dev) < 0)
|
||||||
if (sd_device_get_parent(dev, &parent) < 0)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user