Skip to content

Commit 541d920

Browse files
Samuel Ortizlinvjw
authored andcommitted
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>
1 parent 1ed28f6 commit 541d920

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

drivers/nfc/pn533.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,7 @@ static int pn533_activate_target_nfcdep(struct pn533 *dev)
11211121
{
11221122
struct pn533_cmd_activate_param param;
11231123
struct pn533_cmd_activate_response *resp;
1124+
u16 gt_len;
11241125
int rc;
11251126

11261127
nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
@@ -1146,7 +1147,11 @@ static int pn533_activate_target_nfcdep(struct pn533 *dev)
11461147
if (rc != PN533_CMD_RET_SUCCESS)
11471148
return -EIO;
11481149

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;
11501155
}
11511156

11521157
static int pn533_activate_target(struct nfc_dev *nfc_dev, u32 target_idx,

include/net/nfc/nfc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
170170
unsigned int *err);
171171
struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp);
172172

173+
int nfc_set_remote_general_bytes(struct nfc_dev *dev,
174+
u8 *gt, u8 gt_len);
175+
176+
u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len);
177+
173178
int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
174179
int ntargets);
175180

net/nfc/core.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,24 @@ int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx,
352352
return rc;
353353
}
354354

355+
int 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+
}
365+
EXPORT_SYMBOL(nfc_set_remote_general_bytes);
366+
367+
u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len)
368+
{
369+
return NULL;
370+
}
371+
EXPORT_SYMBOL(nfc_get_local_general_bytes);
372+
355373
/**
356374
* nfc_alloc_send_skb - allocate a skb for data exchange responses
357375
*

0 commit comments

Comments
 (0)