NFC: digital: Add a delay between poll cycles
This replaces the polling work struct with a delayed work struct and add a 10 ms delay between 2 poll cycles. This avoids to flood the device with 'switch off'/'switch on' commands. Signed-off-by: Thierry Escande <thierry.escande@collabora.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Родитель
a81ba50a89
Коммит
7854a44526
|
@ -220,7 +220,7 @@ struct nfc_digital_dev {
|
||||||
struct list_head cmd_queue;
|
struct list_head cmd_queue;
|
||||||
struct mutex cmd_lock;
|
struct mutex cmd_lock;
|
||||||
|
|
||||||
struct work_struct poll_work;
|
struct delayed_work poll_work;
|
||||||
|
|
||||||
u8 curr_protocol;
|
u8 curr_protocol;
|
||||||
u8 curr_rf_tech;
|
u8 curr_rf_tech;
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
|
|
||||||
#define DIGITAL_PROTO_ISO15693_RF_TECH NFC_PROTO_ISO15693_MASK
|
#define DIGITAL_PROTO_ISO15693_RF_TECH NFC_PROTO_ISO15693_MASK
|
||||||
|
|
||||||
|
/* Delay between each poll frame (ms) */
|
||||||
|
#define DIGITAL_POLL_INTERVAL 10
|
||||||
|
|
||||||
struct digital_cmd {
|
struct digital_cmd {
|
||||||
struct list_head queue;
|
struct list_head queue;
|
||||||
|
|
||||||
|
@ -419,7 +422,8 @@ void digital_poll_next_tech(struct nfc_digital_dev *ddev)
|
||||||
|
|
||||||
mutex_unlock(&ddev->poll_lock);
|
mutex_unlock(&ddev->poll_lock);
|
||||||
|
|
||||||
schedule_work(&ddev->poll_work);
|
schedule_delayed_work(&ddev->poll_work,
|
||||||
|
msecs_to_jiffies(DIGITAL_POLL_INTERVAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void digital_wq_poll(struct work_struct *work)
|
static void digital_wq_poll(struct work_struct *work)
|
||||||
|
@ -428,7 +432,7 @@ static void digital_wq_poll(struct work_struct *work)
|
||||||
struct digital_poll_tech *poll_tech;
|
struct digital_poll_tech *poll_tech;
|
||||||
struct nfc_digital_dev *ddev = container_of(work,
|
struct nfc_digital_dev *ddev = container_of(work,
|
||||||
struct nfc_digital_dev,
|
struct nfc_digital_dev,
|
||||||
poll_work);
|
poll_work.work);
|
||||||
mutex_lock(&ddev->poll_lock);
|
mutex_lock(&ddev->poll_lock);
|
||||||
|
|
||||||
if (!ddev->poll_tech_count) {
|
if (!ddev->poll_tech_count) {
|
||||||
|
@ -543,7 +547,7 @@ static int digital_start_poll(struct nfc_dev *nfc_dev, __u32 im_protocols,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
schedule_work(&ddev->poll_work);
|
schedule_delayed_work(&ddev->poll_work, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -564,7 +568,7 @@ static void digital_stop_poll(struct nfc_dev *nfc_dev)
|
||||||
|
|
||||||
mutex_unlock(&ddev->poll_lock);
|
mutex_unlock(&ddev->poll_lock);
|
||||||
|
|
||||||
cancel_work_sync(&ddev->poll_work);
|
cancel_delayed_work_sync(&ddev->poll_work);
|
||||||
|
|
||||||
digital_abort_cmd(ddev);
|
digital_abort_cmd(ddev);
|
||||||
}
|
}
|
||||||
|
@ -770,7 +774,7 @@ struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops,
|
||||||
INIT_WORK(&ddev->cmd_complete_work, digital_wq_cmd_complete);
|
INIT_WORK(&ddev->cmd_complete_work, digital_wq_cmd_complete);
|
||||||
|
|
||||||
mutex_init(&ddev->poll_lock);
|
mutex_init(&ddev->poll_lock);
|
||||||
INIT_WORK(&ddev->poll_work, digital_wq_poll);
|
INIT_DELAYED_WORK(&ddev->poll_work, digital_wq_poll);
|
||||||
|
|
||||||
if (supported_protocols & NFC_PROTO_JEWEL_MASK)
|
if (supported_protocols & NFC_PROTO_JEWEL_MASK)
|
||||||
ddev->protocols |= NFC_PROTO_JEWEL_MASK;
|
ddev->protocols |= NFC_PROTO_JEWEL_MASK;
|
||||||
|
@ -832,7 +836,7 @@ void nfc_digital_unregister_device(struct nfc_digital_dev *ddev)
|
||||||
ddev->poll_tech_count = 0;
|
ddev->poll_tech_count = 0;
|
||||||
mutex_unlock(&ddev->poll_lock);
|
mutex_unlock(&ddev->poll_lock);
|
||||||
|
|
||||||
cancel_work_sync(&ddev->poll_work);
|
cancel_delayed_work_sync(&ddev->poll_work);
|
||||||
cancel_work_sync(&ddev->cmd_work);
|
cancel_work_sync(&ddev->cmd_work);
|
||||||
cancel_work_sync(&ddev->cmd_complete_work);
|
cancel_work_sync(&ddev->cmd_complete_work);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче