summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2020-09-15 13:29:23 +0200
committerBastien Nocera <hadess@hadess.net>2020-09-15 14:39:18 +0200
commit027f435f3227624a9c9dd1215b333d9d26e35b49 (patch)
treee239d54eb955f352c794e07a10d04c1f87c1b617
parent12e4514acec410bb0401efc249e1271b71779e70 (diff)
downloadupower-027f435f3227624a9c9dd1215b333d9d26e35b49.tar.gz
linux: Remove sysfs-utils helpers
They've been replaced by gudev functions.
-rw-r--r--src/linux/Makefile.am2
-rw-r--r--src/linux/sysfs-utils.c158
-rw-r--r--src/linux/sysfs-utils.h35
-rw-r--r--src/linux/up-backend.c2
-rw-r--r--src/linux/up-device-csr.c1
-rw-r--r--src/linux/up-device-hid.c1
-rw-r--r--src/linux/up-device-idevice.c1
-rw-r--r--src/linux/up-device-supply.c1
-rw-r--r--src/linux/up-device-wup.c1
-rw-r--r--src/linux/up-input.c1
10 files changed, 0 insertions, 203 deletions
diff --git a/src/linux/Makefile.am b/src/linux/Makefile.am
index aec0b31..90b1a7f 100644
--- a/src/linux/Makefile.am
+++ b/src/linux/Makefile.am
@@ -46,8 +46,6 @@ libupshared_la_SOURCES = \
up-native.c \
hidpp-device.c \
hidpp-device.h \
- sysfs-utils.c \
- sysfs-utils.h \
$(idevice_files) \
$(BUILT_SOURCES)
diff --git a/src/linux/sysfs-utils.c b/src/linux/sysfs-utils.c
deleted file mode 100644
index 8a811ca..0000000
--- a/src/linux/sysfs-utils.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 David Zeuthen <davidz@redhat.com>
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <grp.h>
-#include <stdint.h>
-#include <linux/fs.h>
-#include <sys/ioctl.h>
-#include <glib.h>
-
-#include "sysfs-utils.h"
-
-gboolean
-sysfs_get_double_with_error (const char *dir,
- const char *attribute,
- double *value)
-{
- char *contents;
- char *filename;
- gboolean ret = FALSE;
- double parsed;
-
- g_return_val_if_fail (value != NULL, FALSE);
-
- filename = g_build_filename (dir, attribute, NULL);
- if (g_file_get_contents (filename, &contents, NULL, NULL)) {
- parsed = g_ascii_strtod (contents, NULL);
- if (errno == 0)
- ret = TRUE;
- g_free (contents);
- }
- g_free (filename);
-
- if (ret)
- *value = parsed;
-
- return ret;
-}
-
-double
-sysfs_get_double (const char *dir, const char *attribute)
-{
- double result;
- char *contents;
- char *filename;
-
- result = 0.0;
- filename = g_build_filename (dir, attribute, NULL);
- if (g_file_get_contents (filename, &contents, NULL, NULL)) {
- result = g_ascii_strtod (contents, NULL);
- g_free (contents);
- }
- g_free (filename);
-
- return result;
-}
-
-char *
-sysfs_get_string (const char *dir, const char *attribute)
-{
- char *result;
- char *filename;
-
- result = NULL;
- filename = g_build_filename (dir, attribute, NULL);
- if (!g_file_get_contents (filename, &result, NULL, NULL)) {
- result = g_strdup ("");
- }
- g_free (filename);
-
- return result;
-}
-
-int
-sysfs_get_int (const char *dir, const char *attribute)
-{
- int result;
- char *contents;
- char *filename;
-
- result = 0;
- filename = g_build_filename (dir, attribute, NULL);
- if (g_file_get_contents (filename, &contents, NULL, NULL)) {
- result = atoi (contents);
- g_free (contents);
- }
- g_free (filename);
-
- return result;
-}
-
-gboolean
-sysfs_get_bool (const char *dir, const char *attribute)
-{
- gboolean result;
- char *contents;
- char *filename;
-
- result = FALSE;
- filename = g_build_filename (dir, attribute, NULL);
- if (g_file_get_contents (filename, &contents, NULL, NULL)) {
- g_strdelimit (contents, "\n", '\0');
- result = (g_strcmp0 (contents, "1") == 0);
- g_free (contents);
- }
- g_free (filename);
-
- return result;
-}
-
-gboolean
-sysfs_file_exists (const char *dir, const char *attribute)
-{
- gboolean result;
- char *filename;
-
- result = FALSE;
- filename = g_build_filename (dir, attribute, NULL);
- if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
- result = TRUE;
- }
- g_free (filename);
-
- return result;
-}
diff --git a/src/linux/sysfs-utils.h b/src/linux/sysfs-utils.h
deleted file mode 100644
index 613c508..0000000
--- a/src/linux/sysfs-utils.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 David Zeuthen <davidz@redhat.com>
- *
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef __SYSFS_UTILS_H__
-#define __SYSFS_UTILS_H__
-
-#include <glib.h>
-
-double sysfs_get_double (const char *dir, const char *attribute);
-char *sysfs_get_string (const char *dir, const char *attribute);
-int sysfs_get_int (const char *dir, const char *attribute);
-gboolean sysfs_get_bool (const char *dir, const char *attribute);
-gboolean sysfs_file_exists (const char *dir, const char *attribute);
-gboolean sysfs_get_double_with_error (const char *dir,
- const char *attribute,
- double *value);
-
-#endif /* __SYSFS_UTILS_H__ */
diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c
index 9c2dc1d..6299a50 100644
--- a/src/linux/up-backend.c
+++ b/src/linux/up-backend.c
@@ -35,8 +35,6 @@
#include "up-daemon.h"
#include "up-device.h"
-#include "sysfs-utils.h"
-
#include "up-device-supply.h"
#include "up-device-csr.h"
#include "up-device-unifying.h"
diff --git a/src/linux/up-device-csr.c b/src/linux/up-device-csr.c
index fab048d..c9ab2c7 100644
--- a/src/linux/up-device-csr.c
+++ b/src/linux/up-device-csr.c
@@ -34,7 +34,6 @@
#include <gudev/gudev.h>
#include <libusb.h>
-#include "sysfs-utils.h"
#include "up-types.h"
#include "up-device-csr.h"
diff --git a/src/linux/up-device-hid.c b/src/linux/up-device-hid.c
index fa5709d..8d584c8 100644
--- a/src/linux/up-device-hid.c
+++ b/src/linux/up-device-hid.c
@@ -47,7 +47,6 @@
#include <sys/ioctl.h>
#include <unistd.h>
-#include "sysfs-utils.h"
#include "up-types.h"
#include "up-device-hid.h"
#include "up-constants.h"
diff --git a/src/linux/up-device-idevice.c b/src/linux/up-device-idevice.c
index d2fa0a1..db7f363 100644
--- a/src/linux/up-device-idevice.c
+++ b/src/linux/up-device-idevice.c
@@ -37,7 +37,6 @@
#include <libimobiledevice/lockdown.h>
#include <plist/plist.h>
-#include "sysfs-utils.h"
#include "up-types.h"
#include "up-device-idevice.h"
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index 5faf22e..2ba1dc9 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -33,7 +33,6 @@
#include <glib-object.h>
#include <gudev/gudev.h>
-#include "sysfs-utils.h"
#include "up-config.h"
#include "up-types.h"
#include "up-constants.h"
diff --git a/src/linux/up-device-wup.c b/src/linux/up-device-wup.c
index a5e0d4c..1f7764d 100644
--- a/src/linux/up-device-wup.c
+++ b/src/linux/up-device-wup.c
@@ -41,7 +41,6 @@
#include <getopt.h>
#include <errno.h>
-#include "sysfs-utils.h"
#include "up-types.h"
#include "up-device-wup.h"
diff --git a/src/linux/up-input.c b/src/linux/up-input.c
index be79b56..2d45d6c 100644
--- a/src/linux/up-input.c
+++ b/src/linux/up-input.c
@@ -39,7 +39,6 @@
#include <glib-object.h>
#include <gudev/gudev.h>
-#include "sysfs-utils.h"
#include "up-types.h"
#include "up-daemon.h"
#include "up-input.h"