aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorThierry Escande <thierry.escande@collabora.com>2016-07-19 05:58:17 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2016-07-19 17:24:49 -0400
commit2a0fe4fe5bf2a6e2277354e7e8f369a20d881891 (patch)
tree79c35f3dc21422ec56ba41e0da9049843272e527 /drivers/nfc
parentf9ac6273e5b8fa45e7cd2086e1bbc91af9af7f19 (diff)
NFC: nfcsim: Simulate lost frames through debugfs entry
This patch allows to simulate the lost of frames exchanged between the 2 nfcsim devices through a control entry in the debugfs and is used as follow: echo n > /sys/kernel/debug/nfcsim/nfcX/dropframe Where n specifies the number of frames to be dropped between 0 and 255 and nfcX is either nfc0 or nfc1, one of the two nfcsim devices. In the following example, the next frame that should be sent by the nfc0 device will be dropped and thus not received by the nfc1 device: echo 1 > /sys/kernel/debug/nfcsim/nfc0/dropframe The value of 0 can be used to reset the dropframe counter. Signed-off-by: Thierry Escande <thierry.escande@collabora.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/nfcsim.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/nfc/nfcsim.c b/drivers/nfc/nfcsim.c
index 97067a5f248c..a466e7978466 100644
--- a/drivers/nfc/nfcsim.c
+++ b/drivers/nfc/nfcsim.c
@@ -54,6 +54,8 @@ struct nfcsim {
54 54
55 nfc_digital_cmd_complete_t cb; 55 nfc_digital_cmd_complete_t cb;
56 void *arg; 56 void *arg;
57
58 u8 dropframe;
57}; 59};
58 60
59struct nfcsim_link { 61struct nfcsim_link {
@@ -223,6 +225,14 @@ static int nfcsim_send(struct nfc_digital_dev *ddev, struct sk_buff *skb,
223 225
224 schedule_work(&dev->recv_work); 226 schedule_work(&dev->recv_work);
225 227
228 if (dev->dropframe) {
229 NFCSIM_DBG(dev, "dropping frame (out of %d)\n", dev->dropframe);
230 dev_kfree_skb(skb);
231 dev->dropframe--;
232
233 return 0;
234 }
235
226 if (skb) { 236 if (skb) {
227 nfcsim_link_set_skb(dev->link_out, skb, dev->rf_tech, 237 nfcsim_link_set_skb(dev->link_out, skb, dev->rf_tech,
228 dev->mode); 238 dev->mode);
@@ -372,6 +382,8 @@ static void nfcsim_debugfs_init_dev(struct nfcsim *dev)
372 idx); 382 idx);
373 return; 383 return;
374 } 384 }
385
386 debugfs_create_u8("dropframe", 0664, dev_dir, &dev->dropframe);
375} 387}
376 388
377static struct nfcsim *nfcsim_device_new(struct nfcsim_link *link_in, 389static struct nfcsim *nfcsim_device_new(struct nfcsim_link *link_in,