aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2011-12-14 10:43:10 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-12-14 14:50:13 -0500
commit541d920b05b538ec0d9ae8ce619ee4fc6fb19e32 (patch)
treee83cbcc06cf2e9a3c34e4fceb222730469117a77
parent1ed28f610653e9b18433c6d87e9d333b7e3e886e (diff)
NFC: Set and get DEP general bytes
Without an API for setting and getting the local and remote general bytes, drivers won't be able to properly establish a DEP link. This API also allows them to propagate the remote general bytes they get from the DEP link establishment up to the LLCP layer. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/nfc/pn533.c7
-rw-r--r--include/net/nfc/nfc.h5
-rw-r--r--net/nfc/core.c18
3 files changed, 29 insertions, 1 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index ea1caaeed13c..dccd96552f5d 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -1121,6 +1121,7 @@ static int pn533_activate_target_nfcdep(struct pn533 *dev)
1121{ 1121{
1122 struct pn533_cmd_activate_param param; 1122 struct pn533_cmd_activate_param param;
1123 struct pn533_cmd_activate_response *resp; 1123 struct pn533_cmd_activate_response *resp;
1124 u16 gt_len;
1124 int rc; 1125 int rc;
1125 1126
1126 nfc_dev_dbg(&dev->interface->dev, "%s", __func__); 1127 nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
@@ -1146,7 +1147,11 @@ static int pn533_activate_target_nfcdep(struct pn533 *dev)
1146 if (rc != PN533_CMD_RET_SUCCESS) 1147 if (rc != PN533_CMD_RET_SUCCESS)
1147 return -EIO; 1148 return -EIO;
1148 1149
1149 return 0; 1150 /* ATR_RES general bytes are located at offset 16 */
1151 gt_len = PN533_FRAME_CMD_PARAMS_LEN(dev->in_frame) - 16;
1152 rc = nfc_set_remote_general_bytes(dev->nfc_dev, resp->gt, gt_len);
1153
1154 return rc;
1150} 1155}
1151 1156
1152static int pn533_activate_target(struct nfc_dev *nfc_dev, u32 target_idx, 1157static int pn533_activate_target(struct nfc_dev *nfc_dev, u32 target_idx,
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h
index bf82d292d68c..ccfe757a94ec 100644
--- a/include/net/nfc/nfc.h
+++ b/include/net/nfc/nfc.h
@@ -170,6 +170,11 @@ struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
170 unsigned int *err); 170 unsigned int *err);
171struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp); 171struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp);
172 172
173int nfc_set_remote_general_bytes(struct nfc_dev *dev,
174 u8 *gt, u8 gt_len);
175
176u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len);
177
173int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, 178int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
174 int ntargets); 179 int ntargets);
175 180
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 785f1f20c7ba..3a45f21b3b97 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -352,6 +352,24 @@ error:
352 return rc; 352 return rc;
353} 353}
354 354
355int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
356{
357 pr_debug("dev_name=%s gb_len=%d\n",
358 dev_name(&dev->dev), gb_len);
359
360 if (gb_len > NFC_MAX_GT_LEN)
361 return -EINVAL;
362
363 return 0;
364}
365EXPORT_SYMBOL(nfc_set_remote_general_bytes);
366
367u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len)
368{
369 return NULL;
370}
371EXPORT_SYMBOL(nfc_get_local_general_bytes);
372
355/** 373/**
356 * nfc_alloc_send_skb - allocate a skb for data exchange responses 374 * nfc_alloc_send_skb - allocate a skb for data exchange responses
357 * 375 *