1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-26 00:28:25 +00:00

sysfs is a Linux-only feature.

Moving sysfs-related functions and defs out of common.h and into
linux.h, as sysfs exists only on Linux, and updating openbsd.c,
netbsd.c, and freebsd.c accordingly.

Signed-off-by: Nikos Ntarmos <ntarmos@cs.uoi.gr>
This commit is contained in:
Nikos Ntarmos 2009-03-28 21:46:20 +02:00 committed by Phil Sutter
parent b3a91362de
commit 15bd2ca5ec
5 changed files with 19 additions and 39 deletions

View File

@ -70,18 +70,6 @@ struct net_stat {
void clear_net_stats(void);
struct net_stat *get_net_stat(const char *);
int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
int *divisor, char *devtype);
#define open_i2c_sensor(dev, type, n, divisor, devtype) \
open_sysfs_sensor("/sys/bus/i2c/devices/", dev, type, n, divisor, devtype)
#define open_platform_sensor(dev, type, n, divisor, devtype) \
open_sysfs_sensor("/sys/bus/platform/devices/", dev, type, n, divisor, devtype)
#define open_hwmon_sensor(dev, type, n, divisor, devtype) \
open_sysfs_sensor("/sys/class/hwmon/", dev, type, n, divisor, devtype)
double get_sysfs_info(int *fd, int arg, char *devtype, char *type);
void get_adt746x_cpu(char *, size_t);
void get_adt746x_fan(char *, size_t);

View File

@ -627,12 +627,14 @@ static void free_text_objects(struct text_object *root)
case OBJ_acpitemp:
close(data.i);
break;
#endif /* !__OpenBSD__ */
#ifdef __linux__
case OBJ_i2c:
case OBJ_platform:
case OBJ_hwmon:
close(data.sysfs.fd);
break;
#endif /* !__OpenBSD__ */
#endif /* __linux__ */
case OBJ_time:
case OBJ_utime:
free(data.s);
@ -1598,7 +1600,7 @@ static struct text_object *construct_text_object(const char *s,
obj->data.pair.a = a;
obj->data.pair.b = b;
#ifndef __OpenBSD__
#ifdef __linux__
END OBJ(i2c, INFO_SYSFS)
char buf1[64], buf2[64];
int n;
@ -2122,7 +2124,7 @@ static struct text_object *construct_text_object(const char *s,
END OBJ(swapbar, INFO_MEM)
scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
END OBJ(sysname, 0)
#ifndef __OpenBSD__
#ifdef __linux__
END OBJ(temp1, INFO_SYSFS)
obj->type = OBJ_i2c;
obj->data.sysfs.fd = open_i2c_sensor(0, "temp", 1,
@ -3918,7 +3920,7 @@ static void generate_text_internal(char *p, int p_max_size,
OBJ(voffset) {
new_voffset(p, obj->data.i);
}
#ifndef __OpenBSD__
#ifdef __linux__
OBJ(i2c) {
double r;
@ -3961,7 +3963,7 @@ static void generate_text_internal(char *p, int p_max_size,
snprintf(p, p_max_size, "%.1f", r);
}
}
#endif /* !__OpenBSD__ */
#endif /* __linux__ */
OBJ(alignr) {
new_alignr(p, obj->data.i);
}

View File

@ -345,11 +345,6 @@ void update_cpu_usage()
oldtotal = total;
}
double get_sysfs_info(int *fd, int arg, char *devtype, char *type)
{
return 0.0;
}
void update_load_average()
{
double v[3];
@ -450,12 +445,6 @@ int get_battery_perct_bar(const char *bar)
return 0;
}
int open_sysfs_sensor(const char *dir, const char *dev, const char *type,
int n, int *div, char *devtype)
{
return 0;
}
int open_acpi_temperature(const char *name)
{
return 0;

View File

@ -28,4 +28,16 @@ void update_gateway_info(void);
enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME };
void get_powerbook_batt_info(char *, size_t, int);
int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
int *divisor, char *devtype);
#define open_i2c_sensor(dev, type, n, divisor, devtype) \
open_sysfs_sensor("/sys/bus/i2c/devices/", dev, type, n, divisor, devtype)
#define open_platform_sensor(dev, type, n, divisor, devtype) \
open_sysfs_sensor("/sys/bus/platform/devices/", dev, type, n, divisor, devtype)
#define open_hwmon_sensor(dev, type, n, divisor, devtype) \
open_sysfs_sensor("/sys/class/hwmon/", dev, type, n, divisor, devtype)
double get_sysfs_info(int *fd, int arg, char *devtype, char *type);
#endif /* _LINUX_H */

View File

@ -302,11 +302,6 @@ void update_cpu_usage()
oldtotal = total;
}
double get_sysfs_info(int *fd, int div, char *devtype)
{
return -1;
}
void update_load_average()
{
double v[3];
@ -327,12 +322,6 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
{
}
int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
int *div, char *devtype)
{
return -1;
}
int open_acpi_temperature(const char *name)
{
return -1;