diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2012-03-04 19:03:50 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-03-06 15:16:23 -0500 |
commit | 47807d3dbb62e93850cbcb797db1a9ee1806f986 (patch) | |
tree | f8e1970083547290e35830e5bedb4a4ce7237f97 | |
parent | 9dda50f4c98f84e32a5f6dc4d9dd7af6085add43 (diff) |
NFC: Remove the rf mode parameter from the DEP link up routine
When calling nfc_dep_link_up, we implicitely are in initiator mode.
Which means we also can provide the general bytes as a function argument,
as all drivers will eventually request them.
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/nfc/pn533.c | 20 | ||||
-rw-r--r-- | include/net/nfc/nfc.h | 6 | ||||
-rw-r--r-- | net/nfc/core.c | 22 | ||||
-rw-r--r-- | net/nfc/llcp/llcp.c | 2 | ||||
-rw-r--r-- | net/nfc/netlink.c | 11 | ||||
-rw-r--r-- | net/nfc/nfc.h | 5 |
6 files changed, 24 insertions, 42 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index ef33f64143b5..cb6204f78300 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c | |||
@@ -1340,21 +1340,15 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg, | |||
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx, | 1342 | static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx, |
1343 | u8 comm_mode, u8 rf_mode) | 1343 | u8 comm_mode, u8* gb, size_t gb_len) |
1344 | { | 1344 | { |
1345 | struct pn533 *dev = nfc_get_drvdata(nfc_dev); | 1345 | struct pn533 *dev = nfc_get_drvdata(nfc_dev); |
1346 | struct pn533_cmd_jump_dep *cmd; | 1346 | struct pn533_cmd_jump_dep *cmd; |
1347 | u8 cmd_len, local_gt_len, *local_gt; | 1347 | u8 cmd_len; |
1348 | int rc; | 1348 | int rc; |
1349 | 1349 | ||
1350 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); | 1350 | nfc_dev_dbg(&dev->interface->dev, "%s", __func__); |
1351 | 1351 | ||
1352 | if (rf_mode == NFC_RF_TARGET) { | ||
1353 | nfc_dev_err(&dev->interface->dev, "Target mode not supported"); | ||
1354 | return -EOPNOTSUPP; | ||
1355 | } | ||
1356 | |||
1357 | |||
1358 | if (dev->poll_mod_count) { | 1352 | if (dev->poll_mod_count) { |
1359 | nfc_dev_err(&dev->interface->dev, | 1353 | nfc_dev_err(&dev->interface->dev, |
1360 | "Cannot bring the DEP link up while polling"); | 1354 | "Cannot bring the DEP link up while polling"); |
@@ -1367,11 +1361,7 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx, | |||
1367 | return -EBUSY; | 1361 | return -EBUSY; |
1368 | } | 1362 | } |
1369 | 1363 | ||
1370 | local_gt = nfc_get_local_general_bytes(dev->nfc_dev, &local_gt_len); | 1364 | cmd_len = sizeof(struct pn533_cmd_jump_dep) + gb_len; |
1371 | if (local_gt_len > NFC_MAX_GT_LEN) | ||
1372 | return -EINVAL; | ||
1373 | |||
1374 | cmd_len = sizeof(struct pn533_cmd_jump_dep) + local_gt_len; | ||
1375 | cmd = kzalloc(cmd_len, GFP_KERNEL); | 1365 | cmd = kzalloc(cmd_len, GFP_KERNEL); |
1376 | if (cmd == NULL) | 1366 | if (cmd == NULL) |
1377 | return -ENOMEM; | 1367 | return -ENOMEM; |
@@ -1380,9 +1370,9 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx, | |||
1380 | 1370 | ||
1381 | cmd->active = !comm_mode; | 1371 | cmd->active = !comm_mode; |
1382 | cmd->baud = 0; | 1372 | cmd->baud = 0; |
1383 | if (local_gt != NULL) { | 1373 | if (gb != NULL && gb_len > 0) { |
1384 | cmd->next = 4; /* We have some Gi */ | 1374 | cmd->next = 4; /* We have some Gi */ |
1385 | memcpy(cmd->gt, local_gt, local_gt_len); | 1375 | memcpy(cmd->gt, gb, gb_len); |
1386 | } else { | 1376 | } else { |
1387 | cmd->next = 0; | 1377 | cmd->next = 0; |
1388 | } | 1378 | } |
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h index d253278e5a96..d608e4eac66f 100644 --- a/include/net/nfc/nfc.h +++ b/include/net/nfc/nfc.h | |||
@@ -53,8 +53,8 @@ struct nfc_ops { | |||
53 | int (*dev_down)(struct nfc_dev *dev); | 53 | int (*dev_down)(struct nfc_dev *dev); |
54 | int (*start_poll)(struct nfc_dev *dev, u32 protocols); | 54 | int (*start_poll)(struct nfc_dev *dev, u32 protocols); |
55 | void (*stop_poll)(struct nfc_dev *dev); | 55 | void (*stop_poll)(struct nfc_dev *dev); |
56 | int (*dep_link_up)(struct nfc_dev *dev, int target_idx, | 56 | int (*dep_link_up)(struct nfc_dev *dev, int target_idx, u8 comm_mode, |
57 | u8 comm_mode, u8 rf_mode); | 57 | u8 *gb, size_t gb_len); |
58 | int (*dep_link_down)(struct nfc_dev *dev); | 58 | int (*dep_link_down)(struct nfc_dev *dev); |
59 | int (*activate_target)(struct nfc_dev *dev, u32 target_idx, | 59 | int (*activate_target)(struct nfc_dev *dev, u32 target_idx, |
60 | u32 protocol); | 60 | u32 protocol); |
@@ -179,8 +179,6 @@ struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp); | |||
179 | int nfc_set_remote_general_bytes(struct nfc_dev *dev, | 179 | int nfc_set_remote_general_bytes(struct nfc_dev *dev, |
180 | u8 *gt, u8 gt_len); | 180 | u8 *gt, u8 gt_len); |
181 | 181 | ||
182 | u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len); | ||
183 | |||
184 | int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, | 182 | int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, |
185 | int ntargets); | 183 | int ntargets); |
186 | 184 | ||
diff --git a/net/nfc/core.c b/net/nfc/core.c index 6089aca67b14..f4f526f73217 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c | |||
@@ -181,13 +181,13 @@ error: | |||
181 | return rc; | 181 | return rc; |
182 | } | 182 | } |
183 | 183 | ||
184 | int nfc_dep_link_up(struct nfc_dev *dev, int target_index, | 184 | int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode) |
185 | u8 comm_mode, u8 rf_mode) | ||
186 | { | 185 | { |
187 | int rc = 0; | 186 | int rc = 0; |
187 | u8 *gb; | ||
188 | size_t gb_len; | ||
188 | 189 | ||
189 | pr_debug("dev_name=%s comm:%d rf:%d\n", | 190 | pr_debug("dev_name=%s comm %d\n", dev_name(&dev->dev), comm_mode); |
190 | dev_name(&dev->dev), comm_mode, rf_mode); | ||
191 | 191 | ||
192 | if (!dev->ops->dep_link_up) | 192 | if (!dev->ops->dep_link_up) |
193 | return -EOPNOTSUPP; | 193 | return -EOPNOTSUPP; |
@@ -204,7 +204,13 @@ int nfc_dep_link_up(struct nfc_dev *dev, int target_index, | |||
204 | goto error; | 204 | goto error; |
205 | } | 205 | } |
206 | 206 | ||
207 | rc = dev->ops->dep_link_up(dev, target_index, comm_mode, rf_mode); | 207 | gb = nfc_llcp_general_bytes(dev, &gb_len); |
208 | if (gb_len > NFC_MAX_GT_LEN) { | ||
209 | rc = -EINVAL; | ||
210 | goto error; | ||
211 | } | ||
212 | |||
213 | rc = dev->ops->dep_link_up(dev, target_index, comm_mode, gb, gb_len); | ||
208 | 214 | ||
209 | error: | 215 | error: |
210 | device_unlock(&dev->dev); | 216 | device_unlock(&dev->dev); |
@@ -367,12 +373,6 @@ int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len) | |||
367 | } | 373 | } |
368 | EXPORT_SYMBOL(nfc_set_remote_general_bytes); | 374 | EXPORT_SYMBOL(nfc_set_remote_general_bytes); |
369 | 375 | ||
370 | u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len) | ||
371 | { | ||
372 | return nfc_llcp_general_bytes(dev, gt_len); | ||
373 | } | ||
374 | EXPORT_SYMBOL(nfc_get_local_general_bytes); | ||
375 | |||
376 | /** | 376 | /** |
377 | * nfc_alloc_send_skb - allocate a skb for data exchange responses | 377 | * nfc_alloc_send_skb - allocate a skb for data exchange responses |
378 | * | 378 | * |
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c index a0cb133c610a..3ce646e35f6b 100644 --- a/net/nfc/llcp/llcp.c +++ b/net/nfc/llcp/llcp.c | |||
@@ -281,7 +281,7 @@ void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap) | |||
281 | mutex_unlock(&local->sdp_lock); | 281 | mutex_unlock(&local->sdp_lock); |
282 | } | 282 | } |
283 | 283 | ||
284 | u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, u8 *general_bytes_len) | 284 | u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len) |
285 | { | 285 | { |
286 | struct nfc_llcp_local *local; | 286 | struct nfc_llcp_local *local; |
287 | 287 | ||
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index a1388e4efd6f..fa620d03799e 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c | |||
@@ -542,13 +542,12 @@ static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info) | |||
542 | struct nfc_dev *dev; | 542 | struct nfc_dev *dev; |
543 | int rc, tgt_idx; | 543 | int rc, tgt_idx; |
544 | u32 idx; | 544 | u32 idx; |
545 | u8 comm, rf; | 545 | u8 comm; |
546 | 546 | ||
547 | pr_debug("DEP link up\n"); | 547 | pr_debug("DEP link up\n"); |
548 | 548 | ||
549 | if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || | 549 | if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || |
550 | !info->attrs[NFC_ATTR_COMM_MODE] || | 550 | !info->attrs[NFC_ATTR_COMM_MODE]) |
551 | !info->attrs[NFC_ATTR_RF_MODE]) | ||
552 | return -EINVAL; | 551 | return -EINVAL; |
553 | 552 | ||
554 | idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); | 553 | idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); |
@@ -558,19 +557,15 @@ static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info) | |||
558 | tgt_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]); | 557 | tgt_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]); |
559 | 558 | ||
560 | comm = nla_get_u8(info->attrs[NFC_ATTR_COMM_MODE]); | 559 | comm = nla_get_u8(info->attrs[NFC_ATTR_COMM_MODE]); |
561 | rf = nla_get_u8(info->attrs[NFC_ATTR_RF_MODE]); | ||
562 | 560 | ||
563 | if (comm != NFC_COMM_ACTIVE && comm != NFC_COMM_PASSIVE) | 561 | if (comm != NFC_COMM_ACTIVE && comm != NFC_COMM_PASSIVE) |
564 | return -EINVAL; | 562 | return -EINVAL; |
565 | 563 | ||
566 | if (rf != NFC_RF_INITIATOR && comm != NFC_RF_TARGET) | ||
567 | return -EINVAL; | ||
568 | |||
569 | dev = nfc_get_device(idx); | 564 | dev = nfc_get_device(idx); |
570 | if (!dev) | 565 | if (!dev) |
571 | return -ENODEV; | 566 | return -ENODEV; |
572 | 567 | ||
573 | rc = nfc_dep_link_up(dev, tgt_idx, comm, rf); | 568 | rc = nfc_dep_link_up(dev, tgt_idx, comm); |
574 | 569 | ||
575 | nfc_put_device(dev); | 570 | nfc_put_device(dev); |
576 | 571 | ||
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index 6d28d75995b0..2fd83b16df68 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h | |||
@@ -54,7 +54,7 @@ void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx, | |||
54 | int nfc_llcp_register_device(struct nfc_dev *dev); | 54 | int nfc_llcp_register_device(struct nfc_dev *dev); |
55 | void nfc_llcp_unregister_device(struct nfc_dev *dev); | 55 | void nfc_llcp_unregister_device(struct nfc_dev *dev); |
56 | int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len); | 56 | int nfc_llcp_set_remote_gb(struct nfc_dev *dev, u8 *gb, u8 gb_len); |
57 | u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, u8 *general_bytes_len); | 57 | u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len); |
58 | int __init nfc_llcp_init(void); | 58 | int __init nfc_llcp_init(void); |
59 | void nfc_llcp_exit(void); | 59 | void nfc_llcp_exit(void); |
60 | 60 | ||
@@ -160,8 +160,7 @@ int nfc_start_poll(struct nfc_dev *dev, u32 protocols); | |||
160 | 160 | ||
161 | int nfc_stop_poll(struct nfc_dev *dev); | 161 | int nfc_stop_poll(struct nfc_dev *dev); |
162 | 162 | ||
163 | int nfc_dep_link_up(struct nfc_dev *dev, int target_idx, | 163 | int nfc_dep_link_up(struct nfc_dev *dev, int target_idx, u8 comm_mode); |
164 | u8 comm_mode, u8 rf_mode); | ||
165 | 164 | ||
166 | int nfc_dep_link_down(struct nfc_dev *dev); | 165 | int nfc_dep_link_down(struct nfc_dev *dev); |
167 | 166 | ||