diff options
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/netlink.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 95818314aea6..44989fc8cddf 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c | |||
@@ -1310,6 +1310,51 @@ static int nfc_genl_dump_ses_done(struct netlink_callback *cb) | |||
1310 | return 0; | 1310 | return 0; |
1311 | } | 1311 | } |
1312 | 1312 | ||
1313 | static int nfc_se_io(struct nfc_dev *dev, u32 se_idx, | ||
1314 | u8 *apdu, size_t apdu_length, | ||
1315 | se_io_cb_t cb, void *cb_context) | ||
1316 | { | ||
1317 | struct nfc_se *se; | ||
1318 | int rc; | ||
1319 | |||
1320 | pr_debug("%s se index %d\n", dev_name(&dev->dev), se_idx); | ||
1321 | |||
1322 | device_lock(&dev->dev); | ||
1323 | |||
1324 | if (!device_is_registered(&dev->dev)) { | ||
1325 | rc = -ENODEV; | ||
1326 | goto error; | ||
1327 | } | ||
1328 | |||
1329 | if (!dev->dev_up) { | ||
1330 | rc = -ENODEV; | ||
1331 | goto error; | ||
1332 | } | ||
1333 | |||
1334 | if (!dev->ops->se_io) { | ||
1335 | rc = -EOPNOTSUPP; | ||
1336 | goto error; | ||
1337 | } | ||
1338 | |||
1339 | se = nfc_find_se(dev, se_idx); | ||
1340 | if (!se) { | ||
1341 | rc = -EINVAL; | ||
1342 | goto error; | ||
1343 | } | ||
1344 | |||
1345 | if (se->state != NFC_SE_ENABLED) { | ||
1346 | rc = -ENODEV; | ||
1347 | goto error; | ||
1348 | } | ||
1349 | |||
1350 | rc = dev->ops->se_io(dev, se_idx, apdu, | ||
1351 | apdu_length, cb, cb_context); | ||
1352 | |||
1353 | error: | ||
1354 | device_unlock(&dev->dev); | ||
1355 | return rc; | ||
1356 | } | ||
1357 | |||
1313 | struct se_io_ctx { | 1358 | struct se_io_ctx { |
1314 | u32 dev_idx; | 1359 | u32 dev_idx; |
1315 | u32 se_idx; | 1360 | u32 se_idx; |
@@ -1392,7 +1437,7 @@ static int nfc_genl_se_io(struct sk_buff *skb, struct genl_info *info) | |||
1392 | ctx->dev_idx = dev_idx; | 1437 | ctx->dev_idx = dev_idx; |
1393 | ctx->se_idx = se_idx; | 1438 | ctx->se_idx = se_idx; |
1394 | 1439 | ||
1395 | return dev->ops->se_io(dev, se_idx, apdu, apdu_len, se_io_cb, ctx); | 1440 | return nfc_se_io(dev, se_idx, apdu, apdu_len, se_io_cb, ctx); |
1396 | } | 1441 | } |
1397 | 1442 | ||
1398 | static const struct genl_ops nfc_genl_ops[] = { | 1443 | static const struct genl_ops nfc_genl_ops[] = { |