aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorChristophe Ricard <christophe.ricard@gmail.com>2014-12-02 15:27:50 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2014-12-02 16:47:37 -0500
commit3682f49f32051765ed6eb77fc882f0458f7d44c3 (patch)
tree85e9879918bd3f8498bc265e6885550f1a606aa1 /net/nfc
parent9295b5b569fc4d5b9cd0fa7b44d03f9f712ecec9 (diff)
NFC: netlink: Add new netlink command NFC_CMD_ACTIVATE_TARGET
Some tag might get deactivated after some read or write tentative. This may happen for example with Mifare Ultralight C tag when trying to read the last 4 blocks (starting block 0x2c) configured as write only. NFC_CMD_ACTIVATE_TARGET will try to reselect the tag in order to detect if it got remove from the field or if it is still present. Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/netlink.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 43cb1c17e267..95818314aea6 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -810,6 +810,31 @@ out:
810 return rc; 810 return rc;
811} 811}
812 812
813static int nfc_genl_activate_target(struct sk_buff *skb, struct genl_info *info)
814{
815 struct nfc_dev *dev;
816 u32 device_idx, target_idx, protocol;
817 int rc;
818
819 if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
820 return -EINVAL;
821
822 device_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
823
824 dev = nfc_get_device(device_idx);
825 if (!dev)
826 return -ENODEV;
827
828 target_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]);
829 protocol = nla_get_u32(info->attrs[NFC_ATTR_PROTOCOLS]);
830
831 nfc_deactivate_target(dev, target_idx);
832 rc = nfc_activate_target(dev, target_idx, protocol);
833
834 nfc_put_device(dev);
835 return 0;
836}
837
813static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info) 838static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info)
814{ 839{
815 struct nfc_dev *dev; 840 struct nfc_dev *dev;
@@ -1455,6 +1480,11 @@ static const struct genl_ops nfc_genl_ops[] = {
1455 .doit = nfc_genl_se_io, 1480 .doit = nfc_genl_se_io,
1456 .policy = nfc_genl_policy, 1481 .policy = nfc_genl_policy,
1457 }, 1482 },
1483 {
1484 .cmd = NFC_CMD_ACTIVATE_TARGET,
1485 .doit = nfc_genl_activate_target,
1486 .policy = nfc_genl_policy,
1487 },
1458}; 1488};
1459 1489
1460 1490