summaryrefslogtreecommitdiffstats
path: root/net/nfc/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/nfc/core.c')
-rw-r--r--net/nfc/core.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 3ddf6e698df0..295d129864d2 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -181,13 +181,13 @@ error:
return rc;
}
-int nfc_dep_link_up(struct nfc_dev *dev, int target_index,
- u8 comm_mode, u8 rf_mode)
+int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode)
{
int rc = 0;
+ u8 *gb;
+ size_t gb_len;
- pr_debug("dev_name=%s comm:%d rf:%d\n",
- dev_name(&dev->dev), comm_mode, rf_mode);
+ pr_debug("dev_name=%s comm %d\n", dev_name(&dev->dev), comm_mode);
if (!dev->ops->dep_link_up)
return -EOPNOTSUPP;
@@ -204,7 +204,13 @@ int nfc_dep_link_up(struct nfc_dev *dev, int target_index,
goto error;
}
- rc = dev->ops->dep_link_up(dev, target_index, comm_mode, rf_mode);
+ gb = nfc_llcp_general_bytes(dev, &gb_len);
+ if (gb_len > NFC_MAX_GT_LEN) {
+ rc = -EINVAL;
+ goto error;
+ }
+
+ rc = dev->ops->dep_link_up(dev, target_index, comm_mode, gb, gb_len);
error:
device_unlock(&dev->dev);
@@ -250,7 +256,7 @@ error:
}
int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx,
- u8 comm_mode, u8 rf_mode)
+ u8 comm_mode, u8 rf_mode)
{
dev->dep_link_up = true;
dev->dep_rf_mode = rf_mode;
@@ -330,10 +336,8 @@ error:
*
* The user must wait for the callback before calling this function again.
*/
-int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx,
- struct sk_buff *skb,
- data_exchange_cb_t cb,
- void *cb_context)
+int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb,
+ data_exchange_cb_t cb, void *cb_context)
{
int rc;
@@ -357,8 +361,7 @@ error:
int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
{
- pr_debug("dev_name=%s gb_len=%d\n",
- dev_name(&dev->dev), gb_len);
+ pr_debug("dev_name=%s gb_len=%d\n", dev_name(&dev->dev), gb_len);
if (gb_len > NFC_MAX_GT_LEN)
return -EINVAL;
@@ -367,12 +370,6 @@ int nfc_set_remote_general_bytes(struct nfc_dev *dev, u8 *gb, u8 gb_len)
}
EXPORT_SYMBOL(nfc_set_remote_general_bytes);
-u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, u8 *gt_len)
-{
- return nfc_llcp_general_bytes(dev, gt_len);
-}
-EXPORT_SYMBOL(nfc_get_local_general_bytes);
-
/**
* nfc_alloc_send_skb - allocate a skb for data exchange responses
*
@@ -380,8 +377,8 @@ EXPORT_SYMBOL(nfc_get_local_general_bytes);
* @gfp: gfp flags
*/
struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk,
- unsigned int flags, unsigned int size,
- unsigned int *err)
+ unsigned int flags, unsigned int size,
+ unsigned int *err)
{
struct sk_buff *skb;
unsigned int total_size;
@@ -428,25 +425,20 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb);
* are found. After calling this function, the device driver must stop
* polling for targets.
*/
-int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
- int n_targets)
+int nfc_targets_found(struct nfc_dev *dev,
+ struct nfc_target *targets, int n_targets)
{
- int i;
-
pr_debug("dev_name=%s n_targets=%d\n", dev_name(&dev->dev), n_targets);
dev->polling = false;
- for (i = 0; i < n_targets; i++)
- targets[i].idx = dev->target_idx++;
-
spin_lock_bh(&dev->targets_lock);
dev->targets_generation++;
kfree(dev->targets);
dev->targets = kmemdup(targets, n_targets * sizeof(struct nfc_target),
- GFP_ATOMIC);
+ GFP_ATOMIC);
if (!dev->targets) {
dev->n_targets = 0;
@@ -506,15 +498,14 @@ struct nfc_dev *nfc_get_device(unsigned idx)
* @supported_protocols: NFC protocols supported by the device
*/
struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
- u32 supported_protocols,
- int tx_headroom,
- int tx_tailroom)
+ u32 supported_protocols,
+ int tx_headroom, int tx_tailroom)
{
static atomic_t dev_no = ATOMIC_INIT(0);
struct nfc_dev *dev;
if (!ops->start_poll || !ops->stop_poll || !ops->activate_target ||
- !ops->deactivate_target || !ops->data_exchange)
+ !ops->deactivate_target || !ops->data_exchange)
return NULL;
if (!supported_protocols)