Skip to contentSkip to conversation

sh: Fix missing prototypes

PATCH Applied Geert Uytterhoeven 4 participants 31 messages Mar 1, 2024 – May 2, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover sh: Fix missing prototypes

Hi all,

This patch series fixes several "no previous prototype for <foo>" warnings when building a kernel for SuperH.

Known issues:
- The various warnings about cache functions are not yet fixed, but I didn't want to hold off the rest of this series,
- sdk7786_defconfig needs "[PATCH/RFC] locking/spinlocks: Make __raw_* lock ops static" [1],
- Probably there are more warnings to fix, I didn't build all defconfigs.

This has been boot-tested on landisk and on qemu/rts7751r2d.

Thanks for your comments!

[1] https://lore.kernel.org/linux-sh/c395b02613572131568bc1fd1bc456d20d1a5426.1709325647.git.geert+renesas@glider.be

Geert Uytterhoeven (20):
sh: pgtable: Fix missing prototypes
sh: fpu: Add missing forward declarations
sh: syscall: Add missing forward declaration for sys_cacheflush()
sh: tlb: Add missing forward declaration for handle_tlbmiss()
sh: return_address: Add missing #include <asm/ftrace.h>
sh: traps: Add missing #include <asm/setup.h>
sh: hw_breakpoint: Add missing forward declaration for
arch_bp_generic_fields()
sh: boot: Add proper forward declarations
sh: ftrace: Fix missing prototypes
sh: nommu: Add missing #include <asm/cacheflush.h>
sh: math-emu: Add missing #include <asm/fpu.h>
sh: dma: Remove unused dmac_search_free_channel()
sh: sh2a: Add missing #include <asm/processor.h>
sh: sh7786: Remove unused sh7786_usb_use_exclock()
sh: smp: Fix missing prototypes
sh: kprobes: Merge arch_copy_kprobe() into arch_prepare_kprobe()
sh: kprobes: Make trampoline_probe_handler() static
sh: kprobes: Remove unneeded kprobe_opcode_t casts
sh: dwarf: Make dwarf_lookup_fde() static
[RFC] sh: dma: Remove unused functionality

 arch/sh/boot/compressed/cache.c         |   3 +
 arch/sh/boot/compressed/cache.h         |  10 ++
 arch/sh/boot/compressed/misc.c          |   8 +-
 arch/sh/boot/compressed/misc.h          |   9 ++
 arch/sh/drivers/dma/dma-api.c           | 143 ------------------------
 arch/sh/include/asm/dma.h               |   7 --
 arch/sh/include/asm/fpu.h               |   3 +
 arch/sh/include/asm/ftrace.h            |  10 ++
 arch/sh/include/asm/hw_breakpoint.h     |   2 +
 arch/sh/include/asm/syscalls.h          |   1 +
 arch/sh/include/asm/tlb.h               |   4 +
 arch/sh/kernel/cpu/sh2a/opcode_helper.c |   2 +
 arch/sh/kernel/cpu/sh4a/setup-sh7786.c  |  14 ---
 arch/sh/kernel/dwarf.c                  |   2 +-
 arch/sh/kernel/kprobes.c                |  13 +--
 arch/sh/kernel/return_address.c         |   2 +
 arch/sh/kernel/smp.c                    |   4 +-
 arch/sh/kernel/traps.c                  |  10 +-
 arch/sh/kernel/traps_32.c               |   1 +
 arch/sh/math-emu/math.c                 |   2 +
 arch/sh/mm/nommu.c                      |   2 +
 arch/sh/mm/pgtable.c                    |   4 +-
 arch/sh/mm/tlbex_32.c                   |   1 +
 23 files changed, 68 insertions(+), 189 deletions(-)
 create mode 100644 arch/sh/boot/compressed/cache.h
 create mode 100644 arch/sh/boot/compressed/misc.h
Signature · 12 lines
2.34.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
#1 lore raw

PATCH 1/20 sh: pgtable: Fix missing prototypes

arch/sh/mm/pgtable.c:12:6: warning: no previous prototype for 'pgd_ctor' [-Wmissing-prototypes] arch/sh/mm/pgtable.c:34:8: warning: no previous prototype for 'pgd_alloc' [-Wmissing-prototypes] arch/sh/mm/pgtable.c:39:6: warning: no previous prototype for 'pgd_free' [-Wmissing-prototypes] arch/sh/mm/pgtable.c:45:6: warning: no previous prototype for 'pud_populate' [-Wmissing-prototypes] arch/sh/mm/pgtable.c:50:8: warning: no previous prototype for 'pmd_alloc_one' [-Wmissing-prototypes] arch/sh/mm/pgtable.c:55:6: warning: no previous prototype for 'pmd_free' [-Wmissing-prototypes]

Make pgd_ctor() static, as it is only used in this file. Include <asm/pgalloc.h> to fix the other warnings.

---
 arch/sh/mm/pgtable.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/sh/mm/pgtable.c +3 -1
index cf7ce4b5735954bf..3a4085ea0161fe56 100644
@@ -2,12 +2,14 @@
 #include <linux/mm.h>
 #include <linux/slab.h>
 
+#include <asm/pgalloc.h>
+
 static struct kmem_cache *pgd_cachep;
 #if PAGETABLE_LEVELS > 2
 static struct kmem_cache *pmd_cachep;
 #endif
 
-void pgd_ctor(void *x)
+static void pgd_ctor(void *x)
 {
 	pgd_t *pgd = x;
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/20 sh: fpu: Add missing forward declarations

In reply to Geert Uytterhoeven

arch/sh/kernel/cpu/sh4/fpu.c:389:6: warning: no previous prototype for ‘float_raise’ [-Wmissing-prototypes] arch/sh/kernel/cpu/sh4/fpu.c:394:5: warning: no previous prototype for ‘float_rounding_mode’ [-Wmissing-prototypes]

---
 arch/sh/include/asm/fpu.h | 3 +++
 1 file changed, 3 insertions(+)
arch/sh/include/asm/fpu.h +3 -0
index 04584be8986c418a..0379f4cce5ed25fb 100644
@@ -64,6 +64,9 @@ static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs)
 	preempt_enable();
 }
 
+void float_raise(unsigned int flags);
+int float_rounding_mode(void);
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_SH_FPU_H */
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/20 sh: syscall: Add missing forward declaration for sys_cacheflush()

In reply to Geert Uytterhoeven

arch/sh/kernel/sys_sh.c:58:16: warning: no previous prototype for ‘sys_cacheflush’ [-Wmissing-prototypes]

---
 arch/sh/include/asm/syscalls.h | 1 +
 1 file changed, 1 insertion(+)
arch/sh/include/asm/syscalls.h +1 -0
index 387105316d2882fe..39240e06e8aa5f6b 100644
@@ -8,6 +8,7 @@ asmlinkage int old_mmap(unsigned long addr, unsigned long len,
 asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
 			  unsigned long prot, unsigned long flags,
 			  unsigned long fd, unsigned long pgoff);
+asmlinkage int sys_cacheflush(unsigned long addr, unsigned long len, int op);
 
 #include <asm/syscalls_32.h>
 
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/20 sh: tlb: Add missing forward declaration for handle_tlbmiss()

In reply to Geert Uytterhoeven

arch/sh/mm/tlbex_32.c:22:1: warning: no previous prototype for ‘handle_tlbmiss’ [-Wmissing-prototypes]

---
 arch/sh/include/asm/tlb.h | 4 ++++
 arch/sh/mm/tlbex_32.c     | 1 +
 2 files changed, 5 insertions(+)
arch/sh/include/asm/tlb.h +4 -0
index aeb8915e92549609..ddf324bfb9a09721 100644
@@ -24,6 +24,10 @@ static inline void tlb_unwire_entry(void)
 	BUG();
 }
 #endif /* CONFIG_CPU_SH4 */
+
+asmlinkage int handle_tlbmiss(struct pt_regs *regs, unsigned long error_code,
+			      unsigned long address);
+
 #endif /* CONFIG_MMU */
 #endif /* __ASSEMBLY__ */
 #endif /* __ASM_SH_TLB_H */
