u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] drivers: net: fsl-mc: cleanup coding style
@ 2023-01-05 15:03 Ioana Ciornei
  2023-01-05 15:03 ` [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable Ioana Ciornei
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Ioana Ciornei @ 2023-01-05 15:03 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, sjg, peng.fan, u-boot; +Cc: Ioana Ciornei

This patch set tries to cleanup the mc.c source file a bit.

The first two patches remove an useless assignment and a brake
statement. Then we fix some debug logs by making sure that we do not
print decimal values with a 0x prefix.

Patches 4-7 just clean-up the coding style a bit and also some of the
checkpatch warnings.

Ioana Ciornei (7):
  drivers: net: fsl-mc: remove useless assignment of variable
  drivers: net: fsl-mc: remove an useless break statement
  drivers: net: fsl-mc: do not prefix decimal values with 0x
  drivers: net: fsl-mc: remove the initialisation of global variables
  drivers: net: fsl-mc: remove explicit cast
  drivers: net: fsl-mc: align parameters to the open paranthesis
  drivers: net: fsl-mc: do not use multiple blank lines

 drivers/net/fsl-mc/mc.c | 55 +++++++++++++++++------------------------
 1 file changed, 23 insertions(+), 32 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable
  2023-01-05 15:03 [PATCH 0/7] drivers: net: fsl-mc: cleanup coding style Ioana Ciornei
@ 2023-01-05 15:03 ` Ioana Ciornei
  2023-01-10 17:04   ` Ramon Fried
  2023-02-03 18:20   ` Tom Rini
  2023-01-05 15:03 ` [PATCH 2/7] drivers: net: fsl-mc: remove an useless break statement Ioana Ciornei
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: Ioana Ciornei @ 2023-01-05 15:03 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, sjg, peng.fan, u-boot; +Cc: Ioana Ciornei

The cur_ptr variable is set to the start of the log buffer but then it's
not used. Just remove the assignment altogether.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/fsl-mc/mc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 6b36860187ca..66fcb48ebd55 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -1796,7 +1796,6 @@ static void mc_dump_log(void)
 	if (size > bytes_end) {
 		print_k_bytes(cur_ptr, &bytes_end);
 
-		cur_ptr = buf;
 		size -= bytes_end;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/7] drivers: net: fsl-mc: remove an useless break statement
  2023-01-05 15:03 [PATCH 0/7] drivers: net: fsl-mc: cleanup coding style Ioana Ciornei
  2023-01-05 15:03 ` [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable Ioana Ciornei
@ 2023-01-05 15:03 ` Ioana Ciornei
  2023-01-10 17:05   ` Ramon Fried
  2023-01-05 15:03 ` [PATCH 3/7] drivers: net: fsl-mc: do not prefix decimal values with 0x Ioana Ciornei
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Ioana Ciornei @ 2023-01-05 15:03 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, sjg, peng.fan, u-boot; +Cc: Ioana Ciornei

The break statement is just after a goto statement, thus it will not get
executed. Just remove it.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/fsl-mc/mc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 66fcb48ebd55..180e57e42266 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -1961,7 +1961,6 @@ static int do_fsl_mc(struct cmd_tbl *cmdtp, int flag, int argc,
 	default:
 		printf("Invalid option: %s\n", argv[1]);
 		goto usage;
-		break;
 	}
 	return err;
  usage:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 3/7] drivers: net: fsl-mc: do not prefix decimal values with 0x
  2023-01-05 15:03 [PATCH 0/7] drivers: net: fsl-mc: cleanup coding style Ioana Ciornei
  2023-01-05 15:03 ` [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable Ioana Ciornei
  2023-01-05 15:03 ` [PATCH 2/7] drivers: net: fsl-mc: remove an useless break statement Ioana Ciornei
@ 2023-01-05 15:03 ` Ioana Ciornei
  2023-01-10 17:05   ` Ramon Fried
  2023-01-05 15:03 ` [PATCH 4/7] drivers: net: fsl-mc: remove the initialisation of global variables Ioana Ciornei
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Ioana Ciornei @ 2023-01-05 15:03 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, sjg, peng.fan, u-boot; +Cc: Ioana Ciornei

The fsl-mc driver printed debug information which used the 0x prefix for
decimal values. This only confuses anyone looking through the log.
Because of this, just remove the prefix and use the "DPXY.<id>" notation
which is the standard one for the DPAA2 objects.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/fsl-mc/mc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 180e57e42266..440273a17562 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -1038,7 +1038,7 @@ static int dpio_init(void)
 	}
 
 #ifdef DEBUG
-	printf("Init: DPIO id=0x%d\n", dflt_dpio->dpio_id);
+	printf("Init: DPIO.%d\n", dflt_dpio->dpio_id);
 #endif
 	err = dpio_enable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
 	if (err < 0) {
@@ -1107,7 +1107,7 @@ static int dpio_exit(void)
 	}
 
 #ifdef DEBUG
-	printf("Exit: DPIO id=0x%d\n", dflt_dpio->dpio_id);
+	printf("Exit: DPIO.%d\n", dflt_dpio->dpio_id);
 #endif
 
 	if (dflt_dpio)
@@ -1312,7 +1312,7 @@ static int dpbp_init(void)
 	}
 
 #ifdef DEBUG
