NFC: NCI: Fix skb->dev usage
skb->dev is used for carrying a net_device pointer and not an nci_dev pointer. Remove usage of skb-dev to carry nci_dev and replace it by parameter in nci_recv_frame(), nci_send_frame() and driver send() functions. NfcWilink driver is also updated to use those functions. Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
4674d0fecb
commit
1095e69f47
@ -109,7 +109,7 @@ enum {
|
|||||||
NFCWILINK_FW_DOWNLOAD,
|
NFCWILINK_FW_DOWNLOAD,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int nfcwilink_send(struct sk_buff *skb);
|
static int nfcwilink_send(struct nci_dev *ndev, struct sk_buff *skb);
|
||||||
|
|
||||||
static inline struct sk_buff *nfcwilink_skb_alloc(unsigned int len, gfp_t how)
|
static inline struct sk_buff *nfcwilink_skb_alloc(unsigned int len, gfp_t how)
|
||||||
{
|
{
|
||||||
@ -156,8 +156,6 @@ static int nfcwilink_get_bts_file_name(struct nfcwilink *drv, char *file_name)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
skb->dev = (void *)drv->ndev;
|
|
||||||
|
|
||||||
cmd = (struct nci_vs_nfcc_info_cmd *)
|
cmd = (struct nci_vs_nfcc_info_cmd *)
|
||||||
skb_put(skb, sizeof(struct nci_vs_nfcc_info_cmd));
|
skb_put(skb, sizeof(struct nci_vs_nfcc_info_cmd));
|
||||||
cmd->gid = NCI_VS_NFCC_INFO_CMD_GID;
|
cmd->gid = NCI_VS_NFCC_INFO_CMD_GID;
|
||||||
@ -166,7 +164,7 @@ static int nfcwilink_get_bts_file_name(struct nfcwilink *drv, char *file_name)
|
|||||||
|
|
||||||
drv->nfcc_info.plen = 0;
|
drv->nfcc_info.plen = 0;
|
||||||
|
|
||||||
rc = nfcwilink_send(skb);
|
rc = nfcwilink_send(drv->ndev, skb);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -232,11 +230,9 @@ static int nfcwilink_send_bts_cmd(struct nfcwilink *drv, __u8 *data, int len)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
skb->dev = (void *)drv->ndev;
|
|
||||||
|
|
||||||
memcpy(skb_put(skb, len), data, len);
|
memcpy(skb_put(skb, len), data, len);
|
||||||
|
|
||||||
rc = nfcwilink_send(skb);
|
rc = nfcwilink_send(drv->ndev, skb);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -371,10 +367,8 @@ static long nfcwilink_receive(void *priv_data, struct sk_buff *skb)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
skb->dev = (void *) drv->ndev;
|
|
||||||
|
|
||||||
/* Forward skb to NCI core layer */
|
/* Forward skb to NCI core layer */
|
||||||
rc = nci_recv_frame(skb);
|
rc = nci_recv_frame(drv->ndev, skb);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
nfc_dev_err(&drv->pdev->dev, "nci_recv_frame failed %d", rc);
|
nfc_dev_err(&drv->pdev->dev, "nci_recv_frame failed %d", rc);
|
||||||
return rc;
|
return rc;
|
||||||
@ -480,9 +474,8 @@ static int nfcwilink_close(struct nci_dev *ndev)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nfcwilink_send(struct sk_buff *skb)
|
static int nfcwilink_send(struct nci_dev *ndev, struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct nci_dev *ndev = (struct nci_dev *)skb->dev;
|
|
||||||
struct nfcwilink *drv = nci_get_drvdata(ndev);
|
struct nfcwilink *drv = nci_get_drvdata(ndev);
|
||||||
struct nfcwilink_hdr hdr = {NFCWILINK_CHNL, NFCWILINK_OPCODE, 0x0000};
|
struct nfcwilink_hdr hdr = {NFCWILINK_CHNL, NFCWILINK_OPCODE, 0x0000};
|
||||||
long len;
|
long len;
|
||||||
|
@ -66,7 +66,7 @@ struct nci_dev;
|
|||||||
struct nci_ops {
|
struct nci_ops {
|
||||||
int (*open)(struct nci_dev *ndev);
|
int (*open)(struct nci_dev *ndev);
|
||||||
int (*close)(struct nci_dev *ndev);
|
int (*close)(struct nci_dev *ndev);
|
||||||
int (*send)(struct sk_buff *skb);
|
int (*send)(struct nci_dev *ndev, struct sk_buff *skb);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NCI_MAX_SUPPORTED_RF_INTERFACES 4
|
#define NCI_MAX_SUPPORTED_RF_INTERFACES 4
|
||||||
@ -153,7 +153,7 @@ struct nci_dev *nci_allocate_device(struct nci_ops *ops,
|
|||||||
void nci_free_device(struct nci_dev *ndev);
|
void nci_free_device(struct nci_dev *ndev);
|
||||||
int nci_register_device(struct nci_dev *ndev);
|
int nci_register_device(struct nci_dev *ndev);
|
||||||
void nci_unregister_device(struct nci_dev *ndev);
|
void nci_unregister_device(struct nci_dev *ndev);
|
||||||
int nci_recv_frame(struct sk_buff *skb);
|
int nci_recv_frame(struct nci_dev *ndev, struct sk_buff *skb);
|
||||||
|
|
||||||
static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev,
|
static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev,
|
||||||
unsigned int len,
|
unsigned int len,
|
||||||
|
@ -797,12 +797,11 @@ EXPORT_SYMBOL(nci_unregister_device);
|
|||||||
/**
|
/**
|
||||||
* nci_recv_frame - receive frame from NCI drivers
|
* nci_recv_frame - receive frame from NCI drivers
|
||||||
*
|
*
|
||||||
|
* @ndev: The nci device
|
||||||
* @skb: The sk_buff to receive
|
* @skb: The sk_buff to receive
|
||||||
*/
|
*/
|
||||||
int nci_recv_frame(struct sk_buff *skb)
|
int nci_recv_frame(struct nci_dev *ndev, struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct nci_dev *ndev = (struct nci_dev *) skb->dev;
|
|
||||||
|
|
||||||
pr_debug("len %d\n", skb->len);
|
pr_debug("len %d\n", skb->len);
|
||||||
|
|
||||||
if (!ndev || (!test_bit(NCI_UP, &ndev->flags) &&
|
if (!ndev || (!test_bit(NCI_UP, &ndev->flags) &&
|
||||||
@ -819,10 +818,8 @@ int nci_recv_frame(struct sk_buff *skb)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(nci_recv_frame);
|
EXPORT_SYMBOL(nci_recv_frame);
|
||||||
|
|
||||||
static int nci_send_frame(struct sk_buff *skb)
|
static int nci_send_frame(struct nci_dev *ndev, struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct nci_dev *ndev = (struct nci_dev *) skb->dev;
|
|
||||||
|
|
||||||
pr_debug("len %d\n", skb->len);
|
pr_debug("len %d\n", skb->len);
|
||||||
|
|
||||||
if (!ndev) {
|
if (!ndev) {
|
||||||
@ -833,7 +830,7 @@ static int nci_send_frame(struct sk_buff *skb)
|
|||||||
/* Get rid of skb owner, prior to sending to the driver. */
|
/* Get rid of skb owner, prior to sending to the driver. */
|
||||||
skb_orphan(skb);
|
skb_orphan(skb);
|
||||||
|
|
||||||
return ndev->ops->send(skb);
|
return ndev->ops->send(ndev, skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send NCI command */
|
/* Send NCI command */
|
||||||
@ -861,8 +858,6 @@ int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload)
|
|||||||
if (plen)
|
if (plen)
|
||||||
memcpy(skb_put(skb, plen), payload, plen);
|
memcpy(skb_put(skb, plen), payload, plen);
|
||||||
|
|
||||||
skb->dev = (void *) ndev;
|
|
||||||
|
|
||||||
skb_queue_tail(&ndev->cmd_q, skb);
|
skb_queue_tail(&ndev->cmd_q, skb);
|
||||||
queue_work(ndev->cmd_wq, &ndev->cmd_work);
|
queue_work(ndev->cmd_wq, &ndev->cmd_work);
|
||||||
|
|
||||||
@ -894,7 +889,7 @@ static void nci_tx_work(struct work_struct *work)
|
|||||||
nci_conn_id(skb->data),
|
nci_conn_id(skb->data),
|
||||||
nci_plen(skb->data));
|
nci_plen(skb->data));
|
||||||
|
|
||||||
nci_send_frame(skb);
|
nci_send_frame(ndev, skb);
|
||||||
|
|
||||||
mod_timer(&ndev->data_timer,
|
mod_timer(&ndev->data_timer,
|
||||||
jiffies + msecs_to_jiffies(NCI_DATA_TIMEOUT));
|
jiffies + msecs_to_jiffies(NCI_DATA_TIMEOUT));
|
||||||
@ -963,7 +958,7 @@ static void nci_cmd_work(struct work_struct *work)
|
|||||||
nci_opcode_oid(nci_opcode(skb->data)),
|
nci_opcode_oid(nci_opcode(skb->data)),
|
||||||
nci_plen(skb->data));
|
nci_plen(skb->data));
|
||||||
|
|
||||||
nci_send_frame(skb);
|
nci_send_frame(ndev, skb);
|
||||||
|
|
||||||
mod_timer(&ndev->cmd_timer,
|
mod_timer(&ndev->cmd_timer,
|
||||||
jiffies + msecs_to_jiffies(NCI_CMD_TIMEOUT));
|
jiffies + msecs_to_jiffies(NCI_CMD_TIMEOUT));
|
||||||
|
@ -80,8 +80,6 @@ static inline void nci_push_data_hdr(struct nci_dev *ndev,
|
|||||||
|
|
||||||
nci_mt_set((__u8 *)hdr, NCI_MT_DATA_PKT);
|
nci_mt_set((__u8 *)hdr, NCI_MT_DATA_PKT);
|
||||||
nci_pbf_set((__u8 *)hdr, pbf);
|
nci_pbf_set((__u8 *)hdr, pbf);
|
||||||
|
|
||||||
skb->dev = (void *) ndev;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nci_queue_tx_data_frags(struct nci_dev *ndev,
|
static int nci_queue_tx_data_frags(struct nci_dev *ndev,
|
||||||
|
Loading…
Reference in New Issue
Block a user