/ Published in: C

This code will print out all sysfs devices under a certain device class (which is supplied as a parameter).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <sysfs/libsysfs.h> #include <stdio.h> /** * @brief Lists all the devices in the given class. * * @param className Name of the class (in /sys/class). */ void sysFsListDevices(char *className) { struct sysfs_class *class; struct dlist *devices; struct sysfs_class_device *class_device; struct sysfs_device *device; class = sysfs_open_class(className); devices = sysfs_get_class_devices(class); dlist_for_each(devices) { class_device = (struct sysfs_class_device *)devices->marker->data; class_device->name, class_device->classname, class_device->path); device = sysfs_get_classdev_device(class_device); ("Device - Name: %s, bus_id: %s, bus: %s, driver_name: %s, path: %s\n\n", device->name, device->bus_id, device->bus, device->driver_name, device->path); } return; }
Comments
