Skip to content

Commit

Permalink
NFC: NCI: Simplify NCI SPI to become a simple framing/checking layer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Lapuyade authored and Samuel Ortiz committed Sep 24, 2013
1 parent 08f13ac commit fa544ff
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 155 deletions.
4 changes: 4 additions & 0 deletions include/net/nfc/nci.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@
#define NCI_GID_NFCEE_MGMT 0x2
#define NCI_GID_PROPRIETARY 0xf

/* ----- NCI over SPI head/crc(tail) room needed for outgoing frames ----- */
#define NCI_SPI_HDR_LEN 4
#define NCI_SPI_CRC_LEN 2

/* ---- NCI Packet structures ---- */
#define NCI_CTRL_HDR_SIZE 3
#define NCI_DATA_HDR_SIZE 3
Expand Down
41 changes: 11 additions & 30 deletions include/net/nfc/nci_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,14 @@ int nci_to_errno(__u8 code);
#define NCI_SPI_CRC_ENABLED 0x01

/* ----- NCI SPI structures ----- */
struct nci_spi_dev;
struct nci_spi;

struct nci_spi_ops {
int (*open)(struct nci_spi_dev *nsdev);
int (*close)(struct nci_spi_dev *nsdev);
void (*assert_int)(struct nci_spi_dev *nsdev);
void (*deassert_int)(struct nci_spi_dev *nsdev);
void (*assert_int)(struct nci_spi *nspi);
void (*deassert_int)(struct nci_spi *nspi);
};

struct nci_spi_dev {
struct nci_spi {
struct nci_dev *ndev;
struct spi_device *spi;
struct nci_spi_ops *ops;
Expand All @@ -227,31 +225,14 @@ struct nci_spi_dev {

struct completion req_completion;
u8 req_result;

void *driver_data;
};

/* ----- NCI SPI Devices ----- */
struct nci_spi_dev *nci_spi_allocate_device(struct spi_device *spi,
struct nci_spi_ops *ops,
u32 supported_protocols,
u32 supported_se,
u8 acknowledge_mode,
unsigned int delay);
void nci_spi_free_device(struct nci_spi_dev *nsdev);
int nci_spi_register_device(struct nci_spi_dev *nsdev);
void nci_spi_unregister_device(struct nci_spi_dev *nsdev);
int nci_spi_recv_frame(struct nci_spi_dev *nsdev);

static inline void nci_spi_set_drvdata(struct nci_spi_dev *nsdev,
void *data)
{
nsdev->driver_data = data;
}

static inline void *nci_spi_get_drvdata(struct nci_spi_dev *nsdev)
{
return nsdev->driver_data;
}
/* ----- NCI SPI ----- */
struct nci_spi *nci_spi_allocate_spi(struct spi_device *spi,
struct nci_spi_ops *ops,
u8 acknowledge_mode, unsigned int delay,
struct nci_dev *ndev);
int nci_spi_send(struct nci_spi *nspi, struct sk_buff *skb);
int nci_spi_recv_frame(struct nci_spi *nspi);

#endif /* __NCI_CORE_H */
Loading

0 comments on commit fa544ff

Please sign in to comment.