-	printf("Init: DPBP id=0x%x\n", dflt_dpbp->dpbp_attr.id);
+	printf("Init: DPBP.%d\n", dflt_dpbp->dpbp_attr.id);
 #endif
 
 	err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle);
@@ -1351,7 +1351,7 @@ static int dpbp_exit(void)
 	}
 
 #ifdef DEBUG
-	printf("Exit: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id);
+	printf("Exit: DPBP.%d\n", dflt_dpbp->dpbp_attr.id);
 #endif
 
 	if (dflt_dpbp)
@@ -1422,7 +1422,7 @@ static int dpni_init(void)
 	}
 
 #ifdef DEBUG
-	printf("Init: DPNI id=0x%d\n", dflt_dpni->dpni_id);
+	printf("Init: DPNI.%d\n", dflt_dpni->dpni_id);
 #endif
 	err = dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
 	if (err < 0) {
@@ -1459,7 +1459,7 @@ static int dpni_exit(void)
 	}
 
 #ifdef DEBUG
-	printf("Exit: DPNI id=0x%d\n", dflt_dpni->dpni_id);
+	printf("Exit: DPNI.%d\n", dflt_dpni->dpni_id);
 #endif
 
 	if (dflt_dpni)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 4/7] drivers: net: fsl-mc: remove the initialisation of global variables
  2023-01-05 15:03 [PATCH 0/7] drivers: net: fsl-mc: cleanup coding style Ioana Ciornei
                   ` (2 preceding siblings ...)
  2023-01-05 15:03 ` [PATCH 3/7] drivers: net: fsl-mc: do not prefix decimal values with 0x Ioana Ciornei
