<refname>sd_device_get_sysname</refname>
<refname>sd_device_get_sysnum</refname>
<refname>sd_device_get_subsystem</refname>
+ <refname>sd_device_get_driver_subsystem</refname>
<refname>sd_device_get_devtype</refname>
<refname>sd_device_get_devname</refname>
<refname>sd_device_get_devnum</refname>
<paramdef>const char **<parameter>ret</parameter></paramdef>
</funcprototype>
+ <funcprototype>
+ <funcdef>int <function>sd_device_get_driver_subsystem</function></funcdef>
+ <paramdef>sd_device *<parameter>device</parameter></paramdef>
+ <paramdef>const char **<parameter>ret</parameter></paramdef>
+ </funcprototype>
+
<funcprototype>
<funcdef>int <function>sd_device_get_devtype</function></funcdef>
<paramdef>sd_device *<parameter>device</parameter></paramdef>
record. This is a short string fitting into a filename, and thus does not contain a slash and cannot be
empty. Example: <literal>tty</literal>, <literal>block</literal> or <literal>net</literal>.</para>
+ <para><function>sd_device_get_driver_subsystem()</function> returns the connected bus type of the devices
+ loaded by the specified driver device record. For example, when <literal>iwlwifi</literal> driver device
+ is specified, which is used by the wireless network interfaces connected to PCI bus, this function returns
+ <literal>pci</literal>. This function only succeeds when <function>sd_device_get_subsystem()</function>
+ returns <literal>drivers</literal>. Example: <literal>pci</literal>, <literal>i2c</literal>, or
+ <literal>hid</literal>.</para>
+
<para><function>sd_device_get_devtype()</function> returns the device type of the specified device
record, if the subsystem manages multiple types of devices. Example: for devices of the
<literal>block</literal> subsystem this can be <literal>disk</literal> or <literal>partition</literal>
<function>sd_device_get_ifindex()</function>,
<function>sd_device_get_driver()</function>, and
<function>sd_device_get_diskseq()</function> were added in version 251.</para>
+ <para><function>sd_device_get_driver_subsystem()</function> was added in version 257.</para>
</refsect1>
<refsect1>
return 0;
}
+_public_ int sd_device_get_driver_subsystem(sd_device *device, const char **ret) {
+ assert_return(device, -EINVAL);
+
+ if (!device_in_subsystem(device, "drivers"))
+ return -ENOENT;
+
+ assert(device->driver_subsystem);
+
+ if (ret)
+ *ret = device->driver_subsystem;
+
+ return 0;
+}
+
_public_ int sd_device_get_devtype(sd_device *device, const char **devtype) {
int r;
* sd_device_new_from_device_id() may not work as expected. */
const char *name, *id;
- if (streq(subsystem, "drivers"))
- name = strjoina(d->driver_subsystem, ":", sysname);
- else
+ if (streq(subsystem, "drivers")) {
+ const char *driver_subsystem;
+ ASSERT_OK(sd_device_get_driver_subsystem(d, &driver_subsystem));
+ name = strjoina(driver_subsystem, ":", sysname);
+ } else
name = sysname;
assert_se(sd_device_new_from_subsystem_sysname(&dev, subsystem, name) >= 0);
assert_se(sd_device_get_syspath(dev, &val) >= 0);
int sd_device_get_syspath(sd_device *device, const char **ret);
int sd_device_get_subsystem(sd_device *device, const char **ret);
+int sd_device_get_driver_subsystem(sd_device *device, const char **ret);
int sd_device_get_devtype(sd_device *device, const char **ret);
int sd_device_get_devnum(sd_device *device, dev_t *devnum);
int sd_device_get_ifindex(sd_device *device, int *ifindex);