arch/sh/mm/tlbex_32.c +1 -0
index 1c53868632ee4c69..7d58578c15f4ef55 100644
@@ -14,6 +14,7 @@
 #include <linux/kdebug.h>
 #include <asm/mmu_context.h>
 #include <asm/thread_info.h>
+#include <asm/tlb.h>
 
 /*
  * Called with interrupts disabled.
Signature · 1 line
2.34.1
#5 lore raw

PATCH 5/20 sh: return_address: Add missing #include <asm/ftrace.h>

In reply to Geert Uytterhoeven

arch/sh/kernel/return_address.c:49:7: warning: no previous prototype for ‘return_address’ [-Wmissing-prototypes]

---
 arch/sh/kernel/return_address.c | 2 ++
 1 file changed, 2 insertions(+)
arch/sh/kernel/return_address.c +2 -0
index 8838094c9ff9444f..2ce22f11eab37839 100644
@@ -7,7 +7,9 @@
  */
 #include <linux/kernel.h>
 #include <linux/module.h>
+
 #include <asm/dwarf.h>
+#include <asm/ftrace.h>
 
 #ifdef CONFIG_DWARF_UNWINDER
 
Signature · 1 line
2.34.1
#6 lore raw

PATCH 6/20 sh: traps: Add missing #include <asm/setup.h>

In reply to Geert Uytterhoeven

arch/sh/kernel/traps_32.c:735:6: warning: no previous prototype for ‘per_cpu_trap_init’ [-Wmissing-prototypes]

---
 arch/sh/kernel/traps_32.c | 1 +
 1 file changed, 1 insertion(+)
arch/sh/kernel/traps_32.c +1 -0
index 6cdda3a621a1e577..8cd4b05df75c3e07 100644
@@ -27,6 +27,7 @@
 #include <asm/alignment.h>
 #include <asm/fpu.h>
 #include <asm/kprobes.h>
+#include <asm/setup.h>
 #include <asm/traps.h>
 #include <asm/bl_bit.h>
 
Signature · 1 line
2.34.1
#7 lore raw

PATCH 7/20 sh: hw_breakpoint: Add missing forward declaration for arch_bp_generic_fields()

In reply to Geert Uytterhoeven

arch/sh/kernel/hw_breakpoint.c:135:5: warning: no previous prototype for ‘arch_bp_generic_fields’ [-Wmissing-prototypes]

---
 arch/sh/include/asm/hw_breakpoint.h | 2 ++
 1 file changed, 2 insertions(+)
arch/sh/include/asm/hw_breakpoint.h +2 -0
index 361a0f57bdebda6e..74a438cea6559efd 100644
@@ -52,6 +52,8 @@ struct pmu;
 
 /* arch/sh/kernel/hw_breakpoint.c */
 extern int arch_check_bp_in_kernelspace(struct arch_hw_breakpoint *hw);
+extern int arch_bp_generic_fields(int sh_len, int sh_type, int *gen_len,
+				  int *gen_type);
 extern int hw_breakpoint_arch_parse(struct perf_event *bp,
 				    const struct perf_event_attr *attr,
 				    struct arch_hw_breakpoint *hw);
Signature · 1 line
2.34.1
#8 lore raw

PATCH 8/20 sh: boot: Add proper forward declarations

In reply to Geert Uytterhoeven

arch/sh/boot/compressed/cache.c:2:5: warning: no previous prototype for ‘cache_control’ [-Wmissing-prototypes] arch/sh/boot/compressed/misc.c:115:6: warning: no previous prototype for ‘ftrace_stub’ [-Wmissing-prototypes] arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for ‘arch_ftrace_ops_list_func’ [-Wmissing-prototypes] arch/sh/boot/compressed/misc.c:128:6: warning: no previous prototype for ‘decompress_kernel’ [-Wmissing-prototypes]

---
 arch/sh/boot/compressed/cache.c |  3 +++
 arch/sh/boot/compressed/cache.h | 10 ++++++++++
 arch/sh/boot/compressed/misc.c  |  8 +++-----
 arch/sh/boot/compressed/misc.h  |  9 +++++++++
 4 files changed, 25 insertions(+), 5 deletions(-)
 create mode 100644 arch/sh/boot/compressed/cache.h
 create mode 100644 arch/sh/boot/compressed/misc.h
arch/sh/boot/compressed/cache.c +3 -0
index 31e04ff4841ed084..95c1e73ccbb7e011 100644
@@ -1,4 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
+
+#include "cache.h"
+
 int cache_control(unsigned int command)
 {
 	volatile unsigned int *p = (volatile unsigned int *) 0x80000000;
arch/sh/boot/compressed/cache.h new file +10 -0
new file mode 100644
index 0000000000000000..b622b68c87f59b97
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef CACHE_H
+#define CACHE_H
+
+#define CACHE_ENABLE	0
+#define CACHE_DISABLE	1
+
+int cache_control(unsigned int command);
+
+#endif /* CACHE_H */
arch/sh/boot/compressed/misc.c +3 -5
index ca05c99a3d5b488d..5178150ca6650dcf 100644
@@ -16,6 +16,9 @@
 #include <asm/addrspace.h>
 #include <asm/page.h>
 
+#include "cache.h"
+#include "misc.h"
+
 /*
  * gzip declarations
  */
@@ -26,11 +29,6 @@
 #undef memcpy
 #define memzero(s, n)     memset ((s), 0, (n))
 
-/* cache.c */
-#define CACHE_ENABLE      0
-#define CACHE_DISABLE     1
-int cache_control(unsigned int command);
-
 extern char input_data[];
 extern int input_len;
 static unsigned char *output;
arch/sh/boot/compressed/misc.h new file +9 -0
new file mode 100644
index 0000000000000000..2b4534faa3052857
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef MISC_H
+#define MISC_H
+
+void arch_ftrace_ops_list_func(void);
+void decompress_kernel(void);
+void ftrace_stub(void);
+
+#endif /* MISC_H */
Signature · 1 line
2.34.1
maintainer
#9 lore raw

Re: [PATCH 08/20] sh: boot: Add proper forward declarations

Quoted 89 lines · Geert Uytterhoeven

arch/sh/boot/compressed/cache.c:2:5: warning: no previous prototype for ‘cache_control’ [-Wmissing-prototypes] arch/sh/boot/compressed/misc.c:115:6: warning: no previous prototype for ‘ftrace_stub’ [-Wmissing-prototypes] arch/sh/boot/compressed/misc.c:118:6: warning: no previous prototype for ‘arch_ftrace_ops_list_func’ [-Wmissing-prototypes] arch/sh/boot/compressed/misc.c:128:6: warning: no previous prototype for ‘decompress_kernel’ [-Wmissing-prototypes]

---
 arch/sh/boot/compressed/cache.c |  3 +++
 arch/sh/boot/compressed/cache.h | 10 ++++++++++
 arch/sh/boot/compressed/misc.c  |  8 +++-----
 arch/sh/boot/compressed/misc.h  |  9 +++++++++
 4 files changed, 25 insertions(+), 5 deletions(-)
 create mode 100644 arch/sh/boot/compressed/cache.h
 create mode 100644 arch/sh/boot/compressed/misc.h
arch/sh/boot/compressed/cache.c +3 -0
index 31e04ff4841ed084..95c1e73ccbb7e011 100644
@@ -1,4 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
+
+#include "cache.h"
+
 int cache_control(unsigned int command)
 {
 	volatile unsigned int *p = (volatile unsigned int *) 0x80000000;
arch/sh/boot/compressed/cache.h new file +10 -0
new file mode 100644
index 0000000000000000..b622b68c87f59b97
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef CACHE_H
+#define CACHE_H
+
+#define CACHE_ENABLE	0
+#define CACHE_DISABLE	1
+
+int cache_control(unsigned int command);
+
+#endif /* CACHE_H */
arch/sh/boot/compressed/misc.c +3 -5
index ca05c99a3d5b488d..5178150ca6650dcf 100644
@@ -16,6 +16,9 @@
 #include <asm/addrspace.h>
 #include <asm/page.h>
 
+#include "cache.h"
+#include "misc.h"
+
 /*
  * gzip declarations
  */
@@ -26,11 +29,6 @@
 #undef memcpy
 #define memzero(s, n)     memset ((s), 0, (n))
 
-/* cache.c */
-#define CACHE_ENABLE      0
-#define CACHE_DISABLE     1
-int cache_control(unsigned int command);
-
 extern char input_data[];
 extern int input_len;
 static unsigned char *output;
arch/sh/boot/compressed/misc.h new file +9 -0
new file mode 100644
index 0000000000000000..2b4534faa3052857
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef MISC_H
+#define MISC_H
+
+void arch_ftrace_ops_list_func(void);
+void decompress_kernel(void);
+void ftrace_stub(void);
+
+#endif /* MISC_H */
Signature · 1 line
2.34.1

This cache control is from SH5, so it is no longer needed. I think it's better to simply delete chace.c and cache_control.

Signature · 1 line
Yosinori Sato
#10 lore raw

PATCH 9/20 sh: ftrace: Fix missing prototypes

In reply to Geert Uytterhoeven

arch/sh/kernel/ftrace.c:130:6: warning: no previous prototype for ‘arch_ftrace_nmi_enter’ [-Wmissing-prototypes] arch/sh/kernel/ftrace.c:140:6: warning: no previous prototype for ‘arch_ftrace_nmi_exit’ [-Wmissing-prototypes] arch/sh/kernel/ftrace.c:316:6: warning: no previous prototype for ‘prepare_ftrace_return’ [-Wmissing-prototypes]

Fix this by moving existing forward declarations to <asm/ftrace.h>, and adding the missing forward declaration for prepare_ftrace_return().

---
 arch/sh/include/asm/ftrace.h | 10 ++++++++++
 arch/sh/kernel/traps.c       | 10 ++--------
 2 files changed, 12 insertions(+), 8 deletions(-)
arch/sh/include/asm/ftrace.h +10 -0
index b1c1dc0cc261d1db..1c10e106639098fc 100644
@@ -33,6 +33,8 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)
 	return addr;
 }
 