@ 2023-01-05 15:03 ` Ioana Ciornei
  2023-01-10 17:07   ` Ramon Fried
  2023-01-05 15:03 ` [PATCH 5/7] drivers: net: fsl-mc: remove explicit cast Ioana Ciornei
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Ioana Ciornei @ 2023-01-05 15:03 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, sjg, peng.fan, u-boot; +Cc: Ioana Ciornei

Some of the global variables were being initialised either to NULL or 0.
This is not needed, just remove the it.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/fsl-mc/mc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 440273a17562..001c77ba8355 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -57,14 +57,14 @@ static int mc_dpl_applied = -1;
 #ifdef CFG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
 static int mc_aiop_applied = -1;
 #endif
-struct fsl_mc_io *root_mc_io = NULL;
-struct fsl_mc_io *dflt_mc_io = NULL; /* child container */
-uint16_t root_dprc_handle = 0;
-uint16_t dflt_dprc_handle = 0;
+struct fsl_mc_io *root_mc_io;
+struct fsl_mc_io *dflt_mc_io;
+uint16_t root_dprc_handle;
+uint16_t dflt_dprc_handle;
 int child_dprc_id;
-struct fsl_dpbp_obj *dflt_dpbp = NULL;
-struct fsl_dpio_obj *dflt_dpio = NULL;
-struct fsl_dpni_obj *dflt_dpni = NULL;
+struct fsl_dpbp_obj *dflt_dpbp;
+struct fsl_dpio_obj *dflt_dpio;
+struct fsl_dpni_obj *dflt_dpni;
 static u64 mc_lazy_dpl_addr;
 static u32 dpsparser_obj_id;
 static u16 dpsparser_handle;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 5/7] drivers: net: fsl-mc: remove explicit cast
  2023-01-05 15:03 [PATCH 0/7] drivers: net: fsl-mc: cleanup coding style Ioana Ciornei
                   ` (3 preceding siblings ...)
  2023-01-05 15:03 ` [PATCH 4/7] drivers: net: fsl-mc: remove the initialisation of global variables Ioana Ciornei
@ 2023-01-05 15:03 ` Ioana Ciornei
  2023-01-10 17:08   ` Ramon Fried
  2023-01-05 15:03 ` [PATCH 6/7] drivers: net: fsl-mc: align parameters to the open paranthesis Ioana Ciornei
  2023-01-05 15:03 ` [PATCH 7/7] drivers: net: fsl-mc: do not use multiple blank lines Ioana Ciornei
  6 siblings, 1 reply; 18+ messages in thread
From: Ioana Ciornei @ 2023-01-05 15:03 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, sjg, peng.fan, u-boot; +Cc: Ioana Ciornei

Remove all the explicit casts from the void* returned by calloc.
With this we also improve a bit the length of those lines and there is
no need to split the assignment.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/fsl-mc/mc.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 001c77ba8355..5ad47e3414b5 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -812,7 +812,7 @@ int mc_init(u64 mc_fw_addr, u64 mc_dpc_addr)
 	 * Initialize the global default MC portal
 	 * And check that the MC firmware is responding portal commands:
 	 */
-	root_mc_io = (struct fsl_mc_io *)calloc(sizeof(struct fsl_mc_io), 1);
+	root_mc_io = calloc(sizeof(struct fsl_mc_io), 1);
 	if (!root_mc_io) {
 		printf(" No memory: calloc() failed\n");
 		return -ENOMEM;
@@ -979,8 +979,7 @@ static int dpio_init(void)
 	int err = 0;
 	uint16_t major_ver, minor_ver;
 
-	dflt_dpio = (struct fsl_dpio_obj *)calloc(
-					sizeof(struct fsl_dpio_obj), 1);
+	dflt_dpio = calloc(sizeof(struct fsl_dpio_obj), 1);
 	if (!dflt_dpio) {
 		printf("No memory: calloc() failed\n");
 		err = -ENOMEM;
@@ -1168,7 +1167,7 @@ static int dprc_init(void)
 		goto err_create;
 	}
 
-	dflt_mc_io = (struct fsl_mc_io *)calloc(sizeof(struct fsl_mc_io), 1);
+	dflt_mc_io = calloc(sizeof(struct fsl_mc_io), 1);
 	if (!dflt_mc_io) {
 		err  = -ENOMEM;
 		printf(" No memory: calloc() failed\n");
@@ -1250,8 +1249,7 @@ static int dpbp_init(void)
 	struct dpbp_cfg dpbp_cfg;
 	uint16_t major_ver, minor_ver;
 
-	dflt_dpbp = (struct fsl_dpbp_obj *)calloc(
-					sizeof(struct fsl_dpbp_obj), 1);
+	dflt_dpbp = calloc(sizeof(struct fsl_dpbp_obj), 1);
 	if (!dflt_dpbp) {
 		printf("No memory: calloc() failed\n");
 		err = -ENOMEM;
@@ -1369,8 +1367,7 @@ static int dpni_init(void)
 	struct dpni_cfg dpni_cfg;
 	uint16_t major_ver, minor_ver;
 
-	dflt_dpni = (struct fsl_dpni_obj *)calloc(
-					sizeof(struct fsl_dpni_obj), 1);
+	dflt_dpni = calloc(sizeof(struct fsl_dpni_obj), 1);
 	if (!dflt_dpni) {
 		printf("No memory: calloc() failed\n");
 		err = -ENOMEM;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 6/7] drivers: net: fsl-mc: align parameters to the open paranthesis
  2023-01-05 15:03 [PATCH 0/7] drivers: net: fsl-mc: cleanup coding style Ioana Ciornei
                   ` (4 preceding siblings ...)
  2023-01-05 15:03 ` [PATCH 5/7] drivers: net: fsl-mc: remove explicit cast Ioana Ciornei
@ 2023-01-05 15:03 ` Ioana Ciornei
  2023-01-10 17:08   ` Ramon Fried
  2023-01-05 15:03 ` [PATCH 7/7] drivers: net: fsl-mc: do not use multiple blank lines Ioana Ciornei
  6 siblings, 1 reply; 18+ messages in thread
From: Ioana Ciornei @ 2023-01-05 15:03 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, sjg, peng.fan, u-boot; +Cc: Ioana Ciornei

There were some cases in which the function parameters were not aligned
to the open paranthesis. Fix those instances.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/fsl-mc/mc.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 5ad47e3414b5..531835fbd503 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -356,8 +356,7 @@ static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id,
 	if (noff < 0) {
 		err = fdt_increase_size(blob, 200);
 		if (err) {
-			printf("fdt_increase_size: err=%s\n",
-				fdt_strerror(err));
+			printf("fdt_increase_size: err=%s\n", fdt_strerror(err));
 			return err;
 		}
 
@@ -373,7 +372,7 @@ static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id,
 					    "link_type", link_type_mode);
 		if (err) {
 			printf("fdt_appendprop_string: err=%s\n",
-				fdt_strerror(err));
+			       fdt_strerror(err));
 			return err;
 		}
 	}
