diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2012-06-01 07:21:13 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-06-04 15:34:30 -0400 |
commit | fc40a8c1a06ab7db45da790693dd9802612a055c (patch) | |
tree | 7ad170c95ff66bce521bc25a6ddf6946cc1ab0c0 /drivers/nfc/pn533.c | |
parent | ad3823cef650bdc1ca9e7bf1a01b87ad3c0425de (diff) |
NFC: Add target mode activation netlink event
Userspace gets a netlink event upon target mode activation.
The LLCP layer is also signaled when we get an ATR_REQ in order to get
the remote general bytes.
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc/pn533.c')
-rw-r--r-- | drivers/nfc/pn533.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index 605a08a62e45..c6b9bc5ac6e6 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c | |||
@@ -260,6 +260,10 @@ struct pn533_cmd_jump_dep_response { | |||
260 | #define PN533_INIT_TARGET_PASSIVE 0x1 | 260 | #define PN533_INIT_TARGET_PASSIVE 0x1 |
261 | #define PN533_INIT_TARGET_DEP 0x2 | 261 | #define PN533_INIT_TARGET_DEP 0x2 |
262 | 262 | ||
263 | #define PN533_INIT_TARGET_RESP_FRAME_MASK 0x3 | ||
264 | #define PN533_INIT_TARGET_RESP_ACTIVE 0x1 | ||
265 | #define PN533_INIT_TARGET_RESP_DEP 0x4 | ||
266 | |||
263 | struct pn533_cmd_init_target { | 267 | struct pn533_cmd_init_target { |
264 | u8 mode; | 268 | u8 mode; |
265 | u8 mifare[6]; | 269 | u8 mifare[6]; |
@@ -1128,10 +1132,13 @@ static int pn533_init_target_frame(struct pn533_frame *frame, | |||
1128 | return 0; | 1132 | return 0; |
1129 | } | 1133 | } |
1130 | 1134 | ||
1135 | #define ATR_REQ_GB_OFFSET 17 | ||
1131 | static int pn533_init_target_complete(struct pn533 *dev, void *arg, | 1136 | static int pn533_init_target_complete(struct pn533 *dev, void *arg, |
1132 | u8 *params, int params_len) | 1137 | u8 *params, int params_len) |
1133 | { | 1138 | { |
1134 | struct pn533_cmd_init_target_response *resp; | 1139 | struct pn533_cmd_init_target_response *resp; |
1140 | u8 frame, comm_mode = NFC_COMM_PASSIVE, *gb; | ||
1141 | size_t gb_len; | ||
1135 | 1142 | ||
1136 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); | 1143 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); |
1137 | 1144 | ||
@@ -1143,11 +1150,27 @@ static int pn533_init_target_complete(struct pn533 *dev, void *arg, | |||
1143 | return params_len; | 1150 | return params_len; |
1144 | } | 1151 | } |
1145 | 1152 | ||
1153 | if (params_len < ATR_REQ_GB_OFFSET + 1) | ||
1154 | return -EINVAL; | ||
1155 | |||
1146 | resp = (struct pn533_cmd_init_target_response *) params; | 1156 | resp = (struct pn533_cmd_init_target_response *) params; |
1147 | 1157 | ||
1148 | nfc_dev_dbg(&dev->interface->dev, "Target mode 0x%x\n", resp->mode); | 1158 | nfc_dev_dbg(&dev->interface->dev, "Target mode 0x%x param len %d\n", |
1159 | resp->mode, params_len); | ||
1149 | 1160 | ||
1150 | return 0; | 1161 | frame = resp->mode & PN533_INIT_TARGET_RESP_FRAME_MASK; |
1162 | if (frame == PN533_INIT_TARGET_RESP_ACTIVE) | ||
1163 | comm_mode = NFC_COMM_ACTIVE; | ||
1164 | |||
1165 | /* Again, only DEP */ | ||
1166 | if ((resp->mode & PN533_INIT_TARGET_RESP_DEP) == 0) | ||
1167 | return -EOPNOTSUPP; | ||
1168 | |||
1169 | gb = resp->cmd + ATR_REQ_GB_OFFSET; | ||
1170 | gb_len = params_len - (ATR_REQ_GB_OFFSET + 1); | ||
1171 | |||
1172 | return nfc_tm_activated(dev->nfc_dev, NFC_PROTO_NFC_DEP_MASK, | ||
1173 | comm_mode, gb, gb_len); | ||
1151 | } | 1174 | } |
1152 | 1175 | ||
1153 | static int pn533_init_target(struct nfc_dev *nfc_dev, u32 protocols) | 1176 | static int pn533_init_target(struct nfc_dev *nfc_dev, u32 protocols) |