Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2286283iof; Wed, 8 Jun 2022 01:27:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBdWBUMjgp5ifUvr2kTd4TX/4e8vB4kGnSv8Cpn7grC8fcqvH2Ud1+r+RYEDqOQDyv9sNh X-Received: by 2002:a17:902:d4cc:b0:167:735a:e796 with SMTP id o12-20020a170902d4cc00b00167735ae796mr16887680plg.5.1654676855739; Wed, 08 Jun 2022 01:27:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654676855; cv=none; d=google.com; s=arc-20160816; b=IeO9RCMEiD5TaHHmLN5ki6m5hLQQLO1qaeXRNlcUAgiLdQh/do69lQcTYDJilceTzS Oc7lU58FOBlruHKfRDUnAXxBgu0UiU7fOkWidzNGW7Nq4GIp55QC3WmleUg7Wb7GGWIK FDlMQ4MrmODoPgRhMQ1IFwJB3hsKmK5xk2k9P1JM2qoHrXA74ZOGfL698wphUOf7Eiyz GeveVPl4yNhVdzpqIy7N21SbNZpYFOe/QOxGxvgDtP6zUs5NDJ7k6Tnqk5aGiaiNH3/J Zyh9jJmWD8ZxhkKGR5gLWGzbmpFH/p2fxRCyGo3oFhywQcRWaaa6FQWmXYa1PyCck4b4 /PoA== 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=k5CVs0djECAJqFenIQCYX9VbEVFXsqlUHTTKoQFejsw=; b=UGlTuD0FIIJzOoiiwGjDCDwLkSC7pWvRgNEI04knTI3t/GnfQ7LLZrTkueYCKdIrVq vNkj8ACXYyWkB+VuQv9ML5YJ7MdVjB0SVDoUkdoBkn9Smsps7hZi0FNFBZSjU0sDiiMk qgHLyGAF8PkwFnRHL0HvdPblDQg8xSGz1ofSurnXzsmTMRyLRV3zlj2p0usiierZDDUm +dMZm9Wq1DM9i2WLAEHBACAqAIOOAVxG+x4QvAuJZgatj1V5Ip9v8A+DfG7EVe/zPjy/ 7nWvcZbB7iIsBv2C6RO5qoMpn7r82ak9fOZoC8aasnaTHFyNGh0Ls1z8W5lHMr5nasIU af+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0uM1UTuC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q14-20020a056a00150e00b0051c29910f1asi9301515pfu.358.2022.06.08.01.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:27:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0uM1UTuC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 9AE6E114ABA; Wed, 8 Jun 2022 00:57:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391432AbiFHBG1 (ORCPT + 99 others); Tue, 7 Jun 2022 21:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383698AbiFGWGJ (ORCPT ); Tue, 7 Jun 2022 18:06:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACB34252263; Tue, 7 Jun 2022 12:17:10 -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 69786B8237B; Tue, 7 Jun 2022 19:17:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D523EC385A2; Tue, 7 Jun 2022 19:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629428; bh=Ob6VwZuU3rWyoNxtlrLAYRh2YRDyw9eDf7Q7qexScRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0uM1UTuCZjaIlBkSt2kqnhhw+LfXAksyyGOtD9Gtv0jccbeADOmPNtzLDx9bj6ImJ FvLIMlfROPEdYTt+nVz0VjoUbO3joaKuFc3fIa6V9OuXKpfKqbuU6cf276PdZLcfSN BVy1p1I0/OOlpUOJrxbrMXw1ckf+VIyOkRxt/P/E= 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.18 688/879] i2c: npcm: Fix timeout calculation Date: Tue, 7 Jun 2022 19:03:26 +0200 Message-Id: <20220607165022.820580845@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 71aad029425d..635ebba52b08 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