@@ -1158,10 +1157,9 @@ static int dprc_init(void)
 	cfg.icid = DPRC_GET_ICID_FROM_POOL;
 	cfg.portal_id = DPRC_GET_PORTAL_ID_FROM_POOL;
 	err = dprc_create_container(root_mc_io, MC_CMD_NO_FLAGS,
-			root_dprc_handle,
-			&cfg,
-			&child_dprc_id,
-			&mc_portal_offset);
+				    root_dprc_handle, &cfg,
+				    &child_dprc_id,
+				    &mc_portal_offset);
 	if (err < 0) {
 		printf("dprc_create_container() failed: %d\n", err);
 		goto err_create;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 7/7] drivers: net: fsl-mc: do not use multiple blank lines
  2023-01-05 15:03 [PATCH 0/7] drivers: net: fsl-mc: cleanup coding style Ioana Ciornei
                   ` (5 preceding siblings ...)
  2023-01-05 15:03 ` [PATCH 6/7] drivers: net: fsl-mc: align parameters to the open paranthesis Ioana Ciornei
@ 2023-01-05 15:03 ` Ioana Ciornei
  2023-01-10 17:08   ` Ramon Fried
  6 siblings, 1 reply; 18+ messages in thread
From: Ioana Ciornei @ 2023-01-05 15:03 UTC (permalink / raw)
  To: joe.hershberger, rfried.dev, sjg, peng.fan, u-boot; +Cc: Ioana Ciornei

Remove the instances in which we have multiple blank lines.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/fsl-mc/mc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 531835fbd503..f78f070aec1c 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -526,7 +526,6 @@ static int load_mc_dpc(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpc_addr)
 	return 0;
 }
 
-
 static int mc_fixup_dpl(u64 dpl_addr)
 {
 	void *blob = (void *)dpl_addr;
@@ -698,7 +697,6 @@ static int wait_for_mc(bool booting_mc, u32 *final_reg_gsr)
 		printf("SUCCESS\n");
 	}
 
-
 	*final_reg_gsr = reg_gsr;
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable
  2023-01-05 15:03 ` [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable Ioana Ciornei
@ 2023-01-10 17:04   ` Ramon Fried
  2023-01-12 10:57     ` Ioana Ciornei
  2023-02-03 18:20   ` Tom Rini
  1 sibling, 1 reply; 18+ messages in thread
From: Ramon Fried @ 2023-01-10 17:04 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: joe.hershberger, sjg, peng.fan, u-boot

On Thu, Jan 5, 2023 at 5:03 PM Ioana Ciornei <ioana.ciornei@nxp.com> wrote:
>
> The cur_ptr variable is set to the start of the log buffer but then it's
> not used. Just remove the assignment altogether.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
>  drivers/net/fsl-mc/mc.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> index 6b36860187ca..66fcb48ebd55 100644
> --- a/drivers/net/fsl-mc/mc.c
> +++ b/drivers/net/fsl-mc/mc.c
> @@ -1796,7 +1796,6 @@ static void mc_dump_log(void)
>         if (size > bytes_end) {
>                 print_k_bytes(cur_ptr, &bytes_end);
>
> -               cur_ptr = buf;
>                 size -= bytes_end;
>         }
>
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/7] drivers: net: fsl-mc: remove an useless break statement
  2023-01-05 15:03 ` [PATCH 2/7] drivers: net: fsl-mc: remove an useless break statement Ioana Ciornei
@ 2023-01-10 17:05   ` Ramon Fried
  0 siblings, 0 replies; 18+ messages in thread
From: Ramon Fried @ 2023-01-10 17:05 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: joe.hershberger, sjg, peng.fan, u-boot

On Thu, Jan 5, 2023 at 5:03 PM Ioana Ciornei <ioana.ciornei@nxp.com> wrote:
>
> The break statement is just after a goto statement, thus it will not get
> executed. Just remove it.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
>  drivers/net/fsl-mc/mc.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> index 66fcb48ebd55..180e57e42266 100644
> --- a/drivers/net/fsl-mc/mc.c
> +++ b/drivers/net/fsl-mc/mc.c
> @@ -1961,7 +1961,6 @@ static int do_fsl_mc(struct cmd_tbl *cmdtp, int flag, int argc,
>         default:
>                 printf("Invalid option: %s\n", argv[1]);
>                 goto usage;
> -               break;
>         }
>         return err;
>   usage:
> --
> 2.25.1
>
It's possible that it's there only to silent dumb compiler who thinks
that break was forgotten.
Let's see if it introduces problems in the CI. meanwhile I'll approve.
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/7] drivers: net: fsl-mc: do not prefix decimal values with 0x
  2023-01-05 15:03 ` [PATCH 3/7] drivers: net: fsl-mc: do not prefix decimal values with 0x Ioana Ciornei
@ 2023-01-10 17:05   ` Ramon Fried
  0 siblings, 0 replies; 18+ messages in thread
