summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2012-06-27 17:26:10 +0800
committerGerrit <chrome-bot@google.com>2012-06-27 03:22:17 -0700
commit0e261504aa6b835ea922e7ccb9511503c2527d84 (patch)
tree72d83ba25d841600ec7f1566373bb38702c5aaa3 /include
parent0909a66d90f1397c69c47fb74bcdb83606e9f273 (diff)
downloadchrome-ec-0e261504aa6b835ea922e7ccb9511503c2527d84.tar.gz
Stub smart battery read/write functions
For better testability, let's move smart battery read/write functions to a stub so that we can easily mock them. BUG=chrome-os-partner:10270 TEST=build success Change-Id: I416580c6dc7911e376bc232e5f0560117d9353c2 Reviewed-on: https://gerrit.chromium.org/gerrit/26227 Reviewed-by: Rong Chang <rongchang@chromium.org> Commit-Ready: Vic Yang <victoryang@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/smart_battery.h14
-rw-r--r--include/smart_battery_stub.h23
2 files changed, 24 insertions, 13 deletions
diff --git a/include/smart_battery.h b/include/smart_battery.h
index 8fd6c6830a..3aab43ef91 100644
--- a/include/smart_battery.h
+++ b/include/smart_battery.h
@@ -11,6 +11,7 @@
#include "board.h"
#include "common.h"
#include "i2c.h"
+#include "smart_battery_stub.h"
/* Smart battery and charger I2C address */
#define BATTERY_ADDR 0x16
@@ -128,19 +129,6 @@
#define INFO_CHARGER_SPEC(INFO) ((INFO) & 0xf)
#define INFO_SELECTOR_SUPPORT(INFO) (((INFO) >> 4) & 1)
-/* Inline helper functions */
-static inline int sbc_read(int cmd, int *param)
- { return i2c_read16(I2C_PORT_CHARGER, CHARGER_ADDR, cmd, param); }
-
-static inline int sbc_write(int cmd, int param)
- { return i2c_write16(I2C_PORT_CHARGER, CHARGER_ADDR, cmd, param); }
-
-static inline int sb_read(int cmd, int *param)
- { return i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR, cmd, param); }
-
-static inline int sb_write(int cmd, int param)
- { return i2c_write16(I2C_PORT_BATTERY, BATTERY_ADDR, cmd, param); }
-
/* Get/set battery mode */
static inline int battery_get_battery_mode(int *mode)
{ return sb_read(SB_BATTERY_MODE, mode); }
diff --git a/include/smart_battery_stub.h b/include/smart_battery_stub.h
new file mode 100644
index 0000000000..35754009c5
--- /dev/null
+++ b/include/smart_battery_stub.h
@@ -0,0 +1,23 @@
+/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Functions needed by smart battery driver.
+ */
+
+#ifndef __CROS_EC_SMART_BATTERY_STUB_H
+#define __CROS_EC_SMART_BATTERY_STUB_H
+
+/* Read from charger */
+int sbc_read(int cmd, int *param);
+
+/* Write to charger */
+int sbc_write(int cmd, int param);
+
+/* Read from battery */
+int sb_read(int cmd, int *param);
+
+/* Write to battery */
+int sb_write(int cmd, int param);
+
+#endif /* __CROS_EC_SMART_BATTERY_STUB_H */