Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3018466rwb; Mon, 15 Aug 2022 16:15:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR4c3XcDJdt3FtDUscbuhPgPerMkqnQZKx0lUpm0mKeJntPjKMT/hiTX/7SCzKAu89CstfVc X-Received: by 2002:a17:906:8b81:b0:733:183b:988e with SMTP id nr1-20020a1709068b8100b00733183b988emr11718484ejc.457.1660605315967; Mon, 15 Aug 2022 16:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605315; cv=none; d=google.com; s=arc-20160816; b=z05HfP7eT6OBcDPhndHSZf4M0uEvw1NCn3NkKH8TrPhF7SMZKcJwHa8l+iMi5CysPO pgzpOM8PH+MA8eapxGc0Xv4hCTK6YjWhNZpcHwJBSwYWXVh/X/b1VIgg1qIgxHQ/4w7O 9OuSnnJT7/FD1aFGwhWg5cxTYWdZBb14gj0564eY10UUvKI6UVoXkXIgMrAe13/MSEN3 HkpHWukVi+GrIoO1NspwIebueXEQoSXbilHCykGI7LgBdxZRK3cPJJOI1PTjPJYzTSRe p0BiuMyb9KsCUyveeupeePlHsrwJ5fAInIa7OjwPETEq2aPqcevMhKSpc6/G3XZeiKDY Dd9g== 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=baPcXqZgw7cIcwq1XPSpiWY0WBuG/WrvOVA8/asxvoo=; b=vN3Kzu1BpJCPifdrYjX5em9rwEw1yenqtVJ1ZsrxwTyLgaiJrYBT8CkuXIy0/IU81i dm8kHqoE12Az8ztfhWlA+l7m252uAPVPfCrfmk3Hpx4In7BWoVOOq8wBgmbPs7TxE9H/ ddOlOvcTBKY5FMHBYtHHlO8xZZ1XDlNMP+caeSoxjTUMHjpQbMVefffmBrZIQwxfkgay xv7O1YGS4cebujANiHcEXVy480bY2k8P36HtmwVdTLdueHaP95wF0H+G5PHobVbU+06n eHn2Rpa0TTiMPJKMcc3m5xAlPMGy7yc5mgk5N7CJEocV7wa0bFvzdTwAX2e5ZHQMTH3v 4jsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EATJtiTT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm22-20020a170907949600b0073151a536f7si8365272ejc.313.2022.08.15.16.14.26; Mon, 15 Aug 2022 16:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EATJtiTT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244568AbiHOVCm (ORCPT + 99 others); Mon, 15 Aug 2022 17:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243990AbiHOVAY (ORCPT ); Mon, 15 Aug 2022 17:00:24 -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 53DBFC3F78; Mon, 15 Aug 2022 12:13:03 -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 80FA9B81113; Mon, 15 Aug 2022 19:13:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB9B1C433D6; Mon, 15 Aug 2022 19:12:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590780; bh=Y2uiP0tWBwL6vxqhyLR7WjAMopNb9WKuAgmZ1YDI9Ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EATJtiTTJbxQdoapJ55ndWb9BiYW5TfV1PCMvR8oAAgIK55hOcjg3Oe3LFC8lEHPG gP6h3bAZCd/z92x+rd3jwyOAvgE70ErplFHfsO+hyDQ/RnpDJEuMYVwjLNxapedA0J eVjF+BcUkRhb54XJm0sglQ+2O/B7nKbLygfos5o0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tali Perry , Tyrone Ting , Andy Shevchenko , Wolfram Sang , Sasha Levin Subject: [PATCH 5.18 0328/1095] i2c: npcm: Correct slave role behavior Date: Mon, 15 Aug 2022 19:55:27 +0200 Message-Id: <20220815180443.359172851@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 d7aa1b149b8fc04d802879cf4662010aa4a42deb ] Correct the slave transaction logic to be compatible with the generic slave backend driver. Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver") Signed-off-by: Tali Perry Signed-off-by: Tyrone Ting Reviewed-by: Andy Shevchenko Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-npcm7xx.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c index bc462d257baa..9f0462fb2504 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -912,11 +912,15 @@ static int npcm_i2c_slave_get_wr_buf(struct npcm_i2c *bus) for (i = 0; i < I2C_HW_FIFO_SIZE; i++) { if (bus->slv_wr_size >= I2C_HW_FIFO_SIZE) break; - i2c_slave_event(bus->slave, I2C_SLAVE_READ_REQUESTED, &value); + if (bus->state == I2C_SLAVE_MATCH) { + i2c_slave_event(bus->slave, I2C_SLAVE_READ_REQUESTED, &value); + bus->state = I2C_OPER_STARTED; + } else { + i2c_slave_event(bus->slave, I2C_SLAVE_READ_PROCESSED, &value); + } ind = (bus->slv_wr_ind + bus->slv_wr_size) % I2C_HW_FIFO_SIZE; bus->slv_wr_buf[ind] = value; bus->slv_wr_size++; - i2c_slave_event(bus->slave, I2C_SLAVE_READ_PROCESSED, &value); } return I2C_HW_FIFO_SIZE - ret; } @@ -964,7 +968,6 @@ static void npcm_i2c_slave_xmit(struct npcm_i2c *bus, u16 nwrite, if (nwrite == 0) return; - bus->state = I2C_OPER_STARTED; bus->operation = I2C_WRITE_OPER; /* get the next buffer */ -- 2.35.1