From: Ramon Fried @ 2023-01-10 17:05 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: joe.hershberger, sjg, peng.fan, u-boot

On Thu, Jan 5, 2023 at 5:03 PM Ioana Ciornei <ioana.ciornei@nxp.com> wrote:
>
> The fsl-mc driver printed debug information which used the 0x prefix for
> decimal values. This only confuses anyone looking through the log.
> Because of this, just remove the prefix and use the "DPXY.<id>" notation
> which is the standard one for the DPAA2 objects.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
>  drivers/net/fsl-mc/mc.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> index 180e57e42266..440273a17562 100644
> --- a/drivers/net/fsl-mc/mc.c
> +++ b/drivers/net/fsl-mc/mc.c
> @@ -1038,7 +1038,7 @@ static int dpio_init(void)
>         }
>
>  #ifdef DEBUG
> -       printf("Init: DPIO id=0x%d\n", dflt_dpio->dpio_id);
> +       printf("Init: DPIO.%d\n", dflt_dpio->dpio_id);
>  #endif
>         err = dpio_enable(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
>         if (err < 0) {
> @@ -1107,7 +1107,7 @@ static int dpio_exit(void)
>         }
>
>  #ifdef DEBUG
> -       printf("Exit: DPIO id=0x%d\n", dflt_dpio->dpio_id);
> +       printf("Exit: DPIO.%d\n", dflt_dpio->dpio_id);
>  #endif
>
>         if (dflt_dpio)
> @@ -1312,7 +1312,7 @@ static int dpbp_init(void)
>         }
>
>  #ifdef DEBUG
> -       printf("Init: DPBP id=0x%x\n", dflt_dpbp->dpbp_attr.id);
> +       printf("Init: DPBP.%d\n", dflt_dpbp->dpbp_attr.id);
>  #endif
>
>         err = dpbp_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpbp->dpbp_handle);
> @@ -1351,7 +1351,7 @@ static int dpbp_exit(void)
>         }
>
>  #ifdef DEBUG
> -       printf("Exit: DPBP id=0x%d\n", dflt_dpbp->dpbp_attr.id);
> +       printf("Exit: DPBP.%d\n", dflt_dpbp->dpbp_attr.id);
>  #endif
>
>         if (dflt_dpbp)
> @@ -1422,7 +1422,7 @@ static int dpni_init(void)
>         }
>
>  #ifdef DEBUG
> -       printf("Init: DPNI id=0x%d\n", dflt_dpni->dpni_id);
> +       printf("Init: DPNI.%d\n", dflt_dpni->dpni_id);
>  #endif
>         err = dpni_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpni->dpni_handle);
>         if (err < 0) {
> @@ -1459,7 +1459,7 @@ static int dpni_exit(void)
>         }
>
>  #ifdef DEBUG
> -       printf("Exit: DPNI id=0x%d\n", dflt_dpni->dpni_id);
> +       printf("Exit: DPNI.%d\n", dflt_dpni->dpni_id);
>  #endif
>
>         if (dflt_dpni)
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/7] drivers: net: fsl-mc: remove the initialisation of global variables
  2023-01-05 15:03 ` [PATCH 4/7] drivers: net: fsl-mc: remove the initialisation of global variables Ioana Ciornei
@ 2023-01-10 17:07   ` Ramon Fried
  0 siblings, 0 replies; 18+ messages in thread
From: Ramon Fried @ 2023-01-10 17:07 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: joe.hershberger, sjg, peng.fan, u-boot

