Skip to content

Commit

Permalink
NFC: Add secure element enablement netlink API
Browse files Browse the repository at this point in the history
Enabling or disabling an NFC accessible secure element through netlink
requires giving both an NFC controller and a secure element indexes.
Once enabled the secure element will handle card emulation once polling
starts.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Samuel Ortiz committed Jun 14, 2013
1 parent c531c9e commit be08565
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions net/nfc/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,52 @@ int nfc_genl_fw_upload_done(struct nfc_dev *dev, const char *firmware_name)
return -EMSGSIZE;
}

static int nfc_genl_enable_se(struct sk_buff *skb, struct genl_info *info)
{
struct nfc_dev *dev;
int rc;
u32 idx, se_idx;

if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
!info->attrs[NFC_ATTR_SE_INDEX])
return -EINVAL;

idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
se_idx = nla_get_u32(info->attrs[NFC_ATTR_SE_INDEX]);

dev = nfc_get_device(idx);
if (!dev)
return -ENODEV;

rc = nfc_enable_se(dev, se_idx);

nfc_put_device(dev);
return rc;
}

static int nfc_genl_disable_se(struct sk_buff *skb, struct genl_info *info)
{
struct nfc_dev *dev;
int rc;
u32 idx, se_idx;

if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
!info->attrs[NFC_ATTR_SE_INDEX])
return -EINVAL;

idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
se_idx = nla_get_u32(info->attrs[NFC_ATTR_SE_INDEX]);

dev = nfc_get_device(idx);
if (!dev)
return -ENODEV;

rc = nfc_disable_se(dev, se_idx);

nfc_put_device(dev);
return rc;
}

static struct genl_ops nfc_genl_ops[] = {
{
.cmd = NFC_CMD_GET_DEVICE,
Expand Down Expand Up @@ -1209,6 +1255,16 @@ static struct genl_ops nfc_genl_ops[] = {
.doit = nfc_genl_fw_upload,
.policy = nfc_genl_policy,
},
{
.cmd = NFC_CMD_ENABLE_SE,
.doit = nfc_genl_enable_se,
.policy = nfc_genl_policy,
},
{
.cmd = NFC_CMD_DISABLE_SE,
.doit = nfc_genl_disable_se,
.policy = nfc_genl_policy,
},
};


Expand Down

0 comments on commit be08565

Please sign in to comment.