+void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr);
+
 #endif /* __ASSEMBLY__ */
 #endif /* CONFIG_FUNCTION_TRACER */
 
@@ -43,6 +45,14 @@ extern void *return_address(unsigned int);
 
 #define ftrace_return_address(n) return_address(n)
 
+#ifdef CONFIG_DYNAMIC_FTRACE
+extern void arch_ftrace_nmi_enter(void);
+extern void arch_ftrace_nmi_exit(void);
+#else
+static inline void arch_ftrace_nmi_enter(void) { }
+static inline void arch_ftrace_nmi_exit(void) { }
+#endif
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_SH_FTRACE_H */
arch/sh/kernel/traps.c +2 -8
index 01884054aeb2bd30..4339c4cafa79ce2a 100644
@@ -15,6 +15,8 @@
 
 #include <linux/extable.h>
 #include <linux/module.h>	/* print_modules */
+
+#include <asm/ftrace.h>
 #include <asm/unwinder.h>
 #include <asm/traps.h>
 
@@ -170,14 +172,6 @@ BUILD_TRAP_HANDLER(bug)
 	force_sig(SIGTRAP);
 }
 
-#ifdef CONFIG_DYNAMIC_FTRACE
-extern void arch_ftrace_nmi_enter(void);
-extern void arch_ftrace_nmi_exit(void);
-#else
-static inline void arch_ftrace_nmi_enter(void) { }
-static inline void arch_ftrace_nmi_exit(void) { }
-#endif
-
 BUILD_TRAP_HANDLER(nmi)
 {
 	TRAP_HANDLER_DECL;
Signature · 1 line
2.34.1
#11 lore raw

PATCH 10/20 sh: nommu: Add missing #include <asm/cacheflush.h>

In reply to Geert Uytterhoeven

arch/sh/mm/nommu.c:76:13: warning: no previous prototype for 'kmap_coherent_init' [-Wmissing-prototypes] arch/sh/mm/nommu.c:80:7: warning: no previous prototype for 'kmap_coherent' [-Wmissing-prototypes] arch/sh/mm/nommu.c:86:6: warning: no previous prototype for 'kunmap_coherent' [-Wmissing-prototypes]

---
 arch/sh/mm/nommu.c | 2 ++
 1 file changed, 2 insertions(+)
arch/sh/mm/nommu.c +2 -0
index 78c4b6e6d33ba3af..fa3dc9428a737ffe 100644
@@ -10,6 +10,8 @@
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/mm.h>
+
+#include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 #include <asm/page.h>
 #include <linux/uaccess.h>
Signature · 1 line
2.34.1
#12 lore raw

PATCH 11/20 sh: math-emu: Add missing #include <asm/fpu.h>

In reply to Geert Uytterhoeven

arch/sh/math-emu/math.c:492:5: warning: no previous prototype for 'do_fpu_inst' [-Wmissing-prototypes]

---
 arch/sh/math-emu/math.c | 2 ++
 1 file changed, 2 insertions(+)
arch/sh/math-emu/math.c +2 -0
index cdaef6501d764a0c..b65703e065735663 100644
@@ -15,6 +15,8 @@
 #include <linux/perf_event.h>
 
 #include <linux/uaccess.h>
+
+#include <asm/fpu.h>
 #include <asm/processor.h>
 #include <asm/io.h>
 
Signature · 1 line
2.34.1
#13 lore raw

PATCH 12/20 sh: dma: Remove unused dmac_search_free_channel()

In reply to Geert Uytterhoeven

arch/sh/drivers/dma/dma-api.c:164:5: warning: no previous prototype for 'dmac_search_free_channel' [-Wmissing-prototypes]

dmac_search_free_channel() never had a user in upstream, remove it.

---
dma_extend(), get_dma_info_by_name(), register_chan_caps(), and request_dma_bycap() are also unused, but don't trigger warnings

---
 arch/sh/drivers/dma/dma-api.c | 27 ---------------------------
 1 file changed, 27 deletions(-)
arch/sh/drivers/dma/dma-api.c +0 -27
index 89cd4a3b4ccafbe2..f49097fa634c36d4 100644
@@ -161,33 +161,6 @@ int request_dma_bycap(const char **dmac, const char **caps, const char *dev_id)
 }
 EXPORT_SYMBOL(request_dma_bycap);
 
-int dmac_search_free_channel(const char *dev_id)
-{
-	struct dma_channel *channel = { 0 };
-	struct dma_info *info = get_dma_info(0);
-	int i;
-
-	for (i = 0; i < info->nr_channels; i++) {
-		channel = &info->channels[i];
-		if (unlikely(!channel))
-			return -ENODEV;
-
-		if (atomic_read(&channel->busy) == 0)
-			break;
-	}
-
-	if (info->ops->request) {
-		int result = info->ops->request(channel);
-		if (result)
-			return result;
-
-		atomic_set(&channel->busy, 1);
-		return channel->chan;
-	}
-
-	return -ENOSYS;
-}
-
 int request_dma(unsigned int chan, const char *dev_id)
 {
 	struct dma_channel *channel = { 0 };
Signature · 1 line
2.34.1
#14 lore raw

Re: [PATCH 12/20] sh: dma: Remove unused dmac_search_free_channel()

Hi Geert,

Quoted 9 lines · Geert Uytterhoeven

arch/sh/drivers/dma/dma-api.c:164:5: warning: no previous prototype for 'dmac_search_free_channel' [-Wmissing-prototypes]

dmac_search_free_channel() never had a user in upstream, remove it.

---
dma_extend(), get_dma_info_by_name(), register_chan_caps(), and request_dma_bycap() are also unused, but don't trigger warnings
---

I assume the other functions didn't trigger a warning because their symbols were exported. Correct me if I'm wrong.

Adrian

Quoted 41 lines
 arch/sh/drivers/dma/dma-api.c | 27 ---------------------------
 1 file changed, 27 deletions(-)
arch/sh/drivers/dma/dma-api.c +0 -27
index 89cd4a3b4ccafbe2..f49097fa634c36d4 100644
@@ -161,33 +161,6 @@ int request_dma_bycap(const char **dmac, const char **caps, const char *dev_id)
 }
 EXPORT_SYMBOL(request_dma_bycap);
 