On Thu, Jan 5, 2023 at 5:03 PM Ioana Ciornei <ioana.ciornei@nxp.com> wrote:
>
> Some of the global variables were being initialised either to NULL or 0.
> This is not needed, just remove the it.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
>  drivers/net/fsl-mc/mc.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> index 440273a17562..001c77ba8355 100644
> --- a/drivers/net/fsl-mc/mc.c
> +++ b/drivers/net/fsl-mc/mc.c
> @@ -57,14 +57,14 @@ static int mc_dpl_applied = -1;
>  #ifdef CFG_SYS_LS_MC_DRAM_AIOP_IMG_OFFSET
>  static int mc_aiop_applied = -1;
>  #endif
> -struct fsl_mc_io *root_mc_io = NULL;
> -struct fsl_mc_io *dflt_mc_io = NULL; /* child container */
> -uint16_t root_dprc_handle = 0;
> -uint16_t dflt_dprc_handle = 0;
> +struct fsl_mc_io *root_mc_io;
> +struct fsl_mc_io *dflt_mc_io;
> +uint16_t root_dprc_handle;
> +uint16_t dflt_dprc_handle;
>  int child_dprc_id;
> -struct fsl_dpbp_obj *dflt_dpbp = NULL;
> -struct fsl_dpio_obj *dflt_dpio = NULL;
> -struct fsl_dpni_obj *dflt_dpni = NULL;
> +struct fsl_dpbp_obj *dflt_dpbp;
> +struct fsl_dpio_obj *dflt_dpio;
> +struct fsl_dpni_obj *dflt_dpni;
>  static u64 mc_lazy_dpl_addr;
>  static u32 dpsparser_obj_id;
>  static u16 dpsparser_handle;
> --
> 2.25.1
>
I don't believe it's a bad habit to initialize static variables. it's
true that they will be initialized to zero by default.
But I don't find this patch helpful in any way for understanding or
decluttering code.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 5/7] drivers: net: fsl-mc: remove explicit cast
  2023-01-05 15:03 ` [PATCH 5/7] drivers: net: fsl-mc: remove explicit cast Ioana Ciornei
@ 2023-01-10 17:08   ` Ramon Fried
  0 siblings, 0 replies; 18+ messages in thread
From: Ramon Fried @ 2023-01-10 17:08 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: joe.hershberger, sjg, peng.fan, u-boot

