aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/nfc
diff options
context:
space:
mode:
authorEric Lapuyade <eric.lapuyade@linux.intel.com>2013-09-05 05:02:21 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2013-09-24 19:35:41 -0400
commitfa544fff62aeeb0cf8008c61077aae10fb1407a9 (patch)
tree42e24efbcaca24ad48bde91259696649388483d3 /include/net/nfc
parent08f13acff960d6c95a371f67ab98785aa9969179 (diff)
NFC: NCI: Simplify NCI SPI to become a simple framing/checking layer
NCI SPI layer should not manage the nci dev, this is the job of the nci chipset driver. This layer should be limited to frame/deframe nci packets, and optionnaly check integrity (crc) and manage the ack/nak protocol. The NCI SPI must not be mixed up with an NCI dev. spi_[dev|device] are therefore renamed to a simple spi for more clarity. The header and crc sizes are moved to nci.h so that drivers can use them to reserve space in outgoing skbs. nci_spi_send() is exported to be accessible by drivers. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'include/net/nfc')
-rw-r--r--include/net/nfc/nci.h4
-rw-r--r--include/net/nfc/nci_core.h41
2 files changed, 15 insertions, 30 deletions
diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h
index 88785e5c6b2c..e5aa5acafea0 100644
--- a/include/net/nfc/nci.h
+++ b/include/net/nfc/nci.h
@@ -166,6 +166,10 @@
166#define NCI_GID_NFCEE_MGMT 0x2 166#define NCI_GID_NFCEE_MGMT 0x2
167#define NCI_GID_PROPRIETARY 0xf 167#define NCI_GID_PROPRIETARY 0xf
168 168
169/* ----- NCI over SPI head/crc(tail) room needed for outgoing frames ----- */
170#define NCI_SPI_HDR_LEN 4
171#define NCI_SPI_CRC_LEN 2
172
169/* ---- NCI Packet structures ---- */ 173/* ---- NCI Packet structures ---- */
170#define NCI_CTRL_HDR_SIZE 3 174#define NCI_CTRL_HDR_SIZE 3
171#define NCI_DATA_HDR_SIZE 3 175#define NCI_DATA_HDR_SIZE 3
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index c08399621c8b..37ba06f2dfa9 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -207,16 +207,14 @@ int nci_to_errno(__u8 code);
207#define NCI_SPI_CRC_ENABLED 0x01 207#define NCI_SPI_CRC_ENABLED 0x01
208 208
209/* ----- NCI SPI structures ----- */ 209/* ----- NCI SPI structures ----- */
210struct nci_spi_dev; 210struct nci_spi;
211 211
212struct nci_spi_ops { 212struct nci_spi_ops {
213 int (*open)(struct nci_spi_dev *nsdev); 213 void (*assert_int)(struct nci_spi *nspi);
214 int (*close)(struct nci_spi_dev *nsdev); 214 void (*deassert_int)(struct nci_spi *nspi);
215 void (*assert_int)(struct nci_spi_dev *nsdev);
216 void (*deassert_int)(struct nci_spi_dev *nsdev);
217}; 215};
218 216
219struct nci_spi_dev { 217struct nci_spi {
220 struct nci_dev *ndev; 218 struct nci_dev *ndev;
221 struct spi_device *spi; 219 struct spi_device *spi;
222 struct nci_spi_ops *ops; 220 struct nci_spi_ops *ops;
@@ -227,31 +225,14 @@ struct nci_spi_dev {
227 225
228 struct completion req_completion; 226 struct completion req_completion;
229 u8 req_result; 227 u8 req_result;
230
231 void *driver_data;
232}; 228};
233 229
234/* ----- NCI SPI Devices ----- */ 230/* ----- NCI SPI ----- */
235struct nci_spi_dev *nci_spi_allocate_device(struct spi_device *spi, 231struct nci_spi *nci_spi_allocate_spi(struct spi_device *spi,
236 struct nci_spi_ops *ops, 232 struct nci_spi_ops *ops,
237 u32 supported_protocols, 233 u8 acknowledge_mode, unsigned int delay,
238 u32 supported_se, 234 struct nci_dev *ndev);
239 u8 acknowledge_mode, 235int nci_spi_send(struct nci_spi *nspi, struct sk_buff *skb);
240 unsigned int delay); 236int nci_spi_recv_frame(struct nci_spi *nspi);
241void nci_spi_free_device(struct nci_spi_dev *nsdev);
242int nci_spi_register_device(struct nci_spi_dev *nsdev);
243void nci_spi_unregister_device(struct nci_spi_dev *nsdev);
244int nci_spi_recv_frame(struct nci_spi_dev *nsdev);
245
246static inline void nci_spi_set_drvdata(struct nci_spi_dev *nsdev,
247 void *data)
248{
249 nsdev->driver_data = data;
250}
251
252static inline void *nci_spi_get_drvdata(struct nci_spi_dev *nsdev)
253{
254 return nsdev->driver_data;
255}
256 237
257#endif /* __NCI_CORE_H */ 238#endif /* __NCI_CORE_H */