aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@linux.intel.com>2012-09-18 13:45:48 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-09-24 18:17:26 -0400
commit412fda538f4b1317ecd0fbe6e5bc9124792bea88 (patch)
treeafd09c49880919110dd1dc25027b75a63f8dd169
parent4a61cd6687fc6348d08724676d34e38160d6cf9b (diff)
NFC: Changed HCI and PN544 HCI driver to use the new HCI LLC Core
The previous shdlc HCI driver and its header are removed from the tree. PN544 now registers directly with HCI and passes the name of the llc it requires (shdlc). HCI instantiation now allocates the required llc instance. The llc is started when the HCI device is brought up. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/nfc/Kconfig2
-rw-r--r--drivers/nfc/pn544_hci.c73
-rw-r--r--include/net/nfc/hci.h3
-rw-r--r--include/net/nfc/shdlc.h106
-rw-r--r--net/nfc/hci/Makefile2
-rw-r--r--net/nfc/hci/core.c210
-rw-r--r--net/nfc/hci/llc_shdlc.c2
-rw-r--r--net/nfc/hci/shdlc.c918
8 files changed, 164 insertions, 1152 deletions
diff --git a/drivers/nfc/Kconfig b/drivers/nfc/Kconfig
index 3b20b73ee649..89c57d1a7cad 100644
--- a/drivers/nfc/Kconfig
+++ b/drivers/nfc/Kconfig
@@ -19,7 +19,7 @@ config PN544_NFC
19 19
20config PN544_HCI_NFC 20config PN544_HCI_NFC
21 tristate "HCI PN544 NFC driver" 21 tristate "HCI PN544 NFC driver"
22 depends on I2C && NFC_SHDLC 22 depends on I2C && NFC_HCI && NFC_SHDLC
23 select CRC_CCITT 23 select CRC_CCITT
24 default n 24 default n
25 ---help--- 25 ---help---
diff --git a/drivers/nfc/pn544_hci.c b/drivers/nfc/pn544_hci.c
index a176d1f7bbf3..e681da2e3413 100644
--- a/drivers/nfc/pn544_hci.c
+++ b/drivers/nfc/pn544_hci.c
@@ -29,7 +29,7 @@
29 29
30#include <linux/nfc.h> 30#include <linux/nfc.h>
31#include <net/nfc/hci.h> 31#include <net/nfc/hci.h>
32#include <net/nfc/shdlc.h> 32#include <net/nfc/llc.h>
33 33
34#include <linux/nfc/pn544.h> 34#include <linux/nfc/pn544.h>
35 35
@@ -133,7 +133,7 @@ static struct nfc_hci_gate pn544_gates[] = {
133 133
134struct pn544_hci_info { 134struct pn544_hci_info {
135 struct i2c_client *i2c_dev; 135 struct i2c_client *i2c_dev;
136 struct nfc_shdlc *shdlc; 136 struct nfc_hci_dev *hdev;
137 137
138 enum pn544_state state; 138 enum pn544_state state;
139 139
@@ -362,21 +362,21 @@ static irqreturn_t pn544_hci_irq_thread_fn(int irq, void *dev_id)
362 if (r == -EREMOTEIO) { 362 if (r == -EREMOTEIO) {
363 info->hard_fault = r; 363 info->hard_fault = r;
364 364
365 nfc_shdlc_recv_frame(info->shdlc, NULL); 365 nfc_hci_recv_frame(info->hdev, NULL);
366 366
367 return IRQ_HANDLED; 367 return IRQ_HANDLED;
368 } else if ((r == -ENOMEM) || (r == -EBADMSG)) { 368 } else if ((r == -ENOMEM) || (r == -EBADMSG)) {
369 return IRQ_HANDLED; 369 return IRQ_HANDLED;
370 } 370 }
371 371
372 nfc_shdlc_recv_frame(info->shdlc, skb); 372 nfc_hci_recv_frame(info->hdev, skb);
373 373
374 return IRQ_HANDLED; 374 return IRQ_HANDLED;
375} 375}
376 376
377static int pn544_hci_open(struct nfc_shdlc *shdlc) 377static int pn544_hci_open(struct nfc_hci_dev *hdev)
378{ 378{
379 struct pn544_hci_info *info = nfc_shdlc_get_clientdata(shdlc); 379 struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
380 int r = 0; 380 int r = 0;
381 381
382 mutex_lock(&info->info_lock); 382 mutex_lock(&info->info_lock);
@@ -396,9 +396,9 @@ out:
396 return r; 396 return r;
397} 397}
398 398
399static void pn544_hci_close(struct nfc_shdlc *shdlc) 399static void pn544_hci_close(struct nfc_hci_dev *hdev)
400{ 400{
401 struct pn544_hci_info *info = nfc_shdlc_get_clientdata(shdlc); 401 struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
402 402
403 mutex_lock(&info->info_lock); 403 mutex_lock(&info->info_lock);
404 404
@@ -413,9 +413,8 @@ out:
413 mutex_unlock(&info->info_lock); 413 mutex_unlock(&info->info_lock);
414} 414}
415 415
416static int pn544_hci_ready(struct nfc_shdlc *shdlc) 416static int pn544_hci_ready(struct nfc_hci_dev *hdev)
417{ 417{
418 struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
419 struct sk_buff *skb; 418 struct sk_buff *skb;
420 static struct hw_config { 419 static struct hw_config {
421 u8 adr[2]; 420 u8 adr[2];
@@ -601,9 +600,9 @@ static void pn544_hci_remove_len_crc(struct sk_buff *skb)
601 skb_trim(skb, PN544_FRAME_TAILROOM); 600 skb_trim(skb, PN544_FRAME_TAILROOM);
602} 601}
603 602
604static int pn544_hci_xmit(struct nfc_shdlc *shdlc, struct sk_buff *skb) 603static int pn544_hci_xmit(struct nfc_hci_dev *hdev, struct sk_buff *skb)
605{ 604{
606 struct pn544_hci_info *info = nfc_shdlc_get_clientdata(shdlc); 605 struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
607 struct i2c_client *client = info->i2c_dev; 606 struct i2c_client *client = info->i2c_dev;
608 int r; 607 int r;
609 608
@@ -617,10 +616,9 @@ static int pn544_hci_xmit(struct nfc_shdlc *shdlc, struct sk_buff *skb)
617 return r; 616 return r;
618} 617}
619 618
620static int pn544_hci_start_poll(struct nfc_shdlc *shdlc, 619static int pn544_hci_start_poll(struct nfc_hci_dev *hdev,
621 u32 im_protocols, u32 tm_protocols) 620 u32 im_protocols, u32 tm_protocols)
622{ 621{
623 struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
624 u8 phases = 0; 622 u8 phases = 0;
625 int r; 623 int r;
626 u8 duration[2]; 624 u8 duration[2];
@@ -671,7 +669,7 @@ static int pn544_hci_start_poll(struct nfc_shdlc *shdlc,
671 return r; 669 return r;
672} 670}
673 671
674static int pn544_hci_target_from_gate(struct nfc_shdlc *shdlc, u8 gate, 672static int pn544_hci_target_from_gate(struct nfc_hci_dev *hdev, u8 gate,
675 struct nfc_target *target) 673 struct nfc_target *target)
676{ 674{
677 switch (gate) { 675 switch (gate) {
@@ -689,11 +687,10 @@ static int pn544_hci_target_from_gate(struct nfc_shdlc *shdlc, u8 gate,
689 return 0; 687 return 0;
690} 688}
691 689
692static int pn544_hci_complete_target_discovered(struct nfc_shdlc *shdlc, 690static int pn544_hci_complete_target_discovered(struct nfc_hci_dev *hdev,
693 u8 gate, 691 u8 gate,
694 struct nfc_target *target) 692 struct nfc_target *target)
695{ 693{
696 struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
697 struct sk_buff *uid_skb; 694 struct sk_buff *uid_skb;
698 int r = 0; 695 int r = 0;
699 696
@@ -765,13 +762,12 @@ static void pn544_hci_data_exchange_cb(void *context, struct sk_buff *skb,
765 * <= 0: driver handled the data exchange 762 * <= 0: driver handled the data exchange
766 * 1: driver doesn't especially handle, please do standard processing 763 * 1: driver doesn't especially handle, please do standard processing
767 */ 764 */
768static int pn544_hci_data_exchange(struct nfc_shdlc *shdlc, 765static int pn544_hci_data_exchange(struct nfc_hci_dev *hdev,
769 struct nfc_target *target, 766 struct nfc_target *target,
770 struct sk_buff *skb, data_exchange_cb_t cb, 767 struct sk_buff *skb, data_exchange_cb_t cb,
771 void *cb_context) 768 void *cb_context)
772{ 769{
773 struct pn544_hci_info *info = nfc_shdlc_get_clientdata(shdlc); 770 struct pn544_hci_info *info = nfc_hci_get_clientdata(hdev);
774 struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
775 771
776 pr_info(DRIVER_DESC ": %s for gate=%d\n", __func__, 772 pr_info(DRIVER_DESC ": %s for gate=%d\n", __func__,
777 target->hci_reader_gate); 773 target->hci_reader_gate);
@@ -824,17 +820,15 @@ static int pn544_hci_data_exchange(struct nfc_shdlc *shdlc,
824 } 820 }
825} 821}
826 822
827static int pn544_hci_check_presence(struct nfc_shdlc *shdlc, 823static int pn544_hci_check_presence(struct nfc_hci_dev *hdev,