On Thu, Jan 5, 2023 at 5:03 PM Ioana Ciornei <ioana.ciornei@nxp.com> wrote:
>
> Remove all the explicit casts from the void* returned by calloc.
> With this we also improve a bit the length of those lines and there is
> no need to split the assignment.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
>  drivers/net/fsl-mc/mc.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> index 001c77ba8355..5ad47e3414b5 100644
> --- a/drivers/net/fsl-mc/mc.c
> +++ b/drivers/net/fsl-mc/mc.c
> @@ -812,7 +812,7 @@ int mc_init(u64 mc_fw_addr, u64 mc_dpc_addr)
>          * Initialize the global default MC portal
>          * And check that the MC firmware is responding portal commands:
>          */
> -       root_mc_io = (struct fsl_mc_io *)calloc(sizeof(struct fsl_mc_io), 1);
> +       root_mc_io = calloc(sizeof(struct fsl_mc_io), 1);
>         if (!root_mc_io) {
>                 printf(" No memory: calloc() failed\n");
>                 return -ENOMEM;
> @@ -979,8 +979,7 @@ static int dpio_init(void)
>         int err = 0;
>         uint16_t major_ver, minor_ver;
>
> -       dflt_dpio = (struct fsl_dpio_obj *)calloc(
> -                                       sizeof(struct fsl_dpio_obj), 1);
> +       dflt_dpio = calloc(sizeof(struct fsl_dpio_obj), 1);
>         if (!dflt_dpio) {
>                 printf("No memory: calloc() failed\n");
>                 err = -ENOMEM;
> @@ -1168,7 +1167,7 @@ static int dprc_init(void)
>                 goto err_create;
>         }
>
> -       dflt_mc_io = (struct fsl_mc_io *)calloc(sizeof(struct fsl_mc_io), 1);
> +       dflt_mc_io = calloc(sizeof(struct fsl_mc_io), 1);
>         if (!dflt_mc_io) {
>                 err  = -ENOMEM;
>                 printf(" No memory: calloc() failed\n");
> @@ -1250,8 +1249,7 @@ static int dpbp_init(void)
>         struct dpbp_cfg dpbp_cfg;
>         uint16_t major_ver, minor_ver;
>
> -       dflt_dpbp = (struct fsl_dpbp_obj *)calloc(
> -                                       sizeof(struct fsl_dpbp_obj), 1);
> +       dflt_dpbp = calloc(sizeof(struct fsl_dpbp_obj), 1);
>         if (!dflt_dpbp) {
>                 printf("No memory: calloc() failed\n");
>                 err = -ENOMEM;
> @@ -1369,8 +1367,7 @@ static int dpni_init(void)
>         struct dpni_cfg dpni_cfg;
>         uint16_t major_ver, minor_ver;
>
> -       dflt_dpni = (struct fsl_dpni_obj *)calloc(
> -                                       sizeof(struct fsl_dpni_obj), 1);
> +       dflt_dpni = calloc(sizeof(struct fsl_dpni_obj), 1);
>         if (!dflt_dpni) {
>                 printf("No memory: calloc() failed\n");
>                 err = -ENOMEM;
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 6/7] drivers: net: fsl-mc: align parameters to the open paranthesis
  2023-01-05 15:03 ` [PATCH 6/7] drivers: net: fsl-mc: align parameters to the open paranthesis Ioana Ciornei
@ 2023-01-10 17:08   ` Ramon Fried
  0 siblings, 0 replies; 18+ messages in thread
From: Ramon Fried @ 2023-01-10 17:08 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: joe.hershberger, sjg, peng.fan, u-boot

On Thu, Jan 5, 2023 at 5:03 PM Ioana Ciornei <ioana.ciornei@nxp.com> wrote:
>
> There were some cases in which the function parameters were not aligned
> to the open paranthesis. Fix those instances.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
>  drivers/net/fsl-mc/mc.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> index 5ad47e3414b5..531835fbd503 100644
> --- a/drivers/net/fsl-mc/mc.c
> +++ b/drivers/net/fsl-mc/mc.c
> @@ -356,8 +356,7 @@ static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id,
>         if (noff < 0) {
>                 err = fdt_increase_size(blob, 200);
>                 if (err) {
> -                       printf("fdt_increase_size: err=%s\n",
> -                               fdt_strerror(err));
> +                       printf("fdt_increase_size: err=%s\n", fdt_strerror(err));
>                         return err;
>                 }
>
> @@ -373,7 +372,7 @@ static int mc_fixup_dpc_mac_addr(void *blob, int dpmac_id,
>                                             "link_type", link_type_mode);
>                 if (err) {
>                         printf("fdt_appendprop_string: err=%s\n",
> -                               fdt_strerror(err));
> +                              fdt_strerror(err));
>                         return err;
>                 }
>         }
> @@ -1158,10 +1157,9 @@ static int dprc_init(void)
>         cfg.icid = DPRC_GET_ICID_FROM_POOL;
>         cfg.portal_id = DPRC_GET_PORTAL_ID_FROM_POOL;
>         err = dprc_create_container(root_mc_io, MC_CMD_NO_FLAGS,
> -                       root_dprc_handle,
> -                       &cfg,
> -                       &child_dprc_id,
> -                       &mc_portal_offset);
> +                                   root_dprc_handle, &cfg,
> +                                   &child_dprc_id,
> +                                   &mc_portal_offset);
>         if (err < 0) {
>                 printf("dprc_create_container() failed: %d\n", err);
>                 goto err_create;
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 7/7] drivers: net: fsl-mc: do not use multiple blank lines
  2023-01-05 15:03 ` [PATCH 7/7] drivers: net: fsl-mc: do not use multiple blank lines Ioana Ciornei
@ 2023-01-10 17:08   ` Ramon Fried
  0 siblings, 0 replies; 18+ messages in thread
From: Ramon Fried @ 2023-01-10 17:08 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: joe.hershberger, sjg, peng.fan, u-boot

On Thu, Jan 5, 2023 at 5:03 PM Ioana Ciornei <ioana.ciornei@nxp.com> wrote:
>
> Remove the instances in which we have multiple blank lines.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
>  drivers/net/fsl-mc/mc.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> index 531835fbd503..f78f070aec1c 100644
> --- a/drivers/net/fsl-mc/mc.c
> +++ b/drivers/net/fsl-mc/mc.c
> @@ -526,7 +526,6 @@ static int load_mc_dpc(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpc_addr)
>         return 0;
>  }
>
> -
>  static int mc_fixup_dpl(u64 dpl_addr)
>  {
>         void *blob = (void *)dpl_addr;
> @@ -698,7 +697,6 @@ static int wait_for_mc(bool booting_mc, u32 *final_reg_gsr)
>                 printf("SUCCESS\n");
>         }
>
> -
>         *final_reg_gsr = reg_gsr;
>         return 0;
>  }
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable
  2023-01-10 17:04   ` Ramon Fried
@ 2023-01-12 10:57     ` Ioana Ciornei
  2023-01-12 19:01       ` Ramon Fried
  0 siblings, 1 reply; 18+ messages in thread
From: Ioana Ciornei @ 2023-01-12 10:57 UTC (permalink / raw)
  To: Ramon Fried; +Cc: joe.hershberger, sjg, peng.fan, u-boot

On Tue, Jan 10, 2023 at 07:04:00PM +0200, Ramon Fried wrote:
> On Thu, Jan 5, 2023 at 5:03 PM Ioana Ciornei <ioana.ciornei@nxp.com> wrote:
> >
> > The cur_ptr variable is set to the start of the log buffer but then it's
> > not used. Just remove the assignment altogether.
> >
> > Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> > ---
> >  drivers/net/fsl-mc/mc.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> > index 6b36860187ca..66fcb48ebd55 100644
> > --- a/drivers/net/fsl-mc/mc.c
> > +++ b/drivers/net/fsl-mc/mc.c
> > @@ -1796,7 +1796,6 @@ static void mc_dump_log(void)
> >         if (size > bytes_end) {
> >                 print_k_bytes(cur_ptr, &bytes_end);
> >
> > -               cur_ptr = buf;
> >                 size -= bytes_end;
> >         }
> >
> > --
> > 2.25.1
> >
> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

Thanks for the reviews!

These kind of network patches go through the u-boot-net tree or is there
another path?

Ioana

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable
  2023-01-12 10:57     ` Ioana Ciornei
