lkml.org 
[lkml]   [2020]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 240/261] mtd: rawnand: Fix nand_gpio_waitrdy()
    Date
    From: Boris Brezillon <boris.brezillon@collabora.com>

    commit e45a4b652dbd2f8b5a3b8e97e89f602a58cb28aa upstream.

    Mimic what's done in nand_soft_waitrdy() and add one to the jiffies
    timeout so we don't end up waiting less than actually required.

    Reported-by: Tudor Ambarus <tudor.ambarus@microchip.com>
    Fixes: b0e137ad24b6c ("mtd: rawnand: Provide helper for polling GPIO R/B pin")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
    Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
    Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Link: https://lore.kernel.org/linux-mtd/20200518155237.297549-1-boris.brezillon@collabora.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/mtd/nand/raw/nand_base.c | 10 ++++++++--
    1 file changed, 8 insertions(+), 2 deletions(-)

    --- a/drivers/mtd/nand/raw/nand_base.c
    +++ b/drivers/mtd/nand/raw/nand_base.c
    @@ -731,8 +731,14 @@ EXPORT_SYMBOL_GPL(nand_soft_waitrdy);
    int nand_gpio_waitrdy(struct nand_chip *chip, struct gpio_desc *gpiod,
    unsigned long timeout_ms)
    {
    - /* Wait until R/B pin indicates chip is ready or timeout occurs */
    - timeout_ms = jiffies + msecs_to_jiffies(timeout_ms);
    +
    + /*
    + * Wait until R/B pin indicates chip is ready or timeout occurs.
    + * +1 below is necessary because if we are now in the last fraction
    + * of jiffy and msecs_to_jiffies is 1 then we will wait only that
    + * small jiffy fraction - possibly leading to false timeout.
    + */
    + timeout_ms = jiffies + msecs_to_jiffies(timeout_ms) + 1;
    do {
    if (gpiod_get_value_cansleep(gpiod))
    return 0;

    \
     
     \ /
      Last update: 2020-06-19 17:53    [W:4.622 / U:0.172 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site