From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E194D3E7BCF; Mon, 8 Jun 2026 20:16:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780949789; cv=none; b=O6ehzb6i8cplsuaw5GQPdcB2UKkDbgbQTs8COBPTni+bgZQApSXo1SKIV/p4D393j+MBKI2jpvGqcJjSfcNDHhrL2hM1pCnFoCQ6oBy0+ChumGQoJ0EkC1D1hDLP6rnSGAvufOpzT89i9CSGSmwSvlodclWRQZnjDFaECIP3k4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780949789; c=relaxed/simple; bh=TEr7jiW1tdVK0sSquMRLdZ0+T94cmxOWGNuw2a7SL3w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hMXw/CEKgzoyN2WOliSG+gI+yDItqCYJkMgapVRwq5+Kf9mCeari/ZMcW4lNTfK6IGg5iJlkpy8Owq+CWjJdqkoeKM+5SZkP8IcfJsIRyPO9jLbOeq84Ky4eLRgUpde8cai3sYn1KJbVA8GH6vvk0M2DeZDXZVGIS/P+aNyq8tc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=STQCalbn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="STQCalbn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C802D1F00898; Mon, 8 Jun 2026 20:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780949786; bh=4sswhCww2SM+DB6DdlgyOdcgr7VXPLt6ZjUt7zMH8B4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=STQCalbnwy7GlJiV4ucOC7dItPB3uFcfObTp0txXXDvcnV4h2GRTVltLX80FGOqDk CXCMYg8MtUxNR0+37vlRHJgibYHauTrlxSSHFbN2BXFuBre4mwZTAHue0/cRZ49ZmR HcgCz0N2d5c5WMG2ob7l1wgG6G2eAN9Ib5L6LurqcGFDk5szKvMyz+pY11eN+9vk+K c0sCV2O6GdsMqg9XesEXBLW/N2vjOKrEl4GEJ4kXmB4FuuB4ZYxvH8DZslRGGONT1w XAZ4tQtgHNJC4IzfI90Nmg20fhm6PpqdaLfAfXL0PkuWV18tO1kllGkDRvkCF6xlXp jnPlDRnXKxttg== From: Claudiu Beznea To: wsa+renesas@sang-engineering.com, tommaso.merciai.xr@bp.renesas.com, alexandre.belloni@bootlin.com, Frank.Li@nxp.com, p.zabel@pengutronix.de Cc: claudiu.beznea@kernel.org, claudiu.beznea@tuxon.dev, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Claudiu Beznea Subject: [PATCH v3 11/17] i3c: renesas: Follow a unified pattern for transfer and command initialization Date: Mon, 8 Jun 2026 23:15:37 +0300 Message-ID: <20260608201543.804902-12-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260608201543.804902-1-claudiu.beznea@kernel.org> References: <20260608201543.804902-1-claudiu.beznea@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Claudiu Beznea Follow a unified pattern for transfer and command initialization across the driver. This keeps the code cleaner and easier to follow. Also, in some cases the I3C device was enabled before the transfer data structure was even allocated. Reviewed-by: Frank Li Signed-off-by: Claudiu Beznea --- Changes in v3: - none Changes in v2: - collected tags drivers/i3c/master/renesas-i3c.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/i3c/master/renesas-i3c.c b/drivers/i3c/master/renesas-i3c.c index 1fd39dd57847..4504c6e6db31 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -726,6 +726,10 @@ static int renesas_i3c_daa(struct i3c_master_controller *m) if (!xfer) return -ENOMEM; + init_completion(&xfer->comp); + cmd = xfer->cmds; + cmd->rx_count = 0; + /* Enable I3C bus. */ renesas_i3c_bus_enable(m, true); @@ -756,10 +760,6 @@ static int renesas_i3c_daa(struct i3c_master_controller *m) renesas_writel(i3c->regs, DATBAS(pos), datbas_dvdyad_with_parity(ret)); } - init_completion(&xfer->comp); - cmd = xfer->cmds; - cmd->rx_count = 0; - if (i3c->resuming) { /* Run ENTDAA for all the I3C devices on the bus, if resuming. */ ret = first_i3c_pos; @@ -883,13 +883,13 @@ static int renesas_i3c_send_ccc_cmd(struct i3c_master_controller *m, if (!xfer) return -ENOMEM; - renesas_i3c_bus_enable(m, true); - init_completion(&xfer->comp); cmd = xfer->cmds; cmd->rnw = ccc->rnw; cmd->cmd0 = 0; + renesas_i3c_bus_enable(m, true); + /* Calculate the command descriptor. */ switch (ccc->id) { case I3C_CCC_SETDASA: @@ -939,15 +939,15 @@ static int renesas_i3c_i3c_xfers(struct i3c_dev_desc *dev, struct i3c_xfer *i3c_ struct renesas_i3c_i2c_dev_data *data = i3c_dev_get_master_data(dev); int i; - /* Enable I3C bus. */ - renesas_i3c_bus_enable(m, true); - struct renesas_i3c_xfer *xfer __free(kfree) = renesas_i3c_alloc_xfer(i3c, 1); if (!xfer) return -ENOMEM; init_completion(&xfer->comp); + /* Enable I3C bus. */ + renesas_i3c_bus_enable(m, true); + for (i = 0; i < i3c_nxfers; i++) { struct renesas_i3c_cmd *cmd = xfer->cmds; @@ -1073,12 +1073,12 @@ static int renesas_i3c_i2c_xfers(struct i2c_dev_desc *dev, if (!xfer) return -ENOMEM; - renesas_i3c_bus_enable(m, false); - init_completion(&xfer->comp); xfer->is_i2c_xfer = true; cmd = xfer->cmds; + renesas_i3c_bus_enable(m, false); + if (!(renesas_readl(i3c->regs, BCST) & BCST_BFREF)) { cmd->err = -EBUSY; return cmd->err; -- 2.43.0