From ebdc7e09a54041022d8276976ea6e59a87b95c29 Mon Sep 17 00:00:00 2001 From: Harry Cutts Date: Tue, 8 Oct 2019 14:32:21 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1848493 Reviewed-by: Daisuke Nojiri --- driver/touchpad_gt7288.c | 6 ------ include/common.h | 7 +++++++ 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" -- cgit v1.2.1