OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anup Patel <apatel@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH 07/12] lib: utils: Improve variable declarations in MPXY RPMI mailbox client
Date: Thu, 16 Jan 2025 21:26:46 +0530	[thread overview]
Message-ID: <20250116155651.103782-8-apatel@ventanamicro.com> (raw)
In-Reply-To: <20250116155651.103782-1-apatel@ventanamicro.com>

The local variable declarations should be at the start of function
and preferrably organized like a inverted pyramid.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c | 31 ++++++++++++-----------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c b/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c
index 26b9e6a6..27f4c571 100644
--- a/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c
+++ b/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c
@@ -34,8 +34,8 @@ struct mpxy_rpmi_mbox {
 static const struct mpxy_rpmi_service_data *mpxy_find_rpmi_srvid(u32 message_id,
 					const struct mpxy_rpmi_mbox_data *mbox_data)
 {
-	int mid = 0;
 	const struct mpxy_rpmi_service_data *srv = mbox_data->service_data;
+	int mid = 0;
 
 	for (mid = 0; srv[mid].id < mbox_data->num_services; mid++) {
 		if (srv[mid].id == (u8)message_id)
@@ -57,12 +57,10 @@ static int mpxy_mbox_read_attributes(struct sbi_mpxy_channel *channel,
 				     u32 *outmem, u32 base_attr_id,
 				     u32 attr_count)
 {
-	u32 end_id;
 	struct mpxy_rpmi_mbox *rmb =
 		container_of(channel, struct mpxy_rpmi_mbox, channel);
 	u32 *attr_array = (u32 *)&rmb->msgprot_attrs;
-
-	end_id = base_attr_id + attr_count - 1;
+	u32 end_id = base_attr_id + attr_count - 1;
 
 	if (end_id >= MPXY_MSGPROT_RPMI_ATTR_MAX_ID)
 		return SBI_EBAD_RANGE;
@@ -108,12 +106,11 @@ static int mpxy_mbox_write_attributes(struct sbi_mpxy_channel *channel,
 				     u32 *outmem, u32 base_attr_id,
 				     u32 attr_count)
 {
-	int ret, mem_idx;
-	u32 end_id, attr_val, idx;
 	struct mpxy_rpmi_mbox *rmb =
 		container_of(channel, struct mpxy_rpmi_mbox, channel);
-
-	end_id = base_attr_id + attr_count - 1;
+	u32 end_id = base_attr_id + attr_count - 1;
+	u32 attr_val, idx;
+	int ret, mem_idx;
 
 	if (end_id >= MPXY_MSGPROT_RPMI_ATTR_MAX_ID)
 		return SBI_EBAD_RANGE;
@@ -140,15 +137,15 @@ static int __mpxy_mbox_send_message(struct sbi_mpxy_channel *channel,
 				  void *rx, u32 rx_max_len,
 				  unsigned long *ack_len)
 {
-	int ret;
-	u32 rx_len = 0;
-	struct mbox_xfer xfer;
-	struct rpmi_message_args args = {0};
 	struct mpxy_rpmi_mbox *rmb =
 		container_of(channel, struct mpxy_rpmi_mbox, channel);
 	const struct mpxy_rpmi_mbox_data *data = rmb->mbox_data;
 	const struct mpxy_rpmi_service_data *srv =
 		mpxy_find_rpmi_srvid(message_id, data);
+	struct rpmi_message_args args = {0};
+	struct mbox_xfer xfer;
+	u32 rx_len = 0;
+	int ret;
 
 	if (!srv)
 		return SBI_ENOTSUPP;
@@ -215,12 +212,12 @@ static int mpxy_mbox_send_message_withoutresp(struct sbi_mpxy_channel *channel,
 
 int mpxy_rpmi_mbox_init(const void *fdt, int nodeoff, const struct fdt_match *match)
 {
-	int rc, len;
+	const struct mpxy_rpmi_mbox_data *data = match->data;
+	struct mpxy_rpmi_mbox *rmb;
+	struct mbox_chan *chan;
 	const fdt32_t *val;
 	u32 channel_id;
-	struct mbox_chan *chan;
-	struct mpxy_rpmi_mbox *rmb;
-	const struct mpxy_rpmi_mbox_data *data = match->data;
+	int rc, len;
 
 	/* Allocate context for RPXY mbox client */
 	rmb = sbi_zalloc(sizeof(*rmb));
@@ -270,8 +267,6 @@ int mpxy_rpmi_mbox_init(const void *fdt, int nodeoff, const struct fdt_match *ma
 					mpxy_mbox_send_message_withresp;
 	rmb->channel.send_message_without_response =
 					mpxy_mbox_send_message_withoutresp;
-	/* No callback to switch events state data */
-	rmb->channel.switch_eventsstate = NULL;
 
 	/* RPMI Message Protocol ID */
 	rmb->channel.attrs.msg_proto_id = SBI_MPXY_MSGPROTO_RPMI_ID;
-- 
2.43.0



  parent reply	other threads:[~2025-01-16 15:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 15:56 [PATCH 00/12] More RPMI and MPXY updates Anup Patel
2025-01-16 15:56 ` [PATCH 01/12] lib: utils: Split the FDT MPXY RPMI mailbox client into two parts Anup Patel
2025-01-19 22:52   ` Samuel Holland
2025-01-20  4:49     ` Anup Patel
2025-01-16 15:56 ` [PATCH 02/12] lib: utils: Constantify mpxy_rpmi_mbox_data in mpxy_rpmi_mbox Anup Patel
2025-01-19 22:54   ` Samuel Holland
2025-01-20  5:12     ` Anup Patel
2025-01-16 15:56 ` [PATCH 03/12] lib: utils: Introduce optional MPXY RPMI service group operations Anup Patel
2025-01-19 22:58   ` Samuel Holland
2025-01-20  8:05     ` Anup Patel
2025-01-16 15:56 ` [PATCH 04/12] lib: sbi: Fix capability bit assignment in MPXY framework Anup Patel
2025-01-19 23:00   ` Samuel Holland
2025-01-16 15:56 ` [PATCH 05/12] lib: sbi: Improve local variable declarations " Anup Patel
2025-01-19 23:02   ` Samuel Holland
2025-01-16 15:56 ` [PATCH 06/12] lib: utils: Drop notifications from MPXY RPMI mailbox client Anup Patel
2025-01-19 23:02   ` Samuel Holland
2025-01-16 15:56 ` Anup Patel [this message]
2025-01-19 23:05   ` [PATCH 07/12] lib: utils: Improve variable declarations in " Samuel Holland
2025-01-20  8:37     ` Anup Patel
2025-01-16 15:56 ` [PATCH 08/12] include: sbi_utils: Include mailbox.h in rpmi_mailbox.h header Anup Patel
2025-01-19 23:05   ` Samuel Holland
2025-01-16 15:56 ` [PATCH 09/12] lib: utils: Implement get_attribute() for the RPMI shared memory mailbox Anup Patel
2025-01-16 15:56 ` [PATCH 10/12] lib: utils: Populate MPXY channel attributes from RPMI channel attributes Anup Patel
2025-01-16 15:56 ` [PATCH 11/12] include: sbi_utils: Update RPMI service group IDs and BASE service group Anup Patel
2025-01-19 23:07   ` Samuel Holland
2025-01-16 15:56 ` [PATCH 12/12] lib: utils: Add MPXY RPMI mailbox driver for System MSI " Anup Patel
2025-01-19 23:11   ` Samuel Holland
2025-01-20  9:16     ` Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250116155651.103782-8-apatel@ventanamicro.com \
    --to=apatel@ventanamicro.com \
    --cc=opensbi@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox