summaryrefslogtreecommitdiffstats
path: root/include/hardware/nfc_tag.h
diff options
context:
space:
mode:
authorStewart Miles <smiles@google.com>2014-05-01 09:03:27 -0700
committerStewart Miles <smiles@google.com>2014-05-12 12:35:37 -0700
commit84d35492b145cebc000f8fd72818eb25b8e65c04 (patch)
tree0a7adfd3f93de27984377aa1e210685540891ff8 /include/hardware/nfc_tag.h
parent4c847f2b79d99b1fecf487b167dd5bbe3ea7da06 (diff)
downloadhardware_libhardware-84d35492b145cebc000f8fd72818eb25b8e65c04.zip
hardware_libhardware-84d35492b145cebc000f8fd72818eb25b8e65c04.tar.gz
hardware_libhardware-84d35492b145cebc000f8fd72818eb25b8e65c04.tar.bz2
Described restrictions for common HAL object methods.
Inheritance of HAL object is performed by composing a child structure of a single parent structure located at offset 0 followed by new data members and function pointers in the child structure. For example, struct child { struct parent common; int a_data_member; void (*a_method)(struct child *c, int v); }; HAL code assumes this layout when accessing child structures given a pointer to a parent structure such that users write code like the following... void child_method(struct *parent, int v) { struct child * c = (struct child*)parent; // do stuff with c } Code above will break if a member is added before "common" in "struct child". This change adds comments that describe the restriction on the location of parent HAL objects within a derived HAL object. HAL objects that already have comments that describe the required location of parent objects are not modified. Change-Id: Ibe4300275286ef275b2097534c84f1029d761d87
Diffstat (limited to 'include/hardware/nfc_tag.h')
-rw-r--r--include/hardware/nfc_tag.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/hardware/nfc_tag.h b/include/hardware/nfc_tag.h
index 72028f4..040a07d 100644
--- a/include/hardware/nfc_tag.h
+++ b/include/hardware/nfc_tag.h
@@ -32,10 +32,22 @@ __BEGIN_DECLS
#define NFC_TAG_ID "tag"
typedef struct nfc_tag_module_t {
+ /**
+ * Common methods of the NFC tag module. This *must* be the first member of
+ * nfc_tag_module_t as users of this structure will cast a hw_module_t to
+ * nfc_tag_module_t pointer in contexts where it's known the hw_module_t references a
+ * nfc_tag_module_t.
+ */
struct hw_module_t common;
} nfc_tag_module_t;
typedef struct nfc_tag_device {
+ /**
+ * Common methods of the NFC tag device. This *must* be the first member of
+ * nfc_tag_device_t as users of this structure will cast a hw_device_t to
+ * nfc_tag_device_t pointer in contexts where it's known the hw_device_t references a
+ * nfc_tag_device_t.
+ */
struct hw_device_t common;
/**