aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc/netlink.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2013-05-10 11:07:32 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-06-14 07:45:02 -0400
commitbe0856535c64697685af47c5bf2be9f36ab5ca08 (patch)
tree7660c74894de0a6116bcaaf12c9c181e7fd79425 /net/nfc/netlink.c
parentc531c9ec2969860c98a8a47f501c4874278388d3 (diff)
NFC: Add secure element enablement netlink API
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>
Diffstat (limited to 'net/nfc/netlink.c')
-rw-r--r--net/nfc/netlink.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 8a11a3a27e69..b05ad909778f 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -1145,6 +1145,52 @@ free_msg:
1145 return -EMSGSIZE; 1145 return -EMSGSIZE;
1146} 1146}
1147 1147
1148static int nfc_genl_enable_se(struct sk_buff *skb, struct genl_info *info)
1149{
1150 struct nfc_dev *dev;
1151 int rc;
1152 u32 idx, se_idx;
1153
1154 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
1155 !info->attrs[NFC_ATTR_SE_INDEX])
1156 return -EINVAL;
1157
1158 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1159 se_idx = nla_get_u32(info->attrs[NFC_ATTR_SE_INDEX]);
1160
1161 dev = nfc_get_device(idx);
1162 if (!dev)
1163 return -ENODEV;
1164
1165 rc = nfc_enable_se(dev, se_idx);
1166
1167 nfc_put_device(dev);
1168 return rc;
1169}
1170
1171static int nfc_genl_disable_se(struct sk_buff *skb, struct genl_info *info)
1172{
1173 struct nfc_dev *dev;
1174 int rc;
1175 u32 idx, se_idx;
1176
1177 if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
1178 !info->attrs[NFC_ATTR_SE_INDEX])
1179 return -EINVAL;
1180
1181 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
1182 se_idx = nla_get_u32(info->attrs[NFC_ATTR_SE_INDEX]);
1183
1184 dev = nfc_get_device(idx);
1185 if (!dev)
1186 return -ENODEV;
1187
1188 rc = nfc_disable_se(dev, se_idx);
1189
1190 nfc_put_device(dev);
1191 return rc;
1192}
1193
1148static struct genl_ops nfc_genl_ops[] = { 1194static struct genl_ops nfc_genl_ops[] = {
1149 { 1195 {
1150 .cmd = NFC_CMD_GET_DEVICE, 1196 .cmd = NFC_CMD_GET_DEVICE,
@@ -1209,6 +1255,16 @@ static struct genl_ops nfc_genl_ops[] = {
1209 .doit = nfc_genl_fw_upload, 1255 .doit = nfc_genl_fw_upload,
1210 .policy = nfc_genl_policy, 1256 .policy = nfc_genl_policy,
1211 }, 1257 },
1258 {
1259 .cmd = NFC_CMD_ENABLE_SE,
1260 .doit = nfc_genl_enable_se,
1261 .policy = nfc_genl_policy,
1262 },
1263 {
1264 .cmd = NFC_CMD_DISABLE_SE,
1265 .doit = nfc_genl_disable_se,
1266 .policy = nfc_genl_policy,
1267 },
1212}; 1268};
1213 1269
1214 1270