summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-04-19 13:06:03 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2012-04-19 13:08:32 +0200
commite718cc7a21a99a99e2c75cd4c89c83f5b576bb17 (patch)
tree518b6c167c8bd53ddbb867a1994968212256e7a4 /plugins
parent93e5a0ca1ade57be96a232f419918749a0b74698 (diff)
downloadneard-e718cc7a21a99a99e2c75cd4c89c83f5b576bb17.tar.gz
neard-e718cc7a21a99a99e2c75cd4c89c83f5b576bb17.tar.bz2
neard-e718cc7a21a99a99e2c75cd4c89c83f5b576bb17.zip
adapter: Bypass the target layer
Adapters talk to tags or device directly. The target vs initiator idea will be removed from the code base. This commit temporarily breaks p2p.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mifare.c12
-rw-r--r--plugins/nfctype1.c16
-rw-r--r--plugins/nfctype2.c14
-rw-r--r--plugins/nfctype3.c12
-rw-r--r--plugins/nfctype4.c11
5 files changed, 47 insertions, 18 deletions
diff --git a/plugins/mifare.c b/plugins/mifare.c
index 9a223bd..a9e5a3e 100644
--- a/plugins/mifare.c
+++ b/plugins/mifare.c
@@ -448,8 +448,10 @@ static int mifare_process_MADs(void *data)
DBG("");
/* Parse MAD entries to get the global size and fill the array */
- if (mf_ck->mad_1 == NULL)
+ if (mf_ck->mad_1 == NULL) {
+ err = -EINVAL;
goto out_err;
+ }
for (i = 0; i < MAD_V1_AIDS_LEN; i++) {
if (mf_ck->mad_1->aids[i] != NFC_AID_TAG)
@@ -482,10 +484,14 @@ done_mad:
/* n sectors, each sector is 3 blocks, each block is 16 bytes */
DBG("TAG Global size: [%d]", global_tag_size);
- mf_ck->tag = near_target_add_tag(mf_ck->adapter_idx,
+ err = near_tag_add_data(mf_ck->adapter_idx,
mf_ck->target_idx,
NULL, /* Empty */
global_tag_size);
+ if (err < 0)
+ goto out_err;
+
+ mf_ck->tag = near_tag_get_tag(mf_ck->adapter_idx, mf_ck->target_idx);
if (mf_ck->tag == NULL) {
err = -ENOMEM;
goto out_err;
@@ -630,7 +636,7 @@ int mifare_read_tag(uint32_t adapter_idx, uint32_t target_idx,
cookie = g_try_malloc0(sizeof(struct mifare_cookie));
/* Get the nfcid1 */
- cookie->nfcid1 = near_target_get_nfcid(adapter_idx, target_idx,
+ cookie->nfcid1 = near_tag_get_nfcid(adapter_idx, target_idx,
&cookie->nfcid1_len);
cookie->adapter_idx = adapter_idx;
cookie->target_idx = target_idx;
diff --git a/plugins/nfctype1.c b/plugins/nfctype1.c
index 7b5c733..3fa1193 100644
--- a/plugins/nfctype1.c
+++ b/plugins/nfctype1.c
@@ -237,9 +237,13 @@ static int meta_recv(uint8_t *resp, int length, void *data)
goto out_err;
}
- /* Associate the DATA length to the tag */
- tag = near_target_add_tag(cookie->adapter_idx, cookie->target_idx,
+ /* Add data to the tag */
+ err = near_tag_add_data(cookie->adapter_idx, cookie->target_idx,
NULL, TAG_T1_DATA_LENGTH(cc));
+ if (err < 0)
+ goto out_err;
+
+ tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx);
if (tag == NULL) {
err = -ENOMEM;
goto out_err;
@@ -251,6 +255,8 @@ static int meta_recv(uint8_t *resp, int length, void *data)
goto out_err;
}
+ DBG("2");
+
t1_tag->adapter_idx = cookie->adapter_idx;
t1_tag->cb = cookie->cb;
t1_tag->tag = tag;
@@ -288,11 +294,15 @@ static int meta_recv(uint8_t *resp, int length, void *data)
}
out_err:
+ DBG("err %d", err);
+
if (err < 0 && cookie->cb)
cookie->cb(cookie->adapter_idx, cookie->target_idx, err);
t1_cookie_release(cookie);
+
+
return err;
}
@@ -467,7 +477,7 @@ static int nfctype1_write_tag(uint32_t adapter_idx, uint32_t target_idx,
if (ndef == NULL || cb == NULL)
return -EINVAL;
- tag = near_target_get_tag(adapter_idx, target_idx);
+ tag = near_tag_get_tag(adapter_idx, target_idx);
if (tag == NULL)
return -EINVAL;
diff --git a/plugins/nfctype2.c b/plugins/nfctype2.c
index 71ef4a2..dade247 100644
--- a/plugins/nfctype2.c
+++ b/plugins/nfctype2.c
@@ -196,8 +196,12 @@ static int meta_recv(uint8_t *resp, int length, void *data)
goto out;
}
- tag = near_target_add_tag(cookie->adapter_idx, cookie->target_idx,
- NULL, TAG_DATA_LENGTH(cc));
+ err = near_tag_add_data(cookie->adapter_idx, cookie->target_idx,
+ NULL, TAG_DATA_LENGTH(cc));
+ if (err < 0)
+ goto out;
+
+ tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx);
if (tag == NULL) {
err = -ENOMEM;
goto out;
@@ -266,7 +270,7 @@ static int nfctype2_read_tag(uint32_t adapter_idx,
DBG("");
- tgt_subtype = near_target_get_subtype(adapter_idx, target_idx);
+ tgt_subtype = near_tag_get_subtype(adapter_idx, target_idx);
switch (tgt_subtype) {
case NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT:
@@ -395,7 +399,7 @@ static int nfctype2_write_tag(uint32_t adapter_idx, uint32_t target_idx,
if (ndef == NULL || cb == NULL)
return -EINVAL;
- tag = near_target_get_tag(adapter_idx, target_idx);
+ tag = near_tag_get_tag(adapter_idx, target_idx);
if (tag == NULL)
return -EINVAL;
@@ -404,7 +408,7 @@ static int nfctype2_write_tag(uint32_t adapter_idx, uint32_t target_idx,
return -EPERM;
}
- tgt_subtype = near_target_get_subtype(adapter_idx, target_idx);
+ tgt_subtype = near_tag_get_subtype(adapter_idx, target_idx);
if (tgt_subtype != NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT) {
DBG("Unknown Tag Type 2 subtype (%d)", tgt_subtype);
diff --git a/plugins/nfctype3.c b/plugins/nfctype3.c
index 75754ee..7929de6 100644
--- a/plugins/nfctype3.c
+++ b/plugins/nfctype3.c
@@ -305,9 +305,13 @@ static int nfctype3_recv_block_0(uint8_t *resp, int length, void *data)
ndef_data_length *= 0x100;
ndef_data_length += resp[OFS_READ_DATA + 13];
- /* Associate the DATA length to the tag */
- tag = near_target_add_tag(cookie->adapter_idx, cookie->target_idx,
+ /* Add data to the tag */
+ err = near_tag_add_data(cookie->adapter_idx, cookie->target_idx,
NULL, ndef_data_length);
+ if (err < 0)
+ goto out;
+
+ tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx);
if (tag == NULL) {
err = -ENOMEM;
goto out;
@@ -609,7 +613,7 @@ static int nfctype3_write_tag(uint32_t adapter_idx, uint32_t target_idx,
if (ndef == NULL || cb == NULL)
return -EINVAL;
- tag = near_target_get_tag(adapter_idx, target_idx);
+ tag = near_tag_get_tag(adapter_idx, target_idx);
if (tag == NULL)
return -EINVAL;
@@ -672,6 +676,8 @@ static int nfctype3_check_presence(uint32_t adapter_idx,
if (err < 0)
goto out;
+ return 0;
+
out:
t3_cookie_release(cookie);
diff --git a/plugins/nfctype4.c b/plugins/nfctype4.c
index 2abdb57..9b9f8b1 100644
--- a/plugins/nfctype4.c
+++ b/plugins/nfctype4.c
@@ -305,11 +305,14 @@ static int t4_readbin_NDEF_ID(uint8_t *resp, int length, void *data)
goto out_err;
}
- tag = near_target_add_tag(cookie->adapter_idx, cookie->target_idx, NULL,
- g_ntohs(*((uint16_t *)(resp + NFC_STATUS_BYTE_LEN))));
+ /* Add data to the tag */
+ err = near_tag_add_data(cookie->adapter_idx, cookie->target_idx, NULL,
+ g_ntohs(*((uint16_t *)(resp + NFC_STATUS_BYTE_LEN))));
+ if (err < 0)
+ goto out_err;
+ tag = near_tag_get_tag(cookie->adapter_idx, cookie->target_idx);
if (tag == NULL) {
- DBG("near_target_add_tag is null") ;
err = -ENOMEM;
goto out_err;
}
@@ -686,7 +689,7 @@ static int nfctype4_write_tag(uint32_t adapter_idx, uint32_t target_idx,
if (ndef == NULL || cb == NULL)
return -EINVAL;
- tag = near_target_get_tag(adapter_idx, target_idx);
+ tag = near_tag_get_tag(adapter_idx, target_idx);
if (tag == NULL)
return -EINVAL;