[PATCH v2 2/3] scripts: socfpga: add coccinelle magic

Steffen Trumtrar s.trumtrar at pengutronix.de
Mon Feb 23 01:15:04 PST 2015


Use coccinelle to cleanup the imported u-boot code some more.
This will remove:
	- debugging macros (TCL_RPT, BFM_STAGE, ALTERA_ASSERT)
	- empty if/else/for blocks resulting from macro deletion
	- some unused functions (scc_mgr_xxx)

Signed-off-by: Steffen Trumtrar <s.trumtrar at pengutronix.de>
---
 scripts/coccinelle/misc/altera_sequencer.cocci | 93 ++++++++++++++++++++++++++
 scripts/socfpga_get_sequencer                  |  3 +
 2 files changed, 96 insertions(+)
 create mode 100644 scripts/coccinelle/misc/altera_sequencer.cocci

diff --git a/scripts/coccinelle/misc/altera_sequencer.cocci b/scripts/coccinelle/misc/altera_sequencer.cocci
new file mode 100644
index 000000000000..9fea239c0c7d
--- /dev/null
+++ b/scripts/coccinelle/misc/altera_sequencer.cocci
@@ -0,0 +1,93 @@
+ at r_shadow@
+@@
+
+- ...curr_shadow_reg = 0;
+
+ at r_out2_delay@
+type T;
+@@
+
+- T scc_mgr_apply_group_dq_out2_delay(...)
+- {
+- ...
+- }
+
+ at r_oct_out2@
+type T;
+@@
+- T scc_mgr_apply_group_dqs_io_and_oct_out2(...)
+- {
+- ...
+- }
+
+ at r_oct_out2_gradual@
+type T;
+@@
+
+- T scc_mgr_set_group_dqs_io_and_oct_out2_gradual(...)
+- {
+- ...
+- }
+
+ at r_eye_diag@
+type T;
+@@
+
+- T rw_mgr_mem_calibrate_eye_diag_aid(...)
+- {
+- ...
+- }
+
+ at r_full_test@
+type T;
+@@
+
+- T rw_mgr_mem_calibrate_full_test(...)
+- {
+- ...
+- }
+
+ at r_user_init_cal_req@
+@@
+
+- static void user_init_cal_req (...)
+- {
+- ...
+- }
+
+ at r_tcl@
+@@
+
+- TCLRPT_SET(...);
+
+ at r_bfm@
+@@
+
+- BFM_STAGE(...);
+
+ at r_trace@
+@@
+
+- TRACE_FUNC(...);
+
+ at r_assert@
+@@
+
+- ALTERA_ASSERT(...);
+
+ at r_if@
+@@
+
+- if (...) {}
+
+ at r_if_else@
+@@
+
+- if (...) {
+- } else {
+- }
+
+ at r_for@
+@@
+
+- for (...;...;...) {}
diff --git a/scripts/socfpga_get_sequencer b/scripts/socfpga_get_sequencer
index de12b35b5d11..5e4eb2d0c46c 100755
--- a/scripts/socfpga_get_sequencer
+++ b/scripts/socfpga_get_sequencer
@@ -46,6 +46,9 @@ copy_source() {
 
 	echo "	Automated readability fixup..."
 	indent -npro -kr -i8 -ts8 -sob -l100 -ss -ncs -cp1 -il0 $tgt
+
+	echo "  Running coccinelle cleanups..."
+	spatch -sp_file scripts/coccinelle/misc/altera_sequencer.cocci -in_place arch/arm/mach-socfpga/include/mach
 }
 
 copy_source ${ubootsrc}/board/altera/socfpga/sdram/sequencer.c arch/arm/mach-socfpga/include/mach/sequencer.c
-- 
2.1.4




More information about the barebox mailing list