summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2013-09-10 18:14:58 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-09-10 18:14:58 +0000
commit6a09617eaa2e47e768b87c341459bf80e008a359 (patch)
treecec245d190ad6e9c310fdc912a145457f89f0b4a
parentbd5015e0f3b79d8b8e7f9b1926bbf76985ac8c61 (diff)
parent36ab8ed76fb751d8570d0323e6ece4c60f730703 (diff)
downloadlibhardware-6a09617eaa2e47e768b87c341459bf80e008a359.tar.gz
Merge "keymaster: use new version fields in hw_module"
-rw-r--r--include/hardware/keymaster.h18
-rw-r--r--tests/keymaster/keymaster_test.cpp2
2 files changed, 11 insertions, 9 deletions
diff --git a/include/hardware/keymaster.h b/include/hardware/keymaster.h
index 968beb96..67521461 100644
--- a/include/hardware/keymaster.h
+++ b/include/hardware/keymaster.h
@@ -33,11 +33,13 @@ __BEGIN_DECLS
#define KEYSTORE_KEYMASTER "keymaster"
/**
- * The API level of this version of the header. The allows the implementing
- * module to recognize which API level of the client it is dealing with in
- * the case of pre-compiled binary clients.
+ * Settings for "module_api_version" and "hal_api_version"
+ * fields in the keymaster_module initialization.
*/
-#define KEYMASTER_API_VERSION 2
+#define KEYMASTER_HEADER_VERSION 2
+
+#define KEYMASTER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2)
+#define KEYMASTER_DEVICE_API_VERSION_0_2 HARDWARE_DEVICE_API_VERSION_2(0, 2, KEYMASTER_HEADER_VERSION)
/**
* Flags for keymaster_device::flags
@@ -139,6 +141,10 @@ typedef struct {
struct keymaster_device {
struct hw_device_t common;
+ /**
+ * THIS IS DEPRECATED. Use the new "module_api_version" and "hal_api_version"
+ * fields in the keymaster_module initialization instead.
+ */
uint32_t client_version;
/**
@@ -238,10 +244,6 @@ static inline int keymaster_open(const struct hw_module_t* module,
int rc = module->methods->open(module, KEYSTORE_KEYMASTER,
(struct hw_device_t**) device);
- if (!rc) {
- (*device)->client_version = KEYMASTER_API_VERSION;
- }
-
return rc;
}
diff --git a/tests/keymaster/keymaster_test.cpp b/tests/keymaster/keymaster_test.cpp
index b3d3f359..ad89012e 100644
--- a/tests/keymaster/keymaster_test.cpp
+++ b/tests/keymaster/keymaster_test.cpp
@@ -343,7 +343,7 @@ public:
ASSERT_EQ(0, keymaster_open(mod, &sDevice))
<< "Should be able to open the keymaster device";
- ASSERT_EQ(2U, sDevice->client_version)
+ ASSERT_EQ(KEYMASTER_MODULE_API_VERSION_0_2, mod->module_api_version)
<< "Keymaster should implement API version 2";
ASSERT_TRUE(sDevice->generate_keypair != NULL)