aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/nfc/core.c')
-rw-r--r--net/nfc/core.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 6089aca67b14..295d129864d2 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
184int nfc_dep_link_up(struct nfc_dev *dev, int target_index, 184int 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
209error: 215error:
210 device_unlock(&dev->dev); 216 device_unlock(&dev->dev);
@@ -250,7 +256,7 @@ error:
250} 256}
251 257
252int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx, 258int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx,
253 u8 comm_mode, u8 rf_mode) 259 u8 comm_mode, u8 rf_mode)
254{ 260{
255 dev->dep_link_up = true; 261 dev->dep_link_up = true;
256 dev->dep_rf_mode = rf_mode; 262 dev->dep_rf_mode = rf_mode;
@@ -330,10 +336,8 @@ error:
330 * 336 *
331 * The user must wait for the callback before calling this function again. 337 * The user must wait for the callback before calling this function again.
332 */ 338 */
333int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, 339int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
334 struct sk_buff *skb, 340 data_exchange_cb_t cb, void *cb_context)
335 data_exchange_cb_t cb,
336 void *cb_context)
337{ 341{
338 int rc; 342 int rc;
339 343
@@ -357,8 +361,7 @@ error:
357 361
358int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len) 362int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
359{ 363{
360 pr_debug("dev_name=%s gb_len=%d\n", 364 pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len);
361 dev_name(&dev->dev), gb_len);
362 365
363 if (gb_len > NFC_MAX_GT_LEN) 366 if (gb_len > NFC_MAX_GT_LEN)
364 return -EINVAL; 367 return -EINVAL;
@@ -367,12 +370,6 @@ int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
367} 370}
368EXPORT_SYMBOL(nfc_set_remote_general_bytes); 371EXPORT_SYMBOL(nfc_set_remote_general_bytes);
369 372
370u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len)
371{
372 return nfc_llcp_general_bytes(dev, gt_len);
373}
374EXPORT_SYMBOL(nfc_get_local_general_bytes);
375
376/** 373/**
377 * nfc_alloc_send_skb - allocate a skb for data exchange responses 374 * nfc_alloc_send_skb - allocate a skb for data exchange responses
378 * 375 *
@@ -380,8 +377,8 @@ EXPORT_SYMBOL(nfc_get_local_general_bytes);
380 * @gfp: gfp flags 377 * @gfp: gfp flags
381 */ 378 */
382struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk, 379struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
383 unsigned int flags, unsigned int size, 380 unsigned int flags, unsigned int size,
384 unsigned int *err) 381 unsigned int *err)
385{ 382{
386 struct sk_buff *skb; 383 struct sk_buff *skb;
387 unsigned int total_size; 384 unsigned int total_size;
@@ -428,8 +425,8 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb);
428 * are found. After calling this function, the device driver must stop 425 * are found. After calling this function, the device driver must stop
429 * polling for targets. 426 * polling for targets.
430 */ 427 */
431int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets, 428int nfc_targets_found(struct nfc_dev *dev,
432 int n_targets) 429 struct nfc_target *targets, int n_targets)
433{ 430{
434 pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets); 431 pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets);
435 432
@@ -441,7 +438,7 @@ int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
441 438
442 kfree(dev->targets); 439 kfree(dev->targets);
443 dev->targets = kmemdup(targets, n_targets * sizeof(struct nfc_target), 440 dev->targets = kmemdup(targets, n_targets * sizeof(struct nfc_target),
444 GFP_ATOMIC); 441 GFP_ATOMIC);
445 442
446 if (!dev->targets) { 443 if (!dev->targets) {
447 dev->n_targets = 0; 444 dev->n_targets = 0;
@@ -501,15 +498,14 @@ struct nfc_dev *nfc_get_device(unsigned idx)
501 * @supported_protocols: NFC protocols supported by the device 498 * @supported_protocols: NFC protocols supported by the device
502 */ 499 */
503struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, 500struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
504 u32 supported_protocols, 501 u32 supported_protocols,
505 int tx_headroom, 502 int tx_headroom, int tx_tailroom)
506 int tx_tailroom)
507{ 503{
508 static atomic_t dev_no = ATOMIC_INIT(0); 504 static atomic_t dev_no = ATOMIC_INIT(0);
509 struct nfc_dev *dev; 505 struct nfc_dev *dev;
510 506
511 if (!ops->start_poll || !ops->stop_poll || !ops->activate_target || 507 if (!ops->start_poll || !ops->stop_poll || !ops->activate_target ||
512 !ops->deactivate_target || !ops->data_exchange) 508 !ops->deactivate_target || !ops->data_exchange)
513 return NULL; 509 return NULL;
514 510
515 if (!supported_protocols) 511 if (!supported_protocols)