-int dmac_search_free_channel(const char *dev_id)
-{
-	struct dma_channel *channel = { 0 };
-	struct dma_info *info = get_dma_info(0);
-	int i;
-
-	for (i = 0; i < info->nr_channels; i++) {
-		channel = &info->channels[i];
-		if (unlikely(!channel))
-			return -ENODEV;
-
-		if (atomic_read(&channel->busy) == 0)
-			break;
-	}
-
-	if (info->ops->request) {
-		int result = info->ops->request(channel);
-		if (result)
-			return result;
-
-		atomic_set(&channel->busy, 1);
-		return channel->chan;
-	}
-
-	return -ENOSYS;
-}
-
 int request_dma(unsigned int chan, const char *dev_id)
 {
 	struct dma_channel *channel = { 0 };
Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#15 lore raw

Re: [PATCH 12/20] sh: dma: Remove unused dmac_search_free_channel()

Hi Adrian,

Quoted 5 lines · John Paul Adrian Glaubitz
Quoted 4 lines · Geert Uytterhoeven

arch/sh/drivers/dma/dma-api.c:164:5: warning: no previous prototype for 'dmac_search_free_channel' [-Wmissing-prototypes]

dmac_search_free_channel() never had a user in upstream, remove it.

Quoted 8 lines
Quoted 5 lines

---
dma_extend(), get_dma_info_by_name(), register_chan_caps(), and request_dma_bycap() are also unused, but don't trigger warnings
---

I assume the other functions didn't trigger a warning because their symbols were exported. Correct me if I'm wrong.

No, because they have a forward declaration in arch/sh/include/asm/dma.h.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#16 lore raw

PATCH 13/20 sh: sh2a: Add missing #include <asm/processor.h>

In reply to Geert Uytterhoeven

arch/sh/kernel/cpu/sh2a/opcode_helper.c:34:14: warning: no previous prototype for 'instruction_size' [-Wmissing-prototypes]

---
 arch/sh/kernel/cpu/sh2a/opcode_helper.c | 2 ++
 1 file changed, 2 insertions(+)
arch/sh/kernel/cpu/sh2a/opcode_helper.c +2 -0
index c509081d90b9affe..fcf53f5827eb286c 100644
@@ -8,6 +8,8 @@
  */
 #include <linux/kernel.h>
 
+#include <asm/processor.h>
+
 /*
  * Instructions on SH are generally fixed at 16-bits, however, SH-2A
  * introduces some 32-bit instructions. Since there are no real
Signature · 1 line
2.34.1
#17 lore raw

PATCH 14/20 sh: sh7786: Remove unused sh7786_usb_use_exclock()

In reply to Geert Uytterhoeven

arch/sh/kernel/cpu/sh4a/setup-sh7786.c:411:13: warning: no previous prototype for 'sh7786_usb_use_exclock' [-Wmissing-prototypes]

Upstream never had a user of sh7786_usb_use_exclock(), remove it.

---
 arch/sh/kernel/cpu/sh4a/setup-sh7786.c | 14 --------------
 1 file changed, 14 deletions(-)
arch/sh/kernel/cpu/sh4a/setup-sh7786.c +0 -14
index 74620f30b19badbd..c048842d8a589866 100644
@@ -400,20 +400,6 @@ static struct platform_device *sh7786_devices[] __initdata = {
 	&usb_ohci_device,
 };
 
-/*
- * Please call this function if your platform board
- * use external clock for USB
- * */
-#define USBCTL0		0xffe70858
-#define CLOCK_MODE_MASK 0xffffff7f
-#define EXT_CLOCK_MODE  0x00000080
-
-void __init sh7786_usb_use_exclock(void)
-{
-	u32 val = __raw_readl(USBCTL0) & CLOCK_MODE_MASK;
-	__raw_writel(val | EXT_CLOCK_MODE, USBCTL0);
-}
-
 #define USBINITREG1	0xffe70094
 #define USBINITREG2	0xffe7009c
 #define USBINITVAL1	0x00ff0040
Signature · 1 line
2.34.1
#18 lore raw

PATCH 15/20 sh: smp: Fix missing prototypes

In reply to Geert Uytterhoeven

arch/sh/kernel/smp.c:173:17: warning: no previous prototype for 'start_secondary' [-Wmissing-prototypes] arch/sh/kernel/smp.c:324:5: warning: no previous prototype for 'setup_profiling_timer' [-Wmissing-prototypes]

Make start_secondary() static, as it is only used in this file. Include <linux/profile.h> to fix the other warning.

There are no users outside this file, so make it static.

---
 arch/sh/kernel/smp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/sh/kernel/smp.c +3 -1
index 5cf35a774dc70082..b3ea50aabba3d7f2 100644
@@ -21,6 +21,8 @@
 #include <linux/sched/hotplug.h>
 #include <linux/atomic.h>
 #include <linux/clockchips.h>
+#include <linux/profile.h>
+
 #include <asm/processor.h>
 #include <asm/mmu_context.h>
 #include <asm/smp.h>
@@ -170,7 +172,7 @@ void native_play_dead(void)
 }
 #endif
 