@ 2023-01-12 19:01       ` Ramon Fried
  0 siblings, 0 replies; 18+ messages in thread
From: Ramon Fried @ 2023-01-12 19:01 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: Joe Hershberger, Simon Glass, Peng Fan, U-Boot Mailing List

On Thu, 12 Jan 2023, 12:58 Ioana Ciornei, <ioana.ciornei@nxp.com> wrote:

> On Tue, Jan 10, 2023 at 07:04:00PM +0200, Ramon Fried wrote:
> > On Thu, Jan 5, 2023 at 5:03 PM Ioana Ciornei <ioana.ciornei@nxp.com>
> wrote:
> > >
> > > The cur_ptr variable is set to the start of the log buffer but then
> it's
> > > not used. Just remove the assignment altogether.
> > >
> > > Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> > > ---
> > >  drivers/net/fsl-mc/mc.c | 1 -
> > >  1 file changed, 1 deletion(-)
> > >
> > > diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
> > > index 6b36860187ca..66fcb48ebd55 100644
> > > --- a/drivers/net/fsl-mc/mc.c
> > > +++ b/drivers/net/fsl-mc/mc.c
> > > @@ -1796,7 +1796,6 @@ static void mc_dump_log(void)
> > >         if (size > bytes_end) {
> > >                 print_k_bytes(cur_ptr, &bytes_end);
> > >
> > > -               cur_ptr = buf;
> > >                 size -= bytes_end;
> > >         }
> > >
> > > --
> > > 2.25.1
> > >
> > Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
>
> Thanks for the reviews!
>
> These kind of network patches go through the u-boot-net tree or is there
> another path?
>
Here is fine.

>
> Ioana
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable
  2023-01-05 15:03 ` [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable Ioana Ciornei
  2023-01-10 17:04   ` Ramon Fried
@ 2023-02-03 18:20   ` Tom Rini
  1 sibling, 0 replies; 18+ messages in thread
From: Tom Rini @ 2023-02-03 18:20 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: joe.hershberger, rfried.dev, sjg, peng.fan, u-boot

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

On Thu, Jan 05, 2023 at 05:03:15PM +0200, Ioana Ciornei wrote:

> The cur_ptr variable is set to the start of the log buffer but then it's
> not used. Just remove the assignment altogether.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

For the series, and except for 4/7 which Ramon rejected, applied to
u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2023-02-03 18:21 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 15:03 [PATCH 0/7] drivers: net: fsl-mc: cleanup coding style Ioana Ciornei
2023-01-05 15:03 ` [PATCH 1/7] drivers: net: fsl-mc: remove useless assignment of variable Ioana Ciornei
2023-01-10 17:04   ` Ramon Fried
2023-01-12 10:57     ` Ioana Ciornei
2023-01-12 19:01       ` Ramon Fried
2023-02-03 18:20   ` Tom Rini
2023-01-05 15:03 ` [PATCH 2/7] drivers: net: fsl-mc: remove an useless break statement Ioana Ciornei
2023-01-10 17:05   ` Ramon Fried
2023-01-05 15:03 ` [PATCH 3/7] drivers: net: fsl-mc: do not prefix decimal values with 0x Ioana Ciornei
2023-01-10 17:05   ` Ramon Fried
2023-01-05 15:03 ` [PATCH 4/7] drivers: net: fsl-mc: remove the initialisation of global variables Ioana Ciornei
2023-01-10 17:07   ` Ramon Fried
2023-01-05 15:03 ` [PATCH 5/7] drivers: net: fsl-mc: remove explicit cast Ioana Ciornei
2023-01-10 17:08   ` Ramon Fried
2023-01-05 15:03 ` [PATCH 6/7] drivers: net: fsl-mc: align parameters to the open paranthesis Ioana Ciornei
2023-01-10 17:08   ` Ramon Fried
2023-01-05 15:03 ` [PATCH 7/7] drivers: net: fsl-mc: do not use multiple blank lines Ioana Ciornei
2023-01-10 17:08   ` Ramon Fried

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).