All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4] platform/chrome: cros_ec_trace: update generating script
@ 2019-07-30 13:47 Tzung-Bi Shih
  2019-07-30 14:07 ` Tzung-Bi Shih
  0 siblings, 1 reply; 8+ messages in thread
From: Tzung-Bi Shih @ 2019-07-30 13:47 UTC (permalink / raw)
  To: bleung, enric.balletbo, groeck, rrangel
  Cc: linux-kernel, cychiang, dgreid, tzungbi

The original script generates unneeded ", \" on the last line which
results in compile error if one would forget to remove them.  Update the
script to not generate ", \" on the last line.  Also add a define guard
for EC_CMDS.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
Changes from v1:
- simpler awk code
Changes from v2:
- use c style comments instead of c++ style
- use '@' delimiter in sed instead of '/' to avoid unintentional end of
  comment "*/"
Changes from v3:
- more detail commit message
- add define guard for EC_CMDS

 drivers/platform/chrome/cros_ec_trace.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_trace.c b/drivers/platform/chrome/cros_ec_trace.c
index 0a76412095a9..1412ae024435 100644
--- a/drivers/platform/chrome/cros_ec_trace.c
+++ b/drivers/platform/chrome/cros_ec_trace.c
@@ -5,8 +5,27 @@
 
 #define TRACE_SYMBOL(a) {a, #a}
 
-// Generate the list using the following script:
-// sed -n 's/^#define \(EC_CMD_[[:alnum:]_]*\)\s.*/\tTRACE_SYMBOL(\1), \\/p' include/linux/mfd/cros_ec_commands.h
+/*
+ * Generate the list using the following script:
+ * sed -n 's@^#define \(EC_CMD_[[:alnum:]_]*\)\s.*@\tTRACE_SYMBOL(\1), \\@p' \
+ * include/linux/mfd/cros_ec_commands.h | awk '
+ * BEGIN {
+ *   print "#ifndef EC_CMDS";
+ *   print "#define EC_CMDS \\";
+ * }
+ * {
+ *   if (NR != 1)
+ *     print buf;
+ *   buf = $0;
+ * }
+ * END {
+ *   gsub(/, \\/, "", buf);
+ *   print buf;
+ *   print "#endif";
+ * }
+ * '
+ */
+#ifndef EC_CMDS
 #define EC_CMDS \
 	TRACE_SYMBOL(EC_CMD_PROTO_VERSION), \
 	TRACE_SYMBOL(EC_CMD_HELLO), \
@@ -119,6 +138,7 @@
 	TRACE_SYMBOL(EC_CMD_PD_CHARGE_PORT_OVERRIDE), \
 	TRACE_SYMBOL(EC_CMD_PD_GET_LOG_ENTRY), \
 	TRACE_SYMBOL(EC_CMD_USB_PD_MUX_INFO)
+#endif
 
 #define CREATE_TRACE_POINTS
 #include "cros_ec_trace.h"
-- 
2.22.0.709.g102302147b-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-08-29 13:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-30 13:47 [PATCH v4] platform/chrome: cros_ec_trace: update generating script Tzung-Bi Shih
2019-07-30 14:07 ` Tzung-Bi Shih
2019-08-01 10:59   ` Enric Balletbo i Serra
2019-08-01 13:04     ` Tzung-Bi Shih
2019-08-01 13:30       ` Enric Balletbo i Serra
2019-08-01 14:50         ` Raul Rangel
     [not found]           ` <CA+Px+wUzyFB6vRM91PTFkY_fBfp2xybegy34rbW_D9zzNX6-8Q@mail.gmail.com>
2019-08-29 13:42             ` Enric Balletbo i Serra
2019-08-29 13:51               ` Enric Balletbo Serra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.