-asmlinkage void start_secondary(void)
+static asmlinkage void start_secondary(void)
 {
 	unsigned int cpu = smp_processor_id();
 	struct mm_struct *mm = &init_mm;
Signature · 1 line
2.34.1
#19 lore raw

PATCH 16/20 sh: kprobes: Merge arch_copy_kprobe() into arch_prepare_kprobe()

In reply to Geert Uytterhoeven

arch/sh/kernel/kprobes.c:52:16: warning: no previous prototype for 'arch_copy_kprobe' [-Wmissing-prototypes]

Although SH kprobes support was only merged in v2.6.28, it missed the earlier removal of the arch_copy_kprobe() callback in v2.6.15.

Based on the powerpc part of commit 49a2a1b83ba6fa40 ("[PATCH] kprobes:
changed from using spinlock to mutex").

Fixes d39f5450146ff39f ("sh: Add kprobes support.")

---
Compile-tested only.

---
 arch/sh/kernel/kprobes.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
arch/sh/kernel/kprobes.c +1 -6
index aed1ea8e2c2f063b..74051b8ddf3e7bf9 100644
@@ -44,17 +44,12 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 	if (OPCODE_RTE(opcode))
 		return -EFAULT;	/* Bad breakpoint */
 
+	memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
 	p->opcode = opcode;
 
 	return 0;
 }
 
-void __kprobes arch_copy_kprobe(struct kprobe *p)
-{
-	memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
-	p->opcode = *p->addr;
-}
-
 void __kprobes arch_arm_kprobe(struct kprobe *p)
 {
 	*p->addr = BREAKPOINT_INSTRUCTION;
Signature · 1 line
2.34.1
#20 lore raw

PATCH 17/20 sh: kprobes: Make trampoline_probe_handler() static

In reply to Geert Uytterhoeven

arch/sh/kernel/kprobes.c:299:15: warning: no previous prototype for 'trampoline_probe_handler' [-Wmissing-prototypes]

There are no users outside this file, so make it static.

---
 arch/sh/kernel/kprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/kernel/kprobes.c +1 -1
index 74051b8ddf3e7bf9..d8c2e399d6e50794 100644
@@ -296,7 +296,7 @@ static void __used kretprobe_trampoline_holder(void)
 /*
  * Called when we hit the probe point at __kretprobe_trampoline
  */
-int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
+static int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
 {
 	regs->pc = __kretprobe_trampoline_handler(regs, NULL);
 
Signature · 1 line
2.34.1
#21 lore raw

PATCH 18/20 sh: kprobes: Remove unneeded kprobe_opcode_t casts

In reply to Geert Uytterhoeven

There is no need to cast a kprobe_opcode_t pointer to a kprobe_opcode_t pointer.

---
 arch/sh/kernel/kprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sh/kernel/kprobes.c +2 -2
index d8c2e399d6e50794..49c4ffd782d6d6c5 100644
@@ -39,7 +39,7 @@ static DEFINE_PER_CPU(struct kprobe, saved_next_opcode2);
 
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
 {
-	kprobe_opcode_t opcode = *(kprobe_opcode_t *) (p->addr);
+	kprobe_opcode_t opcode = *p->addr;
 
 	if (OPCODE_RTE(opcode))
 		return -EFAULT;	/* Bad breakpoint */
@@ -248,7 +248,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
 	p = get_kprobe(addr);
 	if (!p) {
 		/* Not one of ours: let kernel handle it */
-		if (*(kprobe_opcode_t *)addr != BREAKPOINT_INSTRUCTION) {
+		if (*addr != BREAKPOINT_INSTRUCTION) {
 			/*
 			 * The breakpoint instruction was removed right
 			 * after we hit it. Another cpu has removed
Signature · 1 line
2.34.1
#22 lore raw

PATCH 19/20 sh: dwarf: Make dwarf_lookup_fde() static

In reply to Geert Uytterhoeven

arch/sh/kernel/dwarf.c:347:19: warning: no previous prototype for 'dwarf_lookup_fde' [-Wmissing-prototypes]

There are no users outside this file, so make it static.

---
 arch/sh/kernel/dwarf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/kernel/dwarf.c +1 -1
index bf8682e718303051..45c8ae20d10957db 100644
@@ -344,7 +344,7 @@ static struct dwarf_cie *dwarf_lookup_cie(unsigned long cie_ptr)
  *	dwarf_lookup_fde - locate the FDE that covers pc
  *	@pc: the program counter
  */
-struct dwarf_fde *dwarf_lookup_fde(unsigned long pc)
+static struct dwarf_fde *dwarf_lookup_fde(unsigned long pc)
 {
 	struct rb_node **rb_node = &fde_root.rb_node;
 	struct dwarf_fde *fde = NULL;
Signature · 1 line
2.34.1
#23 lore raw

RFC PATCH 20/20 sh: dma: Remove unused functionality

In reply to Geert Uytterhoeven

dma_extend(), get_dma_info_by_name(), register_chan_caps(), and request_dma_bycap() are unused. Remove them, and all related code.

---
 arch/sh/drivers/dma/dma-api.c | 116 ----------------------------------
 arch/sh/include/asm/dma.h     |   7 --
 2 files changed, 123 deletions(-)
arch/sh/drivers/dma/dma-api.c +0 -116
index f49097fa634c36d4..87e5a892887360f5 100644
@@ -41,21 +41,6 @@ struct dma_info *get_dma_info(unsigned int chan)
 }
 EXPORT_SYMBOL(get_dma_info);
 
-struct dma_info *get_dma_info_by_name(const char *dmac_name)
-{
-	struct dma_info *info;
-
-	list_for_each_entry(info, &registered_dmac_list, list) {
-		if (dmac_name && (strcmp(dmac_name, info->name) != 0))
-			continue;
-		else
-			return info;
-	}
-
-	return NULL;
-}
-EXPORT_SYMBOL(get_dma_info_by_name);
-
 static unsigned int get_nr_channels(void)
 {
 	struct dma_info *info;
@@ -101,66 +86,6 @@ int get_dma_residue(unsigned int chan)
 }
 EXPORT_SYMBOL(get_dma_residue);
 
-static int search_cap(const char **haystack, const char *needle)
-{
-	const char **p;
-
-	for (p = haystack; *p; p++)
-		if (strcmp(*p, needle) == 0)
-			return 1;
-
-	return 0;
-}
-
-/**
- * request_dma_bycap - Allocate a DMA channel based on its capabilities
- * @dmac: List of DMA controllers to search
- * @caps: List of capabilities
- *
- * Search all channels of all DMA controllers to find a channel which
- * matches the requested capabilities. The result is the channel
- * number if a match is found, or %-ENODEV if no match is found.
- *
- * Note that not all DMA controllers export capabilities, in which
- * case they can never be allocated using this API, and so
- * request_dma() must be used specifying the channel number.
- */
-int request_dma_bycap(const char **dmac, const char **caps, const char *dev_id)
-{
-	unsigned int found = 0;
-	struct dma_info *info;
-	const char **p;
-	int i;
-
-	BUG_ON(!dmac || !caps);
-
-	list_for_each_entry(info, &registered_dmac_list, list)
-		if (strcmp(*dmac, info->name) == 0) {
-			found = 1;
-			break;
-		}
-
-	if (!found)
-		return -ENODEV;
-
-	for (i = 0; i < info->nr_channels; i++) {
-		struct dma_channel *channel = &info->channels[i];
-
-		if (unlikely(!channel->caps))
-			continue;
-
-		for (p = caps; *p; p++) {
-			if (!search_cap(channel->caps, *p))
-				break;
-			if (request_dma(channel->chan, dev_id) == 0)
-				return channel->chan;
-		}
-	}
-
-	return -EINVAL;
-}
-EXPORT_SYMBOL(request_dma_bycap);
-
 int request_dma(unsigned int chan, const char *dev_id)
 {
 	struct dma_channel *channel = { 0 };
@@ -213,35 +138,6 @@ void dma_wait_for_completion(unsigned int chan)
 }
 EXPORT_SYMBOL(dma_wait_for_completion);
 
-int register_chan_caps(const char *dmac, struct dma_chan_caps *caps)
-{
-	struct dma_info *info;
-	unsigned int found = 0;
-	int i;
-
-	list_for_each_entry(info, &registered_dmac_list, list)
-		if (strcmp(dmac, info->name) == 0) {
-			found = 1;
-			break;
-		}
-
-	if (unlikely(!found))
-		return -ENODEV;
-
-	for (i = 0; i < info->nr_channels; i++, caps++) {
-		struct dma_channel *channel;
-
-		if ((info->first_channel_nr + i) != caps->ch_num)
-			return -EINVAL;
-
-		channel = &info->channels[i];
-		channel->caps = caps->caplist;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(register_chan_caps);
-
 void dma_configure_channel(unsigned int chan, unsigned long flags)
 {
 	struct dma_info *info = get_dma_info(chan);
@@ -267,18 +163,6 @@ int dma_xfer(unsigned int chan, unsigned long from,
 }
 EXPORT_SYMBOL(dma_xfer);
 
-int dma_extend(unsigned int chan, unsigned long op, void *param)
-{
-	struct dma_info *info = get_dma_info(chan);
-	struct dma_channel *channel = get_dma_channel(chan);
-
-	if (info->ops->extend)
-		return info->ops->extend(channel, op, param);
-
-	return -ENOSYS;
-}
-EXPORT_SYMBOL(dma_extend);
-
 static int dma_proc_show(struct seq_file *m, void *v)
 {
 	struct dma_info *info = v;
arch/sh/include/asm/dma.h +0 -7
index c8bee3f985a29393..6b6d409956d17f09 100644
@@ -56,7 +56,6 @@ struct dma_ops {
 	int (*get_residue)(struct dma_channel *chan);
 	int (*xfer)(struct dma_channel *chan);
 	int (*configure)(struct dma_channel *chan, unsigned long flags);
-	int (*extend)(struct dma_channel *chan, unsigned long op, void *param);
 };
 
 struct dma_channel {
@@ -118,8 +117,6 @@ extern int dma_xfer(unsigned int chan, unsigned long from,
 #define dma_read_page(chan, from, to)	\
 	dma_read(chan, from, to, PAGE_SIZE)
 
-extern int request_dma_bycap(const char **dmac, const char **caps,
-			     const char *dev_id);
 extern int get_dma_residue(unsigned int chan);
 extern struct dma_info *get_dma_info(unsigned int chan);
 extern struct dma_channel *get_dma_channel(unsigned int chan);
@@ -128,10 +125,6 @@ extern void dma_configure_channel(unsigned int chan, unsigned long flags);
 
 extern int register_dmac(struct dma_info *info);
 extern void unregister_dmac(struct dma_info *info);
-extern struct dma_info *get_dma_info_by_name(const char *dmac_name);
-
-extern int dma_extend(unsigned int chan, unsigned long op, void *param);
-extern int register_chan_caps(const char *dmac, struct dma_chan_caps *capslist);
 
 /* arch/sh/drivers/dma/dma-sysfs.c */
 extern int dma_create_sysfs_files(struct dma_channel *, struct dma_info *);
Signature · 1 line
2.34.1
#24 lore raw

Re: [PATCH 20/20] [RFC] sh: dma: Remove unused functionality

Hi Geert,

Quoted 179 lines · Geert Uytterhoeven

dma_extend(), get_dma_info_by_name(), register_chan_caps(), and request_dma_bycap() are unused. Remove them, and all related code.

---
 arch/sh/drivers/dma/dma-api.c | 116 ----------------------------------
 arch/sh/include/asm/dma.h     |   7 --
 2 files changed, 123 deletions(-)
arch/sh/drivers/dma/dma-api.c +0 -116
index f49097fa634c36d4..87e5a892887360f5 100644
@@ -41,21 +41,6 @@ struct dma_info *get_dma_info(unsigned int chan)
 }
 EXPORT_SYMBOL(get_dma_info);
 
-struct dma_info *get_dma_info_by_name(const char *dmac_name)
-{
-	struct dma_info *info;
-
-	list_for_each_entry(info, &registered_dmac_list, list) {
-		if (dmac_name && (strcmp(dmac_name, info->name) != 0))
-			continue;
-		else
-			return info;
-	}
-
-	return NULL;
-}
-EXPORT_SYMBOL(get_dma_info_by_name);
-
 static unsigned int get_nr_channels(void)
 {
 	struct dma_info *info;
@@ -101,66 +86,6 @@ int get_dma_residue(unsigned int chan)
 }
 EXPORT_SYMBOL(get_dma_residue);
 
-static int search_cap(const char **haystack, const char *needle)
-{
-	const char **p;
-
-	for (p = haystack; *p; p++)
-		if (strcmp(*p, needle) == 0)
-			return 1;
-
-	return 0;
-}
-
-/**
- * request_dma_bycap - Allocate a DMA channel based on its capabilities
- * @dmac: List of DMA controllers to search
- * @caps: List of capabilities
- *
- * Search all channels of all DMA controllers to find a channel which
- * matches the requested capabilities. The result is the channel
- * number if a match is found, or %-ENODEV if no match is found.
- *
- * Note that not all DMA controllers export capabilities, in which
- * case they can never be allocated using this API, and so
- * request_dma() must be used specifying the channel number.
- */
-int request_dma_bycap(const char **dmac, const char **caps, const char *dev_id)
-{
-	unsigned int found = 0;
-	struct dma_info *info;
-	const char **p;
-	int i;
-
-	BUG_ON(!dmac || !caps);
-
-	list_for_each_entry(info, &registered_dmac_list, list)
-		if (strcmp(*dmac, info->name) == 0) {
-			found = 1;
-			break;
-		}
-
-	if (!found)
-		return -ENODEV;
-
-	for (i = 0; i < info->nr_channels; i++) {
-		struct dma_channel *channel = &info->channels[i];
-
-		if (unlikely(!channel->caps))
-			continue;
-
-		for (p = caps; *p; p++) {
-			if (!search_cap(channel->caps, *p))
-				break;
-			if (request_dma(channel->chan, dev_id) == 0)
-				return channel->chan;
-		}
-	}
-
-	return -EINVAL;
-}
-EXPORT_SYMBOL(request_dma_bycap);
-
 int request_dma(unsigned int chan, const char *dev_id)
 {
 	struct dma_channel *channel = { 0 };
@@ -213,35 +138,6 @@ void dma_wait_for_completion(unsigned int chan)
 }
 EXPORT_SYMBOL(dma_wait_for_completion);
 
-int register_chan_caps(const char *dmac, struct dma_chan_caps *caps)
-{
-	struct dma_info *info;
-	unsigned int found = 0;
-	int i;
-
-	list_for_each_entry(info, &registered_dmac_list, list)
-		if (strcmp(dmac, info->name) == 0) {
-			found = 1;
-			break;
-		}
-
-	if (unlikely(!found))
-		return -ENODEV;
-
-	for (i = 0; i < info->nr_channels; i++, caps++) {
-		struct dma_channel *channel;
-
-		if ((info->first_channel_nr + i) != caps->ch_num)
-			return -EINVAL;
-
-		channel = &info->channels[i];
-		channel->caps = caps->caplist;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(register_chan_caps);
-
 void dma_configure_channel(unsigned int chan, unsigned long flags)
 {
 	struct dma_info *info = get_dma_info(chan);
@@ -267,18 +163,6 @@ int dma_xfer(unsigned int chan, unsigned long from,
 }
 EXPORT_SYMBOL(dma_xfer);
 
-int dma_extend(unsigned int chan, unsigned long op, void *param)
-{
-	struct dma_info *info = get_dma_info(chan);
-	struct dma_channel *channel = get_dma_channel(chan);
-
-	if (info->ops->extend)
-		return info->ops->extend(channel, op, param);
-
-	return -ENOSYS;
-}
-EXPORT_SYMBOL(dma_extend);
-
 static int dma_proc_show(struct seq_file *m, void *v)
 {
 	struct dma_info *info = v;
arch/sh/include/asm/dma.h +0 -3
index c8bee3f985a29393..6b6d409956d17f09 100644
@@ -56,7 +56,6 @@ struct dma_ops {
 	int (*get_residue)(struct dma_channel *chan);
 	int (*xfer)(struct dma_channel *chan);
 	int (*configure)(struct dma_channel *chan, unsigned long flags);
-	int (*extend)(struct dma_channel *chan, unsigned long op, void *param);
 };
 
 struct dma_channel {
@@ -118,8 +117,6 @@ extern int dma_xfer(unsigned int chan, unsigned long from,
 #define dma_read_page(chan, from, to)	\
 	dma_read(chan, from, to, PAGE_SIZE)
 
-extern int request_dma_bycap(const char **dmac, const char **caps,
-			     const char *dev_id);
 extern int get_dma_residue(unsigned int chan);
 extern struct dma_info *get_dma_info(unsigned int chan);
 extern struct dma_channel *get_dma_channel(unsigned int chan);

arch/sh/include/asm/dma.h extern void dma_configure_channel(unsigned int chan, unsigned long flags); · line 130

Quoted 10 lines
arch/sh/include/asm/dma.h +0 -4
@@ -128,10 +125,6 @@ extern void dma_configure_channel(unsigned int chan, unsigned long flags);
 
 extern int register_dmac(struct dma_info *info);
 extern void unregister_dmac(struct dma_info *info);
-extern struct dma_info *get_dma_info_by_name(const char *dmac_name);
-
-extern int dma_extend(unsigned int chan, unsigned long op, void *param);
-extern int register_chan_caps(const char *dmac, struct dma_chan_caps *capslist);
 
 /* arch/sh/drivers/dma/dma-sysfs.c */
 extern int dma_create_sysfs_files(struct dma_channel *, struct dma_info *);

I assume we could re-add these again in case we need them, but it would be good if Yoshinori could comment on whether we should keep these functions or not.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#25 lore raw

Re: [PATCH 20/20] [RFC] sh: dma: Remove unused functionality

Hi Geert,

Quoted 190 lines · John Paul Adrian Glaubitz

Hi Geert,

Quoted 187 lines · Geert Uytterhoeven

dma_extend(), get_dma_info_by_name(), register_chan_caps(), and request_dma_bycap() are unused. Remove them, and all related code.

---
 arch/sh/drivers/dma/dma-api.c | 116 ----------------------------------
 arch/sh/include/asm/dma.h     |   7 --
 2 files changed, 123 deletions(-)
arch/sh/drivers/dma/dma-api.c +0 -116
index f49097fa634c36d4..87e5a892887360f5 100644
@@ -41,21 +41,6 @@ struct dma_info *get_dma_info(unsigned int chan)
 }
 EXPORT_SYMBOL(get_dma_info);
 
-struct dma_info *get_dma_info_by_name(const char *dmac_name)
-{
-	struct dma_info *info;
-
-	list_for_each_entry(info, &registered_dmac_list, list) {
-		if (dmac_name && (strcmp(dmac_name, info->name) != 0))
-			continue;
-		else
-			return info;
-	}
-
-	return NULL;
-}
-EXPORT_SYMBOL(get_dma_info_by_name);
-
 static unsigned int get_nr_channels(void)
 {
 	struct dma_info *info;
@@ -101,66 +86,6 @@ int get_dma_residue(unsigned int chan)
 }
 EXPORT_SYMBOL(get_dma_residue);
 
-static int search_cap(const char **haystack, const char *needle)
-{
-	const char **p;
-
-	for (p = haystack; *p; p++)
-		if (strcmp(*p, needle) == 0)
-			return 1;
-
-	return 0;
-}
-
-/**
- * request_dma_bycap - Allocate a DMA channel based on its capabilities
- * @dmac: List of DMA controllers to search
- * @caps: List of capabilities
- *
- * Search all channels of all DMA controllers to find a channel which
- * matches the requested capabilities. The result is the channel
- * number if a match is found, or %-ENODEV if no match is found.
- *
- * Note that not all DMA controllers export capabilities, in which
- * case they can never be allocated using this API, and so
- * request_dma() must be used specifying the channel number.
- */
-int request_dma_bycap(const char **dmac, const char **caps, const char *dev_id)
-{
-	unsigned int found = 0;
-	struct dma_info *info;
-	const char **p;
-	int i;
-
-	BUG_ON(!dmac || !caps);
-
-	list_for_each_entry(info, &registered_dmac_list, list)
-		if (strcmp(*dmac, info->name) == 0) {
-			found = 1;
-			break;
-		}
-
-	if (!found)
-		return -ENODEV;
-
-	for (i = 0; i < info->nr_channels; i++) {
-		struct dma_channel *channel = &info->channels[i];
-
-		if (unlikely(!channel->caps))
-			continue;
-
-		for (p = caps; *p; p++) {
-			if (!search_cap(channel->caps, *p))
-				break;
-			if (request_dma(channel->chan, dev_id) == 0)
-				return channel->chan;
-		}
-	}
-
-	return -EINVAL;
-}
-EXPORT_SYMBOL(request_dma_bycap);
-
 int request_dma(unsigned int chan, const char *dev_id)
 {
 	struct dma_channel *channel = { 0 };
@@ -213,35 +138,6 @@ void dma_wait_for_completion(unsigned int chan)
 }
 EXPORT_SYMBOL(dma_wait_for_completion);
 
-int register_chan_caps(const char *dmac, struct dma_chan_caps *caps)
-{
-	struct dma_info *info;
-	unsigned int found = 0;
-	int i;
-
-	list_for_each_entry(info, &registered_dmac_list, list)
-		if (strcmp(dmac, info->name) == 0) {
-			found = 1;
-			break;
-		}
-
-	if (unlikely(!found))
-		return -ENODEV;
-
-	for (i = 0; i < info->nr_channels; i++, caps++) {
-		struct dma_channel *channel;
-
-		if ((info->first_channel_nr + i) != caps->ch_num)
-			return -EINVAL;
-
-		channel = &info->channels[i];
-		channel->caps = caps->caplist;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(register_chan_caps);
-
 void dma_configure_channel(unsigned int chan, unsigned long flags)
 {
 	struct dma_info *info = get_dma_info(chan);
@@ -267,18 +163,6 @@ int dma_xfer(unsigned int chan, unsigned long from,
 }
 EXPORT_SYMBOL(dma_xfer);
 
-int dma_extend(unsigned int chan, unsigned long op, void *param)
-{
-	struct dma_info *info = get_dma_info(chan);
-	struct dma_channel *channel = get_dma_channel(chan);
-
-	if (info->ops->extend)
-		return info->ops->extend(channel, op, param);
-
-	return -ENOSYS;
-}
-EXPORT_SYMBOL(dma_extend);
-
 static int dma_proc_show(struct seq_file *m, void *v)
 {
 	struct dma_info *info = v;
arch/sh/include/asm/dma.h +0 -7
index c8bee3f985a29393..6b6d409956d17f09 100644
@@ -56,7 +56,6 @@ struct dma_ops {
 	int (*get_residue)(struct dma_channel *chan);
 	int (*xfer)(struct dma_channel *chan);
 	int (*configure)(struct dma_channel *chan, unsigned long flags);
-	int (*extend)(struct dma_channel *chan, unsigned long op, void *param);
 };
 
 struct dma_channel {
@@ -118,8 +117,6 @@ extern int dma_xfer(unsigned int chan, unsigned long from,
 #define dma_read_page(chan, from, to)	\
 	dma_read(chan, from, to, PAGE_SIZE)
 
-extern int request_dma_bycap(const char **dmac, const char **caps,
-			     const char *dev_id);
 extern int get_dma_residue(unsigned int chan);
 extern struct dma_info *get_dma_info(unsigned int chan);
 extern struct dma_channel *get_dma_channel(unsigned int chan);
@@ -128,10 +125,6 @@ extern void dma_configure_channel(unsigned int chan, unsigned long flags);
 
 extern int register_dmac(struct dma_info *info);
 extern void unregister_dmac(struct dma_info *info);
-extern struct dma_info *get_dma_info_by_name(const char *dmac_name);
-
-extern int dma_extend(unsigned int chan, unsigned long op, void *param);
-extern int register_chan_caps(const char *dmac, struct dma_chan_caps *capslist);
 
Quoted 5 lines

arch/sh/include/asm/dma.h extern void dma_configure_channel(unsigned int chan, unsigned long flags); · line 130

Quoted 2 lines
arch/sh/include/asm/dma.h +0 -0
 /* arch/sh/drivers/dma/dma-sysfs.c */
 extern int dma_create_sysfs_files(struct dma_channel *, struct dma_info *);

I assume we could re-add these again in case we need them, but it would be good if Yoshinori could comment on whether we should keep these functions or not.

I was wondering: Could there be any userland tools using these DMA functions?

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#26 lore raw

Re: [PATCH 20/20] [RFC] sh: dma: Remove unused functionality

Hi Adrian,

Quoted 11 lines · John Paul Adrian Glaubitz
Quoted 8 lines · John Paul Adrian Glaubitz
Quoted 4 lines · Geert Uytterhoeven

dma_extend(), get_dma_info_by_name(), register_chan_caps(), and request_dma_bycap() are unused. Remove them, and all related code.

I assume we could re-add these again in case we need them, but it would be good if Yoshinori could comment on whether we should keep these functions or not.

I was wondering: Could there be any userland tools using these DMA functions?

They cannot be called from userspace, as there is no API for that. They can only be called from inside the kernel, or from a kernel module (possibly out-of-tree).

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#27 lore raw

Re: [PATCH 20/20] [RFC] sh: dma: Remove unused functionality

Hi Geert,

Quoted 9 lines · Geert Uytterhoeven
Quoted 6 lines · John Paul Adrian Glaubitz
Quoted 5 lines · John Paul Adrian Glaubitz
Quoted 4 lines · Geert Uytterhoeven

dma_extend(), get_dma_info_by_name(), register_chan_caps(), and request_dma_bycap() are unused. Remove them, and all related code.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I assume we could re-add these again in case we need them, but it would be good if Yoshinori could comment on whether we should keep these functions or not.

I was wondering: Could there be any userland tools using these DMA functions?

They cannot be called from userspace, as there is no API for that. They can only be called from inside the kernel, or from a kernel module (possibly out-of-tree).

OK, thanks for the confirmation. Then I think it's safe to remove them.

I will apply both your series tonight and the rest of the patches except for the one that moves the paging_init() around as it turns out the current positioning is intentional.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#28 lore raw
In reply to Geert Uytterhoeven

(reducing the audience)

Quoted 2 lines · Geert Uytterhoeven

This patch series fixes several "no previous prototype for <foo>" warnings when building a kernel for SuperH.

This series is still valid, except for [PATCH 08/20][1], which got a v2[2]. Please let me know if you want me to resend a v2 of the full series.

Thanks!

[1] "[PATCH 08/20] sh: boot: Add proper forward declarations"

    https://lore.kernel.org/r/2614d991c816ece903ef47c715bcc53881d34f3f.1709326528.git.geert+renesas@glider.be

[2] "[PATCH v2] sh: boot: Add proper forward declarations"

    https://lore.kernel.org/r/b7ea770a3bf26fb2a5f59f4bb83072b2526f7134.1713959841.git.geert+renesas@glider.be

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Reviewed-by on the v1 series
#29 lore raw
In reply to Geert Uytterhoeven

Hi Geert,

Quoted 60 lines · Geert Uytterhoeven

Hi all,

This patch series fixes several "no previous prototype for <foo>" warnings when building a kernel for SuperH.

Known issues:
- The various warnings about cache functions are not yet fixed, but I didn't want to hold off the rest of this series,
- sdk7786_defconfig needs "[PATCH/RFC] locking/spinlocks: Make __raw_* lock ops static" [1],
- Probably there are more warnings to fix, I didn't build all defconfigs.

This has been boot-tested on landisk and on qemu/rts7751r2d.

Thanks for your comments!

[1] https://lore.kernel.org/linux-sh/c395b02613572131568bc1fd1bc456d20d1a5426.1709325647.git.geert+renesas@glider.be

Geert Uytterhoeven (20):
sh: pgtable: Fix missing prototypes
sh: fpu: Add missing forward declarations
sh: syscall: Add missing forward declaration for sys_cacheflush()
sh: tlb: Add missing forward declaration for handle_tlbmiss()
sh: return_address: Add missing #include <asm/ftrace.h>
sh: traps: Add missing #include <asm/setup.h>
sh: hw_breakpoint: Add missing forward declaration for
arch_bp_generic_fields()
sh: boot: Add proper forward declarations
sh: ftrace: Fix missing prototypes
sh: nommu: Add missing #include <asm/cacheflush.h>
sh: math-emu: Add missing #include <asm/fpu.h>
sh: dma: Remove unused dmac_search_free_channel()
sh: sh2a: Add missing #include <asm/processor.h>
sh: sh7786: Remove unused sh7786_usb_use_exclock()
sh: smp: Fix missing prototypes
sh: kprobes: Merge arch_copy_kprobe() into arch_prepare_kprobe()
sh: kprobes: Make trampoline_probe_handler() static
sh: kprobes: Remove unneeded kprobe_opcode_t casts
sh: dwarf: Make dwarf_lookup_fde() static
[RFC] sh: dma: Remove unused functionality

 arch/sh/boot/compressed/cache.c         |   3 +
 arch/sh/boot/compressed/cache.h         |  10 ++
 arch/sh/boot/compressed/misc.c          |   8 +-
 arch/sh/boot/compressed/misc.h          |   9 ++
 arch/sh/drivers/dma/dma-api.c           | 143 ------------------------
 arch/sh/include/asm/dma.h               |   7 --
 arch/sh/include/asm/fpu.h               |   3 +
 arch/sh/include/asm/ftrace.h            |  10 ++
 arch/sh/include/asm/hw_breakpoint.h     |   2 +
 arch/sh/include/asm/syscalls.h          |   1 +
 arch/sh/include/asm/tlb.h               |   4 +
 arch/sh/kernel/cpu/sh2a/opcode_helper.c |   2 +
 arch/sh/kernel/cpu/sh4a/setup-sh7786.c  |  14 ---
 arch/sh/kernel/dwarf.c                  |   2 +-
 arch/sh/kernel/kprobes.c                |  13 +--
 arch/sh/kernel/return_address.c         |   2 +
 arch/sh/kernel/smp.c                    |   4 +-
 arch/sh/kernel/traps.c                  |  10 +-
Quoted 9 lines
 arch/sh/kernel/traps_32.c               |   1 +
 arch/sh/math-emu/math.c                 |   2 +
 arch/sh/mm/nommu.c                      |   2 +
 arch/sh/mm/pgtable.c                    |   4 +-
 arch/sh/mm/tlbex_32.c                   |   1 +
 23 files changed, 68 insertions(+), 189 deletions(-)
 create mode 100644 arch/sh/boot/compressed/cache.h
 create mode 100644 arch/sh/boot/compressed/misc.h

For the whole series:

I would still like to get feedback from Yoshinori on patch #20 though, i.e.

"sh: dma: Remove unused functionality".

On the other hand, we could just merge this series and re-add the functions later if we decide they're still needed.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
maintainer Applied
#30 lore raw
In reply to Geert Uytterhoeven
Quoted 60 lines · Geert Uytterhoeven

Hi all,

This patch series fixes several "no previous prototype for <foo>" warnings when building a kernel for SuperH.

Known issues:
- The various warnings about cache functions are not yet fixed, but I didn't want to hold off the rest of this series,
- sdk7786_defconfig needs "[PATCH/RFC] locking/spinlocks: Make __raw_* lock ops static" [1],
- Probably there are more warnings to fix, I didn't build all defconfigs.

This has been boot-tested on landisk and on qemu/rts7751r2d.

Thanks for your comments!

[1] https://lore.kernel.org/linux-sh/c395b02613572131568bc1fd1bc456d20d1a5426.1709325647.git.geert+renesas@glider.be

Geert Uytterhoeven (20):
sh: pgtable: Fix missing prototypes
sh: fpu: Add missing forward declarations
sh: syscall: Add missing forward declaration for sys_cacheflush()
sh: tlb: Add missing forward declaration for handle_tlbmiss()
sh: return_address: Add missing #include <asm/ftrace.h>
sh: traps: Add missing #include <asm/setup.h>
sh: hw_breakpoint: Add missing forward declaration for
arch_bp_generic_fields()
sh: boot: Add proper forward declarations
sh: ftrace: Fix missing prototypes
sh: nommu: Add missing #include <asm/cacheflush.h>
sh: math-emu: Add missing #include <asm/fpu.h>
sh: dma: Remove unused dmac_search_free_channel()
sh: sh2a: Add missing #include <asm/processor.h>
sh: sh7786: Remove unused sh7786_usb_use_exclock()
sh: smp: Fix missing prototypes
sh: kprobes: Merge arch_copy_kprobe() into arch_prepare_kprobe()
sh: kprobes: Make trampoline_probe_handler() static
sh: kprobes: Remove unneeded kprobe_opcode_t casts
sh: dwarf: Make dwarf_lookup_fde() static
[RFC] sh: dma: Remove unused functionality

 arch/sh/boot/compressed/cache.c         |   3 +
 arch/sh/boot/compressed/cache.h         |  10 ++
 arch/sh/boot/compressed/misc.c          |   8 +-
 arch/sh/boot/compressed/misc.h          |   9 ++
 arch/sh/drivers/dma/dma-api.c           | 143 ------------------------
 arch/sh/include/asm/dma.h               |   7 --
 arch/sh/include/asm/fpu.h               |   3 +
 arch/sh/include/asm/ftrace.h            |  10 ++
 arch/sh/include/asm/hw_breakpoint.h     |   2 +
 arch/sh/include/asm/syscalls.h          |   1 +
 arch/sh/include/asm/tlb.h               |   4 +
 arch/sh/kernel/cpu/sh2a/opcode_helper.c |   2 +
 arch/sh/kernel/cpu/sh4a/setup-sh7786.c  |  14 ---
 arch/sh/kernel/dwarf.c                  |   2 +-
 arch/sh/kernel/kprobes.c                |  13 +--
 arch/sh/kernel/return_address.c         |   2 +
 arch/sh/kernel/smp.c                    |   4 +-
 arch/sh/kernel/traps.c                  |  10 +-
Quoted 8 lines
 arch/sh/kernel/traps_32.c               |   1 +
 arch/sh/math-emu/math.c                 |   2 +
 arch/sh/mm/nommu.c                      |   2 +
 arch/sh/mm/pgtable.c                    |   4 +-
 arch/sh/mm/tlbex_32.c                   |   1 +
 23 files changed, 68 insertions(+), 189 deletions(-)
 create mode 100644 arch/sh/boot/compressed/cache.h
 create mode 100644 arch/sh/boot/compressed/misc.h

Applied to my sh-linux tree in the for-next branch.

Thanks,
Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913