提交 4d63adfe 编写于 作者: M Mark Greer 提交者: Samuel Ortiz

NFC: Add NFC_CMD_DEACTIVATE_TARGET support

Once an NFC target (i.e., a tag) is found, it remains active until
there is a failure reading or writing it (often caused by the target
moving out of range).  While the target is active, the NFC adapter
and antenna must remain powered.  This wastes power when the target
remains in range but the client application no longer cares whether
it is there or not.

To mitigate this, add a new netlink command that allows userspace
to deactivate an active target.  When issued, this command will cause
the NFC subsystem to act as though the target was moved out of range.
Once the command has been executed, the client application can power
off the NFC adapter to reduce power consumption.
Signed-off-by: NMark Greer <mgreer@animalcreek.com>
Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
上级 72ad533a
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
* @NFC_CMD_ACTIVATE_TARGET: Request NFC controller to reactivate target. * @NFC_CMD_ACTIVATE_TARGET: Request NFC controller to reactivate target.
* @NFC_CMD_VENDOR: Vendor specific command, to be implemented directly * @NFC_CMD_VENDOR: Vendor specific command, to be implemented directly
* from the driver in order to support hardware specific operations. * from the driver in order to support hardware specific operations.
* @NFC_CMD_DEACTIVATE_TARGET: Request NFC controller to deactivate target.
*/ */
enum nfc_commands { enum nfc_commands {
NFC_CMD_UNSPEC, NFC_CMD_UNSPEC,
...@@ -121,6 +122,7 @@ enum nfc_commands { ...@@ -121,6 +122,7 @@ enum nfc_commands {
NFC_CMD_SE_IO, NFC_CMD_SE_IO,
NFC_CMD_ACTIVATE_TARGET, NFC_CMD_ACTIVATE_TARGET,
NFC_CMD_VENDOR, NFC_CMD_VENDOR,
NFC_CMD_DEACTIVATE_TARGET,
/* private: internal use only */ /* private: internal use only */
__NFC_CMD_AFTER_LAST __NFC_CMD_AFTER_LAST
}; };
......
...@@ -928,6 +928,30 @@ static int nfc_genl_activate_target(struct sk_buff *skb, struct genl_info *info) ...@@ -928,6 +928,30 @@ static int nfc_genl_activate_target(struct sk_buff *skb, struct genl_info *info)
return rc; return rc;
} }
static int nfc_genl_deactivate_target(struct sk_buff *skb,
struct genl_info *info)
{
struct nfc_dev *dev;
u32 device_idx, target_idx;
int rc;
if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
return -EINVAL;
device_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
dev = nfc_get_device(device_idx);
if (!dev)
return -ENODEV;
target_idx = nla_get_u32(info->attrs[NFC_ATTR_TARGET_INDEX]);
rc = nfc_deactivate_target(dev, target_idx, NFC_TARGET_MODE_SLEEP);
nfc_put_device(dev);
return rc;
}
static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info) static int nfc_genl_dep_link_up(struct sk_buff *skb, struct genl_info *info)
{ {
struct nfc_dev *dev; struct nfc_dev *dev;
...@@ -1751,6 +1775,11 @@ static const struct genl_ops nfc_genl_ops[] = { ...@@ -1751,6 +1775,11 @@ static const struct genl_ops nfc_genl_ops[] = {
.doit = nfc_genl_vendor_cmd, .doit = nfc_genl_vendor_cmd,
.policy = nfc_genl_policy, .policy = nfc_genl_policy,
}, },
{
.cmd = NFC_CMD_DEACTIVATE_TARGET,
.doit = nfc_genl_deactivate_target,
.policy = nfc_genl_policy,
},
}; };
static struct genl_family nfc_genl_family __ro_after_init = { static struct genl_family nfc_genl_family __ro_after_init = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册