mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 20:33:58 -04:00
Merge "NFC: Add timeout when waiting for responses in probe"
This commit is contained in:
commit
d9918c71df
2 changed files with 27 additions and 5 deletions
|
|
@ -199,11 +199,28 @@ int i3c_nci_kbuf_retrieve(struct nfc_dev *dev, char *buf,
|
|||
break;
|
||||
|
||||
reinit_completion(&i3c_dev->read_cplt);
|
||||
ret = wait_for_completion_interruptible(&i3c_dev->read_cplt);
|
||||
if (ret != 0) {
|
||||
pr_err("didn't get completion, interrupted!! ret %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
/*
|
||||
* During probe if there is no response for NCI commands,
|
||||
* probe shouldn't be blocked, that is why timeout is added.
|
||||
*/
|
||||
|
||||
if (i3c_dev->is_probe_done) {
|
||||
ret = wait_for_completion_interruptible(
|
||||
&i3c_dev->read_cplt);
|
||||
if (ret != 0) {
|
||||
pr_err("nfc completion interrupted! ret %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
ret = wait_for_completion_interruptible_timeout(
|
||||
&i3c_dev->read_cplt,
|
||||
msecs_to_jiffies(MAX_IBI_WAIT_TIME));
|
||||
if (ret <= 0) {
|
||||
pr_err("nfc completion timedout ret %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
} while (available_size < requested_size);
|
||||
|
||||
|
|
@ -675,6 +692,7 @@ int nfc_i3c_dev_probe(struct i3c_device *device)
|
|||
|
||||
atomic_set(&nfc_dev->i3c_dev.pm_state, PM_STATE_NORMAL);
|
||||
device_init_wakeup(&device->dev, true);
|
||||
nfc_dev->i3c_dev.is_probe_done = true;
|
||||
|
||||
pr_info("%s success\n", __func__);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@
|
|||
// I3C WorkQueue name
|
||||
#define NFC_I3C_WORKQUEUE "nfc_i3c_workq"
|
||||
|
||||
/* Time(in ms) to wait for NCI packet respones */
|
||||
#define MAX_IBI_WAIT_TIME (2000)
|
||||
struct nfc_dev;
|
||||
|
||||
/**
|
||||
|
|
@ -72,6 +74,7 @@ struct nci_buf {
|
|||
* @ibi_enabled: IBI enabled or not.
|
||||
* @pm_state: PM state of NFC I3C device.
|
||||
* @nfc_read_direct Do NFC read bypassing the read buffer.
|
||||
* @is_probe_done Is NFC I3C probe completed.
|
||||
*/
|
||||
struct i3c_dev {
|
||||
struct i3c_device *device;
|
||||
|
|
@ -87,6 +90,7 @@ struct i3c_dev {
|
|||
atomic_t pm_state;
|
||||
int (*nfc_read_direct)(struct nfc_dev *dev,
|
||||
char *buf, size_t count);
|
||||
bool is_probe_done;
|
||||
};
|
||||
|
||||
int nfc_i3c_dev_probe(struct i3c_device *device);
|
||||
|
|
|
|||
Loading…
Reference in a new issue