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 5A6123E7BC2 for ; Tue, 2 Jun 2026 13:29:10 +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=1780406951; cv=none; b=PZAhGPkaKffhIhZcSyNkjQHTc4WqHdy/Wb6bT/zqgWbAeRr9ZxLoJaxm7uODKhq5Z8HfqVSpUpmIdFMPWtnENhuxzXJmmHeB7bJyiNFmo/EQOkTkywO69ayXTpXfQ8GxljOYMQtbUTFshh031sxnDE6wbezi/GQRTO8DTn5Zy50= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780406951; c=relaxed/simple; bh=tgVVlSyYOTJDiVPVZXcyTXLuNA09VfTmvTcNL9J3tJk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WwlrmouYrhc5XZf6fa2B2SgoKzCrwOTE6GbufIJYsE8ZU6x5wq/JdJrpgWUlurrpFO1heZgzgEMNTU0FAda0duHvCBvJwSE+KwJlg7O6BnA8ectheY+PWeqfLsAa5Cg/ZcBLk0O2cAK/nRD6TyHQy5cd+vTK7J4wtk+1vEu0S64= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hZNwz7sy; 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="hZNwz7sy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7D961F00898; Tue, 2 Jun 2026 13:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780406950; bh=kB0mTS4bPznyvBQvcWqNat3upb4ComylAy+AiC3M3g8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hZNwz7syLcUbmrM/ow3xjYOeuPvPmns+4mYEF4P9cQF4Z9TlaSqtMSeFzTyEM/H7f +pTrJRNfVeu7Op0Y7NqLn8TghYfLW+gAhy26IkEWcW/l1RS++paQIc8medr431uOkP FXZ995RW3mnEEBwwvUVKygZuP7zrLFJE5kHFXJx0LZHwR3q9xooM/XGpcfhgxiYxVl EzAUkLFpcm0RFFrwdNHuZ6D7HgSi4Q7R2+xtsCxnsSKUNOVSmP8a2jvleiEdfgH3KC HZ7cocmsPGQdNGf/EzVtUyEXyQdONmFTiolkLKC2y0OKGntx7Hgznq2mc5pBMcCDDQ eE3FBm5pLTBUg== 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, Claudiu Beznea Subject: [PATCH v2 11/17] i3c: renesas: Follow a unified pattern for transfer and command initialization Date: Tue, 2 Jun 2026 16:28:18 +0300 Message-ID: <20260602132824.3541151-12-claudiu.beznea@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260602132824.3541151-1-claudiu.beznea@kernel.org> References: <20260602132824.3541151-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 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 ed925b673b38..601d879fce9d 100644 --- a/drivers/i3c/master/renesas-i3c.c +++ b/drivers/i3c/master/renesas-i3c.c @@ -656,6 +656,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); @@ -696,10 +700,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) { /* Nothing to do if all slots are ocupied by I2C devices. */ if (last_i2c_pos == i3c->maxdevs - 1) @@ -804,13 +804,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: @@ -860,15 +860,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; @@ -989,12 +989,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