From 8787a77a5681f393d61fe0f5465cd552bcfbaac0 Mon Sep 17 00:00:00 2001
From: Anders Roxell <anders.roxell@linaro.org>
Date: Fri, 6 Apr 2018 12:33:48 +0200
Subject: [PATCH] drivers/memory: can't open emif-asm-offsets.s for writing
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Build failes due to that the directory isn't created before we execute
the build rule.
cc1: fatal error: can’t open ‘drivers/memory/emif-asm-offsets.s’ for
  writing: No such file or directory compilation terminated.
drivers/memory/Makefile.asm-offsets:2: recipe for target 'drivers/memory/emif-asm-offsets.s' failed
make[2]: *** [drivers/memory/emif-asm-offsets.s] Error 1
Makefile:1060: recipe for target
'arch/arm/mach-omap2' failed
make[1]: *** [arch/arm/mach-omap2] Error 2
make[1]: *** Waiting for unfinished jobs....

Current code adds a file check before checking the dependency, in
filechk it does mkdir -p $(dir $@).

Fixes: 41d9d44d7258 ("ARM: OMAP2+: pm33xx-core: Add platform code needed for PM")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 arch/arm/mach-omap2/Makefile                               | 6 +++++-
 {drivers/memory => arch/arm/mach-omap2}/emif-asm-offsets.c | 0
 drivers/memory/Makefile                                    | 2 --
 drivers/memory/Makefile.asm-offsets                        | 5 -----
 4 files changed, 5 insertions(+), 8 deletions(-)
 rename {drivers/memory => arch/arm/mach-omap2}/emif-asm-offsets.c (100%)
 delete mode 100644 drivers/memory/Makefile.asm-offsets

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 4603c30fef73..b7aeb469abdb 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -244,7 +244,11 @@ include/generated/ti-pm-asm-offsets.h: arch/arm/mach-omap2/pm-asm-offsets.s FORC
 	$(call filechk,offsets,__TI_PM_ASM_OFFSETS_H__)
 
 # For rule to generate ti-emif-asm-offsets.h dependency
-include drivers/memory/Makefile.asm-offsets
+arch/arm/mach-omap2/emif-asm-offsets.s: arch/arm/mach-omap2/emif-asm-offsets.c
+	$(call if_changed_dep,cc_s_c)
+
+include/generated/ti-emif-asm-offsets.h: arch/arm/mach-omap2/emif-asm-offsets.s FORCE
+	$(call filechk,offsets,__TI_EMIF_ASM_OFFSETS_H__)
 
 arch/arm/mach-omap2/sleep33xx.o: include/generated/ti-pm-asm-offsets.h include/generated/ti-emif-asm-offsets.h
 arch/arm/mach-omap2/sleep43xx.o: include/generated/ti-pm-asm-offsets.h include/generated/ti-emif-asm-offsets.h
diff --git a/drivers/memory/emif-asm-offsets.c b/arch/arm/mach-omap2/emif-asm-offsets.c
similarity index 100%
rename from drivers/memory/emif-asm-offsets.c
rename to arch/arm/mach-omap2/emif-asm-offsets.c
diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile
index 66f55240830e..9a8e72ad163e 100644
--- a/drivers/memory/Makefile
+++ b/drivers/memory/Makefile
@@ -28,6 +28,4 @@ ti-emif-sram-objs		:= ti-emif-pm.o ti-emif-sram-pm.o
 
 AFLAGS_ti-emif-sram-pm.o	:=-Wa,-march=armv7-a
 
-include drivers/memory/Makefile.asm-offsets
-
 drivers/memory/ti-emif-sram-pm.o: include/generated/ti-emif-asm-offsets.h
diff --git a/drivers/memory/Makefile.asm-offsets b/drivers/memory/Makefile.asm-offsets
deleted file mode 100644
index 843ff60ccb5a..000000000000
--- a/drivers/memory/Makefile.asm-offsets
+++ /dev/null
@@ -1,5 +0,0 @@
-drivers/memory/emif-asm-offsets.s: drivers/memory/emif-asm-offsets.c
-	$(call if_changed_dep,cc_s_c)
-
-include/generated/ti-emif-asm-offsets.h: drivers/memory/emif-asm-offsets.s FORCE
-	$(call filechk,offsets,__TI_EMIF_ASM_OFFSETS_H__)
-- 
2.16.3

