NFC: nfcmrvl: configure head/tail room values per low level drivers
authorVincent Cuissard <cuissard@marvell.com>
Mon, 26 Oct 2015 09:27:40 +0000 (10:27 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 27 Oct 2015 03:19:44 +0000 (04:19 +0100)
Low-level drivers may need to add some data before and/or
after NCI packet.

Signed-off-by: Vincent Cuissard <cuissard@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/nfcmrvl/main.c
drivers/nfc/nfcmrvl/nfcmrvl.h
drivers/nfc/nfcmrvl/uart.c
drivers/nfc/nfcmrvl/usb.c

index 6fb23cc9a6590c1c5ad65e12bb4bae25b900eaa8..a24a7ca9f33d359a165e5a0dcb9eb902189ab303 100644 (file)
@@ -97,14 +97,16 @@ static struct nci_ops nfcmrvl_nci_ops = {
        .fw_download = nfcmrvl_nci_fw_download,
 };
 
-struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data,
+struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,
+                               void *drv_data,
                                struct nfcmrvl_if_ops *ops,
                                struct device *dev,
                                struct nfcmrvl_platform_data *pdata)
 {
        struct nfcmrvl_private *priv;
        int rc;
-       int headroom = 0;
+       int headroom;
+       int tailroom;
        u32 protocols;
 
        priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -114,6 +116,7 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data,
        priv->drv_data = drv_data;
        priv->if_ops = ops;
        priv->dev = dev;
+       priv->phy = phy;
 
        memcpy(&priv->config, pdata, sizeof(*pdata));
 
@@ -126,8 +129,10 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data,
                        nfc_err(dev, "failed to request reset_n io\n");
        }
 
+       headroom = tailroom = 0;
+
        if (priv->config.hci_muxed)
-               headroom = NFCMRVL_HCI_EVENT_HEADER_SIZE;
+               headroom += NFCMRVL_HCI_EVENT_HEADER_SIZE;
 
        protocols = NFC_PROTO_JEWEL_MASK
                | NFC_PROTO_MIFARE_MASK
@@ -138,7 +143,7 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data,
                | NFC_PROTO_NFC_DEP_MASK;
 
        priv->ndev = nci_allocate_device(&nfcmrvl_nci_ops, protocols,
-                                        headroom, 0);
+                                        headroom, tailroom);
        if (!priv->ndev) {
                nfc_err(dev, "nci_allocate_device failed\n");
                rc = -ENOMEM;
index 1b30f043139c12488b1d6cf11e38a513c7ec2419..f82678be5aa989dd8084f94f02fc376807ee9496 100644 (file)
@@ -100,7 +100,8 @@ struct nfcmrvl_if_ops {
 
 void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv);
 int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, struct sk_buff *skb);
-struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data,
+struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,
+                               void *drv_data,
                                struct nfcmrvl_if_ops *ops,
                                struct device *dev,
                                struct nfcmrvl_platform_data *pdata);
index 835582435560051a9d9557384f23761e0a77a0a6..4dccee2566cf45cf93d6da40a5d976ffdc7a45b3 100644 (file)
@@ -138,11 +138,11 @@ static int nfcmrvl_nci_uart_open(struct nci_uart *nu)
                pdata = &config;
        }
 
-       priv = nfcmrvl_nci_register_dev(nu, &uart_ops, nu->tty->dev, pdata);
+       priv = nfcmrvl_nci_register_dev(NFCMRVL_PHY_UART, nu, &uart_ops,
+                                       nu->tty->dev, pdata);
        if (IS_ERR(priv))
                return PTR_ERR(priv);
 
-       priv->phy = NFCMRVL_PHY_UART;
        priv->support_fw_dnld = true;
 
        nu->drv_data = priv;
index b2761743442784b916a589a31cb6724b3fdd9bc1..585a0f20835b19e19f583b0829d20738d6be0754 100644 (file)
@@ -340,13 +340,12 @@ static int nfcmrvl_probe(struct usb_interface *intf,
        init_usb_anchor(&drv_data->bulk_anchor);
        init_usb_anchor(&drv_data->deferred);
 
-       priv = nfcmrvl_nci_register_dev(drv_data, &usb_ops,
+       priv = nfcmrvl_nci_register_dev(NFCMRVL_PHY_USB, drv_data, &usb_ops,
                                        &drv_data->udev->dev, &config);
        if (IS_ERR(priv))
                return PTR_ERR(priv);
 
        drv_data->priv = priv;
-       drv_data->priv->phy = NFCMRVL_PHY_USB;
        drv_data->priv->support_fw_dnld = false;
 
        priv->dev = &drv_data->udev->dev;