aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Dijkstra <tim@famdijkstra.org>2007-05-13 20:10:16 +0000
committerTim Dijkstra <tim@famdijkstra.org>2007-05-13 20:10:16 +0000
commit55c654d703335d0fe56c0cfb170408602f2a0c48 (patch)
treeec91f375420a1039b2bdc88e40aa22b53515cb21
parentef918f342f9519ee9d6df59975c48806eb65af8d (diff)
downloadsuspend-utils-55c654d703335d0fe56c0cfb170408602f2a0c48.tar.gz
This should have gone in the last commit 'split of x86 s2ram code'
-rw-r--r--Makefile9
-rw-r--r--s2ram-x86.c19
-rw-r--r--s2ram.c23
-rw-r--r--s2ram.h1
4 files changed, 31 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index a5ffab6..5c29103 100644
--- a/Makefile
+++ b/Makefile
@@ -28,8 +28,8 @@ SWSUSP_OBJ=vt.o md5.o encrypt.o config.o loglevel.o splash.o bootsplash.o
S2RAM_LD_FLAGS = $(LD_FLAGS)
SWSUSP_LD_FLAGS = $(LD_FLAGS)
ifeq ($(ARCH), x86)
- S2RAM_OBJ += s2ram-x86.o dmidecode.o radeontool.o vbetool/vbetool.o
- S2RAM_LD_FLAGS += -lx86 -lpci -lz
+S2RAM_OBJ += s2ram-x86.o dmidecode.o radeontool.o vbetool/vbetool.o
+S2RAM_LD_FLAGS += -lx86 -lpci -lz
endif
ifndef CONFIG_RESUME_DYN
@@ -84,6 +84,9 @@ clean:
s2ram-x86.o: %.o : %.c %.h whitelist.c
$(CC) $(CC_FLAGS) -c $< -o $@
+s2ram-both.o: s2ram.c s2ram.h
+ $(CC) $(CC_FLAGS) -DCONFIG_BOTH -c $< -o $@
+
md5.o encrypt.o: %.o : %.c %.h md5.h
$(CC) $(CC_FLAGS) -DHAVE_INTTYPES_H -DHAVE_STDINT_H -c $< -o $@
@@ -102,7 +105,7 @@ s2disk: $(SWSUSP_OBJ) suspend.c
s2ram: $(S2RAM_OBJ) s2ram.c
$(CC) -g $(CC_FLAGS) -include s2ram-$(ARCH).h $^ -o $@ $(S2RAM_LD_FLAGS)
-s2both: $(SWSUSP_OBJ) $(S2RAM_OBJ) suspend.c
+s2both: $(SWSUSP_OBJ) $(S2RAM_OBJ) s2ram-both.o suspend.c
$(CC) -g $(CC_FLAGS) -include s2ram-$(ARCH).h -DCONFIG_BOTH $^ -o $@ $(SWSUSP_LD_FLAGS) $(S2RAM_LD_FLAGS)
resume: resume.c $(SWSUSP_OBJ)
diff --git a/s2ram-x86.c b/s2ram-x86.c
index b1e8bfe..b75f7f6 100644
--- a/s2ram-x86.c
+++ b/s2ram-x86.c
@@ -263,24 +263,7 @@ int s2ram_is_supported(void)
/* Actually enter the suspend. May be ran on frozen system. */
int s2ram_do(void)
{
- int ret = 0;
- FILE *f = fopen("/sys/power/state", "w");
- if (!f) {
- printf("/sys/power/state does not exist; what kind of ninja mutant machine is this?\n");
- return ENODEV;
- }
- if (fprintf(f, "mem") < 0) {
- ret = errno;
- perror("s2ram_do");
- }
- /* usually only fclose fails, not fprintf, so it does not matter
- * that we might overwrite the previous error.
- */
- if (fclose(f) < 0) {
- ret = errno;
- perror("s2ram_do");
- }
- return ret;
+ return s2ram_generic_do();
}
void s2ram_resume(void)
diff --git a/s2ram.c b/s2ram.c
index 5b895d5..9cdaa1c 100644
--- a/s2ram.c
+++ b/s2ram.c
@@ -19,6 +19,29 @@
#include "config.h"
+/* Actually enter the suspend. May be ran on frozen system. */
+int s2ram_generic_do(void)
+{
+ int ret = 0;
+ FILE *f = fopen("/sys/power/state", "w");
+ if (!f) {
+ printf("/sys/power/state does not exist; what kind of ninja mutant machine is this?\n");
+ return ENODEV;
+ }
+ if (fprintf(f, "mem") < 0) {
+ ret = errno;
+ perror("s2ram_do");
+ }
+ /* usually only fclose fails, not fprintf, so it does not matter
+ * that we might overwrite the previous error.
+ */
+ if (fclose(f) < 0) {
+ ret = errno;
+ perror("s2ram_do");
+ }
+ return ret;
+}
+
#ifndef CONFIG_BOTH
int main(int argc, char *argv[])
{
diff --git a/s2ram.h b/s2ram.h
index 93c0835..03eaf4b 100644
--- a/s2ram.h
+++ b/s2ram.h
@@ -21,6 +21,7 @@ int s2ram_is_supported(void);
void identify_machine(void);
void machine_known(void);
int s2ram_do(void);
+int s2ram_generic_do(void);
void s2ram_resume(void);
void s2ram_add_flag(int opt, const char *arg);