diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2013-07-01 04:58:12 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-08-13 18:35:18 -0400 |
commit | 5eef4845619b88957349415b7b1498e00220fa2b (patch) | |
tree | dd99d62aba3c0432f9b01c2275d6fcff38378a73 /drivers/nfc | |
parent | a94e10f7d7ce8e22d3d1cfebdfb7fe0451714799 (diff) |
NFC: pn533: Unconditionaly select the highest p2p bit rate
p2p devices must be able to support 424 kbps, so we should always select
that bitrate in initiator mode.
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r-- | drivers/nfc/pn533.c | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index fa12f59cf7b9..ff3e19dcc7c5 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c | |||
@@ -2086,20 +2086,6 @@ error: | |||
2086 | return rc; | 2086 | return rc; |
2087 | } | 2087 | } |
2088 | 2088 | ||
2089 | static int pn533_mod_to_baud(struct pn533 *dev) | ||
2090 | { | ||
2091 | switch (dev->poll_mod_curr) { | ||
2092 | case PN533_POLL_MOD_106KBPS_A: | ||
2093 | return 0; | ||
2094 | case PN533_POLL_MOD_212KBPS_FELICA: | ||
2095 | return 1; | ||
2096 | case PN533_POLL_MOD_424KBPS_FELICA: | ||
2097 | return 2; | ||
2098 | default: | ||
2099 | return -EINVAL; | ||
2100 | } | ||
2101 | } | ||
2102 | |||
2103 | static int pn533_rf_field(struct nfc_dev *nfc_dev, u8 rf); | 2089 | static int pn533_rf_field(struct nfc_dev *nfc_dev, u8 rf); |
2104 | #define PASSIVE_DATA_LEN 5 | 2090 | #define PASSIVE_DATA_LEN 5 |
2105 | static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, | 2091 | static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, |
@@ -2107,8 +2093,8 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, | |||
2107 | { | 2093 | { |
2108 | struct pn533 *dev = nfc_get_drvdata(nfc_dev); | 2094 | struct pn533 *dev = nfc_get_drvdata(nfc_dev); |
2109 | struct sk_buff *skb; | 2095 | struct sk_buff *skb; |
2110 | int rc, baud, skb_len; | 2096 | int rc, skb_len; |
2111 | u8 *next, *arg; | 2097 | u8 *next, *arg, nfcid3[NFC_NFCID3_MAXSIZE]; |
2112 | 2098 | ||
2113 | u8 passive_data[PASSIVE_DATA_LEN] = {0x00, 0xff, 0xff, 0x00, 0x3}; | 2099 | u8 passive_data[PASSIVE_DATA_LEN] = {0x00, 0xff, 0xff, 0x00, 0x3}; |
2114 | 2100 | ||
@@ -2126,41 +2112,39 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target, | |||
2126 | return -EBUSY; | 2112 | return -EBUSY; |
2127 | } | 2113 | } |
2128 | 2114 | ||
2129 | baud = pn533_mod_to_baud(dev); | ||
2130 | if (baud < 0) { | ||
2131 | nfc_dev_err(&dev->interface->dev, | ||
2132 | "Invalid curr modulation %d", dev->poll_mod_curr); | ||
2133 | return baud; | ||
2134 | } | ||
2135 | |||
2136 | skb_len = 3 + gb_len; /* ActPass + BR + Next */ | 2115 | skb_len = 3 + gb_len; /* ActPass + BR + Next */ |
2137 | if (comm_mode == NFC_COMM_PASSIVE) | 2116 | skb_len += PASSIVE_DATA_LEN; |
2138 | skb_len += PASSIVE_DATA_LEN; | ||
2139 | 2117 | ||
2140 | if (target && target->nfcid2_len) | 2118 | /* NFCID3 */ |
2141 | skb_len += NFC_NFCID3_MAXSIZE; | 2119 | skb_len += NFC_NFCID3_MAXSIZE; |
2120 | if (target && !target->nfcid2_len) { | ||
2121 | nfcid3[0] = 0x1; | ||
2122 | nfcid3[1] = 0xfe; | ||
2123 | get_random_bytes(nfcid3 + 2, 6); | ||
2124 | } | ||
2142 | 2125 | ||
2143 | skb = pn533_alloc_skb(dev, skb_len); | 2126 | skb = pn533_alloc_skb(dev, skb_len); |
2144 | if (!skb) | 2127 | if (!skb) |
2145 | return -ENOMEM; | 2128 | return -ENOMEM; |
2146 | 2129 | ||
2147 | *skb_put(skb, 1) = !comm_mode; /* ActPass */ | 2130 | *skb_put(skb, 1) = !comm_mode; /* ActPass */ |
2148 | *skb_put(skb, 1) = baud; /* Baud rate */ | 2131 | *skb_put(skb, 1) = 0x02; /* 424 kbps */ |
2149 | 2132 | ||
2150 | next = skb_put(skb, 1); /* Next */ | 2133 | next = skb_put(skb, 1); /* Next */ |
2151 | *next = 0; | 2134 | *next = 0; |
2152 | 2135 | ||
2153 | if (comm_mode == NFC_COMM_PASSIVE && baud > 0) { | 2136 | /* Copy passive data */ |
2154 | memcpy(skb_put(skb, PASSIVE_DATA_LEN), passive_data, | 2137 | memcpy(skb_put(skb, PASSIVE_DATA_LEN), passive_data, PASSIVE_DATA_LEN); |
2155 | PASSIVE_DATA_LEN); | 2138 | *next |= 1; |
2156 | *next |= 1; | ||
2157 | } | ||
2158 | 2139 | ||
2159 | if (target && target->nfcid2_len) { | 2140 | /* Copy NFCID3 (which is NFCID2 from SENSF_RES) */ |
2141 | if (target && target->nfcid2_len) | ||
2160 | memcpy(skb_put(skb, NFC_NFCID3_MAXSIZE), target->nfcid2, | 2142 | memcpy(skb_put(skb, NFC_NFCID3_MAXSIZE), target->nfcid2, |
2161 | target->nfcid2_len); | 2143 | target->nfcid2_len); |
2162 | *next |= 2; | 2144 | else |
2163 | } | 2145 | memcpy(skb_put(skb, NFC_NFCID3_MAXSIZE), nfcid3, |
2146 | NFC_NFCID3_MAXSIZE); | ||
2147 | *next |= 2; | ||
2164 | 2148 | ||
2165 | if (gb != NULL && gb_len > 0) { | 2149 | if (gb != NULL && gb_len > 0) { |
2166 | memcpy(skb_put(skb, gb_len), gb, gb_len); | 2150 | memcpy(skb_put(skb, gb_len), gb, gb_len); |