Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scanning: add hwmon only systems to scanning. #1011

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions local.c
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ static int build_names(void *d, const char *path)
char *names = (char *)d;
size_t len;

if (!strstr(path, "iio:device"))
if (!strstr(path, "iio:device") && !(WITH_HWMON && strstr(path, "class/hwmon")))
return 0;

iio_snprintf(buf, sizeof(buf), "%s/name", path);
Expand All @@ -2195,15 +2195,32 @@ int local_context_scan(struct iio_scan_result *scan_result)
bool exists = false;
char *desc, *uri, *machine, buf[2 * BUF_SIZE], names[BUF_SIZE];
int ret;
bool no_iio;

ret = foreach_in_dir(&exists, "/sys/bus/iio", true, check_device);
if (ret < 0 || !exists)
no_iio = ret == -ENOENT;
if (WITH_HWMON && no_iio)
ret = 0; /* Not an error, unless we also have no hwmon devices */
if (ret < 0)
return 0;

names[0] = '\0';
ret = foreach_in_dir(&names, "/sys/bus/iio/devices", true, build_names);
if (ret < 0)
return 0;
if (!no_iio) {
ret = foreach_in_dir(&names, "/sys/bus/iio/devices", true, build_names);
if (ret < 0)
return 0;
}

if (WITH_HWMON) {
ret = foreach_in_dir(&exists, "/sys/class/hwmon", true, check_device);
if (ret == -ENOENT && !no_iio)
ret = 0; /* IIO devices but no hwmon devices - not an error */
if (ret < 0)
return 0;
ret = foreach_in_dir(&names, "/sys/class/hwmon", true, build_names);
if (ret < 0)
return 0;
}

machine = cat_file("/sys/firmware/devicetree/base/model");
if (!machine)
Expand Down