Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2178915iof; Tue, 7 Jun 2022 22:20:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFR+AINftWX6UHtKpdTldiYMzEYFUPyLpFROsfJ19zoqDWfkq3tGvyvq5/s61mx/stkNgx X-Received: by 2002:a63:f002:0:b0:3fd:8a00:817c with SMTP id k2-20020a63f002000000b003fd8a00817cmr15565730pgh.167.1654665607110; Tue, 07 Jun 2022 22:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665607; cv=none; d=google.com; s=arc-20160816; b=kOw77Snotrb6XxJbyRmyNfiDF1LO5kTVTdBn+eg2A4WFhUk5wldjeryiVSi6WGO1dW baoTEIDNQdTuVa/ypsWW6iy2Qb1bNmeR87hfJrdkyeNjXyqM6syroFsHv/y+WtyUM3pl 2vSrgUtwH7mzH4LfcZCXtHyXYKJprtRHwHtSEcAZJdtONwklHaLJVcnh+9wvatbONol6 V78uV1/Dts4u0SrsGRD7k+RrI1TIVxpovA2qZdzKCFTEi+KgqZqcgqsZzCu0X4cEYNNi mzo47dG0cSVdAb6dk3tIRatOB7BwM0ie/SWx5LxA3YE2A2GKoL5nkVLLsPvCV0q2moFj LzcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+lLp5gd+BKQGrE+PrO4BfxFmb7EIlomrVrP4RQltkxs=; b=Y363tI0240i8uYnHA1SnbvMybcQEOS+fKW6+zoTlTa9z2C1Vq+SJdvRRZaz83xKXts x2L5CuLZ5gZOTxhQezg23/S2ws8ZxBMEeeTCOjC1gAwxBgQqyEQ1SIbj1InVAmRnchYv rsxJTAtZEIOebqmejjGH9u4uShvgH+3OXHcrLkEcU1BFkDMPypZZljs/zUpSg6M5Ibpu szsYhRFjAv+2qCi/NqrXo5FuCerp0FRACHeHkeGdMv55d6v12U4+X0qZFtgEc5RyY7J+ iVIB+mbY+kW7PE9XGluGs9lA9I8swMdA5JgKGSN3nJiXrco8PObloyI75ypApHKXvkX8 N1Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ja4WJ22Y; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e2-20020a17090a684200b001d99bca4262si30812076pjm.50.2022.06.07.22.20.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:20:07 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ja4WJ22Y; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4EC5A24123B; Tue, 7 Jun 2022 21:48:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378423AbiFGV3u (ORCPT + 99 others); Tue, 7 Jun 2022 17:29:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378012AbiFGUep (ORCPT ); Tue, 7 Jun 2022 16:34:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 584951E8E99; Tue, 7 Jun 2022 11:37:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 89416B82182; Tue, 7 Jun 2022 18:37:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC68DC341CC; Tue, 7 Jun 2022 18:37:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627030; bh=4JI497rn1w5jLXa3fsVUm1N8VcEniotvqADpCf5bPZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ja4WJ22YzyOvma5gJiv8teeHYwN4j6oZRtiNdtXLH/Jk5CK0Otoc5/Dr8TuyxJCuk cg5EkIbhHD2IrDW4jxy5HY70WoGvh0kvG4IsEogeVDRwrXsmvoz01SKLjVG9kOSHOB k/VDAs7UWB6Cpe3g9T7J2eQ7NvkhkGtNtAOndC/4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tali Perry , Tyrone Ting , Wolfram Sang , Sasha Levin Subject: [PATCH 5.17 591/772] i2c: npcm: Fix timeout calculation Date: Tue, 7 Jun 2022 19:03:03 +0200 Message-Id: <20220607165006.361041110@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tali Perry [ Upstream commit 288b204492fddf28889cea6dc95a23976632c7a0 ] Use adap.timeout for timeout calculation instead of hard-coded value of 35ms. Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver") Signed-off-by: Tali Perry Signed-off-by: Tyrone Ting Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-npcm7xx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index 2ad166355ec9..92fd88a3f415 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -2047,7 +2047,7 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, u16 nwrite, nread; u8 *write_data, *read_data; u8 slave_addr; - int timeout; + unsigned long timeout; int ret = 0; bool read_block = false; bool read_PEC = false; @@ -2099,13 +2099,13 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, * 9: bits per transaction (including the ack/nack) */ timeout_usec = (2 * 9 * USEC_PER_SEC / bus->bus_freq) * (2 + nread + nwrite); - timeout = max(msecs_to_jiffies(35), usecs_to_jiffies(timeout_usec)); + timeout = max_t(unsigned long, bus->adap.timeout, usecs_to_jiffies(timeout_usec)); if (nwrite >= 32 * 1024 || nread >= 32 * 1024) { dev_err(bus->dev, "i2c%d buffer too big\n", bus->num); return -EINVAL; } - time_left = jiffies + msecs_to_jiffies(DEFAULT_STALL_COUNT) + 1; + time_left = jiffies + timeout + 1; do { /* * we must clear slave address immediately when the bus is not @@ -2269,7 +2269,7 @@ static int npcm_i2c_probe_bus(struct platform_device *pdev) adap = &bus->adap; adap->owner = THIS_MODULE; adap->retries = 3; - adap->timeout = HZ; + adap->timeout = msecs_to_jiffies(35); adap->algo = &npcm_i2c_algo; adap->quirks = &npcm_i2c_quirks; adap->algo_data = bus; -- 2.35.1