Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs

From: German Rivera
Date: Wed Sep 17 2014 - 12:35:56 EST




On 09/11/2014 01:45 PM, Joe Perches wrote:

diff --git a/drivers/bus/fsl-mc/dpmng.c b/drivers/bus/fsl-mc/dpmng.c
[]
+int mc_get_version(struct fsl_mc_io *mc_io, struct mc_version *mc_ver_info)
+{
+ struct mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION,
+ DPMNG_CMDSZ_GET_VERSION,
+ MC_CMD_PRI_LOW, 0);
+
+ err = mc_send_command(mc_io, &cmd);
+ if (!err)
+ DPMNG_RSP_GET_VERSION(cmd, mc_ver_info);
+
+ return err;

I think it better style to read when the
failure case is handled immediately by
a return or a "goto out" and the successful
case code is at the same indent level

err = mc_send_command_(etc...)
if (err)
return err;

DPMNG_RSP_GET_VERSION(cmd, mc_ver_info);

return 0;
}

Ok, I'll change this as suggested in the next respin.

diff --git a/drivers/bus/fsl-mc/dprc.c b/drivers/bus/fsl-mc/dprc.c

+int dprc_get_container_id(struct fsl_mc_io *mc_io, int *container_id)
+{
+ struct mc_command cmd = { 0 };
+ int err;
+
+ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONT_ID,
+ DPRC_CMDSZ_GET_CONT_ID,
+ MC_CMD_PRI_LOW, 0);
+
+ err = mc_send_command(mc_io, &cmd);
+ if (!err)
+ DPRC_RSP_GET_CONTAINER_ID(cmd, *container_id);
+
+ return err;
+}

Same sort of thing as above.
Actively fail on err and proceed at the same indent
level on success.

Yes, I'll change all occurrences of this.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/