linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Ortiz <sameo@linux.intel.com>
To: "John W. Linville" <linville@tuxdriver.com>
Cc: Lauro Ramos Venancio <lauro.venancio@openbossa.org>,
	Aloisio Almeida Jr <aloisio.almeida@openbossa.org>,
	Ilan Elias <ilane@ti.com>,
	Eric Lapuyade <eric.lapuyade@linux.intel.com>,
	linux-wireless@vger.kernel.org,
	Samuel Ortiz <sameo@linux.intel.com>
Subject: [PATCH 02/18] NFC: Add a target lost netlink event
Date: Tue, 10 Apr 2012 19:43:04 +0200	[thread overview]
Message-ID: <1334079800-10671-3-git-send-email-sameo@linux.intel.com> (raw)
In-Reply-To: <1334079800-10671-1-git-send-email-sameo@linux.intel.com>

Some chips are capable of detecting when a tag is out of the field, so
they could send a netlink event about it to userspace.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
---
 include/linux/nfc.h |    1 +
 net/nfc/netlink.c   |   30 ++++++++++++++++++++++++++++++
 net/nfc/nfc.h       |    1 +
 3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/include/linux/nfc.h b/include/linux/nfc.h
index 39c1fcf..0ae9b58 100644
--- a/include/linux/nfc.h
+++ b/include/linux/nfc.h
@@ -70,6 +70,7 @@ enum nfc_commands {
 	NFC_EVENT_TARGETS_FOUND,
 	NFC_EVENT_DEVICE_ADDED,
 	NFC_EVENT_DEVICE_REMOVED,
+	NFC_EVENT_TARGET_LOST,
 /* private: internal use only */
 	__NFC_CMD_AFTER_LAST
 };
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 6404052..ebdb605 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -183,6 +183,36 @@ free_msg:
 	return -EMSGSIZE;
 }
 
+int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx)
+{
+	struct sk_buff *msg;
+	void *hdr;
+
+	msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	if (!msg)
+		return -ENOMEM;
+
+	hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
+			  NFC_EVENT_TARGET_LOST);
+	if (!hdr)
+		goto free_msg;
+
+	NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev));
+	NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target_idx);
+
+	genlmsg_end(msg, hdr);
+
+	genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL);
+
+	return 0;
+
+nla_put_failure:
+	genlmsg_cancel(msg, hdr);
+free_msg:
+	nlmsg_free(msg);
+	return -EMSGSIZE;
+}
+
 int nfc_genl_device_added(struct nfc_dev *dev)
 {
 	struct sk_buff *msg;
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
index ec8794c..2c868d2 100644
--- a/net/nfc/nfc.h
+++ b/net/nfc/nfc.h
@@ -119,6 +119,7 @@ void nfc_genl_data_init(struct nfc_genl_data *genl_data);
 void nfc_genl_data_exit(struct nfc_genl_data *genl_data);
 
 int nfc_genl_targets_found(struct nfc_dev *dev);
+int nfc_genl_target_lost(struct nfc_dev *dev, u32 target_idx);
 
 int nfc_genl_device_added(struct nfc_dev *dev);
 int nfc_genl_device_removed(struct nfc_dev *dev);
-- 
1.7.9.1


  parent reply	other threads:[~2012-04-10 17:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-10 17:43 [PATCH 00/18] NFC changes for 3.5 Samuel Ortiz
2012-04-10 17:43 ` [PATCH 01/18 3.4] NFC: Fix the LLCP Tx fragmentation loop Samuel Ortiz
2012-04-10 17:43 ` Samuel Ortiz [this message]
2012-04-10 17:43 ` [PATCH 03/18] NFC: Export target lost function Samuel Ortiz
2012-04-10 17:43 ` [PATCH 04/18] NFC: HCI support Samuel Ortiz
2012-04-10 17:43 ` [PATCH 05/18] NFC: SHDLC implementation Samuel Ortiz
2012-04-10 17:43 ` [PATCH 06/18] NFC: Add HCI documentation Samuel Ortiz
2012-04-10 17:43 ` [PATCH 07/18] NFC: The core part should generate the target index Samuel Ortiz
2012-04-10 17:43 ` [PATCH 08/18] NFC: Fix next target_idx type and rename for clarity Samuel Ortiz
2012-04-10 17:43 ` [PATCH 09/18] NFC: Changed target activated state logic Samuel Ortiz
2012-04-10 17:43 ` [PATCH 10/18] NFC: Add Core support to generate tag lost event Samuel Ortiz
2012-04-10 17:43 ` [PATCH 11/18] NFC: Dump LLCP frames Samuel Ortiz
2012-04-10 17:43 ` [PATCH 12/18] NFC: No need to apply twice the modulo op to LLCP's recv_n Samuel Ortiz
2012-04-10 17:43 ` [PATCH 13/18] NFC: Fix LLCP TLV building routine Samuel Ortiz
2012-04-10 17:43 ` [PATCH 14/18] NFC: Call llcp_add_header properly when sending LLCP DM or DISC Samuel Ortiz
2012-04-10 17:43 ` [PATCH 15/18] NFC: Convert pn533 from tasklet to workqueues Samuel Ortiz
2012-04-10 17:43 ` [PATCH 16/18] NFC: pn533 Rx chaining support Samuel Ortiz
2012-04-10 17:43 ` [PATCH 17/18] NFC: Add MIUX to the local LLCP general bytes Samuel Ortiz
2012-04-10 17:43 ` [PATCH 18/18] NFC: Fix LLCP link timeout typo Samuel Ortiz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1334079800-10671-3-git-send-email-sameo@linux.intel.com \
    --to=sameo@linux.intel.com \
    --cc=aloisio.almeida@openbossa.org \
    --cc=eric.lapuyade@linux.intel.com \
    --cc=ilane@ti.com \
    --cc=lauro.venancio@openbossa.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).