aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
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 /drivers/nfc
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>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/Kconfig2
-rw-r--r--drivers/nfc/pn544_hci.c73
2 files changed, 38 insertions, 37 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,
828 struct nfc_target *target) 824 struct nfc_target *target)
829{ 825{
830 struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
831
832 return nfc_hci_send_cmd(hdev, target->hci_reader_gate, 826 return nfc_hci_send_cmd(hdev, target->hci_reader_gate,
833 PN544_RF_READER_CMD_PRESENCE_CHECK, 827 PN544_RF_READER_CMD_PRESENCE_CHECK,
834 NULL, 0, NULL); 828 NULL, 0, NULL);
835} 829}
836 830
837static struct nfc_shdlc_ops pn544_shdlc_ops = { 831static struct nfc_hci_ops pn544_hci_ops = {
838 .open = pn544_hci_open, 832 .open = pn544_hci_open,
839 .close = pn544_hci_close, 833 .close = pn544_hci_close,
840 .hci_ready = pn544_hci_ready, 834 .hci_ready = pn544_hci_ready,
@@ -926,23 +920,30 @@ static int __devinit pn544_hci_probe(struct i2c_client *client,
926 NFC_PROTO_ISO14443_B_MASK | 920 NFC_PROTO_ISO14443_B_MASK |
927 NFC_PROTO_NFC_DEP_MASK; 921 NFC_PROTO_NFC_DEP_MASK;
928 922
929 info->shdlc = nfc_shdlc_allocate(&pn544_shdlc_ops, 923 info->hdev = nfc_hci_allocate_device(&pn544_hci_ops, &init_data,
930 &init_data, protocols, 924 protocols, LLC_SHDLC_NAME,
931 PN544_FRAME_HEADROOM + PN544_CMDS_HEADROOM, 925 PN544_FRAME_HEADROOM +
932 PN544_FRAME_TAILROOM, 926 PN544_CMDS_HEADROOM,
933 PN544_HCI_LLC_MAX_PAYLOAD, 927 PN544_FRAME_TAILROOM,
934 dev_name(&client->dev)); 928 PN544_HCI_LLC_MAX_PAYLOAD);
935 if (!info->shdlc) { 929 if (!info->hdev) {
936 dev_err(&client->dev, "Cannot allocate nfc shdlc.\n"); 930 dev_err(&client->dev, "Cannot allocate nfc hdev.\n");
937 r = -ENOMEM; 931 r = -ENOMEM;
938 goto err_allocshdlc; 932 goto err_alloc_hdev;
939 } 933 }
940 934
941 nfc_shdlc_set_clientdata(info->shdlc, info); 935 nfc_hci_set_clientdata(info->hdev, info);
936
937 r = nfc_hci_register_device(info->hdev);
938 if (r)
939 goto err_regdev;
942 940
943 return 0; 941 return 0;
944 942
945err_allocshdlc: 943err_regdev:
944 nfc_hci_free_device(info->hdev);
945
946err_alloc_hdev:
946 free_irq(client->irq, info); 947 free_irq(client->irq, info);
947 948
948err_rti: 949err_rti:
@@ -963,7 +964,7 @@ static __devexit int pn544_hci_remove(struct i2c_client *client)
963 964
964 dev_dbg(&client->dev, "%s\n", __func__); 965 dev_dbg(&client->dev, "%s\n", __func__);
965 966
966 nfc_shdlc_free(info->shdlc); 967 nfc_hci_free_device(info->hdev);
967 968
968 if (info->state != PN544_ST_COLD) { 969 if (info->state != PN544_ST_COLD) {
969 if (pdata->disable) 970 if (pdata->disable)