diff --git a/lib/error.c b/lib/error.c index 52ca8038..ab104e96 100644 --- a/lib/error.c +++ b/lib/error.c @@ -1,6 +1,7 @@ /* error.c - Part of libsensors, a Linux library for reading sensor data. Copyright (c) 1998, 1999 Frodo Looijaard + Copyright (C) 2007 Jean Delvare This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,11 +32,11 @@ void (*sensors_fatal_error) (const char *proc, const char *err) = sensors_default_fatal_error; static const char *errorlist[] = { - /* Unknown error */ "sensors_strerror: Unknown error!", + /* Invalid error code */ NULL, /* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name", /* SENSORS_ERR_NO_ENTRY */ "No such subfeature known", - /* SENSORS_ERR_ACCESS */ "Can't read or write", - /* SENSORS_ERR_PROC */ "Can't access sysfs file", + /* SENSORS_ERR_NO_DEVS */ "No devices found", + /* SENSORS_ERR_KERNEL */ "Kernel interface error", /* SENSORS_ERR_DIV_ZERO */ "Divide by zero", /* SENSORS_ERR_CHIP_NAME */ "Can't parse chip name", /* SENSORS_ERR_BUS_NAME */ "Can't parse bus name", diff --git a/lib/error.h b/lib/error.h index 1e7b8ebd..e9be52fb 100644 --- a/lib/error.h +++ b/lib/error.h @@ -1,6 +1,7 @@ /* error.h - Part of libsensors, a Linux library for reading sensor data. Copyright (c) 1998, 1999 Frodo Looijaard + Copyright (C) 2007 Jean Delvare This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,8 +23,8 @@ #define SENSORS_ERR_WILDCARDS 1 /* Wildcard found in chip name */ #define SENSORS_ERR_NO_ENTRY 2 /* No such subfeature known */ -#define SENSORS_ERR_ACCESS 3 /* Can't read or write */ -#define SENSORS_ERR_PROC 4 /* Can't access /proc file */ +#define SENSORS_ERR_NO_DEVS 3 /* No devices found */ +#define SENSORS_ERR_KERNEL 4 /* Kernel interface error */ #define SENSORS_ERR_DIV_ZERO 5 /* Divide by zero */ #define SENSORS_ERR_CHIP_NAME 6 /* Can't parse chip name */ #define SENSORS_ERR_BUS_NAME 7 /* Can't parse bus name */ diff --git a/lib/init.c b/lib/init.c index 94f078eb..e06696d8 100644 --- a/lib/init.c +++ b/lib/init.c @@ -33,7 +33,7 @@ int sensors_init(FILE *input) int res; if (!sensors_init_sysfs()) - return -SENSORS_ERR_PROC; + return -SENSORS_ERR_KERNEL; if ((res = sensors_read_sysfs_bus()) || (res = sensors_read_sysfs_chips())) return res; diff --git a/lib/sysfs.c b/lib/sysfs.c index 8b4720ea..2fe9d826 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -344,7 +344,7 @@ int sensors_init_sysfs(void) static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) { int domain, bus, slot, fn; - int err = -SENSORS_ERR_PARSE; + int err = -SENSORS_ERR_KERNEL; struct sysfs_attribute *attr, *bus_attr; char bus_path[SYSFS_PATH_MAX]; sensors_chip_features entry; @@ -430,13 +430,13 @@ static int sensors_read_sysfs_chips_compat(void) if (!(bus = sysfs_open_bus("i2c"))) { if (errno && errno != ENOENT) - ret = -SENSORS_ERR_PROC; + ret = -SENSORS_ERR_NO_DEVS; goto exit0; } if (!(devs = sysfs_get_bus_devices(bus))) { if (errno && errno != ENOENT) - ret = -SENSORS_ERR_PROC; + ret = -SENSORS_ERR_NO_DEVS; goto exit1; } @@ -467,14 +467,14 @@ int sensors_read_sysfs_chips(void) if (!(clsdevs = sysfs_get_class_devices(cls))) { if (errno && errno != ENOENT) - ret = -SENSORS_ERR_PROC; + ret = -SENSORS_ERR_NO_DEVS; goto exit; } dlist_for_each_data(clsdevs, clsdev, struct sysfs_class_device) { struct sysfs_device *dev; if (!(dev = sysfs_get_classdev_device(clsdev))) { - ret = -SENSORS_ERR_PROC; + ret = -SENSORS_ERR_NO_DEVS; goto exit; } if ((ret = sensors_read_one_sysfs_chip(dev))) @@ -498,13 +498,13 @@ int sensors_read_sysfs_bus(void) if (!(cls = sysfs_open_class("i2c-adapter"))) { if (errno && errno != ENOENT) - ret = -SENSORS_ERR_PROC; + ret = -SENSORS_ERR_KERNEL; goto exit0; } if (!(clsdevs = sysfs_get_class_devices(cls))) { if (errno && errno != ENOENT) - ret = -SENSORS_ERR_PROC; + ret = -SENSORS_ERR_KERNEL; goto exit1; } @@ -553,10 +553,10 @@ int sensors_read_sysfs_attr(const sensors_chip_name *name, int res = fscanf(f, "%lf", value); fclose(f); if (res != 1) - return -SENSORS_ERR_PROC; + return -SENSORS_ERR_KERNEL; *value /= get_type_scaling(subfeature->type); } else - return -SENSORS_ERR_PROC; + return -SENSORS_ERR_KERNEL; return 0; } @@ -574,7 +574,7 @@ int sensors_write_sysfs_attr(const sensors_chip_name *name, fprintf(f, "%d", (int) value); fclose(f); } else - return -SENSORS_ERR_PROC; + return -SENSORS_ERR_KERNEL; return 0; } diff --git a/prog/sensors/main.c b/prog/sensors/main.c index 22f3efb1..d1e723b0 100644 --- a/prog/sensors/main.c +++ b/prog/sensors/main.c @@ -171,8 +171,8 @@ static int do_a_set(const sensors_chip_name *name) int res; if ((res = sensors_do_chip_sets(name))) { - if (res == -SENSORS_ERR_PROC) { - fprintf(stderr, "%s: %s for writing;\n", + if (res == -SENSORS_ERR_KERNEL) { + fprintf(stderr, "%s: %s;\n", sprintf_chip_name(name), sensors_strerror(res)); fprintf(stderr, "Run as root?\n");