Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3033227rwb; Mon, 15 Aug 2022 16:32:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kOGR1ramToDra0K2FZSYtieFxk0BkUw5Q+PM19gDU6/wqHX0hN7/0zNyw6fQGoGekF2Ku X-Received: by 2002:a17:907:724b:b0:731:48b3:6fed with SMTP id ds11-20020a170907724b00b0073148b36fedmr12007090ejc.405.1660606364192; Mon, 15 Aug 2022 16:32:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660606364; cv=none; d=google.com; s=arc-20160816; b=YiqjF8rHzVqfZoe0L1sLzx24OaZX2RVFradGTKvgYUlHqlG/GJ/M7oBEpjhr5LeLpP ib76kmAHKLI15Ui/txZMB+ywCbHlSnIvoOE1vcARKREJ+Pne+0mYQILhp+cT+6YFqGuI 73MaKA87h4xFFAyPodRRFok8w+vlfgjARK4bQKP9+p0tOgCMREMwS5XiL8HD8I6Oin4/ XCFnUhitkCrFh8sWtdfFYahM0yOO8Kkln3SNqNbTEYPuOeryuc+GRHzO5PR4exJgbS4n UXkumiJf2SllyvtwayWbKvRJ9g42BKixaoF8q87iTN0SVF8U0TU4wooMtyEJoIg91L6q 87nQ== 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=xl2kfJlT6XHzZzD/a8wrAwHZ/Q9YOGrK4t0P4iPAkJU=; b=qzoN2UsvqAPPnU1/wueZs2HXeUGSTUSqtfwk0LtftOb+E3KCfZvP22QFj8yed7v7Pw j1o1+qV5hKzM1roRTPcQRrb6wSWhFeFnCSxGazg06gXYN7qZsVxDd3eZ9CnLdCUKv3Aq vUprMsHg/WkRUtELh1BEQAfs2nQ9yqFNdqla99SI+E5LblMnIgNkWqRvvSPyBaMDwlrv f8LFEABlO6RKq/YF20V0LW96KQKaCM4lK1RHak7BwnIvZ/5pck1NpUKZANqxMUESAy7p K3I57HhvwVwpC3aOeBiK2kkdNTzVCIcYdIBSeiNcCylGfeAJO/Z6rVf517XBs7AD42hO hSNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ic1lPlCd; 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 f12-20020a056402354c00b0043bb8df080fsi8410460edd.606.2022.08.15.16.32.12; Mon, 15 Aug 2022 16:32:44 -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=ic1lPlCd; 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 S1345942AbiHOX05 (ORCPT + 99 others); Mon, 15 Aug 2022 19:26:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353267AbiHOXWA (ORCPT ); Mon, 15 Aug 2022 19:22:00 -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 09DC37E817; Mon, 15 Aug 2022 13:05:08 -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 8BACEB80EB1; Mon, 15 Aug 2022 20:05:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBF18C433D6; Mon, 15 Aug 2022 20:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593905; bh=catCIrF+FyTL0WjZLHY3p3AfBbLlV9/q/eoNToE/gr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ic1lPlCd9HWZ/7fIzcoFaPSiIaqL4GvNdgr5P0ZZwvJZl4CczARQdoeF6h0x/2oDr 4olFz7QJX9I65P6P556k+9D+WQyC8UI0WZjaQJ9/w8+whtto0EC1AHD80wqRKeEgoZ mZJtvFNLNUIP3y07rsuYwiwHWMPfwLfTHXEL2S4g= 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.19 0346/1157] i2c: npcm: Correct slave role behavior Date: Mon, 15 Aug 2022 19:55:02 +0200 Message-Id: <20220815180453.551332627@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 f3177cff9591..7b112be5e35c 100644 --- a/drivers/i2c/busses/i2c-npcm7xx.c +++ b/drivers/i2c/busses/i2c-npcm7xx.c @@ -915,11 +915,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; } @@ -967,7 +971,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