2019-04-09 04:21:03

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH 1/2] NFC: st95hf: use msleep for long delay

usleep_ranges is backed by hrtimers - for a delay of 50ms
notably in a loop using a hrtimer is of no benefit and
msleep() should be fine here (see
Documentation/timers/timers-howto.txt).

Signed-off-by: Nicholas Mc Guire <[email protected]>
---

Problem located with an experimental coccinelle script

Patch was compile tested with: x86_64_defconfig + SPI=y,
NFC=y, NFC_DIGITAL=y, NFC_ST95HF=m

Patch is against 5.1-rc3 (localversion-next is -next-20190408)

drivers/nfc/st95hf/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c
index a50a95c..34bf1d7 100644
--- a/drivers/nfc/st95hf/core.c
+++ b/drivers/nfc/st95hf/core.c
@@ -535,7 +535,7 @@ static int st95hf_por_sequence(struct st95hf_context *st95context)
st95hf_send_spi_reset_sequence(st95context);

/* delay of 50 milisecond */
- usleep_range(50000, 51000);
+ msleep(50);
} while (nth_attempt++ < 3);

return -ETIMEDOUT;
--
2.1.4



2019-04-09 04:21:05

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH 2/2] NFC: st95hf: fix timing factor error

The comment suggests that per ISO standard 5-6ms are required
but the code is 50-60ms delay - look like a simple typo - so
set the delay to 5000 to 6000.

Signed-off-by: Nicholas Mc Guire <[email protected]>
Fixes: cab47333f0f7 ("NFC: Add STMicroelectronics ST95HF driver")
---

Problem located with an experimental coccinelle script

Note that as I do not have the standard - it could of course
also be a typo in the comment - in which case it should
then probably be using msleep(60) not usleep_ranges().

Patch was compile tested with: x86_64_defconfig + SPI=y,
NFC=y, NFC_DIGITAL=y, NFC_ST95HF=m

Patch is against 5.1-rc3 (localversion-next is -next-20190408)

drivers/nfc/st95hf/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nfc/st95hf/core.c b/drivers/nfc/st95hf/core.c
index 34bf1d7..89e6160 100644
--- a/drivers/nfc/st95hf/core.c
+++ b/drivers/nfc/st95hf/core.c
@@ -430,7 +430,7 @@ static int st95hf_select_protocol(struct st95hf_context *stcontext, int type)
* delay of 5-6 ms is required after select protocol
* command in case of ISO14443 Type B
*/
- usleep_range(50000, 60000);
+ usleep_range(5000, 6000);

/* secondary config. for 14443Type 4B after protocol select */
result = secondary_configuration_type4b(stcontext);
--
2.1.4