summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Cutts <hcutts@chromium.org>2019-10-08 14:32:21 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-09 07:06:48 +0000
commitebdc7e09a54041022d8276976ea6e59a87b95c29 (patch)
tree24cd6ca38fd551937dc5088f08c56cb1273f2f00
parent9a22d8465107ee1a0b526e4caf70ca9b689b7f57 (diff)
downloadchrome-ec-ebdc7e09a54041022d8276976ea6e59a87b95c29.tar.gz
common: add `RETURN_ERROR` macro
This had been used in the GT7288 driver, but is now being used quite a bit in the private repo, so it's time to put it in common. BRANCH=none BUG=chromium:1008568 TEST=Check that a board which uses the GT7288 driver builds correctly. Change-Id: I111018a73def7a30ff899f9bf435da6f89d9b86a Signed-off-by: Harry Cutts <hcutts@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1848493 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--driver/touchpad_gt7288.c6
-rw-r--r--include/common.h7
2 files changed, 7 insertions, 6 deletions
diff --git a/driver/touchpad_gt7288.c b/driver/touchpad_gt7288.c
index 945f35c0d4..8085315886 100644
--- a/driver/touchpad_gt7288.c
+++ b/driver/touchpad_gt7288.c
@@ -18,12 +18,6 @@
#define CPRINTS(format, args...) cprints(CC_TOUCHPAD, format, ## args)
-#define RETURN_ERROR(fn) do { \
- int error = (fn); \
- if (error != EC_SUCCESS) \
- return error; \
-} while (0)
-
#define GT7288_SLAVE_ADDRESS 0x14
#define GT7288_REPORT_ID_PTP 0x04
diff --git a/include/common.h b/include/common.h
index ee95bf5f15..dfa7270233 100644
--- a/include/common.h
+++ b/include/common.h
@@ -145,6 +145,13 @@
#define TARGET_WITH_MARGIN(target, tenths_percent) \
(((target) * 1000) / (1000 + (tenths_percent)))
+/* Call a function, and return the error value unless it returns EC_SUCCESS. */
+#define RETURN_ERROR(fn) do { \
+ int error = (fn); \
+ if (error != EC_SUCCESS) \
+ return error; \
+} while (0)
+
/* Include top-level configuration file */